Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1236751

[RFC 2/4] pid_namespace: remove .kref field for !CONFIG_PID_NS

From Rasmus Villemoes <linux@rasmusvillemoes.dk>
Newsgroups linux.kernel
Subject [RFC 2/4] pid_namespace: remove .kref field for !CONFIG_PID_NS
Date 2015-09-30 23:00 +0200
Message-ID <qewDM-7OB-9@gated-at.bofh.it> (permalink)
References <qewDL-7OB-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[RFC 2/4] pid_namespace: remove .kref field for !CONFIG_PID_NS Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-09-30 23:00 +0200

csiph-web