Re: [PATCH net-next 3/3] net: remove rcu_barrier() from __dev_change_net_namespace()
From: Eric Dumazet
Date: Fri Oct 16 2026 - 05:25:01 EST
Le ven. 16 oct. 2026 à 08:10, Qiliang Yuan <odys.yuan@xxxxxxxxx> a écrit :
>
> Commit 6549dd43c043 ("net: dev: fix the incorrect hold of net
> namespace's lo device") added rcu_barrier() before
> NETDEV_UNREGISTER_FINAL in dev_change_net_namespace(), so that dst
> entries released by RCU callbacks were on the dst garbage list before
> dst_ifdown() moved them to the loopback device of the old netns.
> Commit 070f2d7e264a ("net: Drop NETDEV_UNREGISTER_FINAL") removed the
> event but kept the barrier, and dead dst entries now point to
> blackhole_netdev instead of a loopback device.
>
> The barrier waits for the RCU callbacks pending on every CPU while RTNL
> is held, which takes a full grace period on each netns move. Container
> and sandbox managers move one end of a veth pair for every new network
> namespace, so this limits how fast such namespaces can be created on the
> whole system, regardless of how many threads create them.
>
> Remove the barrier. The RCU callbacks queued by NETDEV_UNREGISTER
> handlers free memory and drop device references, which the move does not
> wait for. Cached IPv4 and IPv6 routes through the moved device are
> rejected once its netns changes, since rt_genid and fib6_sernum are now
> unique across netns.
>
> Creating 400 netns, each with a veth pair whose host end is moved back
> to the initial netns, a tap device, addresses and routes, in a 16 vCPU
> guest, median of 5 runs:
>
> before after
> 1 thread 68 /s 440 /s
> 4 threads 74 /s 409 /s
> 16 threads 77 /s 283 /s
>
> Signed-off-by: Qiliang Yuan <odys.yuan@xxxxxxxxx>
> ---
I think this is mostly fine. I was working on this months ago but got
distracted.
I sent two patches fixing pre-existing issues that would be widened by
your patch.
https://patchwork.kernel.org/project/netdevbpf/patch/20261016084802.2725187-1-edumazet@xxxxxxxxxx/
https://patchwork.kernel.org/project/netdevbpf/patch/20261016091556.2750902-1-edumazet@xxxxxxxxxx/
Reviewed-by: Eric Dumazet <edumazet@xxxxxxxxxx>
Thanks.