From: Qiliang Yuan <realwujing@gmail.com>
To: kuniyu@google.com
Cc: brauner@kernel.org, davem@davemloft.net, edumazet@google.com,
horms@kernel.org, jlayton@kernel.org, kuba@kernel.org,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
pabeni@redhat.com, realwujing@gmail.com, sd@queasysnail.net,
yuanql9@chinatelecom.cn
Subject: Re: [PATCH net-next v3] netns: optimize netns cleaning by batching unhash_nsid calls
Date: Thu, 29 Jan 2026 21:44:06 -0500 [thread overview]
Message-ID: <20260130024410.2491051-1-realwujing@gmail.com> (raw)
In-Reply-To: <CAAVpQUDbYnzyBuN5SS9bSTfJDvVH18QNXrXGTYzZRb3Cgk=mQg@mail.gmail.com>
Hi Kuniyuki,
Thank you for your valuable feedback!
On Wed, 28 Jan 2026 09:13:59 -0800 Kuniyuki Iwashima <kuniyu@google.com> wrote:
> idr_for_each() sounds better to me.
I have integrated this in v4. It indeed makes the IDR traversal much more
idiomatic and efficient.
> If we replace list_del_rcu(&net->list); with
> list_del_init_rcu(&net->list);, we can check net->list.pprev
> instead of adding dying_net, which is a bit racy since
> idr_for_each() could return a net which would have been
> processed in the next cleanup_net() invocation.
To resolve this race, I've moved the setting of 'is_dying = true' inside
cleanup_net() while still holding the net_rwsem write lock. This ensures
all namespaces in the current kill_list are marked before we release the
lock and perform the batch unhashing.
Regarding list_del_init_rcu(), as it is not a standard API, I evaluated
using list_del_rcu() followed by INIT_LIST_HEAD(). However, resetting
list pointers is generally unsafe for RCU readers (e.g., in for_each_net_rcu),
as it could cause them to enter an infinite loop. Using the 'is_dying'
boolean under the existing lock seems to be the safest and simplest approach.
I've also cleaned up the redundant nsid_lock and the duplicate Signed-off-by
tags as you suggested.
The complexity is now O(N_system * N_ids), effectively eliminating the
O(M_batch) multiplier.
I've just sent out the v4 patch. Looking forward to your thoughts.
Thanks,
Qiliang
prev parent reply other threads:[~2026-01-30 2:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-28 1:21 [PATCH net-next v3] netns: optimize netns cleaning by batching unhash_nsid calls Qiliang Yuan
2026-01-28 2:05 ` Kuniyuki Iwashima
2026-01-28 12:19 ` Qiliang Yuan
2026-01-28 17:13 ` Kuniyuki Iwashima
2026-01-30 2:44 ` Qiliang Yuan [this message]
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=20260130024410.2491051-1-realwujing@gmail.com \
--to=realwujing@gmail.com \
--cc=brauner@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jlayton@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sd@queasysnail.net \
--cc=yuanql9@chinatelecom.cn \
/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