From: Vlastimil Babka Date: Sat, 10 Sep 2016 10:34:15 +0000 (+1000) Subject: mm, compaction: more reliably increase direct compaction priority X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=f07d3d68e73d39c35b604614a74eb024c6873244;p=deliverable%2Flinux.git mm, compaction: more reliably increase direct compaction priority During reclaim/compaction loop, compaction priority can be increased by the should_compact_retry() function, but the current code is not optimal. Priority is only increased when compaction_failed() is true, which means that compaction has scanned the whole zone. This may not happen even after multiple attempts with a lower priority due to parallel activity, so we might needlessly struggle on the lower priorities and possibly run out of compaction retry attempts in the process. After this patch we are guaranteed at least one attempt at the highest compaction priority even if we exhaust all retries at the lower priorities. Link: http://lkml.kernel.org/r/20160906135258.18335-3-vbabka@suse.cz Signed-off-by: Vlastimil Babka Cc: Michal Hocko Cc: Mel Gorman Cc: Joonsoo Kim Cc: David Rientjes Cc: Rik van Riel Cc: Tetsuo Handa Signed-off-by: Andrew Morton --- diff --git a/mm/page_alloc.c b/mm/page_alloc.c index bc0d3c78056c..cf2c989528bb 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3172,13 +3172,8 @@ should_compact_retry(struct alloc_context *ac, int order, int alloc_flags, * so it doesn't really make much sense to retry except when the * failure could be caused by insufficient priority */ - if (compaction_failed(compact_result)) { - if (*compact_priority > MIN_COMPACT_PRIORITY) { - (*compact_priority)--; - return true; - } - return false; - } + if (compaction_failed(compact_result)) + goto check_priority; /* * make sure the compaction wasn't deferred or didn't bail out early @@ -3202,6 +3197,15 @@ should_compact_retry(struct alloc_context *ac, int order, int alloc_flags, if (compaction_retries <= max_retries) return true; + /* + * Make sure there is at least one attempt at the highest priority + * if we exhausted all retries at the lower priorities + */ +check_priority: + if (*compact_priority > MIN_COMPACT_PRIORITY) { + (*compact_priority)--; + return true; + } return false; } #else