mm: memcg: deprecate the non-hierarchical mode
[linux-2.6-microblaze.git] / mm / memcontrol.c
index 466d9ae..fc18a2b 100644 (file)
@@ -1141,12 +1141,6 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root,
        if (prev && !reclaim)
                pos = prev;
 
-       if (!root->use_hierarchy && root != root_mem_cgroup) {
-               if (prev)
-                       goto out;
-               return root;
-       }
-
        rcu_read_lock();
 
        if (reclaim) {
@@ -1226,7 +1220,6 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root,
 
 out_unlock:
        rcu_read_unlock();
-out:
        if (prev && prev != root)
                css_put(&prev->css);
 
@@ -3461,10 +3454,7 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order,
 }
 
 /*
- * Test whether @memcg has children, dead or alive.  Note that this
- * function doesn't care whether @memcg has use_hierarchy enabled and
- * returns %true if there are child csses according to the cgroup
- * hierarchy.  Testing use_hierarchy is the caller's responsibility.
+ * Test whether @memcg has children, dead or alive.
  */
 static inline bool memcg_has_children(struct mem_cgroup *memcg)
 {
@@ -3524,37 +3514,20 @@ static ssize_t mem_cgroup_force_empty_write(struct kernfs_open_file *of,
 static u64 mem_cgroup_hierarchy_read(struct cgroup_subsys_state *css,
                                     struct cftype *cft)
 {
-       return mem_cgroup_from_css(css)->use_hierarchy;
+       return 1;
 }
 
 static int mem_cgroup_hierarchy_write(struct cgroup_subsys_state *css,
                                      struct cftype *cft, u64 val)
 {
-       int retval = 0;
-       struct mem_cgroup *memcg = mem_cgroup_from_css(css);
-       struct mem_cgroup *parent_memcg = mem_cgroup_from_css(memcg->css.parent);
-
-       if (memcg->use_hierarchy == val)
+       if (val == 1)
                return 0;
 
-       /*
-        * If parent's use_hierarchy is set, we can't make any modifications
-        * in the child subtrees. If it is unset, then the change can
-        * occur, provided the current cgroup has no children.
-        *
-        * For the root cgroup, parent_mem is NULL, we allow value to be
-        * set if there are no children.
-        */
-       if ((!parent_memcg || !parent_memcg->use_hierarchy) &&
-                               (val == 1 || val == 0)) {
-               if (!memcg_has_children(memcg))
-                       memcg->use_hierarchy = val;
-               else
-                       retval = -EBUSY;
-       } else
-               retval = -EINVAL;
+       pr_warn_once("Non-hierarchical mode is deprecated. "
+                    "Please report your usecase to linux-mm@kvack.org if you "
+                    "depend on this functionality.\n");
 
-       return retval;
+       return -EINVAL;
 }
 
 static unsigned long mem_cgroup_usage(struct mem_cgroup *memcg, bool swap)
@@ -3742,8 +3715,6 @@ static void memcg_offline_kmem(struct mem_cgroup *memcg)
                child = mem_cgroup_from_css(css);
                BUG_ON(child->kmemcg_id != kmemcg_id);
                child->kmemcg_id = parent->kmemcg_id;
-               if (!memcg->use_hierarchy)
-                       break;
        }
        rcu_read_unlock();
 
@@ -5334,38 +5305,22 @@ mem_cgroup_css_alloc(struct cgroup_subsys_state *parent_css)
        if (parent) {
                memcg->swappiness = mem_cgroup_swappiness(parent);
                memcg->oom_kill_disable = parent->oom_kill_disable;
-       }
-       if (!parent) {
-               page_counter_init(&memcg->memory, NULL);
-               page_counter_init(&memcg->swap, NULL);
-               page_counter_init(&memcg->kmem, NULL);
-               page_counter_init(&memcg->tcpmem, NULL);
-       } else if (parent->use_hierarchy) {
-               memcg->use_hierarchy = true;
+
                page_counter_init(&memcg->memory, &parent->memory);
                page_counter_init(&memcg->swap, &parent->swap);
                page_counter_init(&memcg->kmem, &parent->kmem);
                page_counter_init(&memcg->tcpmem, &parent->tcpmem);
        } else {
-               page_counter_init(&memcg->memory, &root_mem_cgroup->memory);
-               page_counter_init(&memcg->swap, &root_mem_cgroup->swap);
-               page_counter_init(&memcg->kmem, &root_mem_cgroup->kmem);
-               page_counter_init(&memcg->tcpmem, &root_mem_cgroup->tcpmem);
-               /*
-                * Deeper hierachy with use_hierarchy == false doesn't make
-                * much sense so let cgroup subsystem know about this
-                * unfortunate state in our controller.
-                */
-               if (parent != root_mem_cgroup)
-                       memory_cgrp_subsys.broken_hierarchy = true;
-       }
+               page_counter_init(&memcg->memory, NULL);
+               page_counter_init(&memcg->swap, NULL);
+               page_counter_init(&memcg->kmem, NULL);
+               page_counter_init(&memcg->tcpmem, NULL);
 
-       /* The following stuff does not apply to the root */
-       if (!parent) {
                root_mem_cgroup = memcg;
                return &memcg->css;
        }
 
+       /* The following stuff does not apply to the root */
        error = memcg_online_kmem(memcg);
        if (error)
                goto fail;
@@ -6202,24 +6157,6 @@ static void mem_cgroup_move_task(void)
 }
 #endif
 
-/*
- * Cgroup retains root cgroups across [un]mount cycles making it necessary
- * to verify whether we're attached to the default hierarchy on each mount
- * attempt.
- */
-static void mem_cgroup_bind(struct cgroup_subsys_state *root_css)
-{
-       /*
-        * use_hierarchy is forced on the default hierarchy.  cgroup core
-        * guarantees that @root doesn't have any children, so turning it
-        * on for the root memcg is enough.
-        */
-       if (cgroup_subsys_on_dfl(memory_cgrp_subsys))
-               root_mem_cgroup->use_hierarchy = true;
-       else
-               root_mem_cgroup->use_hierarchy = false;
-}
-
 static int seq_puts_memcg_tunable(struct seq_file *m, unsigned long value)
 {
        if (value == PAGE_COUNTER_MAX)
@@ -6557,7 +6494,6 @@ struct cgroup_subsys memory_cgrp_subsys = {
        .can_attach = mem_cgroup_can_attach,
        .cancel_attach = mem_cgroup_cancel_attach,
        .post_attach = mem_cgroup_move_task,
-       .bind = mem_cgroup_bind,
        .dfl_cftypes = memory_files,
        .legacy_cftypes = mem_cgroup_legacy_files,
        .early_init = 0,