|
@@ -5814,6 +5814,7 @@ static struct cftype mem_cgroup_files[] = {
|
|
|
},
|
|
|
{
|
|
|
.name = "use_hierarchy",
|
|
|
+ .flags = CFTYPE_INSANE,
|
|
|
.write_u64 = mem_cgroup_hierarchy_write,
|
|
|
.read_u64 = mem_cgroup_hierarchy_read,
|
|
|
},
|
|
@@ -6784,6 +6785,21 @@ static void mem_cgroup_move_task(struct cgroup *cont,
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+/*
|
|
|
+ * Cgroup retains root cgroups across [un]mount cycles making it necessary
|
|
|
+ * to verify sane_behavior flag on each mount attempt.
|
|
|
+ */
|
|
|
+static void mem_cgroup_bind(struct cgroup *root)
|
|
|
+{
|
|
|
+ /*
|
|
|
+ * use_hierarchy is forced with sane_behavior. cgroup core
|
|
|
+ * guarantees that @root doesn't have any children, so turning it
|
|
|
+ * on for the root memcg is enough.
|
|
|
+ */
|
|
|
+ if (cgroup_sane_behavior(root))
|
|
|
+ mem_cgroup_from_cont(root)->use_hierarchy = true;
|
|
|
+}
|
|
|
+
|
|
|
struct cgroup_subsys mem_cgroup_subsys = {
|
|
|
.name = "memory",
|
|
|
.subsys_id = mem_cgroup_subsys_id,
|
|
@@ -6794,6 +6810,7 @@ struct cgroup_subsys mem_cgroup_subsys = {
|
|
|
.can_attach = mem_cgroup_can_attach,
|
|
|
.cancel_attach = mem_cgroup_cancel_attach,
|
|
|
.attach = mem_cgroup_move_task,
|
|
|
+ .bind = mem_cgroup_bind,
|
|
|
.base_cftypes = mem_cgroup_files,
|
|
|
.early_init = 0,
|
|
|
.use_id = 1,
|