* [PATCH] cgroups: skip processes from other namespaces when listing a cgroup
@ 2008-12-07 14:46 gowrishankar
[not found] ` <493BE1A9.8030503-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: gowrishankar @ 2008-12-07 14:46 UTC (permalink / raw)
To: akpm-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r
Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
menage-hpIqsD4AKlfQT0dZR+AlfA, Balbir
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] cgroups: skip processes from other namespaces when listing a cgroup
@ 2008-12-08 7:22 gowrishankar
[not found] ` <493CCB28.7000005-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: gowrishankar @ 2008-12-08 7:22 UTC (permalink / raw)
To: akpm-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r
Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
Sukadev Bhattiprolu, menage-hpIqsD4AKlfQT0dZR+AlfA, Balbir
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>
---
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] cgroups: skip processes from other namespaces when listing a cgroup
[not found] ` <493BE1A9.8030503-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
@ 2008-12-08 15:14 ` Balbir Singh
[not found] ` <20081208151412.GN13333-SINUvgVNF2CyUtPGxGje5AC/G2K4zDHf@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Balbir Singh @ 2008-12-08 15:14 UTC (permalink / raw)
To: gowrishankar
Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
akpm-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
menage-hpIqsD4AKlfQT0dZR+AlfA
* gowrishankar <gomuthuk-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org> [2008-12-07 20:16:01]:
> 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;
The formatting does not seem right, what is your tab space set to?
> 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
>
>
--
Balbir
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] cgroups: skip processes from other namespaces when listing a cgroup
[not found] ` <20081208151412.GN13333-SINUvgVNF2CyUtPGxGje5AC/G2K4zDHf@public.gmane.org>
@ 2008-12-08 16:31 ` Dave Hansen
0 siblings, 0 replies; 5+ messages in thread
From: Dave Hansen @ 2008-12-08 16:31 UTC (permalink / raw)
To: balbir-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8
Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
Eric W. Biederman, menage-hpIqsD4AKlfQT0dZR+AlfA,
Sukadev Bhattiprolu, akpm-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r
On Mon, 2008-12-08 at 20:44 +0530, Balbir Singh wrote:
> * gowrishankar <gomuthuk-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org> [2008-12-07 20:16:01]:
> > 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;
One more thing...
Please cc Eric and Suka on patches like this. If we get many users like
this we'll probably want to add some common function. Or if someone
missed using one, they can probably suggest one.
-- Dave
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] cgroups: skip processes from other namespaces when listing a cgroup
[not found] ` <493CCB28.7000005-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
@ 2008-12-09 0:19 ` Andrew Morton
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2008-12-09 0:19 UTC (permalink / raw)
To: gowrishankar
Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8,
menage-hpIqsD4AKlfQT0dZR+AlfA,
balbir-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8
On Mon, 08 Dec 2008 12:52:16 +0530
gowrishankar <gomuthuk-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org> wrote:
> 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;
Your email client is replacing tabs with spaces.
> 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;
Please avoid the assignment-in-an-if shorthand. We prefer to avoid
tricky C idioms like this keep the code super-simple:
pid = task_pid_vnr(tsk);
if (pid > 0)
scripts/checkpatch.pl can/should be used to detect this, and many
other little things.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-12-09 0:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-07 14:46 [PATCH] cgroups: skip processes from other namespaces when listing a cgroup gowrishankar
[not found] ` <493BE1A9.8030503-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2008-12-08 15:14 ` 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
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.