]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
cgroups: skip processes from other namespaces when listing a cgroup
authorGowrishankar M <gowrishankar.m@in.ibm.com>
Thu, 8 Jan 2009 02:07:43 +0000 (18:07 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 8 Jan 2009 16:31:03 +0000 (08:31 -0800)
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>
kernel/cgroup.c

index 4c475ce4e22212dcab53e60f3c9174d8e4b927cd..cb7c72b91f4657dfc21f14d0ae06ac725c4176e3 100644 (file)
@@ -2007,14 +2007,16 @@ int cgroup_scan_tasks(struct cgroup_scanner *scan)
  */
 static int pid_array_load(pid_t *pidarray, int npids, struct cgroup *cgrp)
 {
-       int n = 0;
+       int n = 0, pid;
        struct cgroup_iter it;
        struct task_struct *tsk;
        cgroup_iter_start(cgrp, &it);
        while ((tsk = cgroup_iter_next(cgrp, &it))) {
                if (unlikely(n == npids))
                        break;
-               pidarray[n++] = task_pid_vnr(tsk);
+               pid = task_pid_vnr(tsk);
+               if (pid > 0)
+                       pidarray[n++] = pid;
        }
        cgroup_iter_end(cgrp, &it);
        return n;