Skip to content

Commit 94b3dd0

Browse files
gthelentorvalds
authored andcommitted
cgroups: 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 Signed-off-by: Greg Thelen <[email protected]> Acked-by: Paul Menage <[email protected]> Acked-by: KAMEZAWA Hiroyuki <[email protected]> Acked-by: Li Zefan <[email protected]> Cc: <[email protected]> [2.6.34.x] Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 007d086 commit 94b3dd0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/cgroup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4598,7 +4598,7 @@ static int alloc_css_id(struct cgroup_subsys *ss, struct cgroup *parent,
45984598
parent_css = parent->subsys[subsys_id];
45994599
child_css = child->subsys[subsys_id];
46004600
parent_id = parent_css->id;
4601-
depth = parent_id->depth;
4601+
depth = parent_id->depth + 1;
46024602

46034603
child_id = get_new_cssid(ss, depth);
46044604
if (IS_ERR(child_id))

0 commit comments

Comments
 (0)