[PATCH] mm, vmscan: Make kswapd reclaim no more than needed

From: Hillf Danton
Date: Fri Jun 24 2016 - 05:00:28 EST


We stop reclaiming pages if any eligible zone is balanced.

Signed-off-by: Hillf Danton <hillf.zj@xxxxxxxxxxxxxxx>
---

--- a/mm/vmscan.c Thu Jun 23 17:56:34 2016
+++ b/mm/vmscan.c Fri Jun 24 16:45:58 2016
@@ -3185,15 +3185,10 @@ static int balance_pgdat(pg_data_t *pgda
if (!populated_zone(zone))
continue;

- if (!zone_balanced(zone, sc.order, classzone_idx)) {
- classzone_idx = i;
- break;
- }
+ if (zone_balanced(zone, sc.order, classzone_idx))
+ goto out;
}

- if (i < 0)
- goto out;
-
/*
* Do some background aging of the anon list, to give
* pages a chance to be referenced before reclaiming. All
@@ -3236,19 +3231,6 @@ static int balance_pgdat(pg_data_t *pgda
/* Check if kswapd should be suspending */
if (try_to_freeze() || kthread_should_stop())
break;
-
- /*
- * Stop reclaiming if any eligible zone is balanced and clear
- * node writeback or congested.
- */
- for (i = 0; i <= classzone_idx; i++) {
- zone = pgdat->node_zones + i;
- if (!populated_zone(zone))
- continue;
-
- if (zone_balanced(zone, sc.order, classzone_idx))
- goto out;
- }

/*
* Raise priority if scanning rate is too low or there was no
--