Skip to contentSkip to conversation

cgroup: alloc_css_id() increments hierarchy depth

PATCH In review Greg Thelen 8 participants 14 messages May 28, 2010 – May 31, 2010 5 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cgroup: alloc_css_id() increments hierarchy depth

Child groups should have a greater depth than their parents. Prior to this change, the parent would incorrectly report zero memory usage for child cgroups when use_hierarchy is enabled.

test script:
mount -t cgroup none /cgroups -o memory
cd /cgroups
mkdir cg1

echo 1 > cg1/memory.use_hierarchy
mkdir cg1/cg11

echo $$ > cg1/cg11/tasks
dd if=/dev/zero of=/tmp/foo bs=1M count=1

echo
echo CHILD
grep cache cg1/cg11/memory.stat

echo
echo PARENT
grep cache cg1/memory.stat

echo $$ > tasks
rmdir cg1/cg11 cg1
cd /
umount /cgroups

Using fae9c79, a recent patch that changed alloc_css_id() depth computation, the parent incorrectly reports zero usage:

  root@ubuntu:~# ./test
  1+0 records in
  1+0 records out
  1048576 bytes (1.0 MB) copied, 0.0151844 s, 69.1 MB/s

CHILD
cache 1048576
total_cache 1048576

PARENT
cache 0
total_cache 0

With this patch, the parent correctly includes child usage:

  root@ubuntu:~# ./test
  1+0 records in
  1+0 records out
  1048576 bytes (1.0 MB) copied, 0.0136827 s, 76.6 MB/s

CHILD
cache 1052672
total_cache 1052672

PARENT
cache 0
total_cache 1052672

---
 kernel/cgroup.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/cgroup.c +1 -1
index 422cb19..3ac6f5b 100644
@@ -4598,7 +4598,7 @@ static int alloc_css_id(struct cgroup_subsys *ss, struct cgroup *parent,
 	parent_css = parent->subsys[subsys_id];
 	child_css = child->subsys[subsys_id];
 	parent_id = parent_css->id;
-	depth = parent_id->depth;
+	depth = parent_id->depth + 1;
 
 	child_id = get_new_cssid(ss, depth);
 	if (IS_ERR(child_id))
Signature · 1 line
1.7.0.1

A message that is not in the archive (sent off-list or not yet received): 1275059781-9831-1-git-send-email-gthelen-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org

Acked-by
#2 lore raw
Quoted 2 lines · Greg Thelen

Good catch, thanks.

Paul

Quoted 21 lines

---
 kernel/cgroup.c |    2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/cgroup.c +1 -2
index 422cb19..3ac6f5b 100644
@@ -4598,7 +4598,7 @@ static int alloc_css_id(struct cgroup_subsys *ss, struct cgroup *parent,
        parent_css = parent->subsys[subsys_id];
        child_css = child->subsys[subsys_id];
        parent_id = parent_css->id;
-       depth = parent_id->depth;
+       depth = parent_id->depth + 1;
 
        child_id = get_new_cssid(ss, depth);
        if (IS_ERR(child_id))
--

1.7.0.1

Acked-by on v1 1/1
#3 lore raw
In reply to Greg Thelen
Quoted 2 lines · Greg Thelen

Good catch, thanks.

Paul

Quoted 21 lines

---
 kernel/cgroup.c |    2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/cgroup.c +1 -2
index 422cb19..3ac6f5b 100644
@@ -4598,7 +4598,7 @@ static int alloc_css_id(struct cgroup_subsys *ss, struct cgroup *parent,
        parent_css = parent->subsys[subsys_id];
        child_css = child->subsys[subsys_id];
        parent_id = parent_css->id;
-       depth = parent_id->depth;
+       depth = parent_id->depth + 1;
 
        child_id = get_new_cssid(ss, depth);
        if (IS_ERR(child_id))
--

1.7.0.1

A message that is not in the archive (sent off-list or not yet received): AANLkTino0k-wok9kXLmWTyr40dZKSCnR0Uk41uxAj5k1-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#5 lore raw
Quoted 8 lines · On Fri, 28 May 2010 15:25:08 -0700 Paul Menage <[email protected]> wrote:
Quoted 2 lines · Greg Thelen

Good catch, thanks.

Nice Catch.

But, who breaks this ? Do we need backport this against old kernels ?

2.6.33 has this.

Quoted 4 lines

3959 depth = css_depth(parent_css) + 1;
3960 parent_id = parent_css->id;
3961
3962 child_id = get_new_cssid(ss, depth);

Thanks,
-Kame

Quoted 17 lines

Paul

Quoted 15 lines

---
 kernel/cgroup.c |    2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/cgroup.c +1 -1
index 422cb19..3ac6f5b 100644
@@ -4598,7 +4598,7 @@ static int alloc_css_id(struct cgroup_subsys *ss, struct cgroup *parent,
        parent_css = parent->subsys[subsys_id];
        child_css = child->subsys[subsys_id];
        parent_id = parent_css->id;
-       depth = parent_id->depth;
+       depth = parent_id->depth + 1;
 
Quoted 7 lines
Quoted 6 lines
kernel/cgroup.c +0 -1
        child_id = get_new_cssid(ss, depth);
        if (IS_ERR(child_id))
--

1.7.0.1

_______________________________________________
Containers mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/containers

#6 lore raw
In reply to Paul Menage
Quoted 8 lines · On Fri, 28 May 2010 15:25:08 -0700 Paul Menage <[email protected]> wrote:
Quoted 2 lines · Greg Thelen

Good catch, thanks.

Nice Catch.

But, who breaks this ? Do we need backport this against old kernels ?

2.6.33 has this.

Quoted 4 lines

3959 depth = css_depth(parent_css) + 1;
3960 parent_id = parent_css->id;
3961
3962 child_id = get_new_cssid(ss, depth);

Thanks,
-Kame

Quoted 24 lines

Paul

Quoted 21 lines

---
 kernel/cgroup.c |    2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/cgroup.c +1 -2
index 422cb19..3ac6f5b 100644
@@ -4598,7 +4598,7 @@ static int alloc_css_id(struct cgroup_subsys *ss, struct cgroup *parent,
        parent_css = parent->subsys[subsys_id];
        child_css = child->subsys[subsys_id];
        parent_id = parent_css->id;
-       depth = parent_id->depth;
+       depth = parent_id->depth + 1;
 
        child_id = get_new_cssid(ss, depth);
        if (IS_ERR(child_id))
--

1.7.0.1

A message that is not in the archive (sent off-list or not yet received): 20100531084529.2b1f0d25.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org

#8 lore raw
Quoted 7 lines · On Mon, 31 May 2010 08:45:29 +0900 KAMEZAWA Hiroyuki…
Quoted 4 lines · On Fri, 28 May 2010 15:25:08 -0700 Paul Menage…
Quoted 2 lines · Greg Thelen
Quoted 9 lines
Quoted 4 lines

Good catch, thanks.

Nice Catch.

But, who breaks this ? Do we need backport this against old kernels ?

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=fae9c791703606636c1220e47f6690660042ce7f

Hmm. this one. and 2.6.34 needs this patch. Greg, could you post this to stable-2.6.34 tree ?

Thanks,
-Kame

#9 lore raw
In reply to KAMEZAWA Hiroyuki
Quoted 7 lines · On Mon, 31 May 2010 08:45:29 +0900 KAMEZAWA Hiroyuki…
Quoted 4 lines · On Fri, 28 May 2010 15:25:08 -0700 Paul Menage <[email protected]> wrote:
Quoted 2 lines · Greg Thelen
Quoted 9 lines
Quoted 4 lines

Good catch, thanks.

Nice Catch.

But, who breaks this ? Do we need backport this against old kernels ?

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=fae9c791703606636c1220e47f6690660042ce7f

Hmm. this one. and 2.6.34 needs this patch. Greg, could you post this to stable-2.6.34 tree ?

Thanks,
-Kame

#10 lore raw
Quoted 17 lines · KAMEZAWA Hiroyuki
Quoted 14 lines · On Mon, 31 May 2010 08:45:29 +0900 KAMEZAWA Hiroyuki…
Quoted 8 lines · On Fri, 28 May 2010 15:25:08 -0700 Paul Menage <[email protected]> wrote:
Quoted 2 lines · Greg Thelen

Good catch, thanks.

Nice Catch.

Quoted 6 lines
Quoted 2 lines

But, who breaks this ? Do we need backport this against old kernels ?

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=fae9c791703606636c1220e47f6690660042ce7f

Hmm. this one. and 2.6.34 needs this patch. Greg, could you post this to stable-2.6.34 tree ?

Given that I forgot to include "Cc: stable <[email protected]>" in the patch, I assume the best way to get this patch into -stable is for me to email the commit id to [email protected] once the patch is accepted into Linus' tree. Let me know if there is a better way.

--
Greg

A message that is not in the archive (sent off-list or not yet received): AANLkTilNrrsNluDBUlXCsZMz7d_-VHn31Ogvkw9AUPnE-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#12 lore raw
Quoted 23 lines · On Sun, 30 May 2010 17:44:34 -0700 Greg Thelen…
Quoted 21 lines · KAMEZAWA Hiroyuki
Quoted 7 lines · On Mon, 31 May 2010 08:45:29 +0900 KAMEZAWA Hiroyuki…
Quoted 4 lines · On Fri, 28 May 2010 15:25:08 -0700 Paul Menage…
Quoted 2 lines · Greg Thelen
Quoted 9 lines
Quoted 4 lines

Good catch, thanks.

Nice Catch.

But, who breaks this ? Do we need backport this against old kernels ?

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=fae9c791703606636c1220e47f6690660042ce7f

Quoted 8 lines
Quoted 2 lines

Hmm. this one. and 2.6.34 needs this patch. Greg, could you post this to stable-2.6.34 tree ?

Given that I forgot to include "Cc: stable <[email protected]>" in the patch, I assume the best way to get this patch into -stable is for me
to email the commit id to [email protected] once the patch is accepted into Linus' tree. Let me know if there is a better way.

Yes, it's best to CC [email protected] But please specify what version of kernels requires this patch as "for 2.6.34"

Thank you,
-Kame

#13 lore raw
In reply to a message not in the archive
Quoted 13 lines
Quoted 13 lines
Quoted 11 lines
Quoted 6 lines · Greg Thelen
Quoted 1 line

Good catch, thanks.

Nice Catch.

But, who breaks this ? Do we need backport this against old kernels ?

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=fae9c791703606636c1220e47f6690660042ce7f

Quoted 8 lines
Quoted 2 lines

Hmm. this one. and 2.6.34 needs this patch. Greg, could you post this to stable-2.6.34 tree ?

Given that I forgot to include "Cc: stable <[email protected]>" in the patch, I assume the best way to get this patch into -stable is for me
to email the commit id to [email protected] once the patch is accepted into Linus' tree. Let me know if there is a better way.

I think Andrew will mark it and send it to stable.

#14 lore raw
In reply to Greg Thelen
Quoted 23 lines · On Sun, 30 May 2010 17:44:34 -0700 Greg Thelen <[email protected]> wrote:
Quoted 21 lines · KAMEZAWA Hiroyuki
Quoted 7 lines · On Mon, 31 May 2010 08:45:29 +0900 KAMEZAWA Hiroyuki…
Quoted 4 lines · On Fri, 28 May 2010 15:25:08 -0700 Paul Menage <[email protected]> wrote:
Quoted 2 lines · Greg Thelen
Quoted 9 lines
Quoted 4 lines

Good catch, thanks.

Nice Catch.

But, who breaks this ? Do we need backport this against old kernels ?

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=fae9c791703606636c1220e47f6690660042ce7f

Quoted 8 lines
Quoted 2 lines

Hmm. this one. and 2.6.34 needs this patch. Greg, could you post this to stable-2.6.34 tree ?

Given that I forgot to include "Cc: stable <[email protected]>" in the patch, I assume the best way to get this patch into -stable is for me to email the commit id to [email protected] once the patch is accepted into Linus' tree. Let me know if there is a better way.

Yes, it's best to CC [email protected]. But please specify what version of kernels requires this patch as "for 2.6.34"

Thank you,
-Kame

#15 lore raw
In reply to Greg Thelen
Quoted 13 lines
Quoted 13 lines
Quoted 11 lines
Quoted 6 lines · Greg Thelen
Quoted 1 line

Good catch, thanks.

Nice Catch.

But, who breaks this ? Do we need backport this against old kernels ?

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=fae9c791703606636c1220e47f6690660042ce7f

Quoted 8 lines
Quoted 2 lines

Hmm. this one. and 2.6.34 needs this patch. Greg, could you post this to stable-2.6.34 tree ?

Given that I forgot to include "Cc: stable <[email protected]>" in the patch, I assume the best way to get this patch into -stable is for me to email the commit id to [email protected] once the patch is accepted into Linus' tree. Let me know if there is a better way.

I think Andrew will mark it and send it to stable.

A message that is not in the archive (sent off-list or not yet received): 20100531085431.a45b30b9.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org

#17 lore raw
Quoted 17 lines · KAMEZAWA Hiroyuki
Quoted 14 lines · On Mon, 31 May 2010 08:45:29 +0900 KAMEZAWA Hiroyuki…
Quoted 8 lines · On Fri, 28 May 2010 15:25:08 -0700 Paul Menage…
Quoted 2 lines · Greg Thelen

Good catch, thanks.

Nice Catch.

Quoted 6 lines
Quoted 2 lines

But, who breaks this ? Do we need backport this against old kernels ?

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=fae9c791703606636c1220e47f6690660042ce7f

Hmm. this one. and 2.6.34 needs this patch. Greg, could you post this to stable-2.6.34 tree ?

Given that I forgot to include "Cc: stable <[email protected]>" in the patch, I assume the best way to get this patch into -stable is for me
to email the commit id to [email protected] once the patch is accepted into Linus' tree. Let me know if there is a better way.

--
Greg

Acked-by
#18 lore raw
In reply to KAMEZAWA Hiroyuki
Quoted 5 lines · KAMEZAWA Hiroyuki
Quoted 2 lines · On Fri, 28 May 2010 15:25:08 -0700 Paul Menage <[email protected]> wrote:
Quoted 1 line · Greg Thelen
Quoted 9 lines
Quoted 4 lines

Good catch, thanks.

Nice Catch.

But, who breaks this ? Do we need backport this against old kernels ?

Oops, I broke it, and it needs to be backported to 2.6.34.. Thanks for catching this!