mm: kswapd: reset kswapd_max_order and classzone_idx after reading
Mel Gorman [Thu, 13 Jan 2011 23:46:23 +0000 (15:46 -0800)]
When kswapd wakes up, it reads its order and classzone from pgdat and
calls balance_pgdat.  While its awake, it potentially reclaimes at a high
order and a low classzone index.  This might have been a once-off that was
not required by subsequent callers.  However, because the pgdat values
were not reset, they remain artifically high while balance_pgdat() is
running and potentially kswapd enters a second unnecessary reclaim cycle.
Reset the pgdat order and classzone index after reading.

Signed-off-by: Mel Gorman <>
Reviewed-by: Minchan Kim <>
Reviewed-by: KAMEZAWA Hiroyuki <>
Reviewed-by: Eric B Munson <>
Cc: Simon Kirby <>
Cc: KOSAKI Motohiro <>
Cc: Shaohua Li <>
Cc: Dave Hansen <>
Cc: Johannes Weiner <>
Cc: Rik van Riel <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>


index 46711f0..dafb9d9 100644 (file)
@@ -2653,6 +2653,8 @@ static int kswapd(void *p)
                        kswapd_try_to_sleep(pgdat, order);
                        order = pgdat->kswapd_max_order;
                        classzone_idx = pgdat->classzone_idx;
+                       pgdat->kswapd_max_order = 0;
+                       pgdat->classzone_idx = MAX_NR_ZONES - 1;
                ret = try_to_freeze();