]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
memcg,vmscan: do not break out targeted reclaim without reclaimed pages
authorMichal Hocko <mhocko@suse.cz>
Wed, 20 Feb 2013 02:14:04 +0000 (13:14 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 20 Feb 2013 05:52:23 +0000 (16:52 +1100)
Targeted (hard resp.  soft) reclaim has traditionally tried to scan one
group with decreasing priority until nr_to_reclaim (SWAP_CLUSTER_MAX
pages) is reclaimed or all priorities are exhausted.  The reclaim is then
retried until the limit is met.

This approach, however, doesn't work well with deeper hierarchies where
groups higher in the hierarchy do not have any or only very few pages
(this usually happens if those groups do not have any tasks and they have
only re-parented pages after some of their children is removed).  Those
groups are reclaimed with decreasing priority pointlessly as there is
nothing to reclaim from them.

An easiest fix is to break out of the memcg iteration loop in shrink_zone
only if the whole hierarchy has been visited or sufficient pages have been
reclaimed.  This is also more natural because the reclaimer expects that
the hierarchy under the given root is reclaimed.  As a result we can
simplify the soft limit reclaim which does its own iteration.

Signed-off-by: Michal Hocko <mhocko@suse.cz>
Reported-by: Ying Han <yinghan@google.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Tejun Heo <htejun@gmail.com>
Cc: Glauber Costa <glommer@parallels.com>
Cc: Li Zefan <lizefan@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/vmscan.c

index 292f50a2a6856e4cfdec1f7e7c5925949a1349a1..ff869d2db8cd4db62c99dc15f69104eba1a00924 100644 (file)
@@ -1973,18 +1973,17 @@ static void shrink_zone(struct zone *zone, struct scan_control *sc)
                        shrink_lruvec(lruvec, sc);
 
                        /*
-                        * Limit reclaim has historically picked one
-                        * memcg and scanned it with decreasing
-                        * priority levels until nr_to_reclaim had
-                        * been reclaimed.  This priority cycle is
-                        * thus over after a single memcg.
-                        *
-                        * Direct reclaim and kswapd, on the other
-                        * hand, have to scan all memory cgroups to
-                        * fulfill the overall scan target for the
+                        * Direct reclaim and kswapd have to scan all memory
+                        * cgroups to fulfill the overall scan target for the
                         * zone.
+                        *
+                        * Limit reclaim, on the other hand, only cares about
+                        * nr_to_reclaim pages to be reclaimed and it will
+                        * retry with decreasing priority if one round over the
+                        * whole hierarchy is not sufficient.
                         */
-                       if (!global_reclaim(sc)) {
+                       if (!global_reclaim(sc) &&
+                                       sc->nr_to_reclaim >= sc->nr_reclaimed) {
                                mem_cgroup_iter_break(root, memcg);
                                break;
                        }