Skip to content

Commit

Permalink
vmscan: check high watermark after shrink zone
Browse files Browse the repository at this point in the history
Kswapd checks that zone has sufficient pages free via zone_watermark_ok().

If any zone doesn't have enough pages, we set all_zones_ok to zero.
!all_zone_ok makes kswapd retry rather than sleeping.

I think the watermark check before shrink_zone() is pointless.  Only after
kswapd has tried to shrink the zone is the check meaningful.

Move the check to after the call to shrink_zone().

[akpm@linux-foundation.org: fix comment, layout]
Signed-off-by: Minchan Kim <minchan.kim@gmail.com>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Rik van Riel <riel@redhat.com>
Reviewed-by: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Minchan Kim authored and Linus Torvalds committed Mar 6, 2010
1 parent 59e99e5 commit 45973d7
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions mm/vmscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -2060,9 +2060,6 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order)
priority != DEF_PRIORITY)
continue;

if (!zone_watermark_ok(zone, order,
high_wmark_pages(zone), end_zone, 0))
all_zones_ok = 0;
temp_priority[i] = priority;
sc.nr_scanned = 0;
note_zone_scanning_priority(zone, priority);
Expand Down Expand Up @@ -2102,13 +2099,18 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order)
total_scanned > sc.nr_reclaimed + sc.nr_reclaimed / 2)
sc.may_writepage = 1;

/*
* We are still under min water mark. it mean we have
* GFP_ATOMIC allocation failure risk. Hurry up!
*/
if (!zone_watermark_ok(zone, order, min_wmark_pages(zone),
end_zone, 0))
has_under_min_watermark_zone = 1;
if (!zone_watermark_ok(zone, order,
high_wmark_pages(zone), end_zone, 0)) {
all_zones_ok = 0;
/*
* We are still under min water mark. This
* means that we have a GFP_ATOMIC allocation
* failure risk. Hurry up!
*/
if (!zone_watermark_ok(zone, order,
min_wmark_pages(zone), end_zone, 0))
has_under_min_watermark_zone = 1;
}

}
if (all_zones_ok)
Expand Down

0 comments on commit 45973d7

Please sign in to comment.