Skip to content

Commit 63f53de

Browse files
Michal Hockotorvalds
Michal Hocko
authored andcommitted
mm: warn about allocations which stall for too long
Currently we do warn only about allocation failures but small allocations are basically nofail and they might loop in the page allocator for a long time. Especially when the reclaim cannot make any progress - e.g. GFP_NOFS cannot invoke the oom killer and rely on a different context to make a forward progress in case there is a lot memory used by filesystems. Give us at least a clue when something like this happens and warn about allocations which take more than 10s. Print the basic allocation context information along with the cumulative time spent in the allocation as well as the allocation stack. Repeat the warning after every 10 seconds so that we know that the problem is permanent rather than ephemeral. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Michal Hocko <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: Tetsuo Handa <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Dave Hansen <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 7877cdc commit 63f53de

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

mm/page_alloc.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3493,6 +3493,8 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
34933493
enum compact_result compact_result;
34943494
int compaction_retries = 0;
34953495
int no_progress_loops = 0;
3496+
unsigned long alloc_start = jiffies;
3497+
unsigned int stall_timeout = 10 * HZ;
34963498

34973499
/*
34983500
* In the slowpath, we sanity check order to avoid ever trying to
@@ -3648,6 +3650,14 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
36483650
if (order > PAGE_ALLOC_COSTLY_ORDER && !(gfp_mask & __GFP_REPEAT))
36493651
goto nopage;
36503652

3653+
/* Make sure we know about allocations which stall for too long */
3654+
if (time_after(jiffies, alloc_start + stall_timeout)) {
3655+
warn_alloc(gfp_mask,
3656+
"page alloction stalls for %ums, order:%u\n",
3657+
jiffies_to_msecs(jiffies-alloc_start), order);
3658+
stall_timeout += 10 * HZ;
3659+
}
3660+
36513661
if (should_reclaim_retry(gfp_mask, order, ac, alloc_flags,
36523662
did_some_progress > 0, &no_progress_loops))
36533663
goto retry;

0 commit comments

Comments
 (0)