From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932997AbbI3Utz (ORCPT ); Wed, 30 Sep 2015 16:49:55 -0400 Received: from mail-la0-f48.google.com ([209.85.215.48]:36598 "EHLO mail-la0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932906AbbI3Utu (ORCPT ); Wed, 30 Sep 2015 16:49:50 -0400 From: Rasmus Villemoes To: "Eric W. Biederman" , Oleg Nesterov Cc: Rasmus Villemoes , linux-kernel@vger.kernel.org Subject: [RFC 2/4] pid_namespace: remove .kref field for !CONFIG_PID_NS Date: Wed, 30 Sep 2015 22:49:21 +0200 Message-Id: <1443646163-31316-3-git-send-email-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1443646163-31316-1-git-send-email-linux@rasmusvillemoes.dk> References: <1443646163-31316-1-git-send-email-linux@rasmusvillemoes.dk> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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