aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-04-15 16:41:15 -0400
committerTejun Heo <tj@kernel.org>2013-04-15 16:46:27 -0400
commitf00baae7ad6c5f1503528efa852f0be8e9513f0e (patch)
tree6d07f953aa06f01b67ed5161073778118b90e6b9 /mm
parent05fb22ec5456a472a5eadcaacb3e51eca1f8c79c (diff)
memcg: force use_hierarchy if sane_behavior
Turn on use_hierarchy by default if sane_behavior is specified and don't create .use_hierarchy file. It is debatable whether to remove .use_hierarchy file or make it ro as the former could make transition easier in certain cases; however, the behavior changes which will be gated by sane_behavior are intensive including changing basic meaning of certain control knobs in a few controllers and I don't really think keeping this piece would make things easier in any noticeable way, so let's remove it. v2: Explain that mem_cgroup_bind() doesn't have to worry about children as suggested by Michal Hocko. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com> Acked-by: Li Zefan <lizefan@huawei.com> Acked-by: Michal Hocko <mhocko@suse.cz> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Diffstat (limited to 'mm')
-rw-r--r--mm/memcontrol.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 9715c0c491b0..df87bdd4d692 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5814,6 +5814,7 @@ static struct cftype mem_cgroup_files[] = {
5814 }, 5814 },
5815 { 5815 {
5816 .name = "use_hierarchy", 5816 .name = "use_hierarchy",
5817 .flags = CFTYPE_INSANE,
5817 .write_u64 = mem_cgroup_hierarchy_write, 5818 .write_u64 = mem_cgroup_hierarchy_write,
5818 .read_u64 = mem_cgroup_hierarchy_read, 5819 .read_u64 = mem_cgroup_hierarchy_read,
5819 }, 5820 },
@@ -6784,6 +6785,21 @@ static void mem_cgroup_move_task(struct cgroup *cont,
6784} 6785}
6785#endif 6786#endif
6786 6787
6788/*
6789 * Cgroup retains root cgroups across [un]mount cycles making it necessary
6790 * to verify sane_behavior flag on each mount attempt.
6791 */
6792static void mem_cgroup_bind(struct cgroup *root)
6793{
6794 /*
6795 * use_hierarchy is forced with sane_behavior. cgroup core
6796 * guarantees that @root doesn't have any children, so turning it
6797 * on for the root memcg is enough.
6798 */
6799 if (cgroup_sane_behavior(root))
6800 mem_cgroup_from_cont(root)->use_hierarchy = true;
6801}
6802
6787struct cgroup_subsys mem_cgroup_subsys = { 6803struct cgroup_subsys mem_cgroup_subsys = {
6788 .name = "memory", 6804 .name = "memory",
6789 .subsys_id = mem_cgroup_subsys_id, 6805 .subsys_id = mem_cgroup_subsys_id,
@@ -6794,6 +6810,7 @@ struct cgroup_subsys mem_cgroup_subsys = {
6794 .can_attach = mem_cgroup_can_attach, 6810 .can_attach = mem_cgroup_can_attach,
6795 .cancel_attach = mem_cgroup_cancel_attach, 6811 .cancel_attach = mem_cgroup_cancel_attach,
6796 .attach = mem_cgroup_move_task, 6812 .attach = mem_cgroup_move_task,
6813 .bind = mem_cgroup_bind,
6797 .base_cftypes = mem_cgroup_files, 6814 .base_cftypes = mem_cgroup_files,
6798 .early_init = 0, 6815 .early_init = 0,
6799 .use_id = 1, 6816 .use_id = 1,