History

Revert "mm: avoid waking kswapd for THP allocations when compaction is deferred or contended"

This reverts commit 782fd30406ecb9d9b082816abe0c6008fc72a7b0. We are going to reinstate the __GFP_NO_KSWAPD flag that has been removed, the removal reverted, and then removed again. Making this commit a pointless fixup for a problem that was caused by the removal of __GFP_NO_KSWAPD flag. The thing is, we really don't want to wake up kswapd for THP allocations (because they fail quite commonly under any kind of memory pressure, including when there is tons of memory free), and these patches were just trying to fix up the underlying bug: the original removal of __GFP_NO_KSWAPD in commit c654345924f7 ("mm: remove __GFP_NO_KSWAPD") was simply bogus.

Linus Torvalds committed 13 years ago

Commit 31f8d421 parent ed23ec41 file · +10 −27Browse files

Unified · Split

mm/page_alloc.c+10−27
@@ -2378,15 +2378,6 @@ bool gfp_pfmemalloc_allowed(gfp_t gfp_mask) · 2377 unmodified lines
23782378 return !!(gfp_to_alloc_flags(gfp_mask) & ALLOC_NO_WATERMARKS);
23792379 }
23802380
2381−/* Returns true if the allocation is likely for THP */
2382−static bool is_thp_alloc(gfp_t gfp_mask, unsigned int order)
2383−{
2384− if (order == pageblock_order &&
2385− (gfp_mask & (__GFP_MOVABLE|__GFP_REPEAT)) == __GFP_MOVABLE)
2386− return true;
2387− return false;
2388−}
2389−
23902381 static inline struct page *
23912382 __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
23922383 struct zonelist *zonelist, enum zone_type high_zoneidx,
@@ -2425,9 +2416,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, · 32 unmodified lines
24252416 goto nopage;
24262417
24272418 restart:
2428− /* The decision whether to wake kswapd for THP is made later */
2429− if (!is_thp_alloc(gfp_mask, order))
2430− wake_all_kswapd(order, zonelist, high_zoneidx,
2419+ wake_all_kswapd(order, zonelist, high_zoneidx,
24312420 zone_idx(preferred_zone));
24322421
24332422 /*
@@ -2498,21 +2487,15 @@ rebalance: · 64 unmodified lines
24982487 goto got_pg;
24992488 sync_migration = true;
25002489
2501− if (is_thp_alloc(gfp_mask, order)) {
2502− /*
2503− * If compaction is deferred for high-order allocations, it is
2504− * because sync compaction recently failed. If this is the case
2505− * and the caller requested a movable allocation that does not
2506− * heavily disrupt the system then fail the allocation instead
2507− * of entering direct reclaim.
2508− */
2509− if (deferred_compaction || contended_compaction)
2510− goto nopage;
2511−
2512− /* If process is willing to reclaim/compact then wake kswapd */
2513− wake_all_kswapd(order, zonelist, high_zoneidx,
2514− zone_idx(preferred_zone));
2515− }
2490+ /*
2491+ * If compaction is deferred for high-order allocations, it is because
2492+ * sync compaction recently failed. In this is the case and the caller
2493+ * requested a movable allocation that does not heavily disrupt the
2494+ * system then fail the allocation instead of entering direct reclaim.
2495+ */
2496+ if ((deferred_compaction || contended_compaction) &&
2497+ (gfp_mask & (__GFP_MOVABLE|__GFP_REPEAT)) == __GFP_MOVABLE)
2498+ goto nopage;
25162499
25172500 /* Try direct reclaim and then allocating */
25182501 page = __alloc_pages_direct_reclaim(gfp_mask, order,