[RFC][PATCH 2/6] Reimplement pid_nr() using struct pid_nr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Sukadev Bhattiprolu <sukadev@xxxxxxxxxx>
Subject [RFC][PATCH 2/6] Reimplement pid_nr() using struct pid_nr

Replace the pid_nr() stub with a version that uses struct pid_nr
and returns the pid_t based on the pid namespace of the caller.

Signed-off-by: Sukadev Bhattiprolu <sukadev@xxxxxxxxxx>
Cc: Cedric Le Goater <clg@xxxxxxxxxx>
Cc: Dave Hansen <haveblue@xxxxxxxxxx>
Cc: Serge Hallyn <serue@xxxxxxxxxx>
Cc: containers@xxxxxxxxxxxxxx
---
 include/linux/pid.h |    9 +--------
 kernel/pid.c        |   19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 8 deletions(-)

Index: lx26-20-mm2b/include/linux/pid.h
===================================================================
--- lx26-20-mm2b.orig/include/linux/pid.h	2007-03-09 18:27:51.000000000 -0800
+++ lx26-20-mm2b/include/linux/pid.h	2007-03-09 18:28:00.000000000 -0800
@@ -118,14 +118,7 @@ extern void free_pid_nr(struct pid_nr *p
 extern struct pid_nr *alloc_pid_nr(struct pid_namespace *pid_ns);
 extern struct pid *alloc_pid(void);
 extern void FASTCALL(free_pid(struct pid *pid));
-
-static inline pid_t pid_nr(struct pid *pid)
-{
-	pid_t nr = 0;
-	if (pid)
-		nr = pid->nr;
-	return nr;
-}
+extern pid_t pid_nr(struct pid *pid);
 
 #define do_each_pid_task(pid, type, task)				\
 	do {								\
Index: lx26-20-mm2b/kernel/pid.c
===================================================================
--- lx26-20-mm2b.orig/kernel/pid.c	2007-03-09 18:27:51.000000000 -0800
+++ lx26-20-mm2b/kernel/pid.c	2007-03-09 18:28:00.000000000 -0800
@@ -263,6 +263,25 @@ int attach_pid_nr(struct pid *pid, struc
 	return 0;
 }
 
+pid_t pid_nr(struct pid *pid)
+{
+	struct pid_nr* pid_nr;
+	struct hlist_node *pos;
+
+	if (!pid)
+		return 0;
+
+	rcu_read_lock();
+	hlist_for_each_entry_rcu(pid_nr, pos, &pid->pid_nrs, node)
+		if (pid_nr->pid_ns == task_pid_ns(current)) {
+			rcu_read_unlock();
+			return pid_nr->nr;
+		}
+
+	rcu_read_unlock();
+	return 0;
+}
+
 struct pid *alloc_pid(void)
 {
 	struct pid *pid;
_______________________________________________
Containers mailing list
Containers@xxxxxxxxxxxxxx
https://lists.osdl.org/mailman/listinfo/containers


[Index of Archives]     [Cgroups]     [Netdev]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux