mm: compaction: simplify should_compact_retry()
The different branches for retry are unnecessarily complicated. There are really only three outcomes: progress (retry n times), skipped (retry if reclaim can help), failed (retry with higher priority). Rearrange the branches and the retry counter to make it simpler. [hannes@cmpxchg.org: restore behavior when hitting max_retries] Link: https://lkml.kernel.org/r/20230602144705.GB161817@cmpxchg.org Link: https://lkml.kernel.org/r/20230519123959.77335-3-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>
This commit is contained in:
parent
ecd8b2928f
commit
511a69b27f
@ -3469,21 +3469,6 @@ should_compact_retry(struct alloc_context *ac, int order, int alloc_flags,
|
|||||||
if (fatal_signal_pending(current))
|
if (fatal_signal_pending(current))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/*
|
|
||||||
* 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)++;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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 (compact_result == COMPACT_COMPLETE)
|
|
||||||
goto check_priority;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Compaction was skipped due to a lack of free order-0
|
* Compaction was skipped due to a lack of free order-0
|
||||||
* migration targets. Continue if reclaim can help.
|
* migration targets. Continue if reclaim can help.
|
||||||
@ -3494,35 +3479,31 @@ should_compact_retry(struct alloc_context *ac, int order, int alloc_flags,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If compaction backed due to being deferred, due to
|
* Compaction managed to coalesce some page blocks, but the
|
||||||
* contended locks in async mode, or due to scanners meeting
|
* allocation failed presumably due to a race. Retry some.
|
||||||
* after a partial scan, retry with increased priority.
|
|
||||||
*/
|
*/
|
||||||
if (compact_result == COMPACT_DEFERRED ||
|
if (compact_result == COMPACT_SUCCESS) {
|
||||||
compact_result == COMPACT_CONTENDED ||
|
/*
|
||||||
compact_result == COMPACT_PARTIAL_SKIPPED)
|
* !costly requests are much more important than
|
||||||
goto check_priority;
|
* __GFP_RETRY_MAYFAIL costly ones because they are de
|
||||||
|
* facto nofail and invoke OOM killer to move on while
|
||||||
|
* costly can fail and users are ready to cope with
|
||||||
|
* that. 1/4 retries is rather arbitrary but we would
|
||||||
|
* need much more detailed feedback from compaction to
|
||||||
|
* make a better decision.
|
||||||
|
*/
|
||||||
|
if (order > PAGE_ALLOC_COSTLY_ORDER)
|
||||||
|
max_retries /= 4;
|
||||||
|
|
||||||
/*
|
if (++(*compaction_retries) <= max_retries) {
|
||||||
* !costly requests are much more important than __GFP_RETRY_MAYFAIL
|
ret = true;
|
||||||
* costly ones because they are de facto nofail and invoke OOM
|
goto out;
|
||||||
* killer to move on while costly can fail and users are ready
|
}
|
||||||
* to cope with that. 1/4 retries is rather arbitrary but we
|
|
||||||
* would need much more detailed feedback from compaction to
|
|
||||||
* make a better decision.
|
|
||||||
*/
|
|
||||||
if (order > PAGE_ALLOC_COSTLY_ORDER)
|
|
||||||
max_retries /= 4;
|
|
||||||
if (*compaction_retries <= max_retries) {
|
|
||||||
ret = true;
|
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure there are attempts at the highest priority if we exhausted
|
* Compaction failed. Retry with increasing priority.
|
||||||
* all retries or failed at the lower priorities.
|
|
||||||
*/
|
*/
|
||||||
check_priority:
|
|
||||||
min_priority = (order > PAGE_ALLOC_COSTLY_ORDER) ?
|
min_priority = (order > PAGE_ALLOC_COSTLY_ORDER) ?
|
||||||
MIN_COMPACT_COSTLY_PRIORITY : MIN_COMPACT_PRIORITY;
|
MIN_COMPACT_COSTLY_PRIORITY : MIN_COMPACT_PRIORITY;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user