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

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Rasmus Villemoes <linux@rasmusvillemoes.dk>
Newsgroups linux.kernel
Subject [RFC 2/4] pid_namespace: remove .kref field for !CONFIG_PID_NS
Date Wed, 30 Sep 2015 23:00:02 +0200
Message-ID <qewDM-7OB-9@gated-at.bofh.it> (permalink)
References <qewDL-7OB-5@gated-at.bofh.it>
X-Original-To "Eric W. Biederman" <ebiederm@xmission.com>, Oleg Nesterov <oleg@redhat.com>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7NZ67+QQrtodD9lx27FG89SSqoTww7cJrHe4BlQkuII=; b=jP/RQHpuxH7Wg9raa+M/nUUwoqSgGGsK93EB84VWufiI2XrUm/jjSyhY0L+k5a11mx kBP4QmfNV4I3duzOqcDK7rDSMfB1ESXBf5AxpwK9JnzrtXjIebiS2aD2pT87kFjfAJfi HNnBvC2VfooFRAt8ME0oyS3ayMRckMMnaYcZU=
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7NZ67+QQrtodD9lx27FG89SSqoTww7cJrHe4BlQkuII=; b=lqHHaKH+mVVo+itY2HgbhnFGdDJo5OKqZCZ3hoy0OEOqLhcMCRRBS+RM2kCig2BmcG 7fSGZwXRSRwKvc7GEpM+pEoOcPCWZ3+RNbnZnB5ET9HrDv3FcGE2UPBUF7ll6YjQQ3M3 McrgNPY78gdLmgBElrpgex3SBHgmRfA8NzSz4WWRA4etuE6+xYPlbB8c9M96e3KcldDR ItBXyVxLnjsMqR5SAvmaaGdeltk1sdFt9f2FsT7dbBkMr2v9qRD9tKN2sDzBWLCRtlnm UiRw1qhDAWjoQ5gBMvx0jl5y/fJgiO3/MgRZaJNpphgZFCYT/2Pg+49AEpkZTeB12c6I dtZQ==
X-Gm-Message-State ALoCoQmqEUgFLbBhOrQPhSclNhPNKlwj4yOFSPyQaqsZ3mpf68Q78wc8N7XPi/9RrZdnX0dfcyMz
X-Received by 10.112.159.136 with SMTP id xc8mr22381lbb.76.1443646189409; Wed, 30 Sep 2015 13:49:49 -0700 (PDT)
X-Mailer git-send-email 2.1.3
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 49
Organization linux.* mail to news gateway
X-Original-Cc Rasmus Villemoes <linux@rasmusvillemoes.dk>, linux-kernel@vger.kernel.org
X-Original-Date Wed, 30 Sep 2015 22:49:21 +0200
X-Original-Message-ID <1443646163-31316-3-git-send-email-linux@rasmusvillemoes.dk>
X-Original-References <1443646163-31316-1-git-send-email-linux@rasmusvillemoes.dk>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1236751

Show key headers only | 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