aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/pid.c
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2007-10-19 02:40:09 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-19 14:53:39 -0400
commitb461cc03828c743aed6b3855b9ab0d39a9d54ec5 (patch)
treeb39ff42df1564adf800d9c4a01ba78ed14f8f9a2 /kernel/pid.c
parent07543f5c75cee744b791cf7716c69571486fe753 (diff)
pid namespaces: miscellaneous preparations for pid namespaces
* remove pid.h from pid_namespaces.h; * rework is_(cgroup|global)_init; * optimize (get|put)_pid_ns for init_pid_ns; * declare task_child_reaper to return actual reaper. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Cc: Oleg Nesterov <oleg@tv-sign.ru> Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com> Cc: Paul Menage <menage@google.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/pid.c')
-rw-r--r--kernel/pid.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/kernel/pid.c b/kernel/pid.c
index a2b4cbbdd63d..4b17acdb862f 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -73,10 +73,20 @@ struct pid_namespace init_pid_ns = {
73}; 73};
74EXPORT_SYMBOL_GPL(init_pid_ns); 74EXPORT_SYMBOL_GPL(init_pid_ns);
75 75
76int is_global_init(struct task_struct *tsk) 76int is_container_init(struct task_struct *tsk)
77{ 77{
78 return tsk == init_pid_ns.child_reaper; 78 int ret = 0;
79 struct pid *pid;
80
81 rcu_read_lock();
82 pid = task_pid(tsk);
83 if (pid != NULL && pid->numbers[pid->level].nr == 1)
84 ret = 1;
85 rcu_read_unlock();
86
87 return ret;
79} 88}
89EXPORT_SYMBOL(is_container_init);
80 90
81/* 91/*
82 * Note: disable interrupts while the pidmap_lock is held as an 92 * Note: disable interrupts while the pidmap_lock is held as an
@@ -192,8 +202,7 @@ fastcall void put_pid(struct pid *pid)
192 if ((atomic_read(&pid->count) == 1) || 202 if ((atomic_read(&pid->count) == 1) ||
193 atomic_dec_and_test(&pid->count)) { 203 atomic_dec_and_test(&pid->count)) {
194 kmem_cache_free(ns->pid_cachep, pid); 204 kmem_cache_free(ns->pid_cachep, pid);
195 if (ns != &init_pid_ns) 205 put_pid_ns(ns);
196 put_pid_ns(ns);
197 } 206 }
198} 207}
199EXPORT_SYMBOL_GPL(put_pid); 208EXPORT_SYMBOL_GPL(put_pid);
@@ -244,9 +253,7 @@ struct pid *alloc_pid(struct pid_namespace *ns)
244 tmp = tmp->parent; 253 tmp = tmp->parent;
245 } 254 }
246 255
247 if (ns != &init_pid_ns) 256 get_pid_ns(ns);
248 get_pid_ns(ns);
249
250 pid->level = ns->level; 257 pid->level = ns->level;
251 pid->nr = pid->numbers[0].nr; 258 pid->nr = pid->numbers[0].nr;
252 atomic_set(&pid->count, 1); 259 atomic_set(&pid->count, 1);