diff options
| author | Tejun Heo <tj@kernel.org> | 2013-04-15 16:41:15 -0400 |
|---|---|---|
| committer | Tejun Heo <tj@kernel.org> | 2013-04-15 16:46:27 -0400 |
| commit | f00baae7ad6c5f1503528efa852f0be8e9513f0e (patch) | |
| tree | 6d07f953aa06f01b67ed5161073778118b90e6b9 | |
| parent | 05fb22ec5456a472a5eadcaacb3e51eca1f8c79c (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>
| -rw-r--r-- | include/linux/cgroup.h | 3 | ||||
| -rw-r--r-- | mm/memcontrol.c | 17 |
2 files changed, 20 insertions, 0 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 64047ae7fde1..cda7eb2239e1 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h | |||
| @@ -268,6 +268,9 @@ enum { | |||
| 268 | * | 268 | * |
| 269 | * - Remount is disallowed. | 269 | * - Remount is disallowed. |
| 270 | * | 270 | * |
| 271 | * - memcg: use_hierarchy is on by default and the cgroup file for | ||
| 272 | * the flag is not created. | ||
| 273 | * | ||
| 271 | * The followings are planned changes. | 274 | * The followings are planned changes. |
| 272 | * | 275 | * |
| 273 | * - release_agent will be disallowed once replacement notification | 276 | * - release_agent will be disallowed once replacement notification |
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 | */ | ||
| 6792 | static 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 | |||
| 6787 | struct cgroup_subsys mem_cgroup_subsys = { | 6803 | struct 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, |
