From patchwork Wed Feb 21 11:22:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Antipov X-Patchwork-Id: 13565443 Received: from forward205b.mail.yandex.net (forward205b.mail.yandex.net [178.154.239.152]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26ADE41202 for ; Wed, 21 Feb 2024 11:32:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.154.239.152 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708515130; cv=none; b=MQFOFGdVsam/84EjP3bDAnvLt3L8jgjwmdSyp9g5dbr0mfEPcuOX48lQ4PKY2yXmMUxXHjFnZOg/T84t0PNYq1QpDsOBlQghaFg6o51P7Vs53TBss5xjcqozir/CU3ne4fVZXRB8BUdykV8lnP53Szy9tDW4iUNSvNbsRH9fHDY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708515130; c=relaxed/simple; bh=oAaruXt9/L2edQoj9oPD9o+AABk50Qz8WT4nx4OGXS0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=MlJO/Xujjc8FVYaCqdKNYlbw45601V+iL+ny2Uatbu9PiAyrhNVCDerS/f7b4z8slAl5ob25rmhmYGdw1IWt9pdLQEIQoryKP1Kn6FpoxWanBnu0S3cheMP8344rWh1BWEFCJxcuuG/nuM5LG4pEIblMCKbhFfezsNqMclVy3Ac= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex.ru; spf=pass smtp.mailfrom=yandex.ru; dkim=pass (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.b=SwDKR5W6; arc=none smtp.client-ip=178.154.239.152 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=yandex.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.b="SwDKR5W6" Received: from forward101c.mail.yandex.net (forward101c.mail.yandex.net [IPv6:2a02:6b8:c03:500:1:45:d181:d101]) by forward205b.mail.yandex.net (Yandex) with ESMTPS id B368A62BE8 for ; Wed, 21 Feb 2024 14:24:02 +0300 (MSK) Received: from mail-nwsmtp-smtp-production-main-37.myt.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-37.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:291a:0:640:791e:0]) by forward101c.mail.yandex.net (Yandex) with ESMTPS id A72BD60B23; Wed, 21 Feb 2024 14:23:54 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-37.myt.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id rNQqDK0oH4Y0-0zdDuOL6; Wed, 21 Feb 2024 14:23:54 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1708514634; bh=BOwv8+xbZuZsqevA//KsZuBEgz+mAYKmPvHp725XwLg=; h=Message-ID:Date:Cc:Subject:To:From; b=SwDKR5W6m8LbMF5vQ1U6fwLx3TkPp5lsHnDbUOG5AYdxs+wG4lQIDvo/p4/fdkhVY wdltPY8vHXSpYLvOGv+RjbtwshViXJ+XsnIhURtxxJCqFwWonwp0CyvbWeUIL156+M ijjQrVy4yPWTFYBkIXDVr3iDivBA/XWdMnGPHo/A= Authentication-Results: mail-nwsmtp-smtp-production-main-37.myt.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Christian Brauner Cc: Alexander Viro , linux-fsdevel@vger.kernel.org, Dmitry Antipov Subject: [PATCH 1/2] dcache: prefer kfree()/kfree_rcu() in dentry_free() Date: Wed, 21 Feb 2024 14:22:04 +0300 Message-ID: <20240221112205.48389-1-dmantipov@yandex.ru> X-Mailer: git-send-email 2.43.2 Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In 'dentry_free()', prefer plain 'kfree()' and 'kfree_rcu()' over 'call_rcu()' with dummy '__d_free()' callback. This follows commit 878c391f74d6 ("fs: prefer kfree_rcu() in fasync_remove_entry()") and should not be backported to stable as well. Signed-off-by: Dmitry Antipov --- fs/dcache.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index b813528fb147..18770fe4ac10 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -290,13 +290,6 @@ static inline struct external_name *external_name(struct dentry *dentry) return container_of(dentry->d_name.name, struct external_name, name[0]); } -static void __d_free(struct rcu_head *head) -{ - struct dentry *dentry = container_of(head, struct dentry, d_u.d_rcu); - - kmem_cache_free(dentry_cache, dentry); -} - static void __d_free_external(struct rcu_head *head) { struct dentry *dentry = container_of(head, struct dentry, d_u.d_rcu); @@ -371,9 +364,9 @@ static void dentry_free(struct dentry *dentry) } /* if dentry was never visible to RCU, immediate free is OK */ if (dentry->d_flags & DCACHE_NORCU) - __d_free(&dentry->d_u.d_rcu); + kfree(dentry); else - call_rcu(&dentry->d_u.d_rcu, __d_free); + kfree_rcu(dentry, d_u.d_rcu); } /* From patchwork Wed Feb 21 11:22:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Antipov X-Patchwork-Id: 13565439 Received: from forward202c.mail.yandex.net (forward202c.mail.yandex.net [178.154.239.219]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D96313F8DE for ; Wed, 21 Feb 2024 11:24:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.154.239.219 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708514650; cv=none; b=f7IJkgZgw1C6asALJkSgxHk4wFmn4LO19SUcu+db+ZpMt2u5SJWlfsjVTfw01yaj5WJJ/QDY3VKwNV/vlUjkVebtNPvDqIDVPgkHDPmahabi0pRO6oaEIj+EGU9Ngxy6Y5C0Ajf8e+/PgLoyvg9ip/bo3ZV5BWHXubepoGed3eg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708514650; c=relaxed/simple; bh=5B1v+GSW0KNawNGspWptB6v+kveDZ0cfBgr43OW0hds=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LlycZt3Re3/s1VMfgjaKtl5QNRqNE+Y+8LAxi9Npjj2cXZGP9/jeaSKBlrim00sIuWllaOCgH9VBjkRdPo7/lKmrbai8WlR3oj4YU1zNFfK7g5ZW+H3d32XgKfXpF/raUsOOiWw/+Xt2xJCtjyQToBsbRJtmIM7zcj3jEF+W1gQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex.ru; spf=pass smtp.mailfrom=yandex.ru; dkim=pass (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.b=Qazc9y6Y; arc=none smtp.client-ip=178.154.239.219 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=yandex.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.b="Qazc9y6Y" Received: from forward101b.mail.yandex.net (forward101b.mail.yandex.net [IPv6:2a02:6b8:c02:900:1:45:d181:d101]) by forward202c.mail.yandex.net (Yandex) with ESMTPS id AACEB64746 for ; Wed, 21 Feb 2024 14:24:03 +0300 (MSK) Received: from mail-nwsmtp-smtp-production-main-37.myt.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-37.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:291a:0:640:791e:0]) by forward101b.mail.yandex.net (Yandex) with ESMTPS id 5BB8F60B54; Wed, 21 Feb 2024 14:23:55 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-37.myt.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id rNQqDK0oH4Y0-Gq4RMmaV; Wed, 21 Feb 2024 14:23:54 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1708514634; bh=/2K5WkY6huAzgSsUx1MjMrRZqXwVrspkA9joziiw7Is=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=Qazc9y6YWcOWjsYEAbJ5ZBEPuhjLq9qs5pSx9h3tscKb9F3q4qKp9bf5D2GzL5Zel qlbOWZgIfEKuA1BBSi7o8E/yxKkHn8MIi9CJBrr1hXUCHqXvpXQPKrt9h1dc98gDr7 6bOS0Vsz6f5EOn4hl+kbc7iI31nxY0fitqfNM44M= Authentication-Results: mail-nwsmtp-smtp-production-main-37.myt.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Christian Brauner Cc: Alexander Viro , linux-fsdevel@vger.kernel.org, Dmitry Antipov Subject: [PATCH 2/2] eventpoll: prefer kfree_rcu() in __ep_remove() Date: Wed, 21 Feb 2024 14:22:05 +0300 Message-ID: <20240221112205.48389-2-dmantipov@yandex.ru> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240221112205.48389-1-dmantipov@yandex.ru> References: <20240221112205.48389-1-dmantipov@yandex.ru> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In '__ep_remove()', prefer 'kfree_rcu()' over 'call_rcu()' with dummy 'epi_rcu_free()' callback. This follows commit 878c391f74d6 ("fs: prefer kfree_rcu() in fasync_remove_entry()") and should not be backported to stable as well. Signed-off-by: Dmitry Antipov --- fs/eventpoll.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 786e023a48b2..39ac6fdf8bca 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -678,12 +678,6 @@ static void ep_done_scan(struct eventpoll *ep, write_unlock_irq(&ep->lock); } -static void epi_rcu_free(struct rcu_head *head) -{ - struct epitem *epi = container_of(head, struct epitem, rcu); - kmem_cache_free(epi_cache, epi); -} - static void ep_get(struct eventpoll *ep) { refcount_inc(&ep->refcount); @@ -767,7 +761,7 @@ static bool __ep_remove(struct eventpoll *ep, struct epitem *epi, bool force) * ep->mtx. The rcu read side, reverse_path_check_proc(), does not make * use of the rbn field. */ - call_rcu(&epi->rcu, epi_rcu_free); + kfree_rcu(epi, rcu); percpu_counter_dec(&ep->user->epoll_watches); return ep_refcount_dec_and_test(ep);