[Devel] [RFC][PATCH 2/6] Reimplement pid_nr() using struct pid_nr
sukadev at us.ibm.com
sukadev at us.ibm.com
Fri Mar 9 19:58:39 PST 2007
From: Sukadev Bhattiprolu <sukadev at us.ibm.com>
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 at us.ibm.com>
Cc: Cedric Le Goater <clg at fr.ibm.com>
Cc: Dave Hansen <haveblue at us.ibm.com>
Cc: Serge Hallyn <serue at us.ibm.com>
Cc: containers at lists.osdl.org
---
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 at lists.osdl.org
https://lists.osdl.org/mailman/listinfo/containers
More information about the Devel
mailing list