From 114b0865dff32dd82a73d345a3c1907015d08d1f Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Wed, 2 Jun 2004 17:58:03 -0700 Subject: [PATCH] [PATCH] shrink_all_memory() fixes - Off-by-one in balance_pgdat means that we're not scanning the zones all the way down to priority=0. - Always set zone->temp_priority in shrink_caches(). I'm not sure why I had the `if (zone->free_pages < zone->pages_high)' test in there, but it's preventing us from setting ->prev_priority correctly on the try_to_free_pages() path. - Set zone->prev_priority to the current priority if it's currently a "lower" priority. This allows us to build up the pressure on mapped pages on the first scanning pass rather than only on successive passes. Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/vmscan.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 2a111c86b9126..f0ec7d2c67d31 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -813,8 +813,9 @@ shrink_caches(struct zone **zones, int priority, int *total_scanned, struct zone *zone = zones[i]; int max_scan; - if (zone->free_pages < zone->pages_high) - zone->temp_priority = priority; + zone->temp_priority = priority; + if (zone->prev_priority > priority) + zone->prev_priority = priority; if (zone->all_unreclaimable && priority != DEF_PRIORITY) continue; /* Let kswapd poll it */ @@ -945,7 +946,7 @@ static int balance_pgdat(pg_data_t *pgdat, int nr_pages, struct page_state *ps) zone->temp_priority = DEF_PRIORITY; } - for (priority = DEF_PRIORITY; priority; priority--) { + for (priority = DEF_PRIORITY; priority >= 0; priority--) { int all_zones_ok = 1; int end_zone = 0; /* Inclusive. 0 = ZONE_DMA */ @@ -995,6 +996,8 @@ scan: all_zones_ok = 0; } zone->temp_priority = priority; + if (zone->prev_priority > priority) + zone->prev_priority = priority; max_scan = (zone->nr_active + zone->nr_inactive) >> priority; reclaimed = shrink_zone(zone, max_scan, GFP_KERNEL, -- 2.53.0