From: Fushuai Wang <fushuai.wang@linux.dev>
To: kuba@kernel.org
Cc: Jason@zx2c4.com, andrew+netdev@lunn.ch, davem@davemloft.net,
edumazet@google.com, fushuai.wang@linux.dev,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
pabeni@redhat.com, vadim.fedorenko@linux.dev,
wangfushuai@baidu.com, wireguard@lists.zx2c4.com
Subject: Re: [PATCH net-next v3] wireguard: allowedips: Use kfree_rcu() instead of call_rcu()
Date: Thu, 15 Jan 2026 13:12:21 +0800 [thread overview]
Message-ID: <20260115051221.68054-1-fushuai.wang@linux.dev> (raw)
In-Reply-To: <20260115033237.1545400-1-kuba@kernel.org>
>> @@ -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);
>
> Does wg_allowedips_slab_uninit() need to be updated to use
> kvfree_rcu_barrier() instead of rcu_barrier()?
>
> When CONFIG_KVFREE_RCU_BATCHED is enabled (the default), kfree_rcu()
> uses a batched mechanism that queues work via queue_rcu_work(). The
> rcu_barrier() call waits for RCU callbacks to complete, but these
> callbacks only queue the actual free to a workqueue via rcu_work_rcufn().
> The workqueue work that calls kvfree() may still be pending after
> rcu_barrier() returns.
>
> The existing cleanup path is:
> wg_allowedips_slab_uninit() -> rcu_barrier() -> kmem_cache_destroy()
>
> With kfree_rcu(), this sequence could destroy the slab cache while
> kfree_rcu_work() still has pending frees queued. The proper barrier for
> kfree_rcu() is kvfree_rcu_barrier() which also calls flush_rcu_work()
> on all pending batches.
We do not need to add an explict kvfree_rcu_barrier(), becasue the commit
6c6c47b063b5 ("mm, slab: call kvfree_rcu_barrier() from kmem_cache_destroy()")
already does it.
---
Regards,
WANG
next prev parent reply other threads:[~2026-01-15 5:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-12 13:06 [PATCH net-next v3] wireguard: allowedips: Use kfree_rcu() instead of call_rcu() Fushuai Wang
2026-01-14 15:41 ` Simon Horman
2026-01-15 3:32 ` [net-next,v3] " Jakub Kicinski
2026-01-15 5:12 ` Fushuai Wang [this message]
2026-01-15 9:15 ` [PATCH net-next v3] " Eric Dumazet
2026-01-15 14:33 ` Jason A. Donenfeld
2026-01-15 14:40 ` Eric Dumazet
2026-01-22 23:30 ` Jason A. Donenfeld
2026-01-15 8:12 ` [net-next, " Petr Vaněk
2026-01-15 14:26 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260115051221.68054-1-fushuai.wang@linux.dev \
--to=fushuai.wang@linux.dev \
--cc=Jason@zx2c4.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vadim.fedorenko@linux.dev \
--cc=wangfushuai@baidu.com \
--cc=wireguard@lists.zx2c4.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox