Re: [PATCH] wireguard: allowedips: Use kfree_rcu() instead of call_rcu()

Eric Dumazet <[email protected]>
Newsgroups com.zx2c4.lists.wireguard,org.kernel.vger.linux-kernel,org.kernel.vger.netdev
Message-ID <CANn89iJs+Y7Ge2sbAOQSsuE6O1GbxuHbNrFxBO0fq1C3HOfxPA@mail.gmail.com>
On Sun, Oct 5, 2025 at 5:26 AM Fushuai Wang <[email protected]> wrote:
>
> Replace call_rcu() + kmem_cache_free() with kfree_rcu() to simplify
> the code and reduce function size.
>
> Signed-off-by: Fushuai Wang <[email protected]>

Hmm... have you compiled this patch ?

I think  all compilers would complain loudly.

> ---
>  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/allowedips.c
> index 09f7fcd7da78..506f7cf0d7cf 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] = {
> @@ -271,13 +266,13 @@ static void remove_node(struct allowedips_node *node, struct mutex *lock)
>         if (free_parent)
>                 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);

kfree_rcu(node, rcu);

>         if (!free_parent)
>                 return;
>         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);

kfree_rcu(parent, rcu);

>  }
>
>  static int remove(struct allowedips_node __rcu **trie, u8 bits, const u8 *key,
> --
> 2.36.1
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.