Commit 2344d7e4 authored by Johannes Weiner's avatar Johannes Weiner Committed by Linus Torvalds

mm: vmscan: remove all_unreclaimable()

Direct reclaim currently calls shrink_zones() to reclaim all members of
a zonelist, and if that wasn't successful it does another pass through
the same zonelist to check overall reclaimability.

Just check reclaimability in shrink_zones() directly and propagate the
result through the return value.  Then remove all_unreclaimable().
Signed-off-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Rik van Riel <riel@redhat.com>
Acked-by: default avatarMichal Hocko <mhocko@suse.cz>
Cc: Vlastimil Babka <vbabka@suse.cz>
Acked-by: default avatarMinchan Kim <minchan@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 0b06496a
...@@ -2244,9 +2244,10 @@ static inline bool should_continue_reclaim(struct zone *zone, ...@@ -2244,9 +2244,10 @@ static inline bool should_continue_reclaim(struct zone *zone,
} }
} }
static void shrink_zone(struct zone *zone, struct scan_control *sc) static bool shrink_zone(struct zone *zone, struct scan_control *sc)
{ {
unsigned long nr_reclaimed, nr_scanned; unsigned long nr_reclaimed, nr_scanned;
bool reclaimable = false;
do { do {
struct mem_cgroup *root = sc->target_mem_cgroup; struct mem_cgroup *root = sc->target_mem_cgroup;
...@@ -2290,8 +2291,13 @@ static void shrink_zone(struct zone *zone, struct scan_control *sc) ...@@ -2290,8 +2291,13 @@ static void shrink_zone(struct zone *zone, struct scan_control *sc)
sc->nr_scanned - nr_scanned, sc->nr_scanned - nr_scanned,
sc->nr_reclaimed - nr_reclaimed); sc->nr_reclaimed - nr_reclaimed);
if (sc->nr_reclaimed - nr_reclaimed)
reclaimable = true;
} while (should_continue_reclaim(zone, sc->nr_reclaimed - nr_reclaimed, } while (should_continue_reclaim(zone, sc->nr_reclaimed - nr_reclaimed,
sc->nr_scanned - nr_scanned, sc)); sc->nr_scanned - nr_scanned, sc));
return reclaimable;
} }
/* Returns true if compaction should go ahead for a high-order request */ /* Returns true if compaction should go ahead for a high-order request */
...@@ -2340,8 +2346,10 @@ static inline bool compaction_ready(struct zone *zone, int order) ...@@ -2340,8 +2346,10 @@ static inline bool compaction_ready(struct zone *zone, int order)
* *
* If a zone is deemed to be full of pinned pages then just give it a light * If a zone is deemed to be full of pinned pages then just give it a light
* scan then give up on it. * scan then give up on it.
*
* Returns true if a zone was reclaimable.
*/ */
static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc) static bool shrink_zones(struct zonelist *zonelist, struct scan_control *sc)
{ {
struct zoneref *z; struct zoneref *z;
struct zone *zone; struct zone *zone;
...@@ -2354,6 +2362,7 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc) ...@@ -2354,6 +2362,7 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc)
.gfp_mask = sc->gfp_mask, .gfp_mask = sc->gfp_mask,
}; };
enum zone_type requested_highidx = gfp_zone(sc->gfp_mask); enum zone_type requested_highidx = gfp_zone(sc->gfp_mask);
bool reclaimable = false;
/* /*
* If the number of buffer_heads in the machine exceeds the maximum * If the number of buffer_heads in the machine exceeds the maximum
...@@ -2414,10 +2423,17 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc) ...@@ -2414,10 +2423,17 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc)
&nr_soft_scanned); &nr_soft_scanned);
sc->nr_reclaimed += nr_soft_reclaimed; sc->nr_reclaimed += nr_soft_reclaimed;
sc->nr_scanned += nr_soft_scanned; sc->nr_scanned += nr_soft_scanned;
if (nr_soft_reclaimed)
reclaimable = true;
/* need some check for avoid more shrink_zone() */ /* need some check for avoid more shrink_zone() */
} }
shrink_zone(zone, sc); if (shrink_zone(zone, sc))
reclaimable = true;
if (global_reclaim(sc) &&
!reclaimable && zone_reclaimable(zone))
reclaimable = true;
} }
/* /*
...@@ -2439,26 +2455,8 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc) ...@@ -2439,26 +2455,8 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc)
* promoted it to __GFP_HIGHMEM. * promoted it to __GFP_HIGHMEM.
*/ */
sc->gfp_mask = orig_mask; sc->gfp_mask = orig_mask;
}
/* All zones in zonelist are unreclaimable? */
static bool all_unreclaimable(struct zonelist *zonelist,
struct scan_control *sc)
{
struct zoneref *z;
struct zone *zone;
for_each_zone_zonelist_nodemask(zone, z, zonelist, return reclaimable;
gfp_zone(sc->gfp_mask), sc->nodemask) {
if (!populated_zone(zone))
continue;
if (!cpuset_zone_allowed_hardwall(zone, GFP_KERNEL))
continue;
if (zone_reclaimable(zone))
return false;
}
return true;
} }
/* /*
...@@ -2482,6 +2480,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist, ...@@ -2482,6 +2480,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
{ {
unsigned long total_scanned = 0; unsigned long total_scanned = 0;
unsigned long writeback_threshold; unsigned long writeback_threshold;
bool zones_reclaimable;
delayacct_freepages_start(); delayacct_freepages_start();
...@@ -2492,7 +2491,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist, ...@@ -2492,7 +2491,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
vmpressure_prio(sc->gfp_mask, sc->target_mem_cgroup, vmpressure_prio(sc->gfp_mask, sc->target_mem_cgroup,
sc->priority); sc->priority);
sc->nr_scanned = 0; sc->nr_scanned = 0;
shrink_zones(zonelist, sc); zones_reclaimable = shrink_zones(zonelist, sc);
total_scanned += sc->nr_scanned; total_scanned += sc->nr_scanned;
if (sc->nr_reclaimed >= sc->nr_to_reclaim) if (sc->nr_reclaimed >= sc->nr_to_reclaim)
...@@ -2532,8 +2531,8 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist, ...@@ -2532,8 +2531,8 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
if (sc->compaction_ready) if (sc->compaction_ready)
return 1; return 1;
/* top priority shrink_zones still had more to do? don't OOM, then */ /* Any of the zones still reclaimable? Don't OOM. */
if (global_reclaim(sc) && !all_unreclaimable(zonelist, sc)) if (zones_reclaimable)
return 1; return 1;
return 0; return 0;
......
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