[RFC 3/4] pid_namespace: make pid_nr_ns and pid_vnr static inlines for !CONFIG_PID_NS

From: Rasmus Villemoes
Date: Wed Sep 30 2015 - 16:51:01 EST


When there is only a single pid namespace, pid_nr_ns and pid_vnr
perform the same task as pid_nr, so we can save a little .text by
making them simple inlines.

Signed-off-by: Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx>
---
include/linux/pid.h | 11 +++++++++++
kernel/pid.c | 2 ++
2 files changed, 13 insertions(+)

diff --git a/include/linux/pid.h b/include/linux/pid.h
index 23705a53abba..9aba74a90a64 100644
--- a/include/linux/pid.h
+++ b/include/linux/pid.h
@@ -169,8 +169,19 @@ static inline pid_t pid_nr(struct pid *pid)
return nr;
}

+#ifdef CONFIG_PID_NS
pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
pid_t pid_vnr(struct pid *pid);
+#else
+static inline pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
+{
+ return pid_nr(pid);
+}
+static inline pid_t pid_vnr(struct pid *pid)
+{
+ return pid_nr(pid);
+}
+#endif

#define do_each_pid_task(pid, type, task) \
do { \
diff --git a/kernel/pid.c b/kernel/pid.c
index 25332679a4d3..d422ddae0484 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -499,6 +499,7 @@ struct pid *find_get_pid(pid_t nr)
}
EXPORT_SYMBOL_GPL(find_get_pid);

+#ifdef CONFIG_PID_NS
pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
{
struct upid *upid;
@@ -518,6 +519,7 @@ pid_t pid_vnr(struct pid *pid)
return pid_nr_ns(pid, task_active_pid_ns(current));
}
EXPORT_SYMBOL_GPL(pid_vnr);
+#endif

pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
struct pid_namespace *ns)
--
2.1.3

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