From mboxrd@z Thu Jan 1 00:00:00 1970 From: gowrishankar Subject: [PATCH] cgroups: skip processes from other namespaces when listing a cgroup Date: Mon, 08 Dec 2008 12:52:16 +0530 Message-ID: <493CCB28.7000005@linux.vnet.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: akpm-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, Sukadev Bhattiprolu , menage-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org, Balbir List-Id: containers.vger.kernel.org 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 below patch, we check if a process is in same namespace before loading into pid array. Signed-off-by: Gowrishankar M Acked-by: Paul Menage --- kernel/cgroup.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 35eebd5..25fdd2c 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -2011,14 +2011,15 @@ 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); + if ((pid = task_pid_vnr(tsk)) > 0) + pidarray[n++] = pid; } cgroup_iter_end(cgrp, &it); return n; -- 1.5.5.1