Commit bc2f2e7f authored by Vladimir Davydov's avatar Vladimir Davydov Committed by Linus Torvalds

memcg: simplify unreclaimable groups handling in soft limit reclaim

If we fail to reclaim anything from a cgroup during a soft reclaim pass
we want to get the next largest cgroup exceeding its soft limit. To
achieve this, we should obviously remove the current group from the tree
and then pick the largest group. Currently we have a weird loop instead.
Let's simplify it.
Signed-off-by: default avatarVladimir Davydov <vdavydov@parallels.com>
Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Acked-by: default avatarMichal Hocko <mhocko@suse.cz>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 6f7c97e8
...@@ -3518,34 +3518,16 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, ...@@ -3518,34 +3518,16 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,
nr_reclaimed += reclaimed; nr_reclaimed += reclaimed;
*total_scanned += nr_scanned; *total_scanned += nr_scanned;
spin_lock_irq(&mctz->lock); spin_lock_irq(&mctz->lock);
__mem_cgroup_remove_exceeded(mz, mctz);
/* /*
* If we failed to reclaim anything from this memory cgroup * If we failed to reclaim anything from this memory cgroup
* it is time to move on to the next cgroup * it is time to move on to the next cgroup
*/ */
next_mz = NULL; next_mz = NULL;
if (!reclaimed) { if (!reclaimed)
do { next_mz = __mem_cgroup_largest_soft_limit_node(mctz);
/*
* Loop until we find yet another one.
*
* By the time we get the soft_limit lock
* again, someone might have aded the
* group back on the RB tree. Iterate to
* make sure we get a different mem.
* mem_cgroup_largest_soft_limit_node returns
* NULL if no other cgroup is present on
* the tree
*/
next_mz =
__mem_cgroup_largest_soft_limit_node(mctz);
if (next_mz == mz)
css_put(&next_mz->memcg->css);
else /* next_mz == NULL or other memcg */
break;
} while (1);
}
__mem_cgroup_remove_exceeded(mz, mctz);
excess = soft_limit_excess(mz->memcg); excess = soft_limit_excess(mz->memcg);
/* /*
* One school of thought says that we should not add * One school of thought says that we should not add
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment