summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2024-06-13 13:59:10 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2024-06-13 13:59:10 +0200
commite3fdcc94017f685a7908ea33b6d9ffdcffea8d39 (patch)
treed99f9c75d146d9a7c51c2eef2400556b6f1d4359
parentb21bc5f7abcb27604e2b159c0ceb6d026826bf30 (diff)
downloadwireguard-linux-trimmed-e3fdcc94017f685a7908ea33b6d9ffdcffea8d39.tar.gz
wireguard-linux-trimmed-e3fdcc94017f685a7908ea33b6d9ffdcffea8d39.zip
wireguard: allowedips: use kfree_rcu() and don't wait on rcu_barrier()HEADstable
Since SLOB was removed, it is not necessary to use call_rcu() when the callback only performs kmem_cache_free(), so we can use kfree_rcu() directly. kfree_rcu() happens in batches and doesn't need to wait on rcu_barrier() to complete, so also remove the barrier. Cc: Paul E. McKenney <paulmck@kernel.org> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Julia Lawall <Julia.Lawall@inria.fr> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--drivers/net/wireguard/allowedips.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/drivers/net/wireguard/allowedips.c b/drivers/net/wireguard/allowedips.c
index 0ba714c..c95f693 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,
}
}
-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] = {
@@ -330,13 +325,13 @@ void wg_allowedips_remove_by_peer(struct allowedips *table,
child = 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 = parent->parent_bit_packed;
*(struct allowedips_node **)(parent->parent_bit_packed & ~3UL) = child;
- call_rcu(&parent->rcu, node_free_rcu);
+ kfree_rcu(parent, rcu);
}
}
@@ -382,7 +377,6 @@ int __init wg_allowedips_slab_init(void)
void wg_allowedips_slab_uninit(void)
{
- rcu_barrier();
kmem_cache_destroy(node_cache);
}