diff options
author | Tejun Heo <tj@kernel.org> | 2012-09-13 15:20:58 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2012-09-14 15:01:16 -0400 |
commit | 8c7f6edbda01f1b1a2e60ad61f14fe38023e433b (patch) | |
tree | f1db9712b109575cba86e37140e1e4f8a56ca780 /kernel/cgroup.c | |
parent | fbcbe2b3c92ee1c930dcfcf8bb764074c100fd63 (diff) |
cgroup: mark subsystems with broken hierarchy support and whine if cgroups are nested for them
Currently, cgroup hierarchy support is a mess. cpu related subsystems
behave correctly - configuration, accounting and control on a parent
properly cover its children. blkio and freezer completely ignore
hierarchy and treat all cgroups as if they're directly under the root
cgroup. Others show yet different behaviors.
These differing interpretations of cgroup hierarchy make using cgroup
confusing and it impossible to co-mount controllers into the same
hierarchy and obtain sane behavior.
Eventually, we want full hierarchy support from all subsystems and
probably a unified hierarchy. Users using separate hierarchies
expecting completely different behaviors depending on the mounted
subsystem is deterimental to making any progress on this front.
This patch adds cgroup_subsys.broken_hierarchy and sets it to %true
for controllers which are lacking in hierarchy support. The goal of
this patch is two-fold.
* Move users away from using hierarchy on currently non-hierarchical
subsystems, so that implementing proper hierarchy support on those
doesn't surprise them.
* Keep track of which controllers are broken how and nudge the
subsystems to implement proper hierarchy support.
For now, start with a single warning message. We can whine louder
later on.
v2: Fixed a typo spotted by Michal. Warning message updated.
v3: Updated memcg part so that it doesn't generate warning in the
cases where .use_hierarchy=false doesn't make the behavior
different from root.use_hierarchy=true. Fixed a typo spotted by
Glauber.
v4: Check ->broken_hierarchy after cgroup creation is complete so that
->create() can affect the result per Michal. Dropped unnecessary
memcg root handling per Michal.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Michal Hocko <mhocko@suse.cz>
Acked-by: Li Zefan <lizefan@huawei.com>
Acked-by: Serge E. Hallyn <serue@us.ibm.com>
Cc: Glauber Costa <glommer@parallels.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Paul Turner <pjt@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Thomas Graf <tgraf@suug.ch>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r-- | kernel/cgroup.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 79818507e444..b7d9606b17d7 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -3954,8 +3954,9 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, | |||
3954 | set_bit(CGRP_CLONE_CHILDREN, &cgrp->flags); | 3954 | set_bit(CGRP_CLONE_CHILDREN, &cgrp->flags); |
3955 | 3955 | ||
3956 | for_each_subsys(root, ss) { | 3956 | for_each_subsys(root, ss) { |
3957 | struct cgroup_subsys_state *css = ss->create(cgrp); | 3957 | struct cgroup_subsys_state *css; |
3958 | 3958 | ||
3959 | css = ss->create(cgrp); | ||
3959 | if (IS_ERR(css)) { | 3960 | if (IS_ERR(css)) { |
3960 | err = PTR_ERR(css); | 3961 | err = PTR_ERR(css); |
3961 | goto err_destroy; | 3962 | goto err_destroy; |
@@ -3969,6 +3970,15 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, | |||
3969 | /* At error, ->destroy() callback has to free assigned ID. */ | 3970 | /* At error, ->destroy() callback has to free assigned ID. */ |
3970 | if (clone_children(parent) && ss->post_clone) | 3971 | if (clone_children(parent) && ss->post_clone) |
3971 | ss->post_clone(cgrp); | 3972 | ss->post_clone(cgrp); |
3973 | |||
3974 | if (ss->broken_hierarchy && !ss->warned_broken_hierarchy && | ||
3975 | parent->parent) { | ||
3976 | pr_warning("cgroup: %s (%d) created nested cgroup for controller \"%s\" which has incomplete hierarchy support. Nested cgroups may change behavior in the future.\n", | ||
3977 | current->comm, current->pid, ss->name); | ||
3978 | if (!strcmp(ss->name, "memory")) | ||
3979 | pr_warning("cgroup: \"memory\" requires setting use_hierarchy to 1 on the root.\n"); | ||
3980 | ss->warned_broken_hierarchy = true; | ||
3981 | } | ||
3972 | } | 3982 | } |
3973 | 3983 | ||
3974 | list_add(&cgrp->sibling, &cgrp->parent->children); | 3984 | list_add(&cgrp->sibling, &cgrp->parent->children); |