Messages in this thread Patch in this message | | | From | Rasmus Villemoes <> | Subject | [RFC 2/4] pid_namespace: remove .kref field for !CONFIG_PID_NS | Date | Wed, 30 Sep 2015 22:49:21 +0200 |
| |
When there's only one global pid_namespace (init_pid_ns), the kref field is unused (since both get_pid_ns and put_pid_ns are no-ops). While we only save a few bytes by removing it, it could also help catch users manipulating ->kref directly.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> --- include/linux/pid_namespace.h | 2 ++ kernel/pid.c | 2 ++ 2 files changed, 4 insertions(+)
diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h index 03a84a0cdc75..1cac17eb0775 100644 --- a/include/linux/pid_namespace.h +++ b/include/linux/pid_namespace.h @@ -22,7 +22,9 @@ struct pidmap { struct fs_pin; struct pid_namespace { +#ifdef CONFIG_PID_NS struct kref kref; +#endif struct pidmap pidmap[PIDMAP_ENTRIES]; struct rcu_head rcu; int last_pid; diff --git a/kernel/pid.c b/kernel/pid.c index 909d3dcd8085..25332679a4d3 100644 --- a/kernel/pid.c +++ b/kernel/pid.c @@ -68,9 +68,11 @@ static inline int mk_pid(struct pid_namespace *pid_ns, * the scheme scales to up to 4 million PIDs, runtime. */ struct pid_namespace init_pid_ns = { +#ifdef CONFIG_PID_NS .kref = { .refcount = ATOMIC_INIT(2), }, +#endif .pidmap = { [ 0 ... PIDMAP_ENTRIES-1] = { ATOMIC_INIT(BITS_PER_PAGE), NULL } }, -- 2.1.3
| |