Repository : ssh://git@diktynna/batman-adv On branches: ecsv/pu,main,main
commit 22417ae074ce50800b949250b02fd6e2b375982a Author: Julia Lawall Julia.Lawall@inria.fr Date: Sun Oct 13 22:16:53 2024 +0200
batman-adv: replace call_rcu by kfree_rcu for simple kmem_cache_free callback
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 Signed-off-by: Sven Eckelmann sven@narfation.org
22417ae074ce50800b949250b02fd6e2b375982a net/batman-adv/translation-table.c | 81 +++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 41 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 2243cec1..3b8ad587 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -73,6 +73,34 @@ static void batadv_tt_global_del(struct batadv_priv *bat_priv, const unsigned char *addr, unsigned short vid, const char *message, bool roaming); +// UGLY_HACK_OLD +#if LINUX_VERSION_IS_LESS(6, 12, 0) + +static void batadv_tt_local_entry_free_rcu(struct rcu_head *rcu) +{ + struct batadv_tt_local_entry *tt_local_entry; + + tt_local_entry = container_of(rcu, struct batadv_tt_local_entry, common.rcu); + kmem_cache_free(batadv_tl_cache, tt_local_entry); +} + +static void batadv_tt_global_entry_free_rcu(struct rcu_head *rcu) +{ + struct batadv_tt_global_entry *tt_global_entry; + + tt_global_entry = container_of(rcu, struct batadv_tt_global_entry, common.rcu); + kmem_cache_free(batadv_tg_cache, tt_global_entry); +} + +static void batadv_tt_orig_list_entry_free_rcu(struct rcu_head *rcu) +{ + struct batadv_tt_orig_list_entry *orig_entry; + + orig_entry = container_of(rcu, struct batadv_tt_orig_list_entry, rcu); + kmem_cache_free(batadv_tt_orig_cache, orig_entry); +} + +#endif /* LINUX_VERSION_IS_LESS(6, 12, 0) */ // UGLY_HACK_STOP
/** * batadv_compare_tt() - check if two TT entries are the same @@ -208,20 +236,6 @@ batadv_tt_global_hash_find(struct batadv_priv *bat_priv, const u8 *addr, return tt_global_entry; }
-/** - * batadv_tt_local_entry_free_rcu() - free the tt_local_entry - * @rcu: rcu pointer of the tt_local_entry - */ -static void batadv_tt_local_entry_free_rcu(struct rcu_head *rcu) -{ - struct batadv_tt_local_entry *tt_local_entry; - - tt_local_entry = container_of(rcu, struct batadv_tt_local_entry, - common.rcu); - - kmem_cache_free(batadv_tl_cache, tt_local_entry); -} - /** * batadv_tt_local_entry_release() - release tt_local_entry from lists and queue * for free after rcu grace period @@ -236,7 +250,11 @@ static void batadv_tt_local_entry_release(struct kref *ref)
batadv_softif_vlan_put(tt_local_entry->vlan);
+#if LINUX_VERSION_IS_GEQ(6, 12, 0) // UGLY_HACK_NEW + kfree_rcu(tt_local_entry, common.rcu); +#else // UGLY_HACK_OLD call_rcu(&tt_local_entry->common.rcu, batadv_tt_local_entry_free_rcu); +#endif // UGLY_HACK_STOP }
/** @@ -254,20 +272,6 @@ batadv_tt_local_entry_put(struct batadv_tt_local_entry *tt_local_entry) batadv_tt_local_entry_release); }
-/** - * batadv_tt_global_entry_free_rcu() - free the tt_global_entry - * @rcu: rcu pointer of the tt_global_entry - */ -static void batadv_tt_global_entry_free_rcu(struct rcu_head *rcu) -{ - struct batadv_tt_global_entry *tt_global_entry; - - tt_global_entry = container_of(rcu, struct batadv_tt_global_entry, - common.rcu); - - kmem_cache_free(batadv_tg_cache, tt_global_entry); -} - /** * batadv_tt_global_entry_release() - release tt_global_entry from lists and * queue for free after rcu grace period @@ -282,7 +286,11 @@ void batadv_tt_global_entry_release(struct kref *ref)
batadv_tt_global_del_orig_list(tt_global_entry);
+#if LINUX_VERSION_IS_GEQ(6, 12, 0) // UGLY_HACK_NEW + kfree_rcu(tt_global_entry, common.rcu); +#else // UGLY_HACK_OLD call_rcu(&tt_global_entry->common.rcu, batadv_tt_global_entry_free_rcu); +#endif // UGLY_HACK_STOP }
/** @@ -407,19 +415,6 @@ static void batadv_tt_global_size_dec(struct batadv_orig_node *orig_node, batadv_tt_global_size_mod(orig_node, vid, -1); }
-/** - * batadv_tt_orig_list_entry_free_rcu() - free the orig_entry - * @rcu: rcu pointer of the orig_entry - */ -static void batadv_tt_orig_list_entry_free_rcu(struct rcu_head *rcu) -{ - struct batadv_tt_orig_list_entry *orig_entry; - - orig_entry = container_of(rcu, struct batadv_tt_orig_list_entry, rcu); - - kmem_cache_free(batadv_tt_orig_cache, orig_entry); -} - /** * batadv_tt_orig_list_entry_release() - release tt orig entry from lists and * queue for free after rcu grace period @@ -433,7 +428,11 @@ static void batadv_tt_orig_list_entry_release(struct kref *ref) refcount);
batadv_orig_node_put(orig_entry->orig_node); +#if LINUX_VERSION_IS_GEQ(6, 12, 0) // UGLY_HACK_NEW + kfree_rcu(orig_entry, rcu); +#else // UGLY_HACK_OLD call_rcu(&orig_entry->rcu, batadv_tt_orig_list_entry_free_rcu); +#endif // UGLY_HACK_STOP }
/**