From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.182 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794968959; b=sEbRRXsVF1vhbY4lUQbf4QCP+JC4U6b0F4eBCZZxR6l/OEgfnEflx09tuSqUYDBXQVvG zdbqC5GiBYRAy0/MdtWxy6HKMRS/mlwW3aphJerVZK6nhp0ycRanGzoHgFXSzG40NvEro 5cfzunDlB3XGQDoWUdTmwcC87tEGkNKxSMQt8dXIr6HZa4GV0UXg07P61OruhI1m+UdqV YFvp+UhCNlwQjatsS59wWgA+ZL5j6dkqJ3fyGypZ61COLBgtpwN91lVoLchKEiTi8RNPZ vKqT5InPJbTdw/BxNlp4s0umckBA6wCTuL3ppW1UBjQLiPNhJdIingGvC7VlyOa5bDQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794968959; 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=Pwh2SDJdSd/L2GiR4NykafWE8pbDUq5WlGlvFmGumpM=; b=tk62QSgxdbgwEmwySNPt1XrHOny+mDccwaZiobrj+jMOH2m6Pi/HhkKD8g5tWOFd0HeL gVm5BZ/JLa9Yg9QXvAGiffut95EOdggv+DAYq02ybhn9ULT3gpdlVM0R9k0aJxuilOXry LVxkr5aRl+V5Sivn+ICVxbV5ExG20dmcNgbycF3CYL6m83l+c4V1Xpg9W3ad4jLOJJ8DM q6K2z4cZeTdtPgEBIHNGn6YajO1qDPKQ2LdtV+R143PTofTk5VcXNLadZZWQ4VS4TdWjt 0QhUkuF9bCPD2h/C91gzumt59t0nNr+4y5HvbKi2mDbRrFGdR0CvkbBKevSItt2gdOA== 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=dmQgK1JU; arc=none smtp.remote-ip=91.218.175.182 Received: from mta0.migadu.com (out-182.mta0.migadu.com [91.218.175.182]) (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 A940E606A31C for ; Wed, 18 Nov 2026 02:29:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A940E606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev 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=dmQgK1JU X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=Za8I7RX5D0AEG0dcje2wX+jjZGxntdFD9rJ0HE0ABi0=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1794968956; v=1; x=1795573756; b=dmQgK1JUhNlCJ10EWq7cTPOpIdgitI0mcwzbsFttjaF5OaPax0Nqmvd3WIWKP4givUwIQrAw J2i+CetELYXyaL++/v9GbsOpmjrGt1Ynpkk290cFlcMr2Uu/CVCkXtc5Q1KVFDfg5DJOS2F4inZ 6KTz7XYsHWPxP1LDJQWnlD80= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id c09c4fc1383378bf; Wed, 18 Nov 2026 02:29:16 +0000 X-Mizu-Trace-ID: c09c4fc1383378bf X-Migadu-Flow: FLOW_OUT From: Qiliang Yuan Date: Tue, 17 Nov 2026 21:28:33 -0500 Subject: [PATCH net-next v4 4/4] net: remove rcu_barrier() from __dev_change_net_namespace() X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261117-bug-net-netns-move-rcu-barrier-v4-4-43e1ca0aac7f@linux.dev> References: <20261117-bug-net-netns-move-rcu-barrier-v4-0-43e1ca0aac7f@linux.dev> In-Reply-To: <20261117-bug-net-netns-move-rcu-barrier-v4-0-43e1ca0aac7f@linux.dev> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , David Ahern , Ido Schimmel , Nikolay Aleksandrov Cc: Kuniyuki Iwashima , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Qiliang Yuan X-Mailer: b4 0.13.0 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 per-cpu routes and exceptions of a nexthop that leaves a group were already released 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 guest with 4 CPUs online, median of 5 runs: before (netns/s) after (netns/s) change 1 thread 30 32 +6.7% 4 threads 40 48 +20% 16 threads 69 110 +59% Signed-off-by: Qiliang Yuan --- net/core/dev.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/core/dev.c b/net/core/dev.c index 3a520c798d4a8..8a899e10e91c6 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -13153,7 +13153,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