Commit 29423e77 authored by David Rientjes's avatar David Rientjes Committed by Linus Torvalds

oom: suppress show_mem() for many nodes in irq context on page alloc failure

When a page allocation failure occurs, show_mem() is called to dump the
state of the VM so users may understand what happened to get into that
condition.

This output, however, can be extremely verbose.  In irq context, it may
result in significant delays that incur NMI watchdog timeouts when the
machine is large (we use CONFIG_NODES_SHIFT > 8 here to define a "large"
machine since the length of the show_mem() output is proportional to the
number of possible nodes).

This patch suppresses the show_mem() call in irq context when the kernel
has CONFIG_NODES_SHIFT > 8.
Signed-off-by: default avatarDavid Rientjes <rientjes@google.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ddd588b5
...@@ -1714,6 +1714,20 @@ get_page_from_freelist(gfp_t gfp_mask, nodemask_t *nodemask, unsigned int order, ...@@ -1714,6 +1714,20 @@ get_page_from_freelist(gfp_t gfp_mask, nodemask_t *nodemask, unsigned int order,
return page; return page;
} }
/*
* Large machines with many possible nodes should not always dump per-node
* meminfo in irq context.
*/
static inline bool should_suppress_show_mem(void)
{
bool ret = false;
#if NODES_SHIFT > 8
ret = in_interrupt();
#endif
return ret;
}
static inline int static inline int
should_alloc_retry(gfp_t gfp_mask, unsigned int order, should_alloc_retry(gfp_t gfp_mask, unsigned int order,
unsigned long pages_reclaimed) unsigned long pages_reclaimed)
...@@ -2161,6 +2175,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, ...@@ -2161,6 +2175,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
" order:%d, mode:0x%x\n", " order:%d, mode:0x%x\n",
current->comm, order, gfp_mask); current->comm, order, gfp_mask);
dump_stack(); dump_stack();
if (!should_suppress_show_mem())
show_mem(); show_mem();
} }
return page; return page;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment