From: gowrishankar <gomuthuk-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
To: akpm-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org
Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
menage-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
Balbir <balbir-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Subject: [PATCH] cgroups: skip processes from other namespaces when listing a cgroup
Date: Sun, 07 Dec 2008 20:16:01 +0530 [thread overview]
Message-ID: <493BE1A9.8030503@linux.vnet.ibm.com> (raw)
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 <gowrishankar.m-xthvdsQ13ZrQT0dZR+AlfA@public.gmane.org>
Acked-by: Paul Menage <menage-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Acked-by: Serge Hallyn <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
changes for vpid and pid_t
---
kernel/cgroup.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 35eebd5..588d305 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2012,13 +2012,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;
+ pid_t vpid;
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 ((vpid = task_pid_vnr(tsk)) > 0)
+ pidarray[n++] = vpid;
}
cgroup_iter_end(cgrp, &it);
return n;
--
1.5.5.1
next reply other threads:[~2008-12-07 14:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-07 14:46 gowrishankar [this message]
[not found] ` <493BE1A9.8030503-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2008-12-08 15:14 ` [PATCH] cgroups: skip processes from other namespaces when listing a cgroup Balbir Singh
[not found] ` <20081208151412.GN13333-SINUvgVNF2CyUtPGxGje5AC/G2K4zDHf@public.gmane.org>
2008-12-08 16:31 ` Dave Hansen
-- strict thread matches above, loose matches on Subject: below --
2008-12-08 7:22 gowrishankar
[not found] ` <493CCB28.7000005-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2008-12-09 0:19 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=493BE1A9.8030503@linux.vnet.ibm.com \
--to=gomuthuk-23vcf4htsmix0ybbhkvfkdbpr1lh4cv8@public.gmane.org \
--cc=akpm-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=balbir-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
--cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=menage-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox