Skip to content

Commit c2bbd2d

Browse files
committed
ns: drop custom reference count initialization for initial namespaces
Initial namespaces don't modify their reference count anymore. They remain fixed at one so drop the custom refcount initializations. Link: https://patch.msgid.link/20251110-work-namespace-nstree-fixes-v1-16-e8a9264e0fb9@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 282879a commit c2bbd2d

8 files changed

Lines changed: 9 additions & 9 deletions

File tree

fs/namespace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5986,7 +5986,7 @@ SYSCALL_DEFINE4(listmount, const struct mnt_id_req __user *, req,
59865986
}
59875987

59885988
struct mnt_namespace init_mnt_ns = {
5989-
.ns = NS_COMMON_INIT(init_mnt_ns, 1),
5989+
.ns = NS_COMMON_INIT(init_mnt_ns),
59905990
.user_ns = &init_user_ns,
59915991
.passive = REFCOUNT_INIT(1),
59925992
.mounts = RB_ROOT,

include/linux/ns_common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ static __always_inline bool is_ns_init_id(const struct ns_common *ns)
2626
return ns->ns_id <= NS_LAST_INIT_ID;
2727
}
2828

29-
#define NS_COMMON_INIT(nsname, refs) \
29+
#define NS_COMMON_INIT(nsname) \
3030
{ \
3131
.ns_type = ns_common_type(&nsname), \
3232
.ns_id = ns_init_id(&nsname), \
3333
.inum = ns_init_inum(&nsname), \
3434
.ops = to_ns_operations(&nsname), \
3535
.stashed = NULL, \
36-
.__ns_ref = REFCOUNT_INIT(refs), \
36+
.__ns_ref = REFCOUNT_INIT(1), \
3737
.__ns_ref_active = ATOMIC_INIT(1), \
3838
.ns_unified_node.ns_list_entry = LIST_HEAD_INIT(nsname.ns.ns_unified_node.ns_list_entry), \
3939
.ns_tree_node.ns_list_entry = LIST_HEAD_INIT(nsname.ns.ns_tree_node.ns_list_entry), \

init/version-timestamp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <linux/utsname.h>
99

1010
struct uts_namespace init_uts_ns = {
11-
.ns = NS_COMMON_INIT(init_uts_ns, 2),
11+
.ns = NS_COMMON_INIT(init_uts_ns),
1212
.name = {
1313
.sysname = UTS_SYSNAME,
1414
.nodename = UTS_NODENAME,

ipc/msgutil.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ DEFINE_SPINLOCK(mq_lock);
2727
* and not CONFIG_IPC_NS.
2828
*/
2929
struct ipc_namespace init_ipc_ns = {
30-
.ns = NS_COMMON_INIT(init_ipc_ns, 1),
30+
.ns = NS_COMMON_INIT(init_ipc_ns),
3131
.user_ns = &init_user_ns,
3232
};
3333

kernel/cgroup/cgroup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ bool cgroup_enable_per_threadgroup_rwsem __read_mostly;
250250

251251
/* cgroup namespace for init task */
252252
struct cgroup_namespace init_cgroup_ns = {
253-
.ns = NS_COMMON_INIT(init_cgroup_ns, 2),
253+
.ns = NS_COMMON_INIT(init_cgroup_ns),
254254
.user_ns = &init_user_ns,
255255
.root_cset = &init_css_set,
256256
};

kernel/pid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static int pid_max_max = PID_MAX_LIMIT;
7171
* the scheme scales to up to 4 million PIDs, runtime.
7272
*/
7373
struct pid_namespace init_pid_ns = {
74-
.ns = NS_COMMON_INIT(init_pid_ns, 2),
74+
.ns = NS_COMMON_INIT(init_pid_ns),
7575
.idr = IDR_INIT(init_pid_ns.idr),
7676
.pid_allocated = PIDNS_ADDING,
7777
.level = 0,

kernel/time/namespace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ const struct proc_ns_operations timens_for_children_operations = {
478478
};
479479

480480
struct time_namespace init_time_ns = {
481-
.ns = NS_COMMON_INIT(init_time_ns, 3),
481+
.ns = NS_COMMON_INIT(init_time_ns),
482482
.user_ns = &init_user_ns,
483483
.frozen_offsets = true,
484484
};

kernel/user.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ EXPORT_SYMBOL_GPL(init_binfmt_misc);
3535
* and 1 for... ?
3636
*/
3737
struct user_namespace init_user_ns = {
38-
.ns = NS_COMMON_INIT(init_user_ns, 3),
38+
.ns = NS_COMMON_INIT(init_user_ns),
3939
.uid_map = {
4040
{
4141
.extent[0] = {

0 commit comments

Comments
 (0)