* [PATCH] cgroup: disallow disabled controllers on the default hierarchy
@ 2014-06-05 9:16 ` Li Zefan
0 siblings, 0 replies; 4+ messages in thread
From: Li Zefan @ 2014-06-05 9:16 UTC (permalink / raw)
To: Tejun Heo; +Cc: LKML, Cgroups, Michal Hocko, Johannes Weiner
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
Signed-off-by: Li Zefan <lizefan@huawei.com>
---
kernel/cgroup.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index d5032d2..57b647a 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -3070,6 +3070,9 @@ int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts)
{
int ret;
+ if (ss->disabled)
+ return 0;
+
if (!cfts || cfts[0].name[0] == '\0')
return 0;
@@ -4679,8 +4682,6 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss, bool early)
BUG_ON(online_css(css));
- cgrp_dfl_root.subsys_mask |= 1 << ss->id;
-
mutex_unlock(&cgroup_mutex);
}
@@ -4760,10 +4761,13 @@ int __init cgroup_init(void)
/*
* cftype registration needs kmalloc and can't be done
- * during early_init. Register base cftypes separately.
+ * during early_init, and the disable flag is set after
+ * early_init. Register base cftypes separately.
*/
- if (ss->base_cftypes)
+ if (!ss->disabled) {
+ cgrp_dfl_root.subsys_mask |= 1 << ss->id;
WARN_ON(cgroup_add_cftypes(ss, ss->base_cftypes));
+ }
}
cgroup_kobj = kobject_create_and_add("cgroup", fs_kobj);
--
1.8.0.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] cgroup: disallow disabled controllers on the default hierarchy
@ 2014-06-05 9:16 ` Li Zefan
0 siblings, 0 replies; 4+ messages in thread
From: Li Zefan @ 2014-06-05 9:16 UTC (permalink / raw)
To: Tejun Heo; +Cc: LKML, Cgroups, Michal Hocko, Johannes Weiner
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
Signed-off-by: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
---
kernel/cgroup.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index d5032d2..57b647a 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -3070,6 +3070,9 @@ int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts)
{
int ret;
+ if (ss->disabled)
+ return 0;
+
if (!cfts || cfts[0].name[0] == '\0')
return 0;
@@ -4679,8 +4682,6 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss, bool early)
BUG_ON(online_css(css));
- cgrp_dfl_root.subsys_mask |= 1 << ss->id;
-
mutex_unlock(&cgroup_mutex);
}
@@ -4760,10 +4761,13 @@ int __init cgroup_init(void)
/*
* cftype registration needs kmalloc and can't be done
- * during early_init. Register base cftypes separately.
+ * during early_init, and the disable flag is set after
+ * early_init. Register base cftypes separately.
*/
- if (ss->base_cftypes)
+ if (!ss->disabled) {
+ cgrp_dfl_root.subsys_mask |= 1 << ss->id;
WARN_ON(cgroup_add_cftypes(ss, ss->base_cftypes));
+ }
}
cgroup_kobj = kobject_create_and_add("cgroup", fs_kobj);
--
1.8.0.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] cgroup: disallow disabled controllers on the default hierarchy
@ 2014-06-05 13:53 ` Tejun Heo
0 siblings, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2014-06-05 13:53 UTC (permalink / raw)
To: Li Zefan; +Cc: LKML, Cgroups, Michal Hocko, Johannes Weiner
On Thu, Jun 05, 2014 at 05:16:30PM +0800, Li Zefan wrote:
> 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
>
> Signed-off-by: Li Zefan <lizefan@huawei.com>
Applied to cgroup/for-3.16 w/ minor comment update.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] cgroup: disallow disabled controllers on the default hierarchy
@ 2014-06-05 13:53 ` Tejun Heo
0 siblings, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2014-06-05 13:53 UTC (permalink / raw)
To: Li Zefan; +Cc: LKML, Cgroups, Michal Hocko, Johannes Weiner
On Thu, Jun 05, 2014 at 05:16:30PM +0800, Li Zefan wrote:
> 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
>
> Signed-off-by: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Applied to cgroup/for-3.16 w/ minor comment update.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-06-05 13:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-05 9:16 [PATCH] cgroup: disallow disabled controllers on the default hierarchy Li Zefan
2014-06-05 9:16 ` Li Zefan
2014-06-05 13:53 ` Tejun Heo
2014-06-05 13:53 ` Tejun Heo
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.