[PATCH] ction-abstract-compaction-feedback-to-helpers-fix

From: Michal Hocko
Date: Mon Apr 11 2016 - 11:38:22 EST


Preserve the original thp back off checks to not introduce any
functional changes as per Vlastimil.

Signed-off-by: Michal Hocko <mhocko@xxxxxxxx>
---
mm/page_alloc.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index c05de84c8157..c37e6d1ad643 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3362,12 +3362,25 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
if (page)
goto got_pg;

- /*
- * Checks for THP-specific high-order allocations and back off
- * if the the compaction backed off
- */
- if (is_thp_gfp_mask(gfp_mask) && compaction_withdrawn(compact_result))
- goto nopage;
+ /* Checks for THP-specific high-order allocations */
+ if (is_thp_gfp_mask(gfp_mask)) {
+ /*
+ * If compaction is deferred for high-order allocations, it is
+ * because sync compaction recently failed. If this is the case
+ * and the caller requested a THP allocation, we do not want
+ * to heavily disrupt the system, so we fail the allocation
+ * instead of entering direct reclaim.
+ */
+ if (compact_result == COMPACT_DEFERRED)
+ goto nopage;
+
+ /*
+ * Compaction is contended so rather back off than cause
+ * excessive stalls.
+ */
+ if(compact_result == COMPACT_CONTENDED)
+ goto nopage;
+ }

/*
* It can become very expensive to allocate transparent hugepages at
--
2.8.0.rc3

--
Michal Hocko
SUSE Labs