Article View: linux.kernel.netdev
Article #13079[PATCH net-next v3 4/4] net: remove rcu_barrier() from __dev_change_net_namespace()
From: Qiliang Yuan
Date: Mon, 09 Nov 2026 08:18
Date: Mon, 09 Nov 2026 08:18
53 lines
10486 bytes
10486 bytes
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. Routes cached through the moved device are rejected once its
netns changes: IPv4 and per-cpu IPv6 routes no longer match the rt_genid
or fib6_sernum of another netns, and the IPv6 exceptions of a nexthop
that leaves a group were already flushed when it left. 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 4 vCPU guest, median of
5 runs:
before after
1 thread 46 /s 56 /s
4 threads 58 /s 84 /s
16 threads 75 /s 146 /s
Signed-off-by: Qiliang Yuan <qiliang.yuan@linux.dev>
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
---
net/core/dev.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index 3b60b15e2175e..de1fd77440543 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -13044,7 +13044,6 @@ int __dev_change_net_namespace(struct net_device *dev, struct net *net,
* the device is just moving and can keep their slaves up.
*/
call_netdevice_notifiers(NETDEV_UNREGISTER, dev);
- rcu_barrier();
new_nsid = peernet2id_alloc(dev_net(dev), net, GFP_KERNEL);
--
2.43.0
Technical Details
Message-ID:
<20261109-bug-net-netns-move-rcu-barrier-v3-4-6084b02610b3@linux.dev>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359124-linux-kernel-netdev=dewy.ruReferences:
<20261109-bug-net-netns-move-rcu-barrier-v3-0-6084b02610b3@linux.dev>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359124-linux-kernel-netdev=dewy.ru From: qiliang.yuan@linux.dev (Qiliang Yuan) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next v3 4/4] net: remove rcu_barrier() from __dev_change_net_namespace() Date: Mon, 09 Nov 2026 03:18:15 -0500 Organization: Usenet Network Message-ID: <20261109-bug-net-netns-move-rcu-barrier-v3-4-6084b02610b3@linux.dev> References: <20261109-bug-net-netns-move-rcu-barrier-v3-0-6084b02610b3@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="307331"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:ZKjbZGQlDitk7PpRqqsJ42+/+9M= sha256:GBLDagSTdHYamSMqO8nPepTkqdat+tpGRVviJtT5x1M= sha1:Ymqz3UI1pULd0bsD+l82GuPm5II= sha256:FxGd2QQKG6cN3f8F2dBdKB7qSEdbZWXL7oGxGwYjr04= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id B5377113742; Mon, 9 Nov 2026 11:23:32 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=linux.dev X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id G0OLMmBj2Rkf; Mon, 9 Nov 2026 11:23:29 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-359124-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 7D90E11370E; Mon, 9 Nov 2026 11:23:21 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id B0E2BE944F; Mon, 9 Nov 2026 08:18:58 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794212337; b=VYrBZHT8mPYguDiHrrMsuOoKMbBaS5Q+QGdwYvgxo1HnsrgEiH2Bwg5xFZ9EL8mrJOtp C6j8PmE+tkKgMOCFO0TIaB0ZpAjq1IElHiBXWjTCvtkzgIMALgVgl8jmZd6nPzv498BL2 szDRkXgUZoORCaQ/uC3bORmBuB38eHfALueMLoHqSWZyHTveMmerbucIxg9Jl8qlZH8F3 0whSGGoTxM/2D/SkuX0Tp31pNrG4M2vdZjBQUly/yTcs9YYOTaawslKcTOk8cJTrIc23y zRs0diemtiPn9/IiyDU4U0Z+iH9LMc5hYAMp2NIG2mW+aeP1ffYLQ8FOUBolMir9+Ow== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794212337; h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature: X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:From:Date: Subject:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer; bh=BGQtkhiTQEncvaXShKyiOU61Jc8kJGe+kX2TaLjyCwM=; b=mX+0Apqhms8ohTNSe8SLl9SLEUmFJmt/I9Bxzfbh023+avv6wOAqQKEF1t65oKCcJjMQ j/ANMxLR223RyyrKjozue4VsJuvzG8Ukfr8HFBsxX/PTI/syi6cceLgRnZTaxXbdCzoaR WZZZggtQ8asrfM3GXsGZnH2jiZEvLVMJUoALSwS7YTfwPj3GjycOno45GBfUjPChS5+SO LPMQO42akaWgsyLOoAt0JxLouXYd5fk6hpW+qL2W/EV6qObDRVrxUwUUMQcI28JHt+Yaq 9VHsXPfPe3S0/RHherPyR7aGD38chzJMAm24mZwZKESWuKTRkKaR/JzFrYYW5qKFC2A== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=UWzFwCf0; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BC9D1606A33B; Mon, 9 Nov 2026 08:18:57 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=UWzFwCf0 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.167 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794212336; b=h6XJFVDNrBd5JIh/cCUuogf21CTxPuZxu3EXSxjVv8hZGOWBPaCBkSZ6WSe6BdW4VaLH 6VzlZ6+kuPTS+nZHHQUoKuJE5c1NG34q+RMvSg1htO2oH++9dOyWX40Wjw67B/gsb9BrE ZUp6mCMhekQHdOB57FU3f/vGU9Dcmts5PPRZont9XquI5A0/gJwZm7iIfXJZa9D3zN+4+ 5dQi4uKdIlxj0Ylbddk0jkqG4gb8Qsu2g156V/L6AWIlz+unsrEZ+ftjY+SbfY1YFvZvp yQ7GbOXF+63eAmW+ls6VU1XK2OrdvOsSlu7nh/8Yxvn9ANCcm8IMd+rIRoCAKtHvV4Q== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794212336; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer; bh=BGQtkhiTQEncvaXShKyiOU61Jc8kJGe+kX2TaLjyCwM=; b=4wPkrgMMj3WSmVJ8XY8csiH0d9JD3QswsN+zK1ztEF98TVHMlUP+Ifi0Auqs3x48wB/S Yx05LhjJt7kxiOQq3rdjQ/c2Zrwtr0PHWR8dqoa+zkCHbzjhNbWWerxuSwKyE66QohJj1 FLez3dlY9l7k267YTzBodKX6YcgyWKQFUbRUxzc3buXxi56fdEE3NhFcKgYqEL/AD+VIe B6hTpwX3zN1vZwMaxql5GtJZ50yVXMD3/5I8iqKjWIbzJezZ3/jarID9UZaTM7h1gFjeO xrK8360y+px2XaigtSUFPv4vIUmtPLHa2QBx2CzPnio/ZSRlw0do0i7bf6+sVmOkiyA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=UWzFwCf0; arc=none smtp.remote-ip=91.218.175.167 X-Received: from mta0.migadu.com (out-167.mta0.migadu.com [91.218.175.167]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4527C606A323 for <netdev@vger.kernel.org>; Mon, 9 Nov 2026 08:18:55 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4527C606A323 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: netdev@vger.kernel.org X-DKIM-Signature: a=rsa-sha256; bh=KYu9z+Ws9MnPlTPEBe2QxNPdQ6+TgoscUdEZlYypBYI=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1794212334; v=1; x=1794817134; b=UWzFwCf0VIaSctmV61XsClBPdF9TgiGT/RnzRJTRKfcvJnf5q1CA+4GnEKgsNeHqyZ8vOkz9 Cw6JXZmA4o6rFCecon4PnQr3a6cWLrI1srOCGj7P7Fl0/VD/AbMD1cW8FXxGPRNVyJ1Yvuf9g9K 8kG03uO4MUQRiYWSbRi65UMA= X-Envelope-To: netdev@vger.kernel.org X-Received: by smtp.migadu.com with ESMTPS id 4f068457210c7401; Mon, 09 Nov 2026 08:18:54 +0000 X-Mizu-Trace-ID: 4f068457210c7401 X-Migadu-Flow: FLOW_OUT X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <20261109-bug-net-netns-move-rcu-barrier-v3-0-6084b02610b3@linux.dev> X-Cc: Kuniyuki Iwashima <kuniyu@google.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Qiliang Yuan <qiliang.yuan@linux.dev> X-Mailer: b4 0.13.0