memcg: root_cgroup cannot reach mem_cgroup_move_parent
authorMichal Hocko <mhocko@suse.cz>
Fri, 26 Oct 2012 11:37:29 +0000 (13:37 +0200)
committerTejun Heo <tj@kernel.org>
Mon, 29 Oct 2012 23:22:21 +0000 (16:22 -0700)
The root cgroup cannot be destroyed so we never hit it down the
mem_cgroup_pre_destroy path and mem_cgroup_force_empty_write shouldn't
even try to do anything if called for the root.

This means that mem_cgroup_move_parent doesn't have to bother with the
root cgroup and it can assume it can always move charges upwards.

Signed-off-by: Michal Hocko <mhocko@suse.cz>
Reviewed-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Glauber Costa <glommer@parallels.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
mm/memcontrol.c

index 07d92b84f448107200e8851e0307fbd51fa8f6e2..916132a29b36d97d0aa2f8cfc594ef08f72b6206 100644 (file)
@@ -2715,9 +2715,7 @@ static int mem_cgroup_move_parent(struct page *page,
        unsigned long uninitialized_var(flags);
        int ret;
 
-       /* Is ROOT ? */
-       if (mem_cgroup_is_root(child))
-               return -EINVAL;
+       VM_BUG_ON(mem_cgroup_is_root(child));
 
        ret = -EBUSY;
        if (!get_page_unless_zero(page))
@@ -3823,6 +3821,8 @@ static int mem_cgroup_force_empty_write(struct cgroup *cont, unsigned int event)
        struct mem_cgroup *memcg = mem_cgroup_from_cont(cont);
        int ret;
 
+       if (mem_cgroup_is_root(memcg))
+               return -EINVAL;
        css_get(&memcg->css);
        ret = mem_cgroup_force_empty(memcg);
        css_put(&memcg->css);