[PATCH 00/17] ns: header cleanups and initial namespace reference count improvements

Christian Brauner
2025-11-10T15:08:41Z

Cleanup the namespace headers by splitting them into types and helpers.
Better separate common namepace types and functions from namespace tree
types and functions.

Fix the reference counts of initial namespaces so we don't do any
pointless cacheline ping-pong for them when we know they can never go
away. Add a bunch of asserts for both the passive and active reference
counts to catch any changes that would break it.

Signed-off-by: Christian Brauner <brauner@kernel.org>
---
Christian Brauner (17):
ns: move namespace types into separate header
nstree: decouple from ns_common header
nstree: move nstree types into separate header
nstree: add helper to operate on struct ns_tree_{node,root}
nstree: switch to new structures
nstree: simplify owner list iteration
nstree: use guards for ns_tree_lock
ns: make is_initial_namespace() argument const
ns: rename is_initial_namespace()
fs: use boolean to indicate anonymous mount namespace
ipc: enable is_ns_init_id() assertions
ns: make all reference counts on initial namespace a nop
ns: add asserts for initial namespace reference counts
ns: add asserts for initial namespace active reference counts
pid: rely on common reference count behavior
ns: drop custom reference count initialization for initial namespaces
selftests/namespaces: fix nsid tests

fs/mount.h | 3 +-
fs/namespace.c | 9 +-
include/linux/ns/ns_common_types.h | 196 ++++++++++++++++
include/linux/ns/nstree_types.h | 55 +++++
include/linux/ns_common.h | 266 +++++-----------------
include/linux/nstree.h | 38 ++--
include/linux/pid_namespace.h | 3 +-
init/version-timestamp.c | 2 +-
ipc/msgutil.c | 2 +-
ipc/namespace.c | 3 +-
kernel/cgroup/cgroup.c | 2 +-
kernel/nscommon.c | 15 +-
kernel/nstree.c | 304 ++++++++++++++-----------
kernel/pid.c | 2 +-
kernel/pid_namespace.c | 2 +-
kernel/time/namespace.c | 2 +-
kernel/user.c | 2 +-
tools/testing/selftests/namespaces/nsid_test.c | 107 +++++----
18 files changed, 576 insertions(+), 437 deletions(-)
---
base-commit: c9255cbe738098e46c9125c6b409f7f8f4785bf6
change-id: 20251110-work-namespace-nstree-fixes-f23931a00ba2