diff options
author | Li Zefan <lizefan@huawei.com> | 2014-06-05 05:16:30 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2014-06-05 09:52:51 -0400 |
commit | c731ae1d0f02a300697a8b1564780ad28a6c2013 (patch) | |
tree | 4887aaada0e6f6328449bc41d4b4e2b911c29df2 | |
parent | 1f779fb28aa07350d72976d304591d216ca86f0e (diff) |
cgroup: disallow disabled controllers on the default hierarchy
After booting with cgroup_disable=memory, I still saw memcg files
in the default hierarchy, and I can write to them, though it won't
take effect.
# dmesg
...
Disabling memory control group subsystem
...
# mount -t cgroup -o __DEVEL__sane_behavior xxx /cgroup
# ls /cgroup
...
memory.failcnt memory.move_charge_at_immigrate
memory.force_empty memory.numa_stat
memory.limit_in_bytes memory.oom_control
...
# cat /cgroup/memory.usage_in_bytes
0
tj: Minor comment update.
Signed-off-by: Li Zefan <lizefan@huawei.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
-rw-r--r-- | kernel/cgroup.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 3f46165829a4..3edcc8ae83b5 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -3069,6 +3069,9 @@ int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts) | |||
3069 | { | 3069 | { |
3070 | int ret; | 3070 | int ret; |
3071 | 3071 | ||
3072 | if (ss->disabled) | ||
3073 | return 0; | ||
3074 | |||
3072 | if (!cfts || cfts[0].name[0] == '\0') | 3075 | if (!cfts || cfts[0].name[0] == '\0') |
3073 | return 0; | 3076 | return 0; |
3074 | 3077 | ||
@@ -4678,8 +4681,6 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss, bool early) | |||
4678 | 4681 | ||
4679 | BUG_ON(online_css(css)); | 4682 | BUG_ON(online_css(css)); |
4680 | 4683 | ||
4681 | cgrp_dfl_root.subsys_mask |= 1 << ss->id; | ||
4682 | |||
4683 | mutex_unlock(&cgroup_mutex); | 4684 | mutex_unlock(&cgroup_mutex); |
4684 | } | 4685 | } |
4685 | 4686 | ||
@@ -4758,11 +4759,14 @@ int __init cgroup_init(void) | |||
4758 | &cgrp_dfl_root.cgrp.e_csets[ssid]); | 4759 | &cgrp_dfl_root.cgrp.e_csets[ssid]); |
4759 | 4760 | ||
4760 | /* | 4761 | /* |
4761 | * cftype registration needs kmalloc and can't be done | 4762 | * Setting dfl_root subsys_mask needs to consider the |
4762 | * during early_init. Register base cftypes separately. | 4763 | * disabled flag and cftype registration needs kmalloc, |
4764 | * both of which aren't available during early_init. | ||
4763 | */ | 4765 | */ |
4764 | if (ss->base_cftypes) | 4766 | if (!ss->disabled) { |
4767 | cgrp_dfl_root.subsys_mask |= 1 << ss->id; | ||
4765 | WARN_ON(cgroup_add_cftypes(ss, ss->base_cftypes)); | 4768 | WARN_ON(cgroup_add_cftypes(ss, ss->base_cftypes)); |
4769 | } | ||
4766 | } | 4770 | } |
4767 | 4771 | ||
4768 | cgroup_kobj = kobject_create_and_add("cgroup", fs_kobj); | 4772 | cgroup_kobj = kobject_create_and_add("cgroup", fs_kobj); |