summaryrefslogtreecommitdiff
path: root/mm/page_alloc.c
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2023-05-19 14:39:55 +0200
committerAndrew Morton <akpm@linux-foundation.org>2023-06-09 16:25:36 -0700
commitecd8b2928f2efc7b678b361d51920c15b5ef3885 (patch)
tree7fd1329d9f577d3ba397841ef301fb08a2fa2e02 /mm/page_alloc.c
parent62069aace145658bc8ce79cbf7b6cf611db4a22f (diff)
mm: compaction: remove compaction result helpers
Patch series "mm: compaction: cleanups & simplifications". These compaction cleanups are split out from the huge page allocator series[1], as requested by reviewer feedback. [1] https://lore.kernel.org/linux-mm/20230418191313.268131-1-hannes@cmpxchg.org/ This patch (of 5): The compaction result helpers encode quirks that are specific to the allocator's retry logic. E.g. COMPACT_SUCCESS and COMPACT_COMPLETE actually represent failures that should be retried upon, and so on. I frequently found myself pulling up the helper implementation in order to understand and work on the retry logic. They're not quite clean abstractions; rather they split the retry logic into two locations. Remove the helpers and inline the checks. Then comment on the result interpretations directly where the decision making happens. Link: https://lkml.kernel.org/r/20230519123959.77335-1-hannes@cmpxchg.org Link: https://lkml.kernel.org/r/20230519123959.77335-2-hannes@cmpxchg.org Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: Mel Gorman <mgorman@techsingularity.net> Cc: Michal Hocko <mhocko@suse.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r--mm/page_alloc.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index b9a9ba2db9e9..e3a3ebc2dfce 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3469,35 +3469,39 @@ should_compact_retry(struct alloc_context *ac, int order, int alloc_flags,
if (fatal_signal_pending(current))
return false;
- if (compaction_made_progress(compact_result))
+ /*
+ * Compaction managed to coalesce some page blocks, but the
+ * allocation failed presumably due to a race. Retry some.
+ */
+ if (compact_result == COMPACT_SUCCESS)
(*compaction_retries)++;
/*
- * compaction considers all the zone as desperately out of memory
- * so it doesn't really make much sense to retry except when the
+ * All zones were scanned completely and still no result. 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_result == COMPACT_COMPLETE)
goto check_priority;
/*
- * compaction was skipped because there are not enough order-0 pages
- * to work with, so we retry only if it looks like reclaim can help.
+ * Compaction was skipped due to a lack of free order-0
+ * migration targets. Continue if reclaim can help.
*/
- if (compaction_needs_reclaim(compact_result)) {
+ if (compact_result == COMPACT_SKIPPED) {
ret = compaction_zonelist_suitable(ac, order, alloc_flags);
goto out;
}
/*
- * make sure the compaction wasn't deferred or didn't bail out early
- * due to locks contention before we declare that we should give up.
- * But the next retry should use a higher priority if allowed, so
- * we don't just keep bailing out endlessly.
+ * If compaction backed due to being deferred, due to
+ * contended locks in async mode, or due to scanners meeting
+ * after a partial scan, retry with increased priority.
*/
- if (compaction_withdrawn(compact_result)) {
+ if (compact_result == COMPACT_DEFERRED ||
+ compact_result == COMPACT_CONTENDED ||
+ compact_result == COMPACT_PARTIAL_SKIPPED)
goto check_priority;
- }
/*
* !costly requests are much more important than __GFP_RETRY_MAYFAIL