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>
This commit is contained in:
parent
1f779fb28a
commit
c731ae1d0f
|
@ -3069,6 +3069,9 @@ int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (ss->disabled)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (!cfts || cfts[0].name[0] == '\0')
|
if (!cfts || cfts[0].name[0] == '\0')
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -4678,8 +4681,6 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss, bool early)
|
||||||
|
|
||||||
BUG_ON(online_css(css));
|
BUG_ON(online_css(css));
|
||||||
|
|
||||||
cgrp_dfl_root.subsys_mask |= 1 << ss->id;
|
|
||||||
|
|
||||||
mutex_unlock(&cgroup_mutex);
|
mutex_unlock(&cgroup_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4758,11 +4759,14 @@ int __init cgroup_init(void)
|
||||||
&cgrp_dfl_root.cgrp.e_csets[ssid]);
|
&cgrp_dfl_root.cgrp.e_csets[ssid]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* cftype registration needs kmalloc and can't be done
|
* Setting dfl_root subsys_mask needs to consider the
|
||||||
* during early_init. Register base cftypes separately.
|
* disabled flag and cftype registration needs kmalloc,
|
||||||
|
* both of which aren't available during early_init.
|
||||||
*/
|
*/
|
||||||
if (ss->base_cftypes)
|
if (!ss->disabled) {
|
||||||
|
cgrp_dfl_root.subsys_mask |= 1 << ss->id;
|
||||||
WARN_ON(cgroup_add_cftypes(ss, ss->base_cftypes));
|
WARN_ON(cgroup_add_cftypes(ss, ss->base_cftypes));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cgroup_kobj = kobject_create_and_add("cgroup", fs_kobj);
|
cgroup_kobj = kobject_create_and_add("cgroup", fs_kobj);
|
||||||
|
|
Loading…
Reference in New Issue