diff options
author | Gowrishankar M <gowrishankar.m@in.ibm.com> | 2009-01-07 21:07:43 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-08 11:31:03 -0500 |
commit | e7b80bb695a5b64c92e314838e083b2f3bdf29b2 (patch) | |
tree | f5eafb9825a23550dbf903e5cabd71655e4e55ce | |
parent | c12f65d4396e05c51ce3af7f159ead98574a587c (diff) |
cgroups: skip processes from other namespaces when listing a cgroup
Once tasks are populated from system namespace inside cgroup, container
replaces other namespace task with 0 while listing tasks, inside
container.
Though this is expected behaviour from container end, there is no use of
showing unwanted 0s.
In this patch, we check if a process is in same namespace before loading
into pid array.
[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Gowrishankar M <gowrishankar.m@in.ibm.com>
Acked-by: Paul Menage <menage@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | kernel/cgroup.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 4c475ce4e222..cb7c72b91f46 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -2007,14 +2007,16 @@ int cgroup_scan_tasks(struct cgroup_scanner *scan) | |||
2007 | */ | 2007 | */ |
2008 | static int pid_array_load(pid_t *pidarray, int npids, struct cgroup *cgrp) | 2008 | static int pid_array_load(pid_t *pidarray, int npids, struct cgroup *cgrp) |
2009 | { | 2009 | { |
2010 | int n = 0; | 2010 | int n = 0, pid; |
2011 | struct cgroup_iter it; | 2011 | struct cgroup_iter it; |
2012 | struct task_struct *tsk; | 2012 | struct task_struct *tsk; |
2013 | cgroup_iter_start(cgrp, &it); | 2013 | cgroup_iter_start(cgrp, &it); |
2014 | while ((tsk = cgroup_iter_next(cgrp, &it))) { | 2014 | while ((tsk = cgroup_iter_next(cgrp, &it))) { |
2015 | if (unlikely(n == npids)) | 2015 | if (unlikely(n == npids)) |
2016 | break; | 2016 | break; |
2017 | pidarray[n++] = task_pid_vnr(tsk); | 2017 | pid = task_pid_vnr(tsk); |
2018 | if (pid > 0) | ||
2019 | pidarray[n++] = pid; | ||
2018 | } | 2020 | } |
2019 | cgroup_iter_end(cgrp, &it); | 2021 | cgroup_iter_end(cgrp, &it); |
2020 | return n; | 2022 | return n; |