From nobody Thu Oct 2 09:16:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85AFD2882CE; Thu, 18 Sep 2025 10:12:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190321; cv=none; b=H+4FUbW/Wc0Y42MUxpiZq65YOiF5EsRVu62zmfwonSWzihsRfwH6hZiS95oiDk6ejgxkZWfPq/WZ9MgGY6aFGggDe8uphINGwF9qFNnieqnMNAjaECZ3ZQEp+7KHr/QWW81lpQcq2vpnU6sV8LRUxf8juZIHUsyY5zJ/3eCs3/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190321; c=relaxed/simple; bh=HMXSeRrUilMAIcCkJMxqy3gRY2wo6gW53nQ3RSUckPU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BxEl3uMLCLQXaK2pU0shdzk4yASl1wx7gR7g9VsZcmsr3ANLnVfkTnHYSLW55pTlVOcdSJs0FFvTe5mUyIe8u9p8rj0bzUYFuhM1IuoMwBSUFftr9OpkresfPmCfjWY66kc2pWiTdFdgsltjtml+qSf1t6FCSuMDdw5/xZ0y5kU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EjuIoL/s; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EjuIoL/s" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2E00C4CEE7; Thu, 18 Sep 2025 10:11:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758190320; bh=HMXSeRrUilMAIcCkJMxqy3gRY2wo6gW53nQ3RSUckPU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=EjuIoL/sexyH8UUVxjCXWQCZqfxndOp615s0QK8YViIALPPJqALLCJ/FE6IoBkStR brb1o0NlqlrC85gJpAYLnAQ6jbtgsHIv2j3D2wqhf4agvrax7G23+sz9i54dX1UGUt jLowCLsI+1GPGSWQImJ2ZRfpHCmnQA/9+mSl2wjMQl43ZSkwaApbxLpH4TZbdZPlzB Muz46Od5EdRPm0wqeib+g8RxDsxZYXdvtG7qUeRWRNr4OQNaUdD45NMo+FoL5UIpi8 g2zyzgHhYZiZi0OuoafyHbkDXCHAxQMc5+ulaT30vMHVWLaYu0vb6kNmBxcCbw+sp5 FNHZt4ODAcQBw== From: Christian Brauner Date: Thu, 18 Sep 2025 12:11:46 +0200 Subject: [PATCH 01/14] ns: add reference count helpers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250918-work-namespace-ns_ref-v1-1-1b0a98ee041e@kernel.org> References: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> In-Reply-To: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Amir Goldstein , Josef Bacik , Jeff Layton , Mike Yuan , =?utf-8?q?Zbigniew_J=C4=99drzejewski-Szmek?= , Lennart Poettering , Daan De Meyer , Aleksa Sarai , Alexander Viro , Jan Kara , Tejun Heo , Johannes Weiner , =?utf-8?q?Michal_Koutn=C3=BD?= , Jakub Kicinski , Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Christian Brauner X-Mailer: b4 0.15-dev-56183 X-Developer-Signature: v=1; a=openpgp-sha256; l=2929; i=brauner@kernel.org; h=from:subject:message-id; bh=HMXSeRrUilMAIcCkJMxqy3gRY2wo6gW53nQ3RSUckPU=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWScvvXUi9Hxp52uhwzXRas5MzyMG5W8Zz929VqYpbLk1 i4RC5ngjlIWBjEuBlkxRRaHdpNwueU8FZuNMjVg5rAygQxh4OIUgIm8us3wP19nfuu6barnt+xS cfkVGlT1/MsEVWPbGadcL547dZvxezzD/5oe+SWfnX5PUk3RCBRoDNV/wv6DSeokr9oSmxOCezf +5gMA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- include/linux/ns_common.h | 45 +++++++++++++++++++++++++++++++++++--------= -- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/include/linux/ns_common.h b/include/linux/ns_common.h index 5094c0147b54..a65da646aef7 100644 --- a/include/linux/ns_common.h +++ b/include/linux/ns_common.h @@ -43,16 +43,24 @@ struct ns_common { int __ns_common_init(struct ns_common *ns, const struct proc_ns_operations= *ops, int inum); void __ns_common_free(struct ns_common *ns); =20 -#define to_ns_common(__ns) \ - _Generic((__ns), \ - struct cgroup_namespace *: &(__ns)->ns, \ - struct ipc_namespace *: &(__ns)->ns, \ - struct mnt_namespace *: &(__ns)->ns, \ - struct net *: &(__ns)->ns, \ - struct pid_namespace *: &(__ns)->ns, \ - struct time_namespace *: &(__ns)->ns, \ - struct user_namespace *: &(__ns)->ns, \ - struct uts_namespace *: &(__ns)->ns) +#define to_ns_common(__ns) \ + _Generic((__ns), \ + struct cgroup_namespace *: &(__ns)->ns, \ + const struct cgroup_namespace *: &(__ns)->ns, \ + struct ipc_namespace *: &(__ns)->ns, \ + const struct ipc_namespace *: &(__ns)->ns, \ + struct mnt_namespace *: &(__ns)->ns, \ + const struct mnt_namespace *: &(__ns)->ns, \ + struct net *: &(__ns)->ns, \ + const struct net *: &(__ns)->ns, \ + struct pid_namespace *: &(__ns)->ns, \ + const struct pid_namespace *: &(__ns)->ns, \ + struct time_namespace *: &(__ns)->ns, \ + const struct time_namespace *: &(__ns)->ns, \ + struct user_namespace *: &(__ns)->ns, \ + const struct user_namespace *: &(__ns)->ns, \ + struct uts_namespace *: &(__ns)->ns, \ + const struct uts_namespace *: &(__ns)->ns) =20 #define ns_init_inum(__ns) \ _Generic((__ns), \ @@ -85,4 +93,21 @@ void __ns_common_free(struct ns_common *ns); =20 #define ns_common_free(__ns) __ns_common_free(to_ns_common((__ns))) =20 +static __always_inline __must_check bool __ns_ref_put(struct ns_common *ns) +{ + return refcount_dec_and_test(&ns->count); +} + +static __always_inline __must_check bool __ns_ref_get(struct ns_common *ns) +{ + return refcount_inc_not_zero(&ns->count); +} + +#define ns_ref_read(__ns) refcount_read(&to_ns_common((__ns))->count) +#define ns_ref_inc(__ns) refcount_inc(&to_ns_common((__ns))->count) +#define ns_ref_get(__ns) __ns_ref_get(to_ns_common((__ns))) +#define ns_ref_put(__ns) __ns_ref_put(to_ns_common((__ns))) +#define ns_ref_put_and_lock(__ns, __lock) \ + refcount_dec_and_lock(&to_ns_common((__ns))->count, (__lock)) + #endif --=20 2.47.3 From nobody Thu Oct 2 09:16:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D9B22882CE; Thu, 18 Sep 2025 10:12:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190325; cv=none; b=Djbc89TgOtlqUHMyx7CXPyvM6aeTtFj39rj6DN4eulJ3dSyL4OTmFdpm3XriABkyyAmxWDApd4bzBk+pN5QpuSbtaONC+i3yqF2UYuUVzTK6svvWtxU0Y12r+PR1iq2Luwn8yetwoiYGQF9Osp0HJUfg9+wcqU1Vgv/iB8iTyYs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190325; c=relaxed/simple; bh=/sTZR3BClhCuVNNW87kZu8f75t/rIIcDUmwTG0o8auM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WBsU/YWRyezGliitT2caLn+7FCBZ9QBIyl9OIh3KzNf5STQF16NAgFu2poQqozgTyR+O/rfoq47r2lLRy6/4ls2v0mRDlK5LqQbObxSZRHm0mv9kGxQ69KQjEAzmjc5/62RkScXmkpgJwQcRwxV8dmd732T6JgRzt8/adlw5kW8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=e9+pAn2f; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="e9+pAn2f" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A4CAC4CEFC; Thu, 18 Sep 2025 10:12:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758190324; bh=/sTZR3BClhCuVNNW87kZu8f75t/rIIcDUmwTG0o8auM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=e9+pAn2fnvTUZkPCVpHusRFwIzcM4KqyFONGUjWRLl3RMGE4cVivfTfCohGZfq/Rd anD8DIBP9QPeX/qxDhQbgqOuHumbeFnRlhKKnybK3zW+/UDdc6W9gJrqpF3QIX2Ozp jeDJOx/SEdOdfrXnMNX6IQ3gBcHf7Wwx5zSe3k3HGJQqoC71g/F1koQNRybunfh4/g 6nINc27S8xHyCKWJE4+ZQXN/W6GDIyG5ySPw7ereCrSTkaI/3TIBt+MIABt6ZU+Szv tgiKZpRtgfn9zyzuMvcRDJtn5q3ILysC32O/in/wgsu5BL2hwcBL4Yml1GSOeJVWwq 24KG8IeWLd2uA== From: Christian Brauner Date: Thu, 18 Sep 2025 12:11:47 +0200 Subject: [PATCH 02/14] mnt: port to ns_ref_*() helpers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250918-work-namespace-ns_ref-v1-2-1b0a98ee041e@kernel.org> References: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> In-Reply-To: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Amir Goldstein , Josef Bacik , Jeff Layton , Mike Yuan , =?utf-8?q?Zbigniew_J=C4=99drzejewski-Szmek?= , Lennart Poettering , Daan De Meyer , Aleksa Sarai , Alexander Viro , Jan Kara , Tejun Heo , Johannes Weiner , =?utf-8?q?Michal_Koutn=C3=BD?= , Jakub Kicinski , Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Christian Brauner X-Mailer: b4 0.15-dev-56183 X-Developer-Signature: v=1; a=openpgp-sha256; l=1217; i=brauner@kernel.org; h=from:subject:message-id; bh=/sTZR3BClhCuVNNW87kZu8f75t/rIIcDUmwTG0o8auM=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWScvvX07tI4dYm3wu36Wde/957bpWGeaXm1LzXYzM7Ag 0f408enHaUsDGJcDLJiiiwO7Sbhcst5KjYbZWrAzGFlAhnCwMUpABM5tJSRYYta8lvThv3LNsgH GXD/litVOmax74zHmjCjKaaPgj+d+8Dwv6bv+caGc4kXFO3qb9au3RSf8fZU8wzWzyudWTbeVr9 8iRsA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Stop accessing ns.count directly. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- fs/mount.h | 2 +- fs/namespace.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/mount.h b/fs/mount.h index 76bf863c9ae2..79c85639a7ba 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -143,7 +143,7 @@ static inline void detach_mounts(struct dentry *dentry) =20 static inline void get_mnt_ns(struct mnt_namespace *ns) { - refcount_inc(&ns->ns.count); + ns_ref_inc(ns); } =20 extern seqlock_t mount_lock; diff --git a/fs/namespace.c b/fs/namespace.c index 03bd04559e69..8cc04e0e64da 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2111,7 +2111,7 @@ struct mnt_namespace *get_sequential_mnt_ns(struct mn= t_namespace *mntns, bool pr * the mount namespace and it might already be on its * deathbed. */ - if (!refcount_inc_not_zero(&mntns->ns.count)) + if (!ns_ref_get(mntns)) continue; =20 return mntns; @@ -6080,7 +6080,7 @@ void __init mnt_init(void) =20 void put_mnt_ns(struct mnt_namespace *ns) { - if (!refcount_dec_and_test(&ns->ns.count)) + if (!ns_ref_put(ns)) return; namespace_lock(); emptied_ns =3D ns; --=20 2.47.3 From nobody Thu Oct 2 09:16:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D26302DF13C; Thu, 18 Sep 2025 10:12:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190329; cv=none; b=R2Wjd6NEWuEzENUfE4glJtx8vvpUOny7vIGCxCfJZZ494f5WorG+V2H6t54BJ+jrIeN+DUjynaUZkT2kpm+kQYi7sRV7DszEDeVjRpqYq4tzBELTmvYCvA7X36PgaKpm7dJF2QyF/Xk09teWKEmlUdA6fTk7LhmNMW2F1eIKzGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190329; c=relaxed/simple; bh=AwtpcsfwgtDwnthC1bV7e8x5rzSiJNY1IAfYMJ4PVyw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dHRFXUoMGlk0fVG+iXbdud/V9WxH+Kwn4il0IpxcMApR7Y2bF4EuqUbuYHZ+AFjENBY6W1kRzPoQEj6etADfu/QeC+bC4dQxmBkcXoJSGCL/0X4Vz3sD+QUz9RgHadTNDf32w1vhsZAAQmRS1cBBxcDKGRbubq0MkCF/P/7l5WY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cP7bz9WC; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cP7bz9WC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DFC2C4CEE7; Thu, 18 Sep 2025 10:12:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758190329; bh=AwtpcsfwgtDwnthC1bV7e8x5rzSiJNY1IAfYMJ4PVyw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=cP7bz9WCG2K9Yn/WJo5jsHocvHH2K7u/Ohnlf/zHtbQAByPTLJd+CtXaubML2+0qJ 0SyrPYgPOCcO8FB5t+g1PmY9nFbJ3N92nd67F64fF0LzIdnlYls0vyLknoenw26R5e k81q2EXbUSYY6mCq3a7UrY2E6al3MtPEL5WyWr437bZzA5hNoqa7g/cAHh/BGF/5yO yhVv3gDexP5f0VXkOAHIP9R0hDw5+OnIfAxBIxpFU8FlrZFWjVRUHNhskn57SUp0gI Ol8BbKKF1GKUIjTTm8pMiZFuhkcRE4WGbL6NfbItxaPVPAQ5u/oM+rUU5P1LhTDzku L1cMdRoFEi3kw== From: Christian Brauner Date: Thu, 18 Sep 2025 12:11:48 +0200 Subject: [PATCH 03/14] cgroup: port to ns_ref_*() helpers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250918-work-namespace-ns_ref-v1-3-1b0a98ee041e@kernel.org> References: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> In-Reply-To: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Amir Goldstein , Josef Bacik , Jeff Layton , Mike Yuan , =?utf-8?q?Zbigniew_J=C4=99drzejewski-Szmek?= , Lennart Poettering , Daan De Meyer , Aleksa Sarai , Alexander Viro , Jan Kara , Tejun Heo , Johannes Weiner , =?utf-8?q?Michal_Koutn=C3=BD?= , Jakub Kicinski , Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Christian Brauner X-Mailer: b4 0.15-dev-56183 X-Developer-Signature: v=1; a=openpgp-sha256; l=794; i=brauner@kernel.org; h=from:subject:message-id; bh=AwtpcsfwgtDwnthC1bV7e8x5rzSiJNY1IAfYMJ4PVyw=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWScvvXUw16y/nCzcuS60N2va/KZEg21JzIxJ6hddaxdm 5f0gM+8o5SFQYyLQVZMkcWh3SRcbjlPxWajTA2YOaxMIEMYuDgFYCLbTjAy3Lf1elvcUjbjxh/n 0BdHdjxrPqOlto4tzVzqaGXXlAUL9jMytDSeLzyRJr89k1PWi2Gj4exga4e1PSvXHwvu8O2fkB/ HCAA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Stop accessing ns.count directly. Signed-off-by: Christian Brauner Acked-by: Tejun Heo Reviewed-by: Jan Kara --- include/linux/cgroup_namespace.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/cgroup_namespace.h b/include/linux/cgroup_namesp= ace.h index c02bb76c5e32..b7dbf4d623d2 100644 --- a/include/linux/cgroup_namespace.h +++ b/include/linux/cgroup_namespace.h @@ -29,12 +29,12 @@ int cgroup_path_ns(struct cgroup *cgrp, char *buf, size= _t buflen, =20 static inline void get_cgroup_ns(struct cgroup_namespace *ns) { - refcount_inc(&ns->ns.count); + ns_ref_inc(ns); } =20 static inline void put_cgroup_ns(struct cgroup_namespace *ns) { - if (refcount_dec_and_test(&ns->ns.count)) + if (ns_ref_put(ns)) free_cgroup_ns(ns); } =20 --=20 2.47.3 From nobody Thu Oct 2 09:16:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5BCB127E7FC; Thu, 18 Sep 2025 10:12:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190334; cv=none; b=Mi2FHK6efUkYtDsVYCaeuNdL07IUEaz5aFXZ5T57RYzQJTuFvJbyKgtCOwUj6Lb6gI7HIu0GD4oQfgGsUVKNWOy6sCrl1BeF7bhnMNYhraGM5861oSoMcZikV/aVbhJcL2LVpfOnFsXiD2J97uc+y/lu9zkUEfUYUTBnlFZknGo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190334; c=relaxed/simple; bh=YNpbHl0e3vU8E4llPbmuVZsTppgL8lTynK3tRRFcir4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VncPnWsKhGkOOxKOSwZyG6T1wQn49p+xdprTDFAk0faC9zu8h4kWZz2LeM3b06v1GQqoktEvPpDQOQ7Un7SwYMFRLeFSYFy6+HMS6SJaZ4C/AVxT/TTMBKIVYcPWBrtrSh+0owOug6z/B/MnkN5oNXzqMP4Ht99TNfLwCA2UfR4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PJWFp5Pn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PJWFp5Pn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6CB0C4CEF1; Thu, 18 Sep 2025 10:12:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758190334; bh=YNpbHl0e3vU8E4llPbmuVZsTppgL8lTynK3tRRFcir4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=PJWFp5PnGpphs/p6jvX208TBYn7epuzPlkKJIyvGQfu0rG7PUdZ+0q0chtlWExo3a 9BuLf3T2z8SbIgr3Tpu88QvuCgDlNEk6/orz+gwMD9DfetjfVD1CumP8kRDBN5g8cD SHZCFdG3vcBkfomJA2qtB7TQj8GqfFcZQpw6V2DKccS9vm4pP8K5bMzw6kxaMXtJvc jXkKyTcCuq0Gp5MJcQ/N2tsqyxQ5Ng+engEQfzAULWbQTfQabFyBukSvBFqJHMQZXX PGl8kw2ZLdT77nQ+X3cDOP4AkpQBKBpS9132v417FZ4UIgpIR8eSur+oPIi5Yk40hZ 4rPicOED55csg== From: Christian Brauner Date: Thu, 18 Sep 2025 12:11:49 +0200 Subject: [PATCH 04/14] ipc: port to ns_ref_*() helpers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250918-work-namespace-ns_ref-v1-4-1b0a98ee041e@kernel.org> References: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> In-Reply-To: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Amir Goldstein , Josef Bacik , Jeff Layton , Mike Yuan , =?utf-8?q?Zbigniew_J=C4=99drzejewski-Szmek?= , Lennart Poettering , Daan De Meyer , Aleksa Sarai , Alexander Viro , Jan Kara , Tejun Heo , Johannes Weiner , =?utf-8?q?Michal_Koutn=C3=BD?= , Jakub Kicinski , Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Christian Brauner X-Mailer: b4 0.15-dev-56183 X-Developer-Signature: v=1; a=openpgp-sha256; l=1293; i=brauner@kernel.org; h=from:subject:message-id; bh=YNpbHl0e3vU8E4llPbmuVZsTppgL8lTynK3tRRFcir4=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWScvvXUwbyKmWHr1Wl6ExauUjTv2hP4befpr9MKwn6He c5W7wlg6ShlYRDjYpAVU2RxaDcJl1vOU7HZKFMDZg4rE8gQBi5OAZiIwmaG/2Um0V5th2rnnBN1 Ljd6ocjq2XD1iaTJ4iChdZPVFt/4dJ6RoU/u+ymDizGa+3dxPGJJzfJcu4nH4+7Fkth5HAVvo7M CmAA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Stop accessing ns.count directly. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- include/linux/ipc_namespace.h | 4 ++-- ipc/namespace.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h index 924e4754374f..21eff63f47da 100644 --- a/include/linux/ipc_namespace.h +++ b/include/linux/ipc_namespace.h @@ -140,14 +140,14 @@ extern struct ipc_namespace *copy_ipcs(unsigned long = flags, static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns) { if (ns) - refcount_inc(&ns->ns.count); + ns_ref_inc(ns); return ns; } =20 static inline struct ipc_namespace *get_ipc_ns_not_zero(struct ipc_namespa= ce *ns) { if (ns) { - if (refcount_inc_not_zero(&ns->ns.count)) + if (ns_ref_get(ns)) return ns; } =20 diff --git a/ipc/namespace.c b/ipc/namespace.c index 09d261a1a2aa..bd85d1c9d2c2 100644 --- a/ipc/namespace.c +++ b/ipc/namespace.c @@ -199,7 +199,7 @@ static void free_ipc(struct work_struct *unused) */ void put_ipc_ns(struct ipc_namespace *ns) { - if (refcount_dec_and_lock(&ns->ns.count, &mq_lock)) { + if (ns_ref_put_and_lock(ns, &mq_lock)) { mq_clear_sbinfo(ns); spin_unlock(&mq_lock); =20 --=20 2.47.3 From nobody Thu Oct 2 09:16:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03FEF28137A; Thu, 18 Sep 2025 10:12:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190341; cv=none; b=OScsB6SRygqIkIeKi4W6/leUi4RpRKXB/h5GHEFfpkbGOYB/8i9v7NgjhqfnGqUBAagfZ48MwYTDaVfshl2RAxnxUsVA1ky3IYxMWxrHCVtAByrwreGIHJj27ccm53FnSiX4NhyZWo2nYX+1RspdYFznWgYPRJPyWWWhYRdFVhE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190341; c=relaxed/simple; bh=wYEQfvSmlmlDWynjlphXrD2qwb3KWxhdfH/o1XOT9aY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pd4GZ+pAEBdx8+BBVs/AUf4uDd/ePevaMMbvj3AU0iGkAKXG93f5Oi3VDc5yWIC1mtL3RgQZDeI7qwpmU7LGleazMR5MoogoUT9eJ+cTT/DSYO1cp2qU9w3hE3F/3M5bVsoHZxCtrO/hHP2QvrdA2amxH2fvjkhZjq2KqJ1/fn8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GhPDhwhR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GhPDhwhR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68507C4CEF0; Thu, 18 Sep 2025 10:12:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758190338; bh=wYEQfvSmlmlDWynjlphXrD2qwb3KWxhdfH/o1XOT9aY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=GhPDhwhRDK/8wxIUNlLH1gVNLYR/ZvSZ6sPXtDoU9ggEN7lvrxZas52yRbkzRuoig i/BCqdIe089xMP3iZ45uszzUOpu+XSy9P1wZ5IFbSGdNNba5FyEHfGUe0XgnUdtxAD qDLl4vZKvn/NJ20OYqYzoChYW+nOvLIlbMIhwoxM5B2831hXy54P7PDF5blgtbpymW IqpjxMhOnyp0rYdn81tQlXyUOLpscKptWOp4WeZbr68KnsufFmTR3TMOjtidaCNpzG lDSOFaZGk07BnohLEn2wyGsk0D8f3kCrfYToJdlYiMxEl07Pm24/VwiwZVQkz4iccw nHTwpcrcDilQg== From: Christian Brauner Date: Thu, 18 Sep 2025 12:11:50 +0200 Subject: [PATCH 05/14] pid: port to ns_ref_*() helpers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250918-work-namespace-ns_ref-v1-5-1b0a98ee041e@kernel.org> References: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> In-Reply-To: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Amir Goldstein , Josef Bacik , Jeff Layton , Mike Yuan , =?utf-8?q?Zbigniew_J=C4=99drzejewski-Szmek?= , Lennart Poettering , Daan De Meyer , Aleksa Sarai , Alexander Viro , Jan Kara , Tejun Heo , Johannes Weiner , =?utf-8?q?Michal_Koutn=C3=BD?= , Jakub Kicinski , Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Christian Brauner X-Mailer: b4 0.15-dev-56183 X-Developer-Signature: v=1; a=openpgp-sha256; l=1531; i=brauner@kernel.org; h=from:subject:message-id; bh=wYEQfvSmlmlDWynjlphXrD2qwb3KWxhdfH/o1XOT9aY=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWScvvV0YtW6/Usktqzp7cmPCn7+k3/TDVvvml3X3+59e XmSqfT3rx2lLAxiXAyyYoosDu0m4XLLeSo2G2VqwMxhZQIZwsDFKQATWZHEyHB9/tY5WpvceK/p nr1z9fLxYuPmix2WS9QkyuX6gj427NRl+Cu5Olr78Av/RRd9ZYOnSGatPz8p4Jb1nXnF23muJs+ orecHAA== X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Stop accessing ns.count directly. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- include/linux/pid_namespace.h | 2 +- kernel/pid_namespace.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h index ba0efc8c8596..5b2f29d369c4 100644 --- a/include/linux/pid_namespace.h +++ b/include/linux/pid_namespace.h @@ -62,7 +62,7 @@ static inline struct pid_namespace *to_pid_ns(struct ns_c= ommon *ns) static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns) { if (ns !=3D &init_pid_ns) - refcount_inc(&ns->ns.count); + ns_ref_inc(ns); return ns; } =20 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c index 27e2dd9ee051..162f5fb63d75 100644 --- a/kernel/pid_namespace.c +++ b/kernel/pid_namespace.c @@ -169,7 +169,7 @@ static void destroy_pid_namespace_work(struct work_stru= ct *work) parent =3D ns->parent; destroy_pid_namespace(ns); ns =3D parent; - } while (ns !=3D &init_pid_ns && refcount_dec_and_test(&ns->ns.count)); + } while (ns !=3D &init_pid_ns && ns_ref_put(ns)); } =20 struct pid_namespace *copy_pid_ns(unsigned long flags, @@ -184,7 +184,7 @@ struct pid_namespace *copy_pid_ns(unsigned long flags, =20 void put_pid_ns(struct pid_namespace *ns) { - if (ns && ns !=3D &init_pid_ns && refcount_dec_and_test(&ns->ns.count)) + if (ns && ns !=3D &init_pid_ns && ns_ref_put(ns)) schedule_work(&ns->work); } EXPORT_SYMBOL_GPL(put_pid_ns); --=20 2.47.3 From nobody Thu Oct 2 09:16:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A73FF2FFFB2; Thu, 18 Sep 2025 10:12:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190343; cv=none; b=GSnAwldc2ezcKWVAHSvvOPJ4rah48vCcV5H63k0JG9Md86T9X3/CdrR+DrAh6TaMOw22tX2r6DiGa4cXh38dbia3n2+9uAPtr6u/9P0IZbsIzZH7NZoecHEk0KShmFaFxQXp6XBJInEBdKxqqqdhGp3ZLnry03hGBPidULr1oPM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190343; c=relaxed/simple; bh=4amAutzpiwVYLHgtnhIXGGuhoIt8EcWOZn5DDS6SJmE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ASuFiqCx7eDpuXmhFgrx1xom4xPgy1u+I+HGA2MWyohP3d7bQxtWfVEe7iAIfzDqINtJOVtgvvgrMCdsrPP7uMNN3Qf/fdlNkfR++K4K2IA1PqvuDnEre9qH7T4rnmYuN9WVIvtsYg+dyth7cIHILgrH1XPvWb1kwYF31xZLKXs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EsJkMcbP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EsJkMcbP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03ACEC4CEE7; Thu, 18 Sep 2025 10:12:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758190343; bh=4amAutzpiwVYLHgtnhIXGGuhoIt8EcWOZn5DDS6SJmE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=EsJkMcbPk5O5ehnVhIO5sp2dcNyCdQtyKV3tSSGaIHYQEHTJQRBsVpaLYWz1YT/XZ 5r1jqGZIv3XmRrHFGyv0Dz8pTz1N3UfrXIBBg+hxaC7J/vOwO4kESOoXNYp3hVFaJQ LMrdPGiX4AvsW2YyG+LVdaQji2WAmkzP5JUX3j6OCDilBYheciNiHCdO4eEqI7LnEn BKp1qSjcBAaQziAKhUeQHfnN46zEBQNcb23tgVb/EX2HDpJkleBY/UDxI2dMKAwmc0 rSpA2FUzj+vkzJwfNy5lE6qigDmEDSkEm/z+NVD1LgWUqe3Aw1n/JRo5cHTku5IGDz kyGK8ozDBz8rA== From: Christian Brauner Date: Thu, 18 Sep 2025 12:11:51 +0200 Subject: [PATCH 06/14] time: port to ns_ref_*() helpers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250918-work-namespace-ns_ref-v1-6-1b0a98ee041e@kernel.org> References: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> In-Reply-To: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Amir Goldstein , Josef Bacik , Jeff Layton , Mike Yuan , =?utf-8?q?Zbigniew_J=C4=99drzejewski-Szmek?= , Lennart Poettering , Daan De Meyer , Aleksa Sarai , Alexander Viro , Jan Kara , Tejun Heo , Johannes Weiner , =?utf-8?q?Michal_Koutn=C3=BD?= , Jakub Kicinski , Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Christian Brauner X-Mailer: b4 0.15-dev-56183 X-Developer-Signature: v=1; a=openpgp-sha256; l=903; i=brauner@kernel.org; h=from:subject:message-id; bh=4amAutzpiwVYLHgtnhIXGGuhoIt8EcWOZn5DDS6SJmE=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWScvvW013CTaGDpGQGXSuVtyTt/3DqiH/AwSvDmloOLx Hy9OawndpSyMIhxMciKKbI4tJuEyy3nqdhslKkBM4eVCWQIAxenAEyEi4vhn514yeam59ybJDiv H+Bw/prWwX48+YLnuYx9RyvFLv3MrGL4Hxt0Zu+VT+/n+mvyeKk/kVQ7Wc5/sn3T+i8htSp/720 15AIA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Stop accessing ns.count directly. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara Reviewed-by: Thomas Gleixner --- include/linux/time_namespace.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/time_namespace.h b/include/linux/time_namespace.h index a47a4ce4183e..f3b9567cf1f4 100644 --- a/include/linux/time_namespace.h +++ b/include/linux/time_namespace.h @@ -44,7 +44,7 @@ extern void timens_commit(struct task_struct *tsk, struct= time_namespace *ns); =20 static inline struct time_namespace *get_time_ns(struct time_namespace *ns) { - refcount_inc(&ns->ns.count); + ns_ref_inc(ns); return ns; } =20 @@ -57,7 +57,7 @@ struct page *find_timens_vvar_page(struct vm_area_struct = *vma); =20 static inline void put_time_ns(struct time_namespace *ns) { - if (refcount_dec_and_test(&ns->ns.count)) + if (ns_ref_put(ns)) free_time_ns(ns); } =20 --=20 2.47.3 From nobody Thu Oct 2 09:16:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1EE172F39CF; Thu, 18 Sep 2025 10:12:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190348; cv=none; b=KjuBSqJLUG3TaKgMIX1XhL/+g2aDon5RgoHls/ZMt/D8tXyYcWWm/d46zbWA0PALc9TpXYIfmFdsBqBxkoi/ufxesZuj/9rGaxkjuzdQR6iSj6sxg31Z+fEr6VuuRaqXgTVS4/qePtSK7VVNmGLfSvmAD26WK9LR49MEy4HVcVE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190348; c=relaxed/simple; bh=5NGIqPGYw+T/9FWphbn7aLdjuEXBOiEmvs9M0qqiQu4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JPxzPhCt0kP2MHphdEXix96BRJ9CSKakiPAr/s6ebTqEuKfepCOkHRttiIaZrHdufMbMkVawHHgJEWIv64WnmYdbO7IaoUsiho6Ds+jMRfqtpmSJ+ofa4J5Xb0CmhWmFjKY9dgh0fRdcBmSF3xS+O30ejK6uhHvXX6r5/wKy/g0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NcK18o2F; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NcK18o2F" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A67ACC4CEF1; Thu, 18 Sep 2025 10:12:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758190348; bh=5NGIqPGYw+T/9FWphbn7aLdjuEXBOiEmvs9M0qqiQu4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=NcK18o2Fu7rBhYM8IDKQIrJ491P91WuvxXo5Js10Zviv+V155UHN4af2zTORodQDE tdzXM7WhpuUNxJcQYoxfqSbBajoNbAPaTP+nw7cbhFEkoBqPgM76bmpHLx870InEMs 1ip3OPX7uksd1hLIWjuZqjqGOcPXW86IvB6KCpxwZRS6ULXdmhbiNYfFn0tmwlvn6L pavHFZuzqmauPbB9VsZGo2Zp0DBdItmpcnNXCR/neQQyGgYTs+a36ArYT/8qeAoJKo nTfO7sUlpFHOkzNhjLotx9TkrukO7sR23nx3utGDrJMjlLKNhgJ1KG12XqngCNu838 Fr+KOLO2uPO4Q== From: Christian Brauner Date: Thu, 18 Sep 2025 12:11:52 +0200 Subject: [PATCH 07/14] user: port to ns_ref_*() helpers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250918-work-namespace-ns_ref-v1-7-1b0a98ee041e@kernel.org> References: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> In-Reply-To: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Amir Goldstein , Josef Bacik , Jeff Layton , Mike Yuan , =?utf-8?q?Zbigniew_J=C4=99drzejewski-Szmek?= , Lennart Poettering , Daan De Meyer , Aleksa Sarai , Alexander Viro , Jan Kara , Tejun Heo , Johannes Weiner , =?utf-8?q?Michal_Koutn=C3=BD?= , Jakub Kicinski , Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Christian Brauner X-Mailer: b4 0.15-dev-56183 X-Developer-Signature: v=1; a=openpgp-sha256; l=1415; i=brauner@kernel.org; h=from:subject:message-id; bh=5NGIqPGYw+T/9FWphbn7aLdjuEXBOiEmvs9M0qqiQu4=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWScvvXsMtvhiapbDj0Jf11/kkuI24B1j8yGDXN0BQ+Ib g/Ir3S+3lHKwiDGxSArpsji0G4SLrecp2KzUaYGzBxWJpAhDFycAjCR+IuMDA+v82hPCzjuMzPx LNMD5bDH0/cKu2wwn1p2cTe/6lbHRymMDCcXm1sJnlng6T658O+t3a8lL3Kc1jdMnphlNv30+qs 3uTkA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Stop accessing ns.count directly. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- include/linux/user_namespace.h | 4 ++-- kernel/user_namespace.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h index a09056ad090e..9a9aebbf96b9 100644 --- a/include/linux/user_namespace.h +++ b/include/linux/user_namespace.h @@ -176,7 +176,7 @@ static inline struct user_namespace *to_user_ns(struct = ns_common *ns) static inline struct user_namespace *get_user_ns(struct user_namespace *ns) { if (ns) - refcount_inc(&ns->ns.count); + ns_ref_inc(ns); return ns; } =20 @@ -186,7 +186,7 @@ extern void __put_user_ns(struct user_namespace *ns); =20 static inline void put_user_ns(struct user_namespace *ns) { - if (ns && refcount_dec_and_test(&ns->ns.count)) + if (ns && ns_ref_put(ns)) __put_user_ns(ns); } =20 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c index 32406bcab526..f9df45c46235 100644 --- a/kernel/user_namespace.c +++ b/kernel/user_namespace.c @@ -225,7 +225,7 @@ static void free_user_ns(struct work_struct *work) kfree_rcu(ns, ns.ns_rcu); dec_user_namespaces(ucounts); ns =3D parent; - } while (refcount_dec_and_test(&parent->ns.count)); + } while (ns_ref_put(parent)); } =20 void __put_user_ns(struct user_namespace *ns) --=20 2.47.3 From nobody Thu Oct 2 09:16:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E335528643F; Thu, 18 Sep 2025 10:12:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190353; cv=none; b=jbDVuZP6kNLIBLSjkdlgpDse1Jglnma1VhMZYJMP7fve+hJBbgMFJE+D0HcWXqpYaSU5cFA4lWP7u+pPnHr8gfCiCK/xf+JxzWLtIhuN8UjlkZxSig0R9SVNTAeZdF724qac7r0f3XFrFmuSXyuakbx6nodJwKBXF5G5wrtAbd8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190353; c=relaxed/simple; bh=JQj+hKUFm8QJxn9wbCfJ1lqCGI1ADoO5H9i3MIyjzas=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XolWt3nXH/GJ6zuvIBy3JEELvuWEdhK4x5vLUA0k0XL7tv8FvD/iyKbBPdJMlWi/IhK/4AVI0jFDysTfghn78vv5/LCs9pCIHjkxDSG++BJ/o1FZqEcxFH45WfscFf88dw5KB3JE6CifUkklybro+H3M0P7qsaz+s78lNHVKl4Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mFFBIQsK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mFFBIQsK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BE5DC4CEF0; Thu, 18 Sep 2025 10:12:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758190352; bh=JQj+hKUFm8QJxn9wbCfJ1lqCGI1ADoO5H9i3MIyjzas=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=mFFBIQsKlKP2ldt3wifPwejDmvkJh2rAdLxHuSR4r110O9y++g6G3uuyreE5ttmOO x6hBSn2A4X5qcTv3ZFHy7hDHJYfe3eDsB0l/gzBTxIBdtixSjMIPTSbrH9iyhRovUq YCZL+xTWlx1giEvp4ziYos0tN8X27LUlxkhpJpDCuq/7AoT2nl0VsBX084x0xPvGcc 3oNE182z5C8WR951txiGuuB/Z/gizbLtHtj+CS2reC04pEyrTipmKPFf440Hp0OVIh x2Fac2XflAAT3Sf6mJGVvo7bjyzbiivczxUlz/hDP2SOTl0LoE9Wm6tZcni6n5sQfu xKlREslXiQc8A== From: Christian Brauner Date: Thu, 18 Sep 2025 12:11:53 +0200 Subject: [PATCH 08/14] net-sysfs: use check_net() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250918-work-namespace-ns_ref-v1-8-1b0a98ee041e@kernel.org> References: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> In-Reply-To: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Amir Goldstein , Josef Bacik , Jeff Layton , Mike Yuan , =?utf-8?q?Zbigniew_J=C4=99drzejewski-Szmek?= , Lennart Poettering , Daan De Meyer , Aleksa Sarai , Alexander Viro , Jan Kara , Tejun Heo , Johannes Weiner , =?utf-8?q?Michal_Koutn=C3=BD?= , Jakub Kicinski , Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Christian Brauner X-Mailer: b4 0.15-dev-56183 X-Developer-Signature: v=1; a=openpgp-sha256; l=1415; i=brauner@kernel.org; h=from:subject:message-id; bh=JQj+hKUFm8QJxn9wbCfJ1lqCGI1ADoO5H9i3MIyjzas=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWScvvXMdrrzK4VDX09wXDnabSld+U2MyfqnxZpeXe2X9 76qZ5cYdpSyMIhxMciKKbI4tJuEyy3nqdhslKkBM4eVCWQIAxenAExk5guG/3HZVofT4iNezC5t qTpQtMn0sFPTQ58f5VxzJzTbebi/v8/wP0b13VTLTcoy3RrtF3yXrgg9scW8R+Z++3Ot4ANvKt0 kGQE= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Don't directly acess the namespace count. There's even a dedicated helper for this. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- net/core/net-sysfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index c28cd6665444..3c2dc4c5e683 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -1328,7 +1328,7 @@ net_rx_queue_update_kobjects(struct net_device *dev, = int old_num, int new_num) struct netdev_rx_queue *queue =3D &dev->_rx[i]; struct kobject *kobj =3D &queue->kobj; =20 - if (!refcount_read(&dev_net(dev)->ns.count)) + if (!check_net(dev_net(dev))) kobj->uevent_suppress =3D 1; if (dev->sysfs_rx_queue_group) sysfs_remove_group(kobj, dev->sysfs_rx_queue_group); @@ -2061,7 +2061,7 @@ netdev_queue_update_kobjects(struct net_device *dev, = int old_num, int new_num) while (--i >=3D new_num) { struct netdev_queue *queue =3D dev->_tx + i; =20 - if (!refcount_read(&dev_net(dev)->ns.count)) + if (!check_net(dev_net(dev))) queue->kobj.uevent_suppress =3D 1; =20 if (netdev_uses_bql(dev)) @@ -2315,7 +2315,7 @@ void netdev_unregister_kobject(struct net_device *nde= v) { struct device *dev =3D &ndev->dev; =20 - if (!refcount_read(&dev_net(ndev)->ns.count)) + if (!check_net(dev_net(ndev))) dev_set_uevent_suppress(dev, 1); =20 kobject_get(&dev->kobj); --=20 2.47.3 From nobody Thu Oct 2 09:16:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9FC752BEC32; Thu, 18 Sep 2025 10:12:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190357; cv=none; b=iGQO6blqiAuIVT2+GTWX11UDFV2xFoB6S989LHDY1VwFzbJH4yP98EvEuSohdR4r7e9JMZn7l81ECd5i2lDiWcrmnoHDev4QxRxo9upVAFqLObzGYi486mr05swFOkRZhdCygmMc2347VOGNW5JdbTOkK+42adBz1iB5pC2pAr8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190357; c=relaxed/simple; bh=ElLNCBKp3QVkpe3Y+5vJ7NpnjlHdsznRSDUVkiyDnoM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rnnm7/yNkgvNM1TWK9sPSl/MW16ebVYIGqavK76zD/tQ3X74OMGyUiqReFW70Y0V5GYPG2TGQhsyeI+V7nPHKMvzrrgxxHwzjc8a+bDkWTrkDnYcv/QqHnNg6SH9d3Vk8W5rIkckqeuua7s+LRMONldZwbdqT7OB8mdZ0BXYWvU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UHTuzu+0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UHTuzu+0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E8B4C4CEE7; Thu, 18 Sep 2025 10:12:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758190357; bh=ElLNCBKp3QVkpe3Y+5vJ7NpnjlHdsznRSDUVkiyDnoM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=UHTuzu+0oDQTLOw8Waw/mwjkopKOyNbJoHjQAVbhlfnX3CcZpW2SWMjZwuSP/UzMS 7t0nH03vUJQUNUannPMg6lHWetGk5DQuhxU+AJWtGa4woLzVVatHj4z9m5KVCD4Iwd 62Cc6oascOnUyO+YgimzGOayhZYNsGHbUbvjojLLqpTjlbUUnIqOsitL3wGwvRgvtc Ei+ZKW7AkGf2XIn9ytnWrGyuguyeD3qBARArb2hLtO6MWyj1gYF8lTvn4alhbz3Ng2 WNrbh/woYS9M/w5AYYxvCpOsvm6AakZgcWBUCMDnm3ePku9XTPipL6awIKn0pYPFjT TfjjPi/EY2cfQ== From: Christian Brauner Date: Thu, 18 Sep 2025 12:11:54 +0200 Subject: [PATCH 09/14] net: use check_net() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250918-work-namespace-ns_ref-v1-9-1b0a98ee041e@kernel.org> References: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> In-Reply-To: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Amir Goldstein , Josef Bacik , Jeff Layton , Mike Yuan , =?utf-8?q?Zbigniew_J=C4=99drzejewski-Szmek?= , Lennart Poettering , Daan De Meyer , Aleksa Sarai , Alexander Viro , Jan Kara , Tejun Heo , Johannes Weiner , =?utf-8?q?Michal_Koutn=C3=BD?= , Jakub Kicinski , Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Christian Brauner X-Mailer: b4 0.15-dev-56183 X-Developer-Signature: v=1; a=openpgp-sha256; l=662; i=brauner@kernel.org; h=from:subject:message-id; bh=ElLNCBKp3QVkpe3Y+5vJ7NpnjlHdsznRSDUVkiyDnoM=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWScvvXMa8NDCTZXaZedM+Zzaa5r1+xqurhH9aXM0YXLe nIq3YTbOkpZGMS4GGTFFFkc2k3C5ZbzVGw2ytSAmcPKBDKEgYtTACbCl8/wV+D+5DM3C+ae12mM yVse1bksMvbxkY8mBtk8NyfOfdtlqsnIMMtn29H3Dlonrun8NhaZLfvtf/rhC8tSJN7VptWcThE s5AcA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Don't directly acess the namespace count. There's even a dedicated helper for this. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- net/core/net_namespace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index fdbaf5f8ac78..d81a8b291ea8 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c @@ -315,7 +315,7 @@ int peernet2id_alloc(struct net *net, struct net *peer,= gfp_t gfp) { int id; =20 - if (refcount_read(&net->ns.count) =3D=3D 0) + if (!check_net(net)) return NETNSA_NSID_NOT_ASSIGNED; =20 spin_lock(&net->nsid_lock); --=20 2.47.3 From nobody Thu Oct 2 09:16:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA82E286D63; Thu, 18 Sep 2025 10:12:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190363; cv=none; b=CIUq14VBD/FMLSN7+SADsowSoIiMCQUaRQAvr35l/qZuY9KMppnVhr6BbJuulsnzYA1mbJsZXDgojC5TA/55kcTY8BnBm59O8O7sD7qPkYgnvSeEaLKyzf/vufJI6+vb/rMJDH7A6JpuNYD/WaAkzOtUDXW47NikaQoenZUWHZ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190363; c=relaxed/simple; bh=uIMSsnAHpbWVr4ui+E6CVDbYyiFvAOabEJHQhnFAdhg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ghqr4ZB3C0m7xLQ43uL9YQbuVFKsrIg6nQ637gsqGZA5Q7G/+IZXLmpWntNgoBr6Yj887639sMlevJDNKBghTrL6ECinLaFCRCIT8swKL8O15l7wyRP1AK9PrsigLHkAL9GK5fZ4CDBRqc9f59yYpoZgl7VlY1LjtTEvByaaFN8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Dm/orFue; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Dm/orFue" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF46AC4CEE7; Thu, 18 Sep 2025 10:12:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758190362; bh=uIMSsnAHpbWVr4ui+E6CVDbYyiFvAOabEJHQhnFAdhg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Dm/orFuerIhBd0+fZDV4YCNTfqwx55BB3XDRJ8gUyXb6PwUfN9WXQkmgrxnpxhqCD XAwp1oDUVwtkh/9WOTf5Zi86OUb9nYLS2UkYok4Pms7F5qH+/mcJj+9186ukWBE5fz Zuld4zoDaQ1NGxfmqMsCw1JdoIt9iZTq5kcuQvHKbEbPKfPnB6BWfy+aTVz0pLPUYq 8yrBf2fyBZAnK/xsX7t1N9Sq/SrrZGWsNXCDyPvOtI38UO9kzts9mtjMonSE162M/a ShDHW6yhEd0EHSoBj83V/1KgY9PL9MelFBwXfs9lEEYI6SmLSbuTMom5oPmJmwyzr1 avpy//fwTTVZg== From: Christian Brauner Date: Thu, 18 Sep 2025 12:11:55 +0200 Subject: [PATCH 10/14] ipv4: use check_net() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250918-work-namespace-ns_ref-v1-10-1b0a98ee041e@kernel.org> References: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> In-Reply-To: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Amir Goldstein , Josef Bacik , Jeff Layton , Mike Yuan , =?utf-8?q?Zbigniew_J=C4=99drzejewski-Szmek?= , Lennart Poettering , Daan De Meyer , Aleksa Sarai , Alexander Viro , Jan Kara , Tejun Heo , Johannes Weiner , =?utf-8?q?Michal_Koutn=C3=BD?= , Jakub Kicinski , Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Christian Brauner X-Mailer: b4 0.15-dev-56183 X-Developer-Signature: v=1; a=openpgp-sha256; l=1482; i=brauner@kernel.org; h=from:subject:message-id; bh=uIMSsnAHpbWVr4ui+E6CVDbYyiFvAOabEJHQhnFAdhg=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWScvvVMeFrb6jtJN86ufvB9zWIdf6ONsYxyT79nZJol7 1LSsLM70lHKwiDGxSArpsji0G4SLrecp2KzUaYGzBxWJpAhDFycAjCRND9GhttVnpzW24VZ7NqU 1y45bzJxgUn8oZJQkQdmjQFmYt+K4xkZtqfPufEnxePWFdnuy3Xnrs69H5ibdjc5VEb5oYC7sak fHwA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Don't directly acess the namespace count. There's even a dedicated helper for this. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- net/ipv4/inet_timewait_sock.c | 4 ++-- net/ipv4/tcp_metrics.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c index 875ff923a8ed..56a117560c0c 100644 --- a/net/ipv4/inet_timewait_sock.c +++ b/net/ipv4/inet_timewait_sock.c @@ -329,13 +329,13 @@ void inet_twsk_purge(struct inet_hashinfo *hashinfo) TCPF_NEW_SYN_RECV)) continue; =20 - if (refcount_read(&sock_net(sk)->ns.count)) + if (check_net(sock_net(sk))) continue; =20 if (unlikely(!refcount_inc_not_zero(&sk->sk_refcnt))) continue; =20 - if (refcount_read(&sock_net(sk)->ns.count)) { + if (check_net(sock_net(sk))) { sock_gen_put(sk); goto restart; } diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c index 03c068ea27b6..b67f94c60f9f 100644 --- a/net/ipv4/tcp_metrics.c +++ b/net/ipv4/tcp_metrics.c @@ -912,7 +912,7 @@ static void tcp_metrics_flush_all(struct net *net) spin_lock_bh(&tcp_metrics_lock); for (tm =3D deref_locked(*pp); tm; tm =3D deref_locked(*pp)) { match =3D net ? net_eq(tm_net(tm), net) : - !refcount_read(&tm_net(tm)->ns.count); + !check_net(tm_net(tm)); if (match) { rcu_assign_pointer(*pp, tm->tcpm_next); kfree_rcu(tm, rcu_head); --=20 2.47.3 From nobody Thu Oct 2 09:16:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C43A92F362B; Thu, 18 Sep 2025 10:12:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190368; cv=none; b=X5SZ7hSa2rcCYmtBn5Bm2x6sbpX1MNycPaJrjDJjBUy2jkE46TezzcQIDprxrelIIdAAHlqWFKPpDKJI9mNTDX0lTC+PRHz4ihWLbCxPX29jYEVxp/1dPDnCAtXk+XkAwEqrOozQrwsWiOMgOT19Qh81w5o/qEZ3q7AgMdopBGo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190368; c=relaxed/simple; bh=goaLC7wGjxRD/+pG5XJskmBTPzYWvzmUtF2h1nEQg/k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rywbjuiPHr9DY1xTkrfMh46/eWQkpxjiwN4ziFMjixm8CqnxGmK3j3C1yT9TQIIQcGX2hYe4byha6M1lbKnVgfBffhBAloy6sTQ5ghbOcXecg3fjaJl1soChYV/YIqNrKjtM0mUxN7xkadjLANSqjj/QNLphbh114s8vP7eV6Ds= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Uex5kZbW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Uex5kZbW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E41E4C4CEF0; Thu, 18 Sep 2025 10:12:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758190367; bh=goaLC7wGjxRD/+pG5XJskmBTPzYWvzmUtF2h1nEQg/k=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Uex5kZbWnvRfgUTtJXwl+lN1mO9VJI5+XiaOn06l0Bm5NL5Wci9PKdmKokH4gKPrS yN342jr/Q0xPwGAE1QcwiZe0zQTKoXrmMDW4Q/VMBCn7Kc5P1Nt1Ba1A9FoffiXJDj Ofw1lyySrtNr7v9buMFQkZjxExuQaNvMU+4W9gGonpj4hmeGZ69w58+XIh9DjJS/Dx fZFyzqRj2YKO2nKOJrM2fjOLCncQiP4uF9kcJiJUFnkrFgaq908EPWk+NkqRWit7qv xa4bkjZ0rxNjHOPCsDkoGAJUA/cq4diuOMXVzv5s4MVaSnBGOfy4OPzTX7qPVv2i/M Jj0vYYM8N7ZvA== From: Christian Brauner Date: Thu, 18 Sep 2025 12:11:56 +0200 Subject: [PATCH 11/14] uts: port to ns_ref_*() helpers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250918-work-namespace-ns_ref-v1-11-1b0a98ee041e@kernel.org> References: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> In-Reply-To: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Amir Goldstein , Josef Bacik , Jeff Layton , Mike Yuan , =?utf-8?q?Zbigniew_J=C4=99drzejewski-Szmek?= , Lennart Poettering , Daan De Meyer , Aleksa Sarai , Alexander Viro , Jan Kara , Tejun Heo , Johannes Weiner , =?utf-8?q?Michal_Koutn=C3=BD?= , Jakub Kicinski , Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Christian Brauner X-Mailer: b4 0.15-dev-56183 X-Developer-Signature: v=1; a=openpgp-sha256; l=902; i=brauner@kernel.org; h=from:subject:message-id; bh=goaLC7wGjxRD/+pG5XJskmBTPzYWvzmUtF2h1nEQg/k=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWScvvWsNiUs+dat/WWfFtqburw0bZT9uTI84vETVYNnt sc108tTO0pZGMS4GGTFFFkc2k3C5ZbzVGw2ytSAmcPKBDKEgYtTACYSEMfwz9zMXsh8kn+mTfRy p0/fHj3YIHvMulbd7ui9NpHbO16GmDP890o1XMO+aVl7M6vQnUlffTddWhOx+3lB5N54Xj9vlex mRgA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Stop accessing ns.count directly. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- include/linux/uts_namespace.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/uts_namespace.h b/include/linux/uts_namespace.h index c2b619bb4e57..23b4f0e1b338 100644 --- a/include/linux/uts_namespace.h +++ b/include/linux/uts_namespace.h @@ -25,7 +25,7 @@ static inline struct uts_namespace *to_uts_ns(struct ns_c= ommon *ns) =20 static inline void get_uts_ns(struct uts_namespace *ns) { - refcount_inc(&ns->ns.count); + ns_ref_inc(ns); } =20 extern struct uts_namespace *copy_utsname(unsigned long flags, @@ -34,7 +34,7 @@ extern void free_uts_ns(struct uts_namespace *ns); =20 static inline void put_uts_ns(struct uts_namespace *ns) { - if (refcount_dec_and_test(&ns->ns.count)) + if (ns_ref_put(ns)) free_uts_ns(ns); } =20 --=20 2.47.3 From nobody Thu Oct 2 09:16:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 44C8E3054D8; Thu, 18 Sep 2025 10:12:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190372; cv=none; b=VN2woTfJjJVW1qqu6jWuISvIKPsQu1RCOe9aNJrmeqCr8kgo+sLTjrGSTWU/0bIfMHCu+n3woctT5GBFa53GHvGhGRw4pM63HcUdLmcjvRQAUkaHIUONF3SirBnZ4fZBJaWBaXQKU4l3nlaAh7sZtD0JKM7/FfpVgGczVOuLZVY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190372; c=relaxed/simple; bh=yZAVutrvboeNqrTjIA0TeZXp0AfWUyqn3YyVJqMz4LU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=M79+Jbzl4/qf98pKENQyQRxFha+ooOilecIdJjYdDlBVC9ZO8pNf22WH3FgYyal6snAGT2I/IPObtFSIHa5RW3vcZMLPkRvxrMvRjOswLlmLUCdCFI3YHs3MKPnxl1FKY5x1rsAbswpNPTb/aPQNd/LS7AmHa3aI/oywY7QAr8o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cKwYP7DP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cKwYP7DP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5275C4CEF7; Thu, 18 Sep 2025 10:12:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758190371; bh=yZAVutrvboeNqrTjIA0TeZXp0AfWUyqn3YyVJqMz4LU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=cKwYP7DPsusoeqlXE+YfvB+i9BN6bVQ1RE27LpjACDar+JG6Ki18fuV9+W9yX6lkt GVeAyxy1j3unF0lH/rAsY3C1+91Wy5wA+okYo9usmKUUol/jZwB4jrmPlO6QnFA+eL tXTOygbW+fhFXqsTbni+fLlW8jFN4mmtSKXZmzJVhFDPUg88Nqp12aLFVuMh5X8CIh rQ+3AEFmdAoRSHr6poGMKJV5njxfBA/Kp6Ju43oQ+4PMRTmH+w9PH67BGotx1F0mNO Ld3pCxiIM5E09K6albOX+TU4R5d6IpQHW4uThIrm4GXmt4t2g/ibDM8tFcn8IARnD0 K/xrsLFlvOktg== From: Christian Brauner Date: Thu, 18 Sep 2025 12:11:57 +0200 Subject: [PATCH 12/14] net: port to ns_ref_*() helpers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250918-work-namespace-ns_ref-v1-12-1b0a98ee041e@kernel.org> References: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> In-Reply-To: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Amir Goldstein , Josef Bacik , Jeff Layton , Mike Yuan , =?utf-8?q?Zbigniew_J=C4=99drzejewski-Szmek?= , Lennart Poettering , Daan De Meyer , Aleksa Sarai , Alexander Viro , Jan Kara , Tejun Heo , Johannes Weiner , =?utf-8?q?Michal_Koutn=C3=BD?= , Jakub Kicinski , Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Christian Brauner X-Mailer: b4 0.15-dev-56183 X-Developer-Signature: v=1; a=openpgp-sha256; l=1446; i=brauner@kernel.org; h=from:subject:message-id; bh=yZAVutrvboeNqrTjIA0TeZXp0AfWUyqn3YyVJqMz4LU=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWScvvWsLuNHV/AV6dkcltXvTy8N3rYpb/b03atqJ3Fwa 64OWMtR21HKwiDGxSArpsji0G4SLrecp2KzUaYGzBxWJpAhDFycAjARtZMM/53dz3884LP8h+DU b9/uqWcxmT1RLvlZkahSMyOVYYrZXhtGhoOc62cGzLH75BG8Sojpzb6/BZv33A5enz7rdd/e3Ii fMRwA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Stop accessing ns.count directly. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- include/net/net_namespace.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index fd090ceb80bf..3e7c825e5810 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h @@ -270,7 +270,7 @@ static inline struct net *to_net_ns(struct ns_common *n= s) /* Try using get_net_track() instead */ static inline struct net *get_net(struct net *net) { - refcount_inc(&net->ns.count); + ns_ref_inc(net); return net; } =20 @@ -281,7 +281,7 @@ static inline struct net *maybe_get_net(struct net *net) * exists. If the reference count is zero this * function fails and returns NULL. */ - if (!refcount_inc_not_zero(&net->ns.count)) + if (!ns_ref_get(net)) net =3D NULL; return net; } @@ -289,7 +289,7 @@ static inline struct net *maybe_get_net(struct net *net) /* Try using put_net_track() instead */ static inline void put_net(struct net *net) { - if (refcount_dec_and_test(&net->ns.count)) + if (ns_ref_put(net)) __put_net(net); } =20 @@ -301,7 +301,7 @@ int net_eq(const struct net *net1, const struct net *ne= t2) =20 static inline int check_net(const struct net *net) { - return refcount_read(&net->ns.count) !=3D 0; + return ns_ref_read(net) !=3D 0; } =20 void net_drop_ns(void *); --=20 2.47.3 From nobody Thu Oct 2 09:16:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA82E2D1F7E; Thu, 18 Sep 2025 10:12:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190376; cv=none; b=deFzNvVX2Nm6Pssu74euqG++h3yXDzfoJPYyNgtRxSbVc/oR5tKPBRq4jePdhxJ6NOtz0w+y5RVHH7gFqtL5SdTFPl+lDCwMMAobXSq+S38VcA7gwlNw+0mSa3LpAStwBbakGRnSTuhnCLQnCiMp7aRZD3tk245G73NZbAaJlaE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190376; c=relaxed/simple; bh=WYPZnqjxov5ySJTeGcj2T3GXXFm1K7BCUPGggxoHaCA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=X9AEwCWk3T6ED0JiPOT76Chzwlw6bKrEEoNBigKNvvEWhv/zEW5TbNZ1rdTAVsOKa6VWBnnoRrexc1K+/BzqOLXeSfWTa3JL10mEZOiCjYCFzoY8d8t4wbXIsd0/WIWqYKTOAXAp4o5+rKAcHyQjK1U+EHtFwogjJFep3PV+Sjg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bS7a3k9i; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bS7a3k9i" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58CCBC4CEE7; Thu, 18 Sep 2025 10:12:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758190376; bh=WYPZnqjxov5ySJTeGcj2T3GXXFm1K7BCUPGggxoHaCA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=bS7a3k9icI9hiXKIodkziOGlDJ3kP3ucZvNXIqJwwJYs9b/Hm8xLLFYW/tJfzbQpu 5KRXlZjPRV5QCXZ3PIBqMZTU47aO7j1ynvmctbZxUIe0RpMpsHoL2lJ64OIqTAmx7T gcH9NwNXC3GiJzChge0toV7KOlaGHQ6XASjbJAsXRrUWV4pQPaa7s0vSqinDqECRoE ahdm+ayXXARlMK9++SEFCi2F2ZriELeN3s9RSYTTWyzhEJu0Xkg4NShHuhvY1SP8Np R5akMEtxFWV3W9uiTsZJi5H1v1AKWOCL9e07tsYlkSnzEItQn4zBwup4Teo12v2CmU 94ePxuf87LG+w== From: Christian Brauner Date: Thu, 18 Sep 2025 12:11:58 +0200 Subject: [PATCH 13/14] nsfs: port to ns_ref_*() helpers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250918-work-namespace-ns_ref-v1-13-1b0a98ee041e@kernel.org> References: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> In-Reply-To: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Amir Goldstein , Josef Bacik , Jeff Layton , Mike Yuan , =?utf-8?q?Zbigniew_J=C4=99drzejewski-Szmek?= , Lennart Poettering , Daan De Meyer , Aleksa Sarai , Alexander Viro , Jan Kara , Tejun Heo , Johannes Weiner , =?utf-8?q?Michal_Koutn=C3=BD?= , Jakub Kicinski , Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Christian Brauner X-Mailer: b4 0.15-dev-56183 X-Developer-Signature: v=1; a=openpgp-sha256; l=594; i=brauner@kernel.org; h=from:subject:message-id; bh=WYPZnqjxov5ySJTeGcj2T3GXXFm1K7BCUPGggxoHaCA=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWScvvVs1v5NLKd5YsOuyrrOZPBhrXy66f22r5nysRLP8 6c9yvr/tKOUhUGMi0FWTJHFod0kXG45T8Vmo0wNmDmsTCBDGLg4BWAi/MkM//23Hct/krOXa+qP Db0BFW4aD46fYEpzKDmnLW5/84/Lo0kMfziM3hXtcxRer3b949PvpS+6m6rlvlcckrrosUWxUfr rLkYA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Stop accessing ns.count directly. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- fs/nsfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nsfs.c b/fs/nsfs.c index 8484bc4dd3de..dc0a4404b971 100644 --- a/fs/nsfs.c +++ b/fs/nsfs.c @@ -492,7 +492,7 @@ static struct dentry *nsfs_fh_to_dentry(struct super_bl= ock *sb, struct fid *fh, VFS_WARN_ON_ONCE(ns->ops->type !=3D fid->ns_type); VFS_WARN_ON_ONCE(ns->inum !=3D fid->ns_inum); =20 - if (!refcount_inc_not_zero(&ns->count)) + if (!__ns_ref_get(ns)) return NULL; } =20 --=20 2.47.3 From nobody Thu Oct 2 09:16:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B41E2F83CF; Thu, 18 Sep 2025 10:13:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190381; cv=none; b=eIAsIEurK/RBeFtZGTx4gX0tZ3Jf5Fx4RKZAY0HIsTgLPX8vCyDNV/nw5O0s2LZRn5o6gIRY1b6Q6DcTo58nPoiOGOst6d6J7Irc8W0NBrocHaDwIaBy/j+z3soqT3+a9T3MFrwrKqymHqL0Z37blz9E+8yH+fccKjhIHwuUaPk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758190381; c=relaxed/simple; bh=OfQjKy/Zp2oThhXDYDXNlv99L2kJ15thP22bLFaBmOo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RWk9Xu2a6hywbPYMM/JTbVixg2g0hg88PUPsuMCkQSZTvBvPxJDnF49nRVaLLwzlWAwocJ4SmXQTUYMteUob4gFf0i1+SHmq6byOaTF15wRxLu4O9P+nA7OpYMinJCMvM669thPwn49lObqJzuwNLPtMzOOxk8+XK2wxc5Ras+U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oOFLOrWv; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oOFLOrWv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05201C4CEF0; Thu, 18 Sep 2025 10:12:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758190381; bh=OfQjKy/Zp2oThhXDYDXNlv99L2kJ15thP22bLFaBmOo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=oOFLOrWvcdU7ANEGYkH6htNM4dZCxw+DskXxE6xIZAnXhjHlMLGmYprKZEIXPf/fa sEEIaCd6ui6C1nTNJHxko+ip7GLjRDWbyxotBH8eVDWrX4dTgC7abLkxusuwMx58NN o0OjkJ8MLDz28TGPjagQ7EltmgPV28OsEfvgxNq6iJBYpRD/4Zf0/aVgMhvLk5UrSP mpsjKswUKEY7EGsgi6hGr8tpxBzB+bCxUTwMJAuxaKmlM4SM7CxSdkau7L2ao7qQr2 fhcrY/0NDsofn05aeiixLKQXPhfxw686dq3gU/dL3Zz2F1e2+wFLR02LlTZXotUnjD knA1RsG5qXD2w== From: Christian Brauner Date: Thu, 18 Sep 2025 12:11:59 +0200 Subject: [PATCH 14/14] ns: rename to __ns_ref Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250918-work-namespace-ns_ref-v1-14-1b0a98ee041e@kernel.org> References: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> In-Reply-To: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Amir Goldstein , Josef Bacik , Jeff Layton , Mike Yuan , =?utf-8?q?Zbigniew_J=C4=99drzejewski-Szmek?= , Lennart Poettering , Daan De Meyer , Aleksa Sarai , Alexander Viro , Jan Kara , Tejun Heo , Johannes Weiner , =?utf-8?q?Michal_Koutn=C3=BD?= , Jakub Kicinski , Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Christian Brauner X-Mailer: b4 0.15-dev-56183 X-Developer-Signature: v=1; a=openpgp-sha256; l=4926; i=brauner@kernel.org; h=from:subject:message-id; bh=OfQjKy/Zp2oThhXDYDXNlv99L2kJ15thP22bLFaBmOo=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWScvvXM/ot1cOoPNcnGhxz/Vor+D/tpkyl+gWUNt31Lz p+XMuHvO0pZGMS4GGTFFFkc2k3C5ZbzVGw2ytSAmcPKBDKEgYtTACbymZvhv+e8UNdLgXukN/8I e8Ybqh8brL2rq+f5g4c7H3/KTnU+48vwi+lI4K98/6KJxT5fj+U+Zw9sue22+cOXf0fY7x670cJ 1kRkA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Make it easier to grep and rename to ns_count. Signed-off-by: Christian Brauner Acked-by: Thomas Gleixner Reviewed-by: Jan Kara --- include/linux/ns_common.h | 12 ++++++------ init/version-timestamp.c | 2 +- ipc/msgutil.c | 2 +- kernel/cgroup/cgroup.c | 2 +- kernel/nscommon.c | 2 +- kernel/pid.c | 2 +- kernel/time/namespace.c | 2 +- kernel/user.c | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/linux/ns_common.h b/include/linux/ns_common.h index a65da646aef7..24bbeb5161a5 100644 --- a/include/linux/ns_common.h +++ b/include/linux/ns_common.h @@ -29,7 +29,7 @@ struct ns_common { struct dentry *stashed; const struct proc_ns_operations *ops; unsigned int inum; - refcount_t count; + refcount_t __ns_ref; /* do not use directly */ union { struct { u64 ns_id; @@ -95,19 +95,19 @@ void __ns_common_free(struct ns_common *ns); =20 static __always_inline __must_check bool __ns_ref_put(struct ns_common *ns) { - return refcount_dec_and_test(&ns->count); + return refcount_dec_and_test(&ns->__ns_ref); } =20 static __always_inline __must_check bool __ns_ref_get(struct ns_common *ns) { - return refcount_inc_not_zero(&ns->count); + return refcount_inc_not_zero(&ns->__ns_ref); } =20 -#define ns_ref_read(__ns) refcount_read(&to_ns_common((__ns))->count) -#define ns_ref_inc(__ns) refcount_inc(&to_ns_common((__ns))->count) +#define ns_ref_read(__ns) refcount_read(&to_ns_common((__ns))->__ns_ref) +#define ns_ref_inc(__ns) refcount_inc(&to_ns_common((__ns))->__ns_ref) #define ns_ref_get(__ns) __ns_ref_get(to_ns_common((__ns))) #define ns_ref_put(__ns) __ns_ref_put(to_ns_common((__ns))) #define ns_ref_put_and_lock(__ns, __lock) \ - refcount_dec_and_lock(&to_ns_common((__ns))->count, (__lock)) + refcount_dec_and_lock(&to_ns_common((__ns))->__ns_ref, (__lock)) =20 #endif diff --git a/init/version-timestamp.c b/init/version-timestamp.c index 043cbf80a766..547e522e6016 100644 --- a/init/version-timestamp.c +++ b/init/version-timestamp.c @@ -8,7 +8,7 @@ #include =20 struct uts_namespace init_uts_ns =3D { - .ns.count =3D REFCOUNT_INIT(2), + .ns.__ns_ref =3D REFCOUNT_INIT(2), .name =3D { .sysname =3D UTS_SYSNAME, .nodename =3D UTS_NODENAME, diff --git a/ipc/msgutil.c b/ipc/msgutil.c index bbf61275df41..d0f7dcf4c208 100644 --- a/ipc/msgutil.c +++ b/ipc/msgutil.c @@ -27,7 +27,7 @@ DEFINE_SPINLOCK(mq_lock); * and not CONFIG_IPC_NS. */ struct ipc_namespace init_ipc_ns =3D { - .ns.count =3D REFCOUNT_INIT(1), + .ns.__ns_ref =3D REFCOUNT_INIT(1), .user_ns =3D &init_user_ns, .ns.inum =3D PROC_IPC_INIT_INO, #ifdef CONFIG_IPC_NS diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 092e6bf081ed..a0e24adceef0 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -219,7 +219,7 @@ static bool have_favordynmods __ro_after_init =3D IS_EN= ABLED(CONFIG_CGROUP_FAVOR_D =20 /* cgroup namespace for init task */ struct cgroup_namespace init_cgroup_ns =3D { - .ns.count =3D REFCOUNT_INIT(2), + .ns.__ns_ref =3D REFCOUNT_INIT(2), .user_ns =3D &init_user_ns, .ns.ops =3D &cgroupns_operations, .ns.inum =3D PROC_CGROUP_INIT_INO, diff --git a/kernel/nscommon.c b/kernel/nscommon.c index 7c1b07e2a6c9..7aa2be6a0c32 100644 --- a/kernel/nscommon.c +++ b/kernel/nscommon.c @@ -5,7 +5,7 @@ =20 int __ns_common_init(struct ns_common *ns, const struct proc_ns_operations= *ops, int inum) { - refcount_set(&ns->count, 1); + refcount_set(&ns->__ns_ref, 1); ns->stashed =3D NULL; ns->ops =3D ops; ns->ns_id =3D 0; diff --git a/kernel/pid.c b/kernel/pid.c index c45a28c16cd2..e222426f745d 100644 --- a/kernel/pid.c +++ b/kernel/pid.c @@ -71,7 +71,7 @@ static int pid_max_max =3D PID_MAX_LIMIT; * the scheme scales to up to 4 million PIDs, runtime. */ struct pid_namespace init_pid_ns =3D { - .ns.count =3D REFCOUNT_INIT(2), + .ns.__ns_ref =3D REFCOUNT_INIT(2), .idr =3D IDR_INIT(init_pid_ns.idr), .pid_allocated =3D PIDNS_ADDING, .level =3D 0, diff --git a/kernel/time/namespace.c b/kernel/time/namespace.c index d49c73015d6e..d70bdfb7b001 100644 --- a/kernel/time/namespace.c +++ b/kernel/time/namespace.c @@ -480,7 +480,7 @@ const struct proc_ns_operations timens_for_children_ope= rations =3D { }; =20 struct time_namespace init_time_ns =3D { - .ns.count =3D REFCOUNT_INIT(3), + .ns.__ns_ref =3D REFCOUNT_INIT(3), .user_ns =3D &init_user_ns, .ns.inum =3D PROC_TIME_INIT_INO, .ns.ops =3D &timens_operations, diff --git a/kernel/user.c b/kernel/user.c index f46b1d41163b..17a742fb4e10 100644 --- a/kernel/user.c +++ b/kernel/user.c @@ -65,7 +65,7 @@ struct user_namespace init_user_ns =3D { .nr_extents =3D 1, }, }, - .ns.count =3D REFCOUNT_INIT(3), + .ns.__ns_ref =3D REFCOUNT_INIT(3), .owner =3D GLOBAL_ROOT_UID, .group =3D GLOBAL_ROOT_GID, .ns.inum =3D PROC_USER_INIT_INO, --=20 2.47.3