From: Christian Brauner <brauner@kernel.org>
To: linux-fsdevel@vger.kernel.org
Cc: "Amir Goldstein" <amir73il@gmail.com>,
"Josef Bacik" <josef@toxicpanda.com>,
"Jeff Layton" <jlayton@kernel.org>, "Mike Yuan" <me@yhndnzj.com>,
"Zbigniew Jędrzejewski-Szmek" <zbyszek@in.waw.pl>,
"Lennart Poettering" <mzxreary@0pointer.de>,
"Daan De Meyer" <daan.j.demeyer@gmail.com>,
"Aleksa Sarai" <cyphar@cyphar.com>,
"Alexander Viro" <viro@zeniv.linux.org.uk>,
"Jan Kara" <jack@suse.cz>, "Tejun Heo" <tj@kernel.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Anna-Maria Behnsen" <anna-maria@linutronix.de>,
"Frederic Weisbecker" <frederic@kernel.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, "Christian Brauner" <brauner@kernel.org>
Subject: [PATCH 07/14] user: port to ns_ref_*() helpers
Date: Thu, 18 Sep 2025 12:11:52 +0200 [thread overview]
Message-ID: <20250918-work-namespace-ns_ref-v1-7-1b0a98ee041e@kernel.org> (raw)
In-Reply-To: <20250918-work-namespace-ns_ref-v1-0-1b0a98ee041e@kernel.org>
Stop accessing ns.count directly.
Signed-off-by: Christian Brauner <brauner@kernel.org>
---
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;
}
@@ -186,7 +186,7 @@ extern void __put_user_ns(struct user_namespace *ns);
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);
}
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 = parent;
- } while (refcount_dec_and_test(&parent->ns.count));
+ } while (ns_ref_put(parent));
}
void __put_user_ns(struct user_namespace *ns)
--
2.47.3
next prev parent reply other threads:[~2025-09-18 10:12 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-18 10:11 [PATCH 00/14] ns: rework reference counting Christian Brauner
2025-09-18 10:11 ` [PATCH 01/14] ns: add reference count helpers Christian Brauner
2025-09-18 10:11 ` [PATCH 02/14] mnt: port to ns_ref_*() helpers Christian Brauner
2025-09-18 10:11 ` [PATCH 03/14] cgroup: " Christian Brauner
2025-09-18 15:51 ` Tejun Heo
2025-09-18 10:11 ` [PATCH 04/14] ipc: " Christian Brauner
2025-09-18 10:11 ` [PATCH 05/14] pid: " Christian Brauner
2025-09-18 10:11 ` [PATCH 06/14] time: " Christian Brauner
2025-09-21 7:36 ` Thomas Gleixner
2025-09-18 10:11 ` Christian Brauner [this message]
2025-09-18 10:11 ` [PATCH 08/14] net-sysfs: use check_net() Christian Brauner
2025-09-18 10:11 ` [PATCH 09/14] net: " Christian Brauner
2025-09-18 10:11 ` [PATCH 10/14] ipv4: " Christian Brauner
2025-09-18 10:11 ` [PATCH 11/14] uts: port to ns_ref_*() helpers Christian Brauner
2025-09-18 10:11 ` [PATCH 12/14] net: " Christian Brauner
2025-09-18 10:11 ` [PATCH 13/14] nsfs: " Christian Brauner
2025-09-18 10:11 ` [PATCH 14/14] ns: rename to __ns_ref Christian Brauner
2025-09-18 12:12 ` Michal Koutný
2025-09-21 7:37 ` Thomas Gleixner
2025-09-18 10:41 ` [PATCH 00/14] ns: rework reference counting Jan Kara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250918-work-namespace-ns_ref-v1-7-1b0a98ee041e@kernel.org \
--to=brauner@kernel.org \
--cc=amir73il@gmail.com \
--cc=anna-maria@linutronix.de \
--cc=cgroups@vger.kernel.org \
--cc=cyphar@cyphar.com \
--cc=daan.j.demeyer@gmail.com \
--cc=frederic@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=jack@suse.cz \
--cc=jlayton@kernel.org \
--cc=josef@toxicpanda.com \
--cc=kuba@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=me@yhndnzj.com \
--cc=mkoutny@suse.com \
--cc=mzxreary@0pointer.de \
--cc=netdev@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=zbyszek@in.waw.pl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).