aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/cgroup.h3
-rw-r--r--mm/memcontrol.c17
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 */
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,