Skip to content

Commit d23b834

Browse files
Michal Hockosfrothwell
Michal Hocko
authored andcommitted
mm: use watermark checks for __GFP_REPEAT high order allocations
__alloc_pages_slowpath retries costly allocations until at least order worth of pages were reclaimed or the watermark check for at least one zone would succeed after all reclaiming all pages if the reclaim hasn't made any progress. The first condition was added by a41f24e ("page allocator: smarter retry of costly-order allocations) and it assumed that lumpy reclaim could have created a page of the sufficient order. Lumpy reclaim, has been removed quite some time ago so the assumption doesn't hold anymore. It would be more appropriate to check the compaction progress instead but this patch simply removes the check and relies solely on the watermark check. To prevent from too many retries the no_progress_loops is not reseted after a reclaim which made progress because we cannot assume it helped high order situation. Only costly allocation requests depended on pages_reclaimed so we can drop it. Signed-off-by: Michal Hocko <[email protected]> Acked-by: Hillf Danton <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Mel Gorman <[email protected]> Cc: David Rientjes <[email protected]> Cc: Tetsuo Handa <[email protected]> Cc: Hillf Danton <[email protected]> Cc: KAMEZAWA Hiroyuki <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 1cae9d6 commit d23b834

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

mm/page_alloc.c

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3146,18 +3146,17 @@ static inline bool is_thp_gfp_mask(gfp_t gfp_mask)
31463146
* Checks whether it makes sense to retry the reclaim to make a forward progress
31473147
* for the given allocation request.
31483148
* The reclaim feedback represented by did_some_progress (any progress during
3149-
* the last reclaim round), pages_reclaimed (cumulative number of reclaimed
3150-
* pages) and no_progress_loops (number of reclaim rounds without any progress
3151-
* in a row) is considered as well as the reclaimable pages on the applicable
3152-
* zone list (with a backoff mechanism which is a function of
3149+
* the last reclaim round) and no_progress_loops (number of reclaim rounds without
3150+
* any progress in a row) is considered as well as the reclaimable pages on the
3151+
* applicable zone list (with a backoff mechanism which is a function of
31533152
* no_progress_loops).
31543153
*
31553154
* Returns true if a retry is viable or false to enter the oom path.
31563155
*/
31573156
static inline bool
31583157
should_reclaim_retry(gfp_t gfp_mask, unsigned order,
31593158
struct alloc_context *ac, int alloc_flags,
3160-
bool did_some_progress, unsigned long pages_reclaimed,
3159+
bool did_some_progress,
31613160
int no_progress_loops)
31623161
{
31633162
struct zone *zone;
@@ -3171,13 +3170,8 @@ should_reclaim_retry(gfp_t gfp_mask, unsigned order,
31713170
return false;
31723171

31733172
/* Do not retry high order allocations unless they are __GFP_REPEAT */
3174-
if (order > PAGE_ALLOC_COSTLY_ORDER) {
3175-
if (!(gfp_mask & __GFP_REPEAT) || pages_reclaimed >= (1<<order))
3176-
return false;
3177-
3178-
if (did_some_progress)
3179-
return true;
3180-
}
3173+
if (order > PAGE_ALLOC_COSTLY_ORDER && !(gfp_mask & __GFP_REPEAT))
3174+
return false;
31813175

31823176
/*
31833177
* Keep reclaiming pages while there is a chance this will lead
@@ -3246,7 +3240,6 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
32463240
bool can_direct_reclaim = gfp_mask & __GFP_DIRECT_RECLAIM;
32473241
struct page *page = NULL;
32483242
int alloc_flags;
3249-
unsigned long pages_reclaimed = 0;
32503243
unsigned long did_some_progress;
32513244
enum migrate_mode migration_mode = MIGRATE_ASYNC;
32523245
bool deferred_compaction = false;
@@ -3403,16 +3396,18 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
34033396
if (gfp_mask & __GFP_NORETRY)
34043397
goto noretry;
34053398

3406-
if (did_some_progress) {
3399+
/*
3400+
* Costly allocations might have made a progress but this doesn't mean
3401+
* their order will become available due to high fragmentation so do
3402+
* not reset the no progress counter for them
3403+
*/
3404+
if (did_some_progress && order <= PAGE_ALLOC_COSTLY_ORDER)
34073405
no_progress_loops = 0;
3408-
pages_reclaimed += did_some_progress;
3409-
} else {
3406+
else
34103407
no_progress_loops++;
3411-
}
34123408

34133409
if (should_reclaim_retry(gfp_mask, order, ac, alloc_flags,
3414-
did_some_progress > 0, pages_reclaimed,
3415-
no_progress_loops))
3410+
did_some_progress > 0, no_progress_loops))
34163411
goto retry;
34173412

34183413
/* Reclaim has failed us, start killing things */

0 commit comments

Comments
 (0)