From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f180.google.com (mail-dy1-f180.google.com [74.125.82.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10DF238F237 for ; Wed, 4 Feb 2026 07:53:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770191636; cv=none; b=fMKnrCdtc+LK7qPm8Pw8zXUpIbVcIhqbX99ra5M5ODWtBR2SXFbiKmJYMVG6ptyLe7niyFMNz5fusnJMwXG/ICZ8gKJgmf/UaO1WuPa83lzJosgupLBD2DGe4Ma4pPIDlfTTB74eWxPmxZhp8GoqaG/ODmtjxiTfBabIFs9fBj0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770191636; c=relaxed/simple; bh=deSrgkODxQPpr1oSyoric1oNk8vow5CKgaxFEicnd48=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Xy0RtOtDFG1DvIVDWaPwoKBkFNOWGgwwEA7rk5T/rASNHQTK7z6yGE18xXS7jYzdSYPiNkXiJy7SRoHCVojGuV9m589Q6Nf4FmCDKiA183Lp7Yr++WMMjP1B+ruKzud8DgNrTcHz4+f6slwq3ZC/6Gb1SR34/pBBa0nFd1PxSOc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JgSXeK5r; arc=none smtp.client-ip=74.125.82.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JgSXeK5r" Received: by mail-dy1-f180.google.com with SMTP id 5a478bee46e88-2b7da62b487so911327eec.1 for ; Tue, 03 Feb 2026 23:53:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770191635; x=1770796435; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5A6EW3EVViAYvc52ZtU2GD042oNzF8OTzWWfQQFxFBs=; b=JgSXeK5rcoIrnFh1lBtTALOZpJgy4YJhNXi5mI3GxoiSL/LiGttuMhs4Cjuy5wtOEs d76FrNf8RYU99KfvjHbhEJHt6nqB4cSL/jz5sUe6m5YCkBh0gO+RP8VaagqMdcREn3pT Ci/GdqT442qbeZLvjslYKgY+eSudyZ0I3Nhx9PAPxY4b40/ZvOAM5tL4B75uYb+Wsvqr rU56X79hleG87axesS6a2CcaxQkN0jsd5kC3/o9jAeoYlfHTy+2X1c102ZDI99P8/adw P2I2Nl8uV8x1fTgqTeMifoWysLIazE6PTNWRznFySArhoO6Lz94E66B2kUFoURRqT0wP VIig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770191635; x=1770796435; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=5A6EW3EVViAYvc52ZtU2GD042oNzF8OTzWWfQQFxFBs=; b=J+p4x9kWdDqvnuxykS7d4ZklOIKwPbVbJfjCgR5404jG930SEibA0Bn5VdtTG4KB7h 1fu47ZYI42vpnYVNeRIzBajBUhgYIx7KUAHz8CU/Ub5ji4WMCPYuUlL+uagULTwCJ5FL TSkAyPVNEqMIV0xN0q85io1rIG7LNCVwM+QIJeE1tZRJPqVySKQLgldisB/uG3yc+4tz Q/ky9RZLdb9Y2dwu4lvb3TZ+I0q9Ybx05mE9LazR1elHLh3GnMCkn21buGJwbsV/nCtV mCZkmmUsfe4c76kw3yjdmr8PzAdV8Tvsx7uh9hvAtU1L9LeNXzD0HExUC8axpPqn12rZ j6tg== X-Forwarded-Encrypted: i=1; AJvYcCXBL/Xma+70k8PmAnCs+cJ7JQ12rN1p4opVL+5ycmeoGp9SyvD97gQOEpR9EQLr8a7u9/oBPBpP+7MWQrQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yz3XUtx/912YKMs2SGRuA20h6o6Ax7M+S6eVMKnnmtBCMDY+93q rnIHB+L0U5eglHhjC6rb5uK2YWhQE+GVTZBiG61QwxMAilNDJMFTQSWz X-Gm-Gg: AZuq6aLZQAhGh3x3M9pOmfQr0S4mW3ozpRzRpIEQdgHV9F9jRYBUbT96DtR2hkA1t2G t6qChGynzD/4QwESG4Gpsip1bUurtRgtFczjW4t9bTLw/4Kk9SXAH3/+Yk+/S7z1M+9+oxoUJx+ j6LW2CMcI6hNrytS3WFR0Gduur6LLmV3ccL1jRKTVZaxwV0YzBISSjinS4Vv8TBAlNbCLCN9Zm6 /W/f9TYqWAZYlUXJfVxZ/MdqWQ4TTAN0e388b8t/VKGnROBOlo0IGwwwx4AkK0KCleXyutlqhms YdsowHx/mLbocEYZUeQjVCEaszqtZ7s2Ds+ZsmsV75H9cvhHPw9JLtBa84Ah8tqsbL6rCqdYLBd vgXHok1ZrM/tGk4ImjkuzlFB+bQTwmVMY5ysGpFE0ANYX7aqUJq/8JP/XTwWnyGow/uX7DBHyIN IC7Zw= X-Received: by 2002:a05:7300:e7a1:b0:2b7:ef84:9123 with SMTP id 5a478bee46e88-2b8329d0045mr966879eec.41.1770191634983; Tue, 03 Feb 2026 23:53:54 -0800 (PST) Received: from debian ([74.48.213.230]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2b832e12893sm1163577eec.7.2026.02.03.23.53.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Feb 2026 23:53:54 -0800 (PST) From: Qiliang Yuan To: kuniyu@google.com Cc: brauner@kernel.org, davem@davemloft.net, edumazet@google.com, horms@kernel.org, jack@suse.cz, 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 v5] netns: optimize netns cleaning by batching unhash_nsid calls Date: Wed, 4 Feb 2026 02:53:42 -0500 Message-ID: <20260204075347.3508631-1-realwujing@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi Kuniyuki, Thanks for your review and suggestions! On Tue, 3 Feb 2026 16:20:18 -0800 Kuniyuki Iwashima wrote: > batch and system is a bit unclear, maybe M_dying_net, > N_alive_net or something ? Good point. I've updated the terminology in the commit message to M_dying_net and N_alive_net for better clarity. > Also, isn't __peernet2id() also O(N_ids) ? Yes, you are right. __peernet2id() performs a linear search in the IDR, so it is indeed O(N_id). I've corrected the complexity analysis in the commit log. This actually makes the batching optimization even more valuable. > Please put this in a hole, maybe after after hash_mix : > > $ pahole -C net vmlinux Updated. I've moved the 'is_dying' flag to the hole after 'hash_mix' to avoid increasing the size of struct net. > No need to move id up. Fixed. I've scoped the 'id' variable locally within the traversal loop to keep it cleaner. > This can be done unconditionally as the id will never > be assigned to dying nets. > > while (...) { > id++; > > if (!net->dying) > continue; > > /* do cleanup */ > } Simplified as suggested. The loop logic is much cleaner now with the unconditional increment. I've sent out v6 with these changes. v6 link: https://lore.kernel.org/all/20260204074854.3506916-1-realwujing@gmail.com/ Best regards, Qiliang