From nobody Thu Feb 12 19:05:46 2026 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) (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 904511CF9B; Sun, 9 Jun 2024 08:28:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.134.164.83 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921683; cv=none; b=PVd8zT8xyyrd43B/s+f4HCaBW/obix7/covmfV1DZG03bwnhVUGt89jfQn5d5Fs3mzFhqtSy0WPBr5sNLk7vAypTE2zLR5rpU60+GHKTiE+KMN5iHy6j9+APQwozXI0IAMYQ5vAmNEVkDlhJeJ1SDykIQc8CQ/k4iXv6HT/2reY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921683; c=relaxed/simple; bh=DIOSKqTpToIMwFVNjlUEe3yI6S/nMaYNXYjDOcuM4EQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eQ2uixf4yt9FP3JWMU65dxLXK7JqNz4PUfqY+Ywy4MCh8JjJtZ1JMlbvrnLbz3UHFj/0i3Gz8OSpkFdYnC3Qq7sE5f8E5/lrVyL9nHHf4gitEHoJV3WVoTwDd8K1YOvgb1Mkse/1ChvI/pZszCNJaJD91A4HJEHyVZYhpDgx6fo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr; spf=pass smtp.mailfrom=inria.fr; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b=DagXZfUz; arc=none smtp.client-ip=192.134.164.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inria.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b="DagXZfUz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zD7ynr/1tlkX1uaDOLGJoOQ33RKpDATGoutWutKpPm8=; b=DagXZfUzdJWxwoYzmzmcEEdumUzJIa5J0CQYYbILkDG/vxnjNLrQtADH Zr3+IGWHHTGjtQGCVa5ooF0J9nev/GChyQeMc6SmkGK2HoL3KVzdspOzO VEuZqOgM9n6vbqQ+I7kkL+HhJhbcnrmDykDjT6SypihrjH36fewBvsXo3 Q=; Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=Julia.Lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.08,225,1712613600"; d="scan'208";a="169696896" Received: from i80.paris.inria.fr (HELO i80.paris.inria.fr.) ([128.93.90.48]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2024 10:27:48 +0200 From: Julia Lawall To: "Jason A. Donenfeld" Cc: kernel-janitors@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , wireguard@lists.zx2c4.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Paul E . McKenney" , Vlastimil Babka Subject: [PATCH 01/14] wireguard: allowedips: replace call_rcu by kfree_rcu for simple kmem_cache_free callback Date: Sun, 9 Jun 2024 10:27:13 +0200 Message-Id: <20240609082726.32742-2-Julia.Lawall@inria.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240609082726.32742-1-Julia.Lawall@inria.fr> References: <20240609082726.32742-1-Julia.Lawall@inria.fr> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since SLOB was removed, it is not necessary to use call_rcu when the callback only performs kmem_cache_free. Use kfree_rcu() directly. The changes were done using the following Coccinelle semantic patch. This semantic patch is designed to ignore cases where the callback function is used in another way. // @r@ expression e; local idexpression e2; identifier cb,f; position p; @@ ( call_rcu(...,e2) | call_rcu(&e->f,cb@p) ) @r1@ type T; identifier x,r.cb; @@ cb(...) { ( kmem_cache_free(...); | T x =3D ...; kmem_cache_free(...,x); | T x; x =3D ...; kmem_cache_free(...,x); ) } @s depends on r1@ position p !=3D r.p; identifier r.cb; @@ cb@p @script:ocaml@ cb << r.cb; p << s.p; @@ Printf.eprintf "Other use of %s at %s:%d\n" cb (List.hd p).file (List.hd p).line @depends on r1 && !s@ expression e; identifier r.cb,f; position r.p; @@ - call_rcu(&e->f,cb@p) + kfree_rcu(e,f) @r1a depends on !s@ type T; identifier x,r.cb; @@ - cb(...) { ( - kmem_cache_free(...); | - T x =3D ...; - kmem_cache_free(...,x); | - T x; - x =3D ...; - kmem_cache_free(...,x); ) - } // Signed-off-by: Julia Lawall Reviewed-by: Paul E. McKenney Reviewed-by: Vlastimil Babka --- drivers/net/wireguard/allowedips.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireguard/allowedips.c b/drivers/net/wireguard/all= owedips.c index 0ba714ca5185..e4e1638fce1b 100644 --- a/drivers/net/wireguard/allowedips.c +++ b/drivers/net/wireguard/allowedips.c @@ -48,11 +48,6 @@ static void push_rcu(struct allowedips_node **stack, } } =20 -static void node_free_rcu(struct rcu_head *rcu) -{ - kmem_cache_free(node_cache, container_of(rcu, struct allowedips_node, rcu= )); -} - static void root_free_rcu(struct rcu_head *rcu) { struct allowedips_node *node, *stack[MAX_ALLOWEDIPS_DEPTH] =3D { @@ -330,13 +325,13 @@ void wg_allowedips_remove_by_peer(struct allowedips *= table, child =3D rcu_dereference_protected( parent->bit[!(node->parent_bit_packed & 1)], lockdep_is_held(lock)); - call_rcu(&node->rcu, node_free_rcu); + kfree_rcu(node, rcu); if (!free_parent) continue; if (child) child->parent_bit_packed =3D parent->parent_bit_packed; *(struct allowedips_node **)(parent->parent_bit_packed & ~3UL) =3D child; - call_rcu(&parent->rcu, node_free_rcu); + kfree_rcu(parent, rcu); } } From nobody Thu Feb 12 19:05:46 2026 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) (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 6B1731A29A; Sun, 9 Jun 2024 08:28:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.134.164.83 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921684; cv=none; b=SxS0UwzBM9yPbwdMmWfLwSU+XSdbZc1k7LEuPkDatNtOYY9s36SCyGwbQNRechzjyKVu1lcmmli8n2p/4IVgVIeyIbI/ih2+f9tFl7Bak1nm3xjjpF8J4HQenu7MPQTbFEiRCjTeHgVtwlHhpZ9HiSOMEqNq5/Bx9DxJ9dY7ZPs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921684; c=relaxed/simple; bh=8EOTu8NZ4aHBZgpM4sxRA7ZWvdlSMq3KQ0y6cMJN7EE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aR3zwsckDkEdXJRsdpyYYa4mVEffDKWk7KIvMciLQFC1mUOwPcH0c12AHF053AMkHCBbRrBd4o3YZRLSVhl2R/rtZmklWj1Y5gboPimsFFfpXeMxONBtTm4dvUYKcH76C9dzFCGqP5tyrUOUfasJzJyCCtfiI7yyZMy84tYAMIk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr; spf=pass smtp.mailfrom=inria.fr; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b=F/R38cNn; arc=none smtp.client-ip=192.134.164.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inria.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b="F/R38cNn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oAvqrV96Fd95umTQHo+JdDNYWaawM6mlWB63mVkkehs=; b=F/R38cNn+JijIjLHTLOX5+YPa5oWs1wb9JyMvpLOTRx9OetOCootFXIw V88tEZuxx6Phy2thcxn8H6+fL5njGx+5It8ZdyEN69Dug8nJemoyTfVTA DNoYk+4n4yCjlrIaGjp1/sbibgwL2/KkGyeRLdL44lGPeBKvxJbt91Sdt 4=; Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=Julia.Lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.08,225,1712613600"; d="scan'208";a="169696897" Received: from i80.paris.inria.fr (HELO i80.paris.inria.fr.) ([128.93.90.48]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2024 10:27:48 +0200 From: Julia Lawall To: "David S. Miller" Cc: kernel-janitors@vger.kernel.org, David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Paul E . McKenney" , Vlastimil Babka Subject: [PATCH 02/14] net: replace call_rcu by kfree_rcu for simple kmem_cache_free callback Date: Sun, 9 Jun 2024 10:27:14 +0200 Message-Id: <20240609082726.32742-3-Julia.Lawall@inria.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240609082726.32742-1-Julia.Lawall@inria.fr> References: <20240609082726.32742-1-Julia.Lawall@inria.fr> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since SLOB was removed, it is not necessary to use call_rcu when the callback only performs kmem_cache_free. Use kfree_rcu() directly. The changes were done using the following Coccinelle semantic patch. This semantic patch is designed to ignore cases where the callback function is used in another way. // @r@ expression e; local idexpression e2; identifier cb,f; position p; @@ ( call_rcu(...,e2) | call_rcu(&e->f,cb@p) ) @r1@ type T; identifier x,r.cb; @@ cb(...) { ( kmem_cache_free(...); | T x =3D ...; kmem_cache_free(...,x); | T x; x =3D ...; kmem_cache_free(...,x); ) } @s depends on r1@ position p !=3D r.p; identifier r.cb; @@ cb@p @script:ocaml@ cb << r.cb; p << s.p; @@ Printf.eprintf "Other use of %s at %s:%d\n" cb (List.hd p).file (List.hd p).line @depends on r1 && !s@ expression e; identifier r.cb,f; position r.p; @@ - call_rcu(&e->f,cb@p) + kfree_rcu(e,f) @r1a depends on !s@ type T; identifier x,r.cb; @@ - cb(...) { ( - kmem_cache_free(...); | - T x =3D ...; - kmem_cache_free(...,x); | - T x; - x =3D ...; - kmem_cache_free(...,x); ) - } // Signed-off-by: Julia Lawall Reviewed-by: Paul E. McKenney Reviewed-by: Vlastimil Babka --- net/ipv4/fib_trie.c | 8 +------- net/ipv4/inetpeer.c | 9 ++------- net/ipv6/ip6_fib.c | 9 +-------- 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index f474106464d2..3ed92e583417 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c @@ -292,15 +292,9 @@ static const int inflate_threshold =3D 50; static const int halve_threshold_root =3D 15; static const int inflate_threshold_root =3D 30; =20 -static void __alias_free_mem(struct rcu_head *head) -{ - struct fib_alias *fa =3D container_of(head, struct fib_alias, rcu); - kmem_cache_free(fn_alias_kmem, fa); -} - static inline void alias_free_mem_rcu(struct fib_alias *fa) { - call_rcu(&fa->rcu, __alias_free_mem); + kfree_rcu(fa, rcu); } =20 #define TNODE_VMALLOC_MAX \ diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c index 5bd759963451..5ab56f4cb529 100644 --- a/net/ipv4/inetpeer.c +++ b/net/ipv4/inetpeer.c @@ -128,11 +128,6 @@ static struct inet_peer *lookup(const struct inetpeer_= addr *daddr, return NULL; } =20 -static void inetpeer_free_rcu(struct rcu_head *head) -{ - kmem_cache_free(peer_cachep, container_of(head, struct inet_peer, rcu)); -} - /* perform garbage collect on all items stacked during a lookup */ static void inet_peer_gc(struct inet_peer_base *base, struct inet_peer *gc_stack[], @@ -168,7 +163,7 @@ static void inet_peer_gc(struct inet_peer_base *base, if (p) { rb_erase(&p->rb_node, &base->rb_root); base->total--; - call_rcu(&p->rcu, inetpeer_free_rcu); + kfree_rcu(p, rcu); } } } @@ -242,7 +237,7 @@ void inet_putpeer(struct inet_peer *p) WRITE_ONCE(p->dtime, (__u32)jiffies); =20 if (refcount_dec_and_test(&p->refcnt)) - call_rcu(&p->rcu, inetpeer_free_rcu); + kfree_rcu(p, rcu); } EXPORT_SYMBOL_GPL(inet_putpeer); =20 diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index d9c9a542a414..bf6908010641 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c @@ -198,16 +198,9 @@ static void node_free_immediate(struct net *net, struc= t fib6_node *fn) net->ipv6.rt6_stats->fib_nodes--; } =20 -static void node_free_rcu(struct rcu_head *head) -{ - struct fib6_node *fn =3D container_of(head, struct fib6_node, rcu); - - kmem_cache_free(fib6_node_kmem, fn); -} - static void node_free(struct net *net, struct fib6_node *fn) { - call_rcu(&fn->rcu, node_free_rcu); + kfree_rcu(fn, rcu); net->ipv6.rt6_stats->fib_nodes--; } From nobody Thu Feb 12 19:05:46 2026 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) (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 9CF7222F1C; Sun, 9 Jun 2024 08:28:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.134.164.83 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921685; cv=none; b=TolEDEeEqo6v5XU6Ru0kculx8XB8mo/L1xEsTZixjqE0Fc3ho18lNn+rzamIPjHZP7cvlK0zEhogPitMwuUj27R8jic/BI5F219qk9fItRJyM1QMuRbTEZQFIap5gYD59y51Dnr9ku99l9kRz3hk2R3nBebLFQXjHOIe/1D5ZLY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921685; c=relaxed/simple; bh=yoTu63QouQ0BjTg8zv0l9uF0vA2xd9QWsFgV+/ef3vY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=D6sXbMwEFhKcj5pXbSkmvhvi5FSVt1L6UUSbdjnY3lS95WA/QU95YH40KrCjHxvE+RiGiGJupJDbWnkRGRxFW55sQnn1rRjt6xhwtWgTFSMcj7c1skj9xwubGIPRM1kklIP2IEloxd6QIM6CjGJzhIPkFUA1D5vorDm+0CTas6Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr; spf=pass smtp.mailfrom=inria.fr; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b=Np+fYlbG; arc=none smtp.client-ip=192.134.164.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inria.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b="Np+fYlbG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZwDxwbFMfkAGTj6xpSZP0MBWfEJMR+icep3KWfFQ5q4=; b=Np+fYlbGt3JUPSQjzXCtgXi8lRudY+xTEr+op3xX7Nwe4QAO64Nvz0am rZWIZtJpKcVG2lVroSwyQ3jRnIZ27KTGZbkh1lAjD+6wVfqlpHsabtPr6 SBJ0rTMWogAnMwz6+VzZO/NGZMFvEtfSzWwmyt6IR3LdYRSo6pzF1YTOG w=; Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=Julia.Lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.08,225,1712613600"; d="scan'208";a="169696898" Received: from i80.paris.inria.fr (HELO i80.paris.inria.fr.) ([128.93.90.48]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2024 10:27:48 +0200 From: Julia Lawall To: Michael Ellerman Cc: kernel-janitors@vger.kernel.org, Nicholas Piggin , Christophe Leroy , "Naveen N. Rao" , linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, "Paul E . McKenney" , Vlastimil Babka Subject: [PATCH 03/14] KVM: PPC: replace call_rcu by kfree_rcu for simple kmem_cache_free callback Date: Sun, 9 Jun 2024 10:27:15 +0200 Message-Id: <20240609082726.32742-4-Julia.Lawall@inria.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240609082726.32742-1-Julia.Lawall@inria.fr> References: <20240609082726.32742-1-Julia.Lawall@inria.fr> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since SLOB was removed, it is not necessary to use call_rcu when the callback only performs kmem_cache_free. Use kfree_rcu() directly. The changes were done using the following Coccinelle semantic patch. This semantic patch is designed to ignore cases where the callback function is used in another way. // @r@ expression e; local idexpression e2; identifier cb,f; position p; @@ ( call_rcu(...,e2) | call_rcu(&e->f,cb@p) ) @r1@ type T; identifier x,r.cb; @@ cb(...) { ( kmem_cache_free(...); | T x =3D ...; kmem_cache_free(...,x); | T x; x =3D ...; kmem_cache_free(...,x); ) } @s depends on r1@ position p !=3D r.p; identifier r.cb; @@ cb@p @script:ocaml@ cb << r.cb; p << s.p; @@ Printf.eprintf "Other use of %s at %s:%d\n" cb (List.hd p).file (List.hd p).line @depends on r1 && !s@ expression e; identifier r.cb,f; position r.p; @@ - call_rcu(&e->f,cb@p) + kfree_rcu(e,f) @r1a depends on !s@ type T; identifier x,r.cb; @@ - cb(...) { ( - kmem_cache_free(...); | - T x =3D ...; - kmem_cache_free(...,x); | - T x; - x =3D ...; - kmem_cache_free(...,x); ) - } // Signed-off-by: Julia Lawall Reviewed-by: Paul E. McKenney Reviewed-by: Vlastimil Babka --- arch/powerpc/kvm/book3s_mmu_hpte.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/powerpc/kvm/book3s_mmu_hpte.c b/arch/powerpc/kvm/book3s_m= mu_hpte.c index ce79ac33e8d3..d904e13e069b 100644 --- a/arch/powerpc/kvm/book3s_mmu_hpte.c +++ b/arch/powerpc/kvm/book3s_mmu_hpte.c @@ -92,12 +92,6 @@ void kvmppc_mmu_hpte_cache_map(struct kvm_vcpu *vcpu, st= ruct hpte_cache *pte) spin_unlock(&vcpu3s->mmu_lock); } =20 -static void free_pte_rcu(struct rcu_head *head) -{ - struct hpte_cache *pte =3D container_of(head, struct hpte_cache, rcu_head= ); - kmem_cache_free(hpte_cache, pte); -} - static void invalidate_pte(struct kvm_vcpu *vcpu, struct hpte_cache *pte) { struct kvmppc_vcpu_book3s *vcpu3s =3D to_book3s(vcpu); @@ -126,7 +120,7 @@ static void invalidate_pte(struct kvm_vcpu *vcpu, struc= t hpte_cache *pte) =20 spin_unlock(&vcpu3s->mmu_lock); =20 - call_rcu(&pte->rcu_head, free_pte_rcu); + kfree_rcu(pte, rcu_head); } =20 static void kvmppc_mmu_pte_flush_all(struct kvm_vcpu *vcpu) From nobody Thu Feb 12 19:05:46 2026 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) (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 02F412B9DE; Sun, 9 Jun 2024 08:28:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.134.164.83 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921687; cv=none; b=kDuC3jgKXJcFIJRpncpCawW7JxgB+WL5bksZJUgNjzKe11dIx2xJZ+XKahPey36LC05tUzftBCxlkoDdrnC9drb28FVit/ksEh1fHoQmlLD8B2s6Uhgzcr6MqJNVyFHpQNCeF5EaNmqP11E1CFzisUHlp5UVLPXgn9bjx6lBQvU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921687; c=relaxed/simple; bh=qLLVPjhv4+wYws/zoYNgUIy1WO/VEbOv0vP9ijH0hiA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TQT1bz45xWV+s61mwNrOZi3F1GDIjSwgIlA+ovsXx4UUKkTZGRtgQVuyiatISXjHQq+Bd2S3QtMAiTlZgi8gfjSK2knoA2QOntww/DiR1FXrWk7wKS8Kc3N+RO8UTaowQYFLsXoAgRXnSnoX+J+pQuMk+dOAMzZo9pcTrKuXsYo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr; spf=pass smtp.mailfrom=inria.fr; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b=VR9ZkR/t; arc=none smtp.client-ip=192.134.164.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inria.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b="VR9ZkR/t" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iFEsC8pdLHrqgm1R6uMYK9SmKFFJArc3WZMs1JbRrx4=; b=VR9ZkR/tb+iYAA9REZgVRsraxFHkhZ11fgfCacvLyn02NmHJfc87gyLD Ojt+FUosbkgoSE2C1JMAQN7vG2gd5dwBE+hs3r4NSMfW9A2ghm9xVo/Oy EOcbUxpNmR1GmMsTZzlJnUFmbdZ+8sCYfx7nFLbM81IfNLvBurUvDfYLL A=; Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=Julia.Lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.08,225,1712613600"; d="scan'208";a="169696899" Received: from i80.paris.inria.fr (HELO i80.paris.inria.fr.) ([128.93.90.48]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2024 10:27:48 +0200 From: Julia Lawall To: Steffen Klassert Cc: kernel-janitors@vger.kernel.org, Herbert Xu , "David S. Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Paul E . McKenney" , Vlastimil Babka Subject: [PATCH 04/14] xfrm6_tunnel: replace call_rcu by kfree_rcu for simple kmem_cache_free callback Date: Sun, 9 Jun 2024 10:27:16 +0200 Message-Id: <20240609082726.32742-5-Julia.Lawall@inria.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240609082726.32742-1-Julia.Lawall@inria.fr> References: <20240609082726.32742-1-Julia.Lawall@inria.fr> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since SLOB was removed, it is not necessary to use call_rcu when the callback only performs kmem_cache_free. Use kfree_rcu() directly. The changes were done using the following Coccinelle semantic patch. This semantic patch is designed to ignore cases where the callback function is used in another way. // @r@ expression e; local idexpression e2; identifier cb,f; position p; @@ ( call_rcu(...,e2) | call_rcu(&e->f,cb@p) ) @r1@ type T; identifier x,r.cb; @@ cb(...) { ( kmem_cache_free(...); | T x =3D ...; kmem_cache_free(...,x); | T x; x =3D ...; kmem_cache_free(...,x); ) } @s depends on r1@ position p !=3D r.p; identifier r.cb; @@ cb@p @script:ocaml@ cb << r.cb; p << s.p; @@ Printf.eprintf "Other use of %s at %s:%d\n" cb (List.hd p).file (List.hd p).line @depends on r1 && !s@ expression e; identifier r.cb,f; position r.p; @@ - call_rcu(&e->f,cb@p) + kfree_rcu(e,f) @r1a depends on !s@ type T; identifier x,r.cb; @@ - cb(...) { ( - kmem_cache_free(...); | - T x =3D ...; - kmem_cache_free(...,x); | - T x; - x =3D ...; - kmem_cache_free(...,x); ) - } // Signed-off-by: Julia Lawall Reviewed-by: Paul E. McKenney Reviewed-by: Vlastimil Babka --- net/ipv6/xfrm6_tunnel.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c index bf140ef781c1..c3c893ddb6ee 100644 --- a/net/ipv6/xfrm6_tunnel.c +++ b/net/ipv6/xfrm6_tunnel.c @@ -178,12 +178,6 @@ __be32 xfrm6_tunnel_alloc_spi(struct net *net, xfrm_ad= dress_t *saddr) } EXPORT_SYMBOL(xfrm6_tunnel_alloc_spi); =20 -static void x6spi_destroy_rcu(struct rcu_head *head) -{ - kmem_cache_free(xfrm6_tunnel_spi_kmem, - container_of(head, struct xfrm6_tunnel_spi, rcu_head)); -} - static void xfrm6_tunnel_free_spi(struct net *net, xfrm_address_t *saddr) { struct xfrm6_tunnel_net *xfrm6_tn =3D xfrm6_tunnel_pernet(net); @@ -200,7 +194,7 @@ static void xfrm6_tunnel_free_spi(struct net *net, xfrm= _address_t *saddr) if (refcount_dec_and_test(&x6spi->refcnt)) { hlist_del_rcu(&x6spi->list_byaddr); hlist_del_rcu(&x6spi->list_byspi); - call_rcu(&x6spi->rcu_head, x6spi_destroy_rcu); + kfree_rcu(x6spi, rcu_head); break; } } From nobody Thu Feb 12 19:05:46 2026 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) (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 2F4902C19E; Sun, 9 Jun 2024 08:28:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.134.164.83 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921687; cv=none; b=IZ5Hb46i/ghjymQSfKhIw5yNFekLDMfHWyy/QFSbpIn/nBIGDfYXLuT0NzTmAq2hrgnkIebD28j+v4rJ9A/F3X7FKmrdW3R8b96cxB22BdQof4wgyeD06BOoRNseFqgoCGGLrw7YdW4zVQ7ryaVnGJRWgUokemV5RkwGNCGXyGc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921687; c=relaxed/simple; bh=NiNHIvLM53266J2UpSupU/mhEjqFwYGKpKv/PxEnfjg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iMvqTtc8OxJ/bcazbLB6tHWmsivPUY3XgEuxkcKHXxe4TT+0k71431dlvaB4aBHq/J08OnfiEMk4nvsheIEn16UpErARxQKTfQiFvhxzX/okbJ5rYru8wjgRg7Ht+18JtZufXWQh+l4E+pvfuL6azLqYaVl6quK7hrCZphZ6VLY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr; spf=pass smtp.mailfrom=inria.fr; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b=MIfxNhRD; arc=none smtp.client-ip=192.134.164.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inria.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b="MIfxNhRD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZGX1+w2KuTr4rSi8N+qfCTHA1YisBmkGA0Ss7Dju5os=; b=MIfxNhRDBVUjuFmHXlb+sNburKUTYfbjg/5uLy1R/ywhQBlUW+zmy4Xu 2tU+2GFyi/wU/NwekIaEysW7i7MDCEFJKzQ8LxGDPQTvwvOMtfm0mKKVZ Hzr8XViuT/8Vp0pCRmkFXP49qaxPROuwsqKjRs23k8XwrZq8qMHUd4FeW 8=; Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=Julia.Lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.08,225,1712613600"; d="scan'208";a="169696900" Received: from i80.paris.inria.fr (HELO i80.paris.inria.fr.) ([128.93.90.48]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2024 10:27:49 +0200 From: Julia Lawall To: Steven Rostedt Cc: kernel-janitors@vger.kernel.org, Masami Hiramatsu , Mathieu Desnoyers , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, "Paul E . McKenney" , Vlastimil Babka Subject: [PATCH 05/14] tracefs: replace call_rcu by kfree_rcu for simple kmem_cache_free callback Date: Sun, 9 Jun 2024 10:27:17 +0200 Message-Id: <20240609082726.32742-6-Julia.Lawall@inria.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240609082726.32742-1-Julia.Lawall@inria.fr> References: <20240609082726.32742-1-Julia.Lawall@inria.fr> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since SLOB was removed, it is not necessary to use call_rcu when the callback only performs kmem_cache_free. Use kfree_rcu() directly. The changes were done using the following Coccinelle semantic patch. This semantic patch is designed to ignore cases where the callback function is used in another way. // @r@ expression e; local idexpression e2; identifier cb,f; position p; @@ ( call_rcu(...,e2) | call_rcu(&e->f,cb@p) ) @r1@ type T; identifier x,r.cb; @@ cb(...) { ( kmem_cache_free(...); | T x =3D ...; kmem_cache_free(...,x); | T x; x =3D ...; kmem_cache_free(...,x); ) } @s depends on r1@ position p !=3D r.p; identifier r.cb; @@ cb@p @script:ocaml@ cb << r.cb; p << s.p; @@ Printf.eprintf "Other use of %s at %s:%d\n" cb (List.hd p).file (List.hd p).line @depends on r1 && !s@ expression e; identifier r.cb,f; position r.p; @@ - call_rcu(&e->f,cb@p) + kfree_rcu(e,f) @r1a depends on !s@ type T; identifier x,r.cb; @@ - cb(...) { ( - kmem_cache_free(...); | - T x =3D ...; - kmem_cache_free(...,x); | - T x; - x =3D ...; - kmem_cache_free(...,x); ) - } // Signed-off-by: Julia Lawall Reviewed-by: Paul E. McKenney Reviewed-by: Vlastimil Babka Acked-by: Steven Rostedt (Google) --- fs/tracefs/inode.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index 7c29f4afc23d..338c52168e61 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -53,14 +53,6 @@ static struct inode *tracefs_alloc_inode(struct super_bl= ock *sb) return &ti->vfs_inode; } =20 -static void tracefs_free_inode_rcu(struct rcu_head *rcu) -{ - struct tracefs_inode *ti; - - ti =3D container_of(rcu, struct tracefs_inode, rcu); - kmem_cache_free(tracefs_inode_cachep, ti); -} - static void tracefs_free_inode(struct inode *inode) { struct tracefs_inode *ti =3D get_tracefs(inode); @@ -70,7 +62,7 @@ static void tracefs_free_inode(struct inode *inode) list_del_rcu(&ti->list); spin_unlock_irqrestore(&tracefs_inode_lock, flags); =20 - call_rcu(&ti->rcu, tracefs_free_inode_rcu); + kfree_rcu(ti, rcu); } =20 static ssize_t default_read_file(struct file *file, char __user *buf, From nobody Thu Feb 12 19:05:46 2026 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) (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 403C63C08A; Sun, 9 Jun 2024 08:28:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.134.164.83 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921688; cv=none; b=s75HsizOVppMaJiOSTUcUWdiwfJpLCAC6GDPaO68d5mzw6FyRts5uEFo61RAPhOoymZRzVtNgcsvHpUFTVDTvFHksprkIWnlSX/CeH0peOCiCbftNfGxcXx17lNvE0S+kDSWjRSKCHB6JcsYzOjP1H7wdeAN2rMMkHwTyTvGBAU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921688; c=relaxed/simple; bh=5wI1NTKdDad7dOStebKBSk9uWDGpHBDxRnxOxJWOoVo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=M7qyrUC+yRWgcvBsZrhQxPwua/1eY6hhcTlpMQHCOsFcOMGYAJ5zDiGaaNXAo7DirrpRNy9OnR93NaITbPHPuqVQoVBcsFrQskI93Wpxv+fQvSjQe9j7dY7EJir2BD681zmw+lYNwp98ct6yVfv9RIfgZ6C71/wYPbUxAUrPSPY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr; spf=pass smtp.mailfrom=inria.fr; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b=blhbqvv0; arc=none smtp.client-ip=192.134.164.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inria.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b="blhbqvv0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xAStzLZkQB6YwSsZPfAII2SYwdVea64Ufn5+/gSYkrE=; b=blhbqvv0Wb9SIDXwLzTi0L0Z9DajeIrlkeJbk5bnT7Gfqs4bFlCpK5XG gG5EHbmBIY65EQMWVx5yi27suOz6HhOuM+rSLZm7xMOBpg/jRj91zXwzo L3RG1ioMbgf9bBJ6WWuX1uxfa7lBLbNMLWWOWt/7ZfXJMSx2IpI0bWRRr w=; Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=Julia.Lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.08,225,1712613600"; d="scan'208";a="169696901" Received: from i80.paris.inria.fr (HELO i80.paris.inria.fr.) ([128.93.90.48]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2024 10:27:49 +0200 From: Julia Lawall To: Tyler Hicks Cc: kernel-janitors@vger.kernel.org, ecryptfs@vger.kernel.org, linux-kernel@vger.kernel.org, "Paul E . McKenney" , Vlastimil Babka Subject: [PATCH 06/14] eCryptfs: replace call_rcu by kfree_rcu for simple kmem_cache_free callback Date: Sun, 9 Jun 2024 10:27:18 +0200 Message-Id: <20240609082726.32742-7-Julia.Lawall@inria.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240609082726.32742-1-Julia.Lawall@inria.fr> References: <20240609082726.32742-1-Julia.Lawall@inria.fr> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since SLOB was removed, it is not necessary to use call_rcu when the callback only performs kmem_cache_free. Use kfree_rcu() directly. The changes were done using the following Coccinelle semantic patch. This semantic patch is designed to ignore cases where the callback function is used in another way. // @r@ expression e; local idexpression e2; identifier cb,f; position p; @@ ( call_rcu(...,e2) | call_rcu(&e->f,cb@p) ) @r1@ type T; identifier x,r.cb; @@ cb(...) { ( kmem_cache_free(...); | T x =3D ...; kmem_cache_free(...,x); | T x; x =3D ...; kmem_cache_free(...,x); ) } @s depends on r1@ position p !=3D r.p; identifier r.cb; @@ cb@p @script:ocaml@ cb << r.cb; p << s.p; @@ Printf.eprintf "Other use of %s at %s:%d\n" cb (List.hd p).file (List.hd p).line @depends on r1 && !s@ expression e; identifier r.cb,f; position r.p; @@ - call_rcu(&e->f,cb@p) + kfree_rcu(e,f) @r1a depends on !s@ type T; identifier x,r.cb; @@ - cb(...) { ( - kmem_cache_free(...); | - T x =3D ...; - kmem_cache_free(...,x); | - T x; - x =3D ...; - kmem_cache_free(...,x); ) - } // Signed-off-by: Julia Lawall Reviewed-by: Paul E. McKenney Reviewed-by: Vlastimil Babka --- fs/ecryptfs/dentry.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/fs/ecryptfs/dentry.c b/fs/ecryptfs/dentry.c index acaa0825e9bb..49d626ff33a9 100644 --- a/fs/ecryptfs/dentry.c +++ b/fs/ecryptfs/dentry.c @@ -51,12 +51,6 @@ static int ecryptfs_d_revalidate(struct dentry *dentry, = unsigned int flags) =20 struct kmem_cache *ecryptfs_dentry_info_cache; =20 -static void ecryptfs_dentry_free_rcu(struct rcu_head *head) -{ - kmem_cache_free(ecryptfs_dentry_info_cache, - container_of(head, struct ecryptfs_dentry_info, rcu)); -} - /** * ecryptfs_d_release * @dentry: The ecryptfs dentry @@ -68,7 +62,7 @@ static void ecryptfs_d_release(struct dentry *dentry) struct ecryptfs_dentry_info *p =3D dentry->d_fsdata; if (p) { path_put(&p->lower_path); - call_rcu(&p->rcu, ecryptfs_dentry_free_rcu); + kfree_rcu(p, rcu); } } From nobody Thu Feb 12 19:05:46 2026 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) (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 9E53D42ABB; Sun, 9 Jun 2024 08:28:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.134.164.83 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921689; cv=none; b=Y62g/MtfU5iZ4rkXTmN3KoHlSmCnGuJEJyueK/UnfP6XlQ/IAmwJPdTpny2y6vNDu2xH751eRo3gdRgoUeBoLTaLbyEIW429wkjdI7bAD1avnozXfHTjSxPJJEVPafuhnPa+i9sabmlMcPfIHobF3/0WwYuADvAKkmezAIFWT0w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921689; c=relaxed/simple; bh=irC8fbFwp7wQh8iZf7JFEGok5dZ8XencbVCgVtWTxS4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UPPsO7Qrz8SL2DWIPtgXvCBygIIZNuJwwF+PD6CoiydOMxrcSCClU0dG59uzgHi6X7wuzFCJFOOgBqtOBrpZQQVNcNDYVTZiwnSvKtmrP2Io1ph9Feew0sdzMNwDfb/pL6La93ZwHmsV+Qul05S05Dj1cHSAq+9sINQivyjjMno= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr; spf=pass smtp.mailfrom=inria.fr; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b=fCRsvyXY; arc=none smtp.client-ip=192.134.164.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inria.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b="fCRsvyXY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UkPBDoz0/T0BpEX6aT7kB9YfBRlH8trgIJDVH+Mo814=; b=fCRsvyXYKWWrMrtyUOKC2r+mAOP1Mrr62JK1is8IDKXo5ovDWJdvl/nf QIq+Nr4EWSjWRKc49yr+WQgBkgPta5K6/mM3TjllkKlJQdhFO1J/AuBI3 ZnLRlK7FLXCBkj/50gAAQpfu+Wdgx+7vb55zQNIgbIgPEjqQCWVlfDTkp U=; Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=Julia.Lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.08,225,1712613600"; d="scan'208";a="169696902" Received: from i80.paris.inria.fr (HELO i80.paris.inria.fr.) ([128.93.90.48]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2024 10:27:49 +0200 From: Julia Lawall To: Roopa Prabhu Cc: kernel-janitors@vger.kernel.org, Nikolay Aleksandrov , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , bridge@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Paul E . McKenney" , Vlastimil Babka Subject: [PATCH 07/14] net: bridge: replace call_rcu by kfree_rcu for simple kmem_cache_free callback Date: Sun, 9 Jun 2024 10:27:19 +0200 Message-Id: <20240609082726.32742-8-Julia.Lawall@inria.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240609082726.32742-1-Julia.Lawall@inria.fr> References: <20240609082726.32742-1-Julia.Lawall@inria.fr> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since SLOB was removed, it is not necessary to use call_rcu when the callback only performs kmem_cache_free. Use kfree_rcu() directly. The changes were done using the following Coccinelle semantic patch. This semantic patch is designed to ignore cases where the callback function is used in another way. // @r@ expression e; local idexpression e2; identifier cb,f; position p; @@ ( call_rcu(...,e2) | call_rcu(&e->f,cb@p) ) @r1@ type T; identifier x,r.cb; @@ cb(...) { ( kmem_cache_free(...); | T x =3D ...; kmem_cache_free(...,x); | T x; x =3D ...; kmem_cache_free(...,x); ) } @s depends on r1@ position p !=3D r.p; identifier r.cb; @@ cb@p @script:ocaml@ cb << r.cb; p << s.p; @@ Printf.eprintf "Other use of %s at %s:%d\n" cb (List.hd p).file (List.hd p).line @depends on r1 && !s@ expression e; identifier r.cb,f; position r.p; @@ - call_rcu(&e->f,cb@p) + kfree_rcu(e,f) @r1a depends on !s@ type T; identifier x,r.cb; @@ - cb(...) { ( - kmem_cache_free(...); | - T x =3D ...; - kmem_cache_free(...,x); | - T x; - x =3D ...; - kmem_cache_free(...,x); ) - } // Signed-off-by: Julia Lawall Reviewed-by: Paul E. McKenney Reviewed-by: Vlastimil Babka Acked-by: Nikolay Aleksandrov --- net/bridge/br_fdb.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c index c77591e63841..6d04b48f7e2c 100644 --- a/net/bridge/br_fdb.c +++ b/net/bridge/br_fdb.c @@ -73,13 +73,6 @@ static inline int has_expired(const struct net_bridge *b= r, time_before_eq(fdb->updated + hold_time(br), jiffies); } =20 -static void fdb_rcu_free(struct rcu_head *head) -{ - struct net_bridge_fdb_entry *ent - =3D container_of(head, struct net_bridge_fdb_entry, rcu); - kmem_cache_free(br_fdb_cache, ent); -} - static int fdb_to_nud(const struct net_bridge *br, const struct net_bridge_fdb_entry *fdb) { @@ -329,7 +322,7 @@ static void fdb_delete(struct net_bridge *br, struct ne= t_bridge_fdb_entry *f, if (test_and_clear_bit(BR_FDB_DYNAMIC_LEARNED, &f->flags)) atomic_dec(&br->fdb_n_learned); fdb_notify(br, f, RTM_DELNEIGH, swdev_notify); - call_rcu(&f->rcu, fdb_rcu_free); + kfree_rcu(f, rcu); } =20 /* Delete a local entry if no other port had the same address. From nobody Thu Feb 12 19:05:46 2026 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) (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 C77D943AC4; Sun, 9 Jun 2024 08:28:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.134.164.83 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921690; cv=none; b=h3BoOJizbQQXksn62KpjKwtGwb0H+VFj4usW8sVOuoS0ccrP6EqlpePEa0LcTJFkZezAqhfAGonnDwexRZf8myo68himvH8QgNV9lqsAZ9rURyQtQ27YX999l5nx5MudManLStEKQi4wgcvw1ACX/X9+CWDadpKiwwXn1iy7fjE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921690; c=relaxed/simple; bh=Qp2RjQ8VkOQTaoXnD6TX34dUZQu054wgPDHLmAVYGDE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EW12XT1am2cHXQeFPSFO9GdqKblnwmbm3e8QGFtln1hcb78URR8SYlmkEM6xmlLJHY9NkwHjHqeUvijZO0RLIhS1rDvkyti8Bv/+wDth0thcZU+vPcaJ/ILY+sCoaEziUXzuExGeG8EReXKX+d5VlYcqL743+GlLaynZozocsEc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr; spf=pass smtp.mailfrom=inria.fr; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b=viK9I564; arc=none smtp.client-ip=192.134.164.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inria.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b="viK9I564" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BdnoVUpltl/xR9ROt1N8oEK2JrBwDybKM3Rgid1qRFg=; b=viK9I564wPsJ6oXpH75f7+76jd/W7CEEEcz8PWhM3NI+B7p3XIKIdzWY oeE8X9eXCdOJJaUhsLSM5nwgLXAD6KUDdj1Onf8NB9Y9G/RiZ0WO4XA7A Ezu2Qfc8+S+pgV9uUy3fTs4rwYYer3VfGnX9RYZf3+fboFQLayo81iZe1 c=; Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=Julia.Lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.08,225,1712613600"; d="scan'208";a="169696903" Received: from i80.paris.inria.fr (HELO i80.paris.inria.fr.) ([128.93.90.48]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2024 10:27:49 +0200 From: Julia Lawall To: Chuck Lever Cc: kernel-janitors@vger.kernel.org, Jeff Layton , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, "Paul E . McKenney" , Vlastimil Babka Subject: [PATCH 08/14] nfsd: replace call_rcu by kfree_rcu for simple kmem_cache_free callback Date: Sun, 9 Jun 2024 10:27:20 +0200 Message-Id: <20240609082726.32742-9-Julia.Lawall@inria.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240609082726.32742-1-Julia.Lawall@inria.fr> References: <20240609082726.32742-1-Julia.Lawall@inria.fr> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since SLOB was removed, it is not necessary to use call_rcu when the callback only performs kmem_cache_free. Use kfree_rcu() directly. The changes were done using the following Coccinelle semantic patch. This semantic patch is designed to ignore cases where the callback function is used in another way. // @r@ expression e; local idexpression e2; identifier cb,f; position p; @@ ( call_rcu(...,e2) | call_rcu(&e->f,cb@p) ) @r1@ type T; identifier x,r.cb; @@ cb(...) { ( kmem_cache_free(...); | T x =3D ...; kmem_cache_free(...,x); | T x; x =3D ...; kmem_cache_free(...,x); ) } @s depends on r1@ position p !=3D r.p; identifier r.cb; @@ cb@p @script:ocaml@ cb << r.cb; p << s.p; @@ Printf.eprintf "Other use of %s at %s:%d\n" cb (List.hd p).file (List.hd p).line @depends on r1 && !s@ expression e; identifier r.cb,f; position r.p; @@ - call_rcu(&e->f,cb@p) + kfree_rcu(e,f) @r1a depends on !s@ type T; identifier x,r.cb; @@ - cb(...) { ( - kmem_cache_free(...); | - T x =3D ...; - kmem_cache_free(...,x); | - T x; - x =3D ...; - kmem_cache_free(...,x); ) - } // Signed-off-by: Julia Lawall Reviewed-by: Paul E. McKenney Reviewed-by: Vlastimil Babka Acked-by: Chuck Lever Reviewed-by: Jeff Layton --- fs/nfsd/nfs4state.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index a20c2c9d7d45..eba5083504c7 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -571,13 +571,6 @@ opaque_hashval(const void *ptr, int nbytes) return x; } =20 -static void nfsd4_free_file_rcu(struct rcu_head *rcu) -{ - struct nfs4_file *fp =3D container_of(rcu, struct nfs4_file, fi_rcu); - - kmem_cache_free(file_slab, fp); -} - void put_nfs4_file(struct nfs4_file *fi) { @@ -585,7 +578,7 @@ put_nfs4_file(struct nfs4_file *fi) nfsd4_file_hash_remove(fi); WARN_ON_ONCE(!list_empty(&fi->fi_clnt_odstate)); WARN_ON_ONCE(!list_empty(&fi->fi_delegations)); - call_rcu(&fi->fi_rcu, nfsd4_free_file_rcu); + kfree_rcu(fi, fi_rcu); } } From nobody Thu Feb 12 19:05:46 2026 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) (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 DA8DE46450; Sun, 9 Jun 2024 08:28:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.134.164.83 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921691; cv=none; b=IjGXWO+0raqIOlIYBFNISPM4QqIp68erIY3xJYKxIT0qcnVgBvGIuVzLhMTXGvFqjuiWFcBIk8QLw6Xwu+Jx4TiRQbQJ2SL8R3+7YEz+DUkY1ePIG6OT2syTbIZDUfw4ahk7mT0RQRj0sJEsCNKYMQnF3GeNrQgF4bh6oFgImjM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921691; c=relaxed/simple; bh=GPl3J34M1d7NjmG00uBdfMYpPYDtbP1uZbBHCNdhJQc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QQS972VpI44Ka0TYbz1Euw1KMiQ5MQhTqL34Av4ypvicDKwp9xOjXqYbUMF/uomQOeq2+EDGwiMPSAGbMzw0MAeQyI0xuuOliHaNPCASle2t6Y/1NBx+RshtbUtYoLiVd8K76obvBv4TNRslrQUB2yXZIk4f9NAeZnJStyaA2O4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr; spf=pass smtp.mailfrom=inria.fr; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b=IgQ0MyW2; arc=none smtp.client-ip=192.134.164.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inria.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b="IgQ0MyW2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YQXnrH/08rhpNkHP4SNUqJ/atSEr8v14IoPZZmef880=; b=IgQ0MyW2rkojQw4XJ41XCYNyMbhdPXIdKBamHkri3xuQXbotjCSMI0PI 7bMEDVQSODgpQ5t3pXWVvE1Ck+JMwYJ5vvwSMbuWhDWEOVMQHlCI3Vhsf JKCB30mAP/Y0kzTFt2wadul2Jc2GMBRC04jev/bvyWJj4x6d+13yI4Qgj s=; Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=Julia.Lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.08,225,1712613600"; d="scan'208";a="169696904" Received: from i80.paris.inria.fr (HELO i80.paris.inria.fr.) ([128.93.90.48]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2024 10:27:49 +0200 From: Julia Lawall To: Jens Axboe Cc: kernel-janitors@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, "Paul E . McKenney" , Vlastimil Babka Subject: [PATCH 09/14] block: replace call_rcu by kfree_rcu for simple kmem_cache_free callback Date: Sun, 9 Jun 2024 10:27:21 +0200 Message-Id: <20240609082726.32742-10-Julia.Lawall@inria.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240609082726.32742-1-Julia.Lawall@inria.fr> References: <20240609082726.32742-1-Julia.Lawall@inria.fr> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since SLOB was removed, it is not necessary to use call_rcu when the callback only performs kmem_cache_free. Use kfree_rcu() directly. The changes were done using the following Coccinelle semantic patch. This semantic patch is designed to ignore cases where the callback function is used in another way. // @r@ expression e; local idexpression e2; identifier cb,f; position p; @@ ( call_rcu(...,e2) | call_rcu(&e->f,cb@p) ) @r1@ type T; identifier x,r.cb; @@ cb(...) { ( kmem_cache_free(...); | T x =3D ...; kmem_cache_free(...,x); | T x; x =3D ...; kmem_cache_free(...,x); ) } @s depends on r1@ position p !=3D r.p; identifier r.cb; @@ cb@p @script:ocaml@ cb << r.cb; p << s.p; @@ Printf.eprintf "Other use of %s at %s:%d\n" cb (List.hd p).file (List.hd p).line @depends on r1 && !s@ expression e; identifier r.cb,f; position r.p; @@ - call_rcu(&e->f,cb@p) + kfree_rcu(e,f) @r1a depends on !s@ type T; identifier x,r.cb; @@ - cb(...) { ( - kmem_cache_free(...); | - T x =3D ...; - kmem_cache_free(...,x); | - T x; - x =3D ...; - kmem_cache_free(...,x); ) - } // Signed-off-by: Julia Lawall Reviewed-by: Paul E. McKenney Reviewed-by: Vlastimil Babka --- block/blk-ioc.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/block/blk-ioc.c b/block/blk-ioc.c index 25dd4db11121..ce82770c72ab 100644 --- a/block/blk-ioc.c +++ b/block/blk-ioc.c @@ -32,13 +32,6 @@ static void get_io_context(struct io_context *ioc) atomic_long_inc(&ioc->refcount); } =20 -static void icq_free_icq_rcu(struct rcu_head *head) -{ - struct io_cq *icq =3D container_of(head, struct io_cq, __rcu_head); - - kmem_cache_free(icq->__rcu_icq_cache, icq); -} - /* * Exit an icq. Called with ioc locked for blk-mq, and with both ioc * and queue locked for legacy. @@ -102,7 +95,7 @@ static void ioc_destroy_icq(struct io_cq *icq) */ icq->__rcu_icq_cache =3D et->icq_cache; icq->flags |=3D ICQ_DESTROYED; - call_rcu(&icq->__rcu_head, icq_free_icq_rcu); + kfree_rcu(icq, __rcu_head); } =20 /* From nobody Thu Feb 12 19:05:46 2026 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) (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 3BAAA482FF; Sun, 9 Jun 2024 08:28:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.134.164.83 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921692; cv=none; b=N8ifeB0voo3JHccnLWotuGn6u28WDVMhv8LEVez8TN6TKm/ZxZAmxKNq6qqVN6ytlrRVSVk0YbG8AcKXBGycUvQRCWbfqJ3n6mcDuqAoRKKLGWAfJTSw6l7ilYGKGnZM8chnUfwCxE5Zk/WwOs4uSHiBgI5/y6nyJi+MkxI4PnE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921692; c=relaxed/simple; bh=6GIjz5N6hc/+rjpb+kIsuZe52mzAkiPpkv+A8YoO+MI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iTNc/NTORkIq/AT6N+klMd4gTdIdTs3p0j/DIynbTRRoUFreid/nenoIMdVGY2/G+/MtzutFN5qCyuwiEPCzsC/2D5WC3zzCY4Pm1iY0oSqr06YuhQIY75T7L/bG3wdBG3XYaaH24doZ9UyUAGD8xZNvFAF8rqV0ZwCMx4dYH+Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr; spf=pass smtp.mailfrom=inria.fr; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b=piJcIS//; arc=none smtp.client-ip=192.134.164.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inria.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b="piJcIS//" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=X9IqNiprrXZb6MHGk7aZq3SWcPVK5fPzmf82pe9GCT8=; b=piJcIS//x58NzsIAPazGIB+abmqDcnvkuqGskL8US1zhYqDV8rt3qBPc h6CIeifF90XNr/yhhLY/VPzaE2/VJlIk3jEopBvzmI7jbBXkvoD1+yEhu rz7e3w+JXN9wDDW+odxmdOb54ZSBeILJrZZFdlEEnR1kl0UtOmhnkrj4t k=; Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=Julia.Lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.08,225,1712613600"; d="scan'208";a="169696905" Received: from i80.paris.inria.fr (HELO i80.paris.inria.fr.) ([128.93.90.48]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2024 10:27:49 +0200 From: Julia Lawall To: Oliver Hartkopp Cc: kernel-janitors@vger.kernel.org, Marc Kleine-Budde , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Paul E . McKenney" , Vlastimil Babka Subject: [PATCH 10/14] can: gw: replace call_rcu by kfree_rcu for simple kmem_cache_free callback Date: Sun, 9 Jun 2024 10:27:22 +0200 Message-Id: <20240609082726.32742-11-Julia.Lawall@inria.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240609082726.32742-1-Julia.Lawall@inria.fr> References: <20240609082726.32742-1-Julia.Lawall@inria.fr> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since SLOB was removed, it is not necessary to use call_rcu when the callback only performs kmem_cache_free. Use kfree_rcu() directly. The changes were done using the following Coccinelle semantic patch. This semantic patch is designed to ignore cases where the callback function is used in another way. // @r@ expression e; local idexpression e2; identifier cb,f; position p; @@ ( call_rcu(...,e2) | call_rcu(&e->f,cb@p) ) @r1@ type T; identifier x,r.cb; @@ cb(...) { ( kmem_cache_free(...); | T x =3D ...; kmem_cache_free(...,x); | T x; x =3D ...; kmem_cache_free(...,x); ) } @s depends on r1@ position p !=3D r.p; identifier r.cb; @@ cb@p @script:ocaml@ cb << r.cb; p << s.p; @@ Printf.eprintf "Other use of %s at %s:%d\n" cb (List.hd p).file (List.hd p).line @depends on r1 && !s@ expression e; identifier r.cb,f; position r.p; @@ - call_rcu(&e->f,cb@p) + kfree_rcu(e,f) @r1a depends on !s@ type T; identifier x,r.cb; @@ - cb(...) { ( - kmem_cache_free(...); | - T x =3D ...; - kmem_cache_free(...,x); | - T x; - x =3D ...; - kmem_cache_free(...,x); ) - } // Signed-off-by: Julia Lawall Reviewed-by: Paul E. McKenney Reviewed-by: Vlastimil Babka Acked-by: Oliver Hartkopp --- net/can/gw.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/net/can/gw.c b/net/can/gw.c index 37528826935e..ffb9870e2d01 100644 --- a/net/can/gw.c +++ b/net/can/gw.c @@ -577,13 +577,6 @@ static inline void cgw_unregister_filter(struct net *n= et, struct cgw_job *gwj) gwj->ccgw.filter.can_mask, can_can_gw_rcv, gwj); } =20 -static void cgw_job_free_rcu(struct rcu_head *rcu_head) -{ - struct cgw_job *gwj =3D container_of(rcu_head, struct cgw_job, rcu); - - kmem_cache_free(cgw_cache, gwj); -} - static int cgw_notifier(struct notifier_block *nb, unsigned long msg, void *ptr) { @@ -603,7 +596,7 @@ static int cgw_notifier(struct notifier_block *nb, if (gwj->src.dev =3D=3D dev || gwj->dst.dev =3D=3D dev) { hlist_del(&gwj->list); cgw_unregister_filter(net, gwj); - call_rcu(&gwj->rcu, cgw_job_free_rcu); + kfree_rcu(gwj, rcu); } } } @@ -1168,7 +1161,7 @@ static void cgw_remove_all_jobs(struct net *net) hlist_for_each_entry_safe(gwj, nx, &net->can.cgw_list, list) { hlist_del(&gwj->list); cgw_unregister_filter(net, gwj); - call_rcu(&gwj->rcu, cgw_job_free_rcu); + kfree_rcu(gwj, rcu); } } =20 @@ -1236,7 +1229,7 @@ static int cgw_remove_job(struct sk_buff *skb, struct= nlmsghdr *nlh, =20 hlist_del(&gwj->list); cgw_unregister_filter(net, gwj); - call_rcu(&gwj->rcu, cgw_job_free_rcu); + kfree_rcu(gwj, rcu); err =3D 0; break; } From nobody Thu Feb 12 19:05:46 2026 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) (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 6407A4AEEF; Sun, 9 Jun 2024 08:28:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.134.164.83 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921692; cv=none; b=KgHh4JOULa6nN9zC4PEpQYlhrxkmDi4Vod9pnQmf31b8kxBlO39ebGJgL0hoD0R1LzFzbb+xNHVuH9BgnD6NVoeQxte3YRb4dLzed7yH5izbh464wMo1RIfi1Wea4d5uFDMvBPCbewHzfZZ8T27rA1274RMM2V87aB/JMFU5nbQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921692; c=relaxed/simple; bh=GdljLaLr8e2ac9pRTDj/L0VN9xs0OlSFKWDz1A6N+NQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lBckZwFHtb14FUDfTizyr9FHmYco6F0MRtfEoVeOMx4gaMlZrvQYEW3GaOzDC9Mxl0MzKD6R1zOI3Bmtl82lpFhjr+2BT4/xN+ql2p/z1MrC3kHK+tNrbzOSAzt2t/uYDXB/ME67Wk04WpXfSLnrVvKIjl6UDyWFMrR71ByuPMY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr; spf=pass smtp.mailfrom=inria.fr; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b=bb3XFAHK; arc=none smtp.client-ip=192.134.164.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inria.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b="bb3XFAHK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=a78ss3v9OAJO+CKMzQy2rYpVoY9Q0ZyloAHjx8C4Uac=; b=bb3XFAHK0DaOwijmTFrc0riw8PXL4V4YRFwXnaE8buCbFWlGyHgIACL3 JEQnoTZ16ALbyqH62TEtlLkcP49cjqDZJIt/tbmXgoVOdNucLX/1BEtyU CxHi4/QSlmFcsJl+Ke5d6RuugzOyOFyeAWFiSeVJMhZFKbGTMkFPaiQ5L I=; Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=Julia.Lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.08,225,1712613600"; d="scan'208";a="169696906" Received: from i80.paris.inria.fr (HELO i80.paris.inria.fr.) ([128.93.90.48]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2024 10:27:49 +0200 From: Julia Lawall To: Anna-Maria Behnsen Cc: kernel-janitors@vger.kernel.org, Frederic Weisbecker , Thomas Gleixner , linux-kernel@vger.kernel.org, "Paul E . McKenney" , Vlastimil Babka Subject: [PATCH 11/14] posix-timers: replace call_rcu by kfree_rcu for simple kmem_cache_free callback Date: Sun, 9 Jun 2024 10:27:23 +0200 Message-Id: <20240609082726.32742-12-Julia.Lawall@inria.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240609082726.32742-1-Julia.Lawall@inria.fr> References: <20240609082726.32742-1-Julia.Lawall@inria.fr> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since SLOB was removed, it is not necessary to use call_rcu when the callback only performs kmem_cache_free. Use kfree_rcu() directly. The changes were done using the following Coccinelle semantic patch. This semantic patch is designed to ignore cases where the callback function is used in another way. // @r@ expression e; local idexpression e2; identifier cb,f; position p; @@ ( call_rcu(...,e2) | call_rcu(&e->f,cb@p) ) @r1@ type T; identifier x,r.cb; @@ cb(...) { ( kmem_cache_free(...); | T x =3D ...; kmem_cache_free(...,x); | T x; x =3D ...; kmem_cache_free(...,x); ) } @s depends on r1@ position p !=3D r.p; identifier r.cb; @@ cb@p @script:ocaml@ cb << r.cb; p << s.p; @@ Printf.eprintf "Other use of %s at %s:%d\n" cb (List.hd p).file (List.hd p).line @depends on r1 && !s@ expression e; identifier r.cb,f; position r.p; @@ - call_rcu(&e->f,cb@p) + kfree_rcu(e,f) @r1a depends on !s@ type T; identifier x,r.cb; @@ - cb(...) { ( - kmem_cache_free(...); | - T x =3D ...; - kmem_cache_free(...,x); | - T x; - x =3D ...; - kmem_cache_free(...,x); ) - } // Signed-off-by: Julia Lawall Reviewed-by: Paul E. McKenney Reviewed-by: Vlastimil Babka --- kernel/time/posix-timers.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index b924f0f096fa..bad5db979664 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -412,18 +412,11 @@ static struct k_itimer * alloc_posix_timer(void) return tmr; } =20 -static void k_itimer_rcu_free(struct rcu_head *head) -{ - struct k_itimer *tmr =3D container_of(head, struct k_itimer, rcu); - - kmem_cache_free(posix_timers_cache, tmr); -} - static void posix_timer_free(struct k_itimer *tmr) { put_pid(tmr->it_pid); sigqueue_free(tmr->sigq); - call_rcu(&tmr->rcu, k_itimer_rcu_free); + kfree_rcu(tmr, rcu); } =20 static void posix_timer_unhash_and_free(struct k_itimer *tmr) From nobody Thu Feb 12 19:05:46 2026 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) (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 757DC4D8BF; Sun, 9 Jun 2024 08:28:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.134.164.83 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921693; cv=none; b=qMdcomPV44e4S5nqEwEko0ymf9wOFXSyBV47zUwJ+mr12zgf8p2hJq5ndxTVhAShoN6T/Xf5bz4vGn2SsumUX5y93nxLFVQ4jV6jp071+qMsJmaEWrtJgLHDXGwfqbZIfSa2JdgvznNLpzQyLE6hEe3aIHEeov4dzHb+LcWLU3I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921693; c=relaxed/simple; bh=mQ3EDAVm4CCUHrkqlx/DX6sXVOIvE+vo6Q6lBCjqo4U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nG3xiyM5cvaMKuOd427maNAbAtoHljgfHcsfXxt2bBUqbhtcDX0Yjo27u2tq1kY6+bIW7ZFThzmtJxtVvsZgPgOCplVaY7vEli3osjzp74rK08LwxdbF/yk+kZ3EWcUdsUuPIPpdmlgW94rDK4gi5vEbjyElSFIt1I0ZTyhOM+k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr; spf=pass smtp.mailfrom=inria.fr; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b=jVC72JU7; arc=none smtp.client-ip=192.134.164.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inria.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b="jVC72JU7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ygyQ5hnv+3lKS8dtNJ/yFc43Rpbcbrp+lT/TZAkOJVM=; b=jVC72JU7hF53dnZUuUMgmhliEsXK3xdP852+pxN3iJY+4py8rdh5w9j1 KjpVieoTCrs6zpAhqC9mmNZlBo4etvXQdfHTLJsNLO8S6+3q1tZkBXm7f R17cewoA53OG2cKOeI3V1wnLEUz5YJbOCrKDi1iFyKuochepa6zjIo4Vo M=; Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=Julia.Lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.08,225,1712613600"; d="scan'208";a="169696907" Received: from i80.paris.inria.fr (HELO i80.paris.inria.fr.) ([128.93.90.48]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2024 10:27:49 +0200 From: Julia Lawall To: Tejun Heo Cc: kernel-janitors@vger.kernel.org, Lai Jiangshan , linux-kernel@vger.kernel.org, "Paul E . McKenney" , Vlastimil Babka Subject: [PATCH 12/14] workqueue: replace call_rcu by kfree_rcu for simple kmem_cache_free callback Date: Sun, 9 Jun 2024 10:27:24 +0200 Message-Id: <20240609082726.32742-13-Julia.Lawall@inria.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240609082726.32742-1-Julia.Lawall@inria.fr> References: <20240609082726.32742-1-Julia.Lawall@inria.fr> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since SLOB was removed, it is not necessary to use call_rcu when the callback only performs kmem_cache_free. Use kfree_rcu() directly. The changes were done using the following Coccinelle semantic patch. This semantic patch is designed to ignore cases where the callback function is used in another way. // @r@ expression e; local idexpression e2; identifier cb,f; position p; @@ ( call_rcu(...,e2) | call_rcu(&e->f,cb@p) ) @r1@ type T; identifier x,r.cb; @@ cb(...) { ( kmem_cache_free(...); | T x =3D ...; kmem_cache_free(...,x); | T x; x =3D ...; kmem_cache_free(...,x); ) } @s depends on r1@ position p !=3D r.p; identifier r.cb; @@ cb@p @script:ocaml@ cb << r.cb; p << s.p; @@ Printf.eprintf "Other use of %s at %s:%d\n" cb (List.hd p).file (List.hd p).line @depends on r1 && !s@ expression e; identifier r.cb,f; position r.p; @@ - call_rcu(&e->f,cb@p) + kfree_rcu(e,f) @r1a depends on !s@ type T; identifier x,r.cb; @@ - cb(...) { ( - kmem_cache_free(...); | - T x =3D ...; - kmem_cache_free(...,x); | - T x; - x =3D ...; - kmem_cache_free(...,x); ) - } // Signed-off-by: Julia Lawall Reviewed-by: Paul E. McKenney Reviewed-by: Vlastimil Babka --- kernel/workqueue.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 3fbaecfc88c2..2ec195dcc2bb 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5038,12 +5038,6 @@ static struct worker_pool *get_unbound_pool(const st= ruct workqueue_attrs *attrs) return NULL; } =20 -static void rcu_free_pwq(struct rcu_head *rcu) -{ - kmem_cache_free(pwq_cache, - container_of(rcu, struct pool_workqueue, rcu)); -} - /* * Scheduled on pwq_release_worker by put_pwq() when an unbound pwq hits z= ero * refcnt and needs to be destroyed. @@ -5089,7 +5083,7 @@ static void pwq_release_workfn(struct kthread_work *w= ork) raw_spin_unlock_irq(&nna->lock); } =20 - call_rcu(&pwq->rcu, rcu_free_pwq); + kfree_rcu(pwq, rcu); =20 /* * If we're the last pwq going away, @wq is already dead and no one From nobody Thu Feb 12 19:05:46 2026 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) (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 D15A4524C4; Sun, 9 Jun 2024 08:28:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.134.164.83 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921695; cv=none; b=Sn1CxzKmZdr0gs4VhC5k+2oEeaVOJsFSKAsZwY0RBkfi6Hqlt2FcStS1aqrUMRRMSQYlqJyjvM1UbDzqqgb7IJrAk2DXcd6k+6Hm+Ojr7NeV7KY2Fx2SDY4wQBxe8/GC+8prU7EaF5U6kfY3I/tfI3CoTHAdjW9WEYSDwGpdISY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921695; c=relaxed/simple; bh=fR12+M+APr/jd/Ecu2I15utUI4N3KHLcSGf4K4f6s/s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pjdLYLrlGxaHl1bcVrjUPAoewAfE0Gwl1c2Ubk95mIM5QOTWlyV+dA/WuUdxjC/URVKFjbDzLOG0lRZS94v0pCkhzCESIKr28JT9XQHp7Bh858p/nO0xAVIXzVtE5ZwqMa78OmPHrCPj/3FCB7Xjcmutwp6ON7vfAgRnin/qALo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr; spf=pass smtp.mailfrom=inria.fr; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b=RJ+U44L7; arc=none smtp.client-ip=192.134.164.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inria.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b="RJ+U44L7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tUDxrqQiWbXlWuXN/Tr1rDsMKk8ae92U1Hm7BKqU4jI=; b=RJ+U44L7RR+i7JTpW1vs4VVKKFFrUGQKAc6FoO1bz1zuIIzuO824qiFn wtyNmkaoiFDVLOUiVYVMqlnSy3ShvrrAtKDBIxuA/f+cDy3h3PPiCWVzB CihqDphX7Jflln/MpPO7Po2np2ikiLbceKL+xGbwrufkxltBFWgxYyVEl U=; Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=Julia.Lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.08,225,1712613600"; d="scan'208";a="169696908" Received: from i80.paris.inria.fr (HELO i80.paris.inria.fr.) ([128.93.90.48]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2024 10:27:49 +0200 From: Julia Lawall To: "David S. Miller" Cc: kernel-janitors@vger.kernel.org, Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Paul E . McKenney" , Vlastimil Babka Subject: [PATCH 13/14] kcm: replace call_rcu by kfree_rcu for simple kmem_cache_free callback Date: Sun, 9 Jun 2024 10:27:25 +0200 Message-Id: <20240609082726.32742-14-Julia.Lawall@inria.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240609082726.32742-1-Julia.Lawall@inria.fr> References: <20240609082726.32742-1-Julia.Lawall@inria.fr> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since SLOB was removed, it is not necessary to use call_rcu when the callback only performs kmem_cache_free. Use kfree_rcu() directly. The changes were done using the following Coccinelle semantic patch. This semantic patch is designed to ignore cases where the callback function is used in another way. // @r@ expression e; local idexpression e2; identifier cb,f; position p; @@ ( call_rcu(...,e2) | call_rcu(&e->f,cb@p) ) @r1@ type T; identifier x,r.cb; @@ cb(...) { ( kmem_cache_free(...); | T x =3D ...; kmem_cache_free(...,x); | T x; x =3D ...; kmem_cache_free(...,x); ) } @s depends on r1@ position p !=3D r.p; identifier r.cb; @@ cb@p @script:ocaml@ cb << r.cb; p << s.p; @@ Printf.eprintf "Other use of %s at %s:%d\n" cb (List.hd p).file (List.hd p).line @depends on r1 && !s@ expression e; identifier r.cb,f; position r.p; @@ - call_rcu(&e->f,cb@p) + kfree_rcu(e,f) @r1a depends on !s@ type T; identifier x,r.cb; @@ - cb(...) { ( - kmem_cache_free(...); | - T x =3D ...; - kmem_cache_free(...,x); | - T x; - x =3D ...; - kmem_cache_free(...,x); ) - } // Signed-off-by: Julia Lawall Reviewed-by: Paul E. McKenney Reviewed-by: Vlastimil Babka --- net/kcm/kcmsock.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c index 2f191e50d4fc..fbb730cd2d38 100644 --- a/net/kcm/kcmsock.c +++ b/net/kcm/kcmsock.c @@ -1580,14 +1580,6 @@ static int kcm_ioctl(struct socket *sock, unsigned i= nt cmd, unsigned long arg) return err; } =20 -static void free_mux(struct rcu_head *rcu) -{ - struct kcm_mux *mux =3D container_of(rcu, - struct kcm_mux, rcu); - - kmem_cache_free(kcm_muxp, mux); -} - static void release_mux(struct kcm_mux *mux) { struct kcm_net *knet =3D mux->knet; @@ -1615,7 +1607,7 @@ static void release_mux(struct kcm_mux *mux) knet->count--; mutex_unlock(&knet->mutex); =20 - call_rcu(&mux->rcu, free_mux); + kfree_rcu(mux, rcu); } =20 static void kcm_done(struct kcm_sock *kcm) From nobody Thu Feb 12 19:05:46 2026 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) (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 EE1BA5337C; Sun, 9 Jun 2024 08:28:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.134.164.83 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921695; cv=none; b=bBFQM2MB6rJwgtyJvdsaG5EsmenFo2HKL8ZrqMmVd6v68zHQP+dHeakmw281fOmv5CmJuNn9gz5QM6w5FDNL82k7NBRKMOZSxD8H5wyDn+068Y/LBElPIiDtEUlKFrySyfD6b8wsmZndOX2nucMmi8AQYsIP2kLZJKP/yaXYKDU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921695; c=relaxed/simple; bh=XjSGzBEEN4R1uM6+FzoVLzsuvTNxmayPngOiT1u3sG0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=irqZFMnBerrKO9/dHkCbHAgcjTyzMDE6dZIul0kBZpPCtsoXXS//pDPBFbLde8tm6Q7mWXuQczy6gAS3dGuuR+Q5kv9WLx2RHyM6hQbV8S2O9tMPgLK2KIXGA2sGfgAoy4WSLdm8GF+Fxd0LPowO9Dc7IZmvK88Uy7yntxsGK+g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr; spf=pass smtp.mailfrom=inria.fr; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b=PQ8uixq9; arc=none smtp.client-ip=192.134.164.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inria.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b="PQ8uixq9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UDrliNsi6qf9iZ0cJTSfrv8FntRHZmJcOSPF/U9CCyU=; b=PQ8uixq9gJb8XJ5kYQyD9s/ymp/dqHay+TNM4exQnNxtZvPryBNvScc0 yKx1TUYcF+ilJUMjUqmuURKc0OVGwc7MvninM1ky5jsSke9R2PMmzcoBq 5PKM4rmRoXEoS5gWDJL6KrtSpCRSd6OHyLzDTxvaFTRnqD67aFFemBGjC w=; Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=Julia.Lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.08,225,1712613600"; d="scan'208";a="169696909" Received: from i80.paris.inria.fr (HELO i80.paris.inria.fr.) ([128.93.90.48]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2024 10:27:49 +0200 From: Julia Lawall To: Pablo Neira Ayuso Cc: kernel-janitors@vger.kernel.org, Jozsef Kadlecsik , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Paul E . McKenney" , Vlastimil Babka Subject: [PATCH 14/14] netfilter: replace call_rcu by kfree_rcu for simple kmem_cache_free callback Date: Sun, 9 Jun 2024 10:27:26 +0200 Message-Id: <20240609082726.32742-15-Julia.Lawall@inria.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240609082726.32742-1-Julia.Lawall@inria.fr> References: <20240609082726.32742-1-Julia.Lawall@inria.fr> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since SLOB was removed, it is not necessary to use call_rcu when the callback only performs kmem_cache_free. Use kfree_rcu() directly. The changes were done using the following Coccinelle semantic patch. This semantic patch is designed to ignore cases where the callback function is used in another way. // @r@ expression e; local idexpression e2; identifier cb,f; position p; @@ ( call_rcu(...,e2) | call_rcu(&e->f,cb@p) ) @r1@ type T; identifier x,r.cb; @@ cb(...) { ( kmem_cache_free(...); | T x =3D ...; kmem_cache_free(...,x); | T x; x =3D ...; kmem_cache_free(...,x); ) } @s depends on r1@ position p !=3D r.p; identifier r.cb; @@ cb@p @script:ocaml@ cb << r.cb; p << s.p; @@ Printf.eprintf "Other use of %s at %s:%d\n" cb (List.hd p).file (List.hd p).line @depends on r1 && !s@ expression e; identifier r.cb,f; position r.p; @@ - call_rcu(&e->f,cb@p) + kfree_rcu(e,f) @r1a depends on !s@ type T; identifier x,r.cb; @@ - cb(...) { ( - kmem_cache_free(...); | - T x =3D ...; - kmem_cache_free(...,x); | - T x; - x =3D ...; - kmem_cache_free(...,x); ) - } // Signed-off-by: Julia Lawall Reviewed-by: Paul E. McKenney Reviewed-by: Vlastimil Babka --- net/netfilter/nf_conncount.c | 10 +--------- net/netfilter/nf_conntrack_expect.c | 10 +--------- net/netfilter/xt_hashlimit.c | 9 +-------- 3 files changed, 3 insertions(+), 26 deletions(-) diff --git a/net/netfilter/nf_conncount.c b/net/netfilter/nf_conncount.c index 8715617b02fe..587bfcb79723 100644 --- a/net/netfilter/nf_conncount.c +++ b/net/netfilter/nf_conncount.c @@ -275,14 +275,6 @@ bool nf_conncount_gc_list(struct net *net, } EXPORT_SYMBOL_GPL(nf_conncount_gc_list); =20 -static void __tree_nodes_free(struct rcu_head *h) -{ - struct nf_conncount_rb *rbconn; - - rbconn =3D container_of(h, struct nf_conncount_rb, rcu_head); - kmem_cache_free(conncount_rb_cachep, rbconn); -} - /* caller must hold tree nf_conncount_locks[] lock */ static void tree_nodes_free(struct rb_root *root, struct nf_conncount_rb *gc_nodes[], @@ -295,7 +287,7 @@ static void tree_nodes_free(struct rb_root *root, spin_lock(&rbconn->list.list_lock); if (!rbconn->list.count) { rb_erase(&rbconn->node, root); - call_rcu(&rbconn->rcu_head, __tree_nodes_free); + kfree_rcu(rbconn, rcu_head); } spin_unlock(&rbconn->list.list_lock); } diff --git a/net/netfilter/nf_conntrack_expect.c b/net/netfilter/nf_conntra= ck_expect.c index 21fa550966f0..9dcaef6f3663 100644 --- a/net/netfilter/nf_conntrack_expect.c +++ b/net/netfilter/nf_conntrack_expect.c @@ -367,18 +367,10 @@ void nf_ct_expect_init(struct nf_conntrack_expect *ex= p, unsigned int class, } EXPORT_SYMBOL_GPL(nf_ct_expect_init); =20 -static void nf_ct_expect_free_rcu(struct rcu_head *head) -{ - struct nf_conntrack_expect *exp; - - exp =3D container_of(head, struct nf_conntrack_expect, rcu); - kmem_cache_free(nf_ct_expect_cachep, exp); -} - void nf_ct_expect_put(struct nf_conntrack_expect *exp) { if (refcount_dec_and_test(&exp->use)) - call_rcu(&exp->rcu, nf_ct_expect_free_rcu); + kfree_rcu(exp, rcu); } EXPORT_SYMBOL_GPL(nf_ct_expect_put); =20 diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c index 0859b8f76764..c2b9b954eb53 100644 --- a/net/netfilter/xt_hashlimit.c +++ b/net/netfilter/xt_hashlimit.c @@ -256,18 +256,11 @@ dsthash_alloc_init(struct xt_hashlimit_htable *ht, return ent; } =20 -static void dsthash_free_rcu(struct rcu_head *head) -{ - struct dsthash_ent *ent =3D container_of(head, struct dsthash_ent, rcu); - - kmem_cache_free(hashlimit_cachep, ent); -} - static inline void dsthash_free(struct xt_hashlimit_htable *ht, struct dsthash_ent *ent) { hlist_del_rcu(&ent->node); - call_rcu(&ent->rcu, dsthash_free_rcu); + kfree_rcu(ent, rcu); ht->count--; } static void htable_gc(struct work_struct *work);