Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ns: make all reference counts on initial namespace a nop

They are always active so no need to needlessly cacheline ping-pong.

Link: https://patch.msgid.link/20251110-work-namespace-nstree-fixes-v1-12-e8a9264e0fb9@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>

+22 -3
+22 -3
include/linux/ns_common.h
··· 62 62 63 63 static __always_inline __must_check bool __ns_ref_put(struct ns_common *ns) 64 64 { 65 + if (is_ns_init_id(ns)) 66 + return false; 65 67 if (refcount_dec_and_test(&ns->__ns_ref)) { 66 68 VFS_WARN_ON_ONCE(__ns_ref_active_read(ns)); 67 69 return true; ··· 73 71 74 72 static __always_inline __must_check bool __ns_ref_get(struct ns_common *ns) 75 73 { 74 + if (is_ns_init_id(ns)) 75 + return true; 76 76 if (refcount_inc_not_zero(&ns->__ns_ref)) 77 77 return true; 78 78 VFS_WARN_ON_ONCE(__ns_ref_active_read(ns)); ··· 86 82 return refcount_read(&ns->__ns_ref); 87 83 } 88 84 85 + static __always_inline void __ns_ref_inc(struct ns_common *ns) 86 + { 87 + if (is_ns_init_id(ns)) 88 + return; 89 + refcount_inc(&ns->__ns_ref); 90 + } 91 + 92 + static __always_inline __must_check bool __ns_ref_dec_and_lock(struct ns_common *ns, 93 + spinlock_t *ns_lock) 94 + { 95 + if (is_ns_init_id(ns)) 96 + return false; 97 + return refcount_dec_and_lock(&ns->__ns_ref, ns_lock); 98 + } 99 + 89 100 #define ns_ref_read(__ns) __ns_ref_read(to_ns_common((__ns))) 90 - #define ns_ref_inc(__ns) refcount_inc(&to_ns_common((__ns))->__ns_ref) 101 + #define ns_ref_inc(__ns) __ns_ref_inc(to_ns_common((__ns))) 91 102 #define ns_ref_get(__ns) __ns_ref_get(to_ns_common((__ns))) 92 103 #define ns_ref_put(__ns) __ns_ref_put(to_ns_common((__ns))) 93 - #define ns_ref_put_and_lock(__ns, __lock) \ 94 - refcount_dec_and_lock(&to_ns_common((__ns))->__ns_ref, (__lock)) 104 + #define ns_ref_put_and_lock(__ns, __ns_lock) \ 105 + __ns_ref_dec_and_lock(to_ns_common((__ns)), __ns_lock) 95 106 96 107 #define ns_ref_active_read(__ns) \ 97 108 ((__ns) ? __ns_ref_active_read(to_ns_common(__ns)) : 0)