提交 e7b80bb6 编写于 作者: G Gowrishankar M 提交者: Linus Torvalds

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: NGowrishankar M <gowrishankar.m@in.ibm.com>
Acked-by: NPaul Menage <menage@google.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 c12f65d4
...@@ -2007,14 +2007,16 @@ int cgroup_scan_tasks(struct cgroup_scanner *scan) ...@@ -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) 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 cgroup_iter it;
struct task_struct *tsk; struct task_struct *tsk;
cgroup_iter_start(cgrp, &it); cgroup_iter_start(cgrp, &it);
while ((tsk = cgroup_iter_next(cgrp, &it))) { while ((tsk = cgroup_iter_next(cgrp, &it))) {
if (unlikely(n == npids)) if (unlikely(n == npids))
break; break;
pidarray[n++] = task_pid_vnr(tsk); pid = task_pid_vnr(tsk);
if (pid > 0)
pidarray[n++] = pid;
} }
cgroup_iter_end(cgrp, &it); cgroup_iter_end(cgrp, &it);
return n; return n;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册