[PATCH 02/17] ipv4: replace call_rcu by kfree_rcu for simple kmem_cache_free callback

Julia Lawall posted 17 patches 1 month, 2 weeks ago
[PATCH 02/17] ipv4: replace call_rcu by kfree_rcu for simple kmem_cache_free callback
Posted by Julia Lawall 1 month, 2 weeks ago
Since SLOB was removed and since
commit 6c6c47b063b5 ("mm, slab: call kvfree_rcu_barrier() from kmem_cache_destroy()"),
it is not necessary to use call_rcu when the callback only performs
kmem_cache_free. Use kfree_rcu() directly.

The changes were made using Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>

---
 net/ipv4/fib_trie.c |    8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 09e31757e96c..161f5526b86c 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -292,15 +292,9 @@ static const int inflate_threshold = 50;
 static const int halve_threshold_root = 15;
 static const int inflate_threshold_root = 30;
 
-static void __alias_free_mem(struct rcu_head *head)
-{
-	struct fib_alias *fa = 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);
 }
 
 #define TNODE_VMALLOC_MAX \
Re: [PATCH 02/17] ipv4: replace call_rcu by kfree_rcu for simple kmem_cache_free callback
Posted by Eric Dumazet 1 month, 1 week ago
On Sun, Oct 13, 2024 at 10:18 PM Julia Lawall <Julia.Lawall@inria.fr> wrote:
>
> Since SLOB was removed and since
> commit 6c6c47b063b5 ("mm, slab: call kvfree_rcu_barrier() from kmem_cache_destroy()"),
> it is not necessary to use call_rcu when the callback only performs
> kmem_cache_free. Use kfree_rcu() directly.
>
> The changes were made using Coccinelle.
>
> Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>

Note that fn_alias_kmem is never destroyed, so commit 6c6c47b063b5
seems not relevant.

Reviewed-by: Eric Dumazet <edumazet@google.com>