[PATCH] mm: stop kswapd's infinite loop at high order allocation

From: Mel Gorman
Date: Tue Dec 30 2008 - 13:53:23 EST


Wassim Dagash reported the following (editted) kswapd infinite loop problem.

kswapd runs in some infinite loop trying to swap until order 10 of zone
highmem is OK.... kswapd will continue to try to balance order 10 of zone
highmem forever (or until someone release a very large chunk of highmem).

For costly high-order allocations, the system may never be balanced due to
fragmentation but kswapd should not infinitely loop as a result. The
following patch lets kswapd stop reclaiming in the event it cannot
balance zones and the order is high-order.

Reported-by: wassim dagash <wassim.dagash@xxxxxxxxx>
Signed-off-by: Mel Gorman <mel@xxxxxxxxx>

---
mm/vmscan.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 62e7f62..7b0f412 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1867,7 +1867,16 @@ out:

zone->prev_priority = temp_priority[i];
}
- if (!all_zones_ok) {
+
+ /*
+ * If zones are still not balanced, loop again and continue attempting
+ * to rebalance the system. For high-order allocations, fragmentation
+ * can prevent the zones being rebalanced no matter how hard kswapd
+ * works, particularly on systems with little or no swap. For
+ * high-orders, just give up and assume interested processes will
+ * either direct reclaim or wake up kswapd again as necessary.
+ */
+ if (!all_zones_ok && sc.order == 0) {
cond_resched();

try_to_freeze();

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/