For high-order allocations, kswapd will either manage to create the free page by reclaim itself, or reclaim just enough to let compaction proceed, set its order to 0 (so that watermark checks don't look for high-order pages anymore) and goes to sleep while waking up kcompactd. This doesn't work as expected in case when kswapd cannot reclaim compact_gap() worth of pages (nor balance the node by itself) even at highest priority. Then it won't go to sleep and wake up kcompactd. This patch fixes this corner case by setting sc.order to 0 in such case. Signed-off-by: Vlastimil Babka <vbabka@xxxxxxx> --- mm/vmscan.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mm/vmscan.c b/mm/vmscan.c index ae897a85e7f3..a3f914c88dea 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -3340,6 +3340,14 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx) if (!sc.nr_reclaimed) pgdat->kswapd_failures++; + /* + * Even at highest priority, we could not reclaim enough to balance + * the zone or reclaim over compact_gap() (see kswapd_shrink_node()) + * so we better give up now and wake up kcompactd instead. + */ + if (sc.order > 0 && sc.priority == 0) + sc.order = 0; + out: snapshot_refaults(NULL, pgdat); /* -- 2.13.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>