mm, show_mem: suppress page counts in non-blockable contexts

On large systems with a lot of memory, walking all RAM to determine page
types may take a half second or even more.

In non-blockable contexts, the page allocator will emit a page allocation
failure warning unless __GFP_NOWARN is specified.  In such contexts, irqs
are typically disabled and such a lengthy delay may even result in NMI
watchdog timeouts.

To fix this, suppress the page walk in such contexts when printing the
page allocation failure warning.

Signed-off-by: David Rientjes <rientjes@google.com>
Cc: Mel Gorman <mgorman@suse.de>
Acked-by: Michal Hocko <mhocko@suse.cz>
Cc: Dave Hansen <dave@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
David Rientjes 2013-04-29 15:06:11 -07:00 committed by Linus Torvalds
parent fe0bfaaff8
commit 4b59e6c473
8 changed files with 24 additions and 1 deletions

View file

@ -2002,6 +2002,13 @@ void warn_alloc_failed(gfp_t gfp_mask, int order, const char *fmt, ...)
debug_guardpage_minorder() > 0)
return;
/*
* Walking all memory to count page types is very expensive and should
* be inhibited in non-blockable contexts.
*/
if (!(gfp_mask & __GFP_WAIT))
filter |= SHOW_MEM_FILTER_PAGE_COUNT;
/*
* This documents exceptions given to allocations in certain
* contexts that are allowed to allocate outside current's set