From: Greg Thelen <gthelen@google.com>
To: Paul Menage <menage@google.com>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Li Zefan <lizf@cn.fujitsu.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
Ben Blum <bblum@andrew.cmu.edu>,
containers@lists.linux-foundation.org,
linux-kernel@vger.kernel.org, Greg Thelen <gthelen@google.com>
Subject: [PATCH] cgroup: alloc_css_id() increments hierarchy depth
Date: Fri, 28 May 2010 08:16:21 -0700 [thread overview]
Message-ID: <1275059781-9831-1-git-send-email-gthelen@google.com> (raw)
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
Signed-off-by: Greg Thelen <gthelen@google.com>
---
kernel/cgroup.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 422cb19..3ac6f5b 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -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
next reply other threads:[~2010-05-28 15:20 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-28 15:16 Greg Thelen [this message]
2010-05-28 22:25 ` [PATCH] cgroup: alloc_css_id() increments hierarchy depth Paul Menage
2010-05-30 23:45 ` KAMEZAWA Hiroyuki
2010-05-30 23:54 ` KAMEZAWA Hiroyuki
[not found] ` <20100531085431.a45b30b9.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2010-05-31 0:44 ` Greg Thelen
2010-05-31 0:44 ` Greg Thelen
2010-05-31 0:43 ` KAMEZAWA Hiroyuki
[not found] ` <AANLkTilNrrsNluDBUlXCsZMz7d_-VHn31Ogvkw9AUPnE-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-05-31 0:43 ` KAMEZAWA Hiroyuki
2010-05-31 1:01 ` Li Zefan
2010-05-31 1:01 ` Li Zefan
[not found] ` <20100531084529.2b1f0d25.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2010-05-30 23:54 ` KAMEZAWA Hiroyuki
2010-05-31 0:59 ` Li Zefan
2010-05-31 0:59 ` Li Zefan
[not found] ` <AANLkTino0k-wok9kXLmWTyr40dZKSCnR0Uk41uxAj5k1-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-05-30 23:45 ` KAMEZAWA Hiroyuki
[not found] ` <1275059781-9831-1-git-send-email-gthelen-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2010-05-28 22:25 ` Paul Menage
-- strict thread matches above, loose matches on Subject: below --
2010-05-28 15:16 Greg Thelen
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=1275059781-9831-1-git-send-email-gthelen@google.com \
--to=gthelen@google.com \
--cc=akpm@linux-foundation.org \
--cc=bblum@andrew.cmu.edu \
--cc=containers@lists.linux-foundation.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
--cc=menage@google.com \
--cc=paulmck@linux.vnet.ibm.com \
/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 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.