mm: replace vma prio_tree with an interval tree
[firefly-linux-kernel-4.4.55.git] / kernel / cgroup.c
index 2bfc78f531b66ab764d07b303990216620216747..13774b3b39aac9b73e25ba34a366d5402b70df00 100644 (file)
@@ -4076,8 +4076,9 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
                set_bit(CGRP_CLONE_CHILDREN, &cgrp->flags);
 
        for_each_subsys(root, ss) {
-               struct cgroup_subsys_state *css = ss->create(cgrp);
+               struct cgroup_subsys_state *css;
 
+               css = ss->create(cgrp);
                if (IS_ERR(css)) {
                        err = PTR_ERR(css);
                        goto err_destroy;
@@ -4091,6 +4092,15 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
                /* At error, ->destroy() callback has to free assigned ID. */
                if (clone_children(parent) && ss->post_clone)
                        ss->post_clone(cgrp);
+
+               if (ss->broken_hierarchy && !ss->warned_broken_hierarchy &&
+                   parent->parent) {
+                       pr_warning("cgroup: %s (%d) created nested cgroup for controller \"%s\" which has incomplete hierarchy support. Nested cgroups may change behavior in the future.\n",
+                                  current->comm, current->pid, ss->name);
+                       if (!strcmp(ss->name, "memory"))
+                               pr_warning("cgroup: \"memory\" requires setting use_hierarchy to 1 on the root.\n");
+                       ss->warned_broken_hierarchy = true;
+               }
        }
 
        list_add(&cgrp->sibling, &cgrp->parent->children);
@@ -4451,24 +4461,8 @@ int __init_or_module cgroup_load_subsys(struct cgroup_subsys *ss)
        /* init base cftset */
        cgroup_init_cftsets(ss);
 
-       /*
-        * need to register a subsys id before anything else - for example,
-        * init_cgroup_css needs it.
-        */
        mutex_lock(&cgroup_mutex);
-       /* find the first empty slot in the array */
-       for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) {
-               if (subsys[i] == NULL)
-                       break;
-       }
-       if (i == CGROUP_SUBSYS_COUNT) {
-               /* maximum number of subsystems already registered! */
-               mutex_unlock(&cgroup_mutex);
-               return -EBUSY;
-       }
-       /* assign ourselves the subsys_id */
-       ss->subsys_id = i;
-       subsys[i] = ss;
+       subsys[ss->subsys_id] = ss;
 
        /*
         * no ss->create seems to need anything important in the ss struct, so
@@ -4477,7 +4471,7 @@ int __init_or_module cgroup_load_subsys(struct cgroup_subsys *ss)
        css = ss->create(dummytop);
        if (IS_ERR(css)) {
                /* failure case - need to deassign the subsys[] slot. */
-               subsys[i] = NULL;
+               subsys[ss->subsys_id] = NULL;
                mutex_unlock(&cgroup_mutex);
                return PTR_ERR(css);
        }
@@ -4493,7 +4487,7 @@ int __init_or_module cgroup_load_subsys(struct cgroup_subsys *ss)
                if (ret) {
                        dummytop->subsys[ss->subsys_id] = NULL;
                        ss->destroy(dummytop);
-                       subsys[i] = NULL;
+                       subsys[ss->subsys_id] = NULL;
                        mutex_unlock(&cgroup_mutex);
                        return ret;
                }