]> git.hungrycats.org Git - linux/commitdiff
mm, show_mem: suppress page counts in non-blockable contexts
authorDavid Rientjes <rientjes@google.com>
Mon, 29 Apr 2013 22:06:11 +0000 (15:06 -0700)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 26 Oct 2013 20:06:13 +0000 (21:06 +0100)
commit 4b59e6c4730978679b414a8da61514a2518da512 upstream.

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>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
arch/arm/mm/init.c
arch/ia64/mm/contig.c
arch/ia64/mm/discontig.c
arch/parisc/mm/init.c
arch/unicore32/mm/init.c
include/linux/mm.h
lib/show_mem.c
mm/page_alloc.c

index fbdd12ea3a587a146497f9e560d28d86c52fca45..cc3f35dc102a61c324bd453123c9e801baf1ce55 100644 (file)
@@ -98,6 +98,9 @@ void show_mem(unsigned int filter)
        printk("Mem-info:\n");
        show_free_areas(filter);
 
+       if (filter & SHOW_MEM_FILTER_PAGE_COUNT)
+               return;
+
        for_each_bank (i, mi) {
                struct membank *bank = &mi->bank[i];
                unsigned int pfn1, pfn2;
index f114a3b14c6ad73c7fa6afbe950375f46d98b876..ce6e7a80945eda67745d5101e5758b50a3e72768 100644 (file)
@@ -46,6 +46,8 @@ void show_mem(unsigned int filter)
        printk(KERN_INFO "Mem-info:\n");
        show_free_areas(filter);
        printk(KERN_INFO "Node memory in pages:\n");
+       if (filter & SHOW_MEM_FILTER_PAGE_COUNT)
+               return;
        for_each_online_pgdat(pgdat) {
                unsigned long present;
                unsigned long flags;
index c641333cd997635f1c885d12d895459111168e4a..2230817b4e9395053390b83e4c9d2a3c7a15845d 100644 (file)
@@ -623,6 +623,8 @@ void show_mem(unsigned int filter)
 
        printk(KERN_INFO "Mem-info:\n");
        show_free_areas(filter);
+       if (filter & SHOW_MEM_FILTER_PAGE_COUNT)
+               return;
        printk(KERN_INFO "Node memory in pages:\n");
        for_each_online_pgdat(pgdat) {
                unsigned long present;
index 82f364e209fc5a059f1be77fd5563e7c4a70c122..0b621625a6fb8e0935c0542db77d69c0e2c35626 100644 (file)
@@ -685,6 +685,8 @@ void show_mem(unsigned int filter)
 
        printk(KERN_INFO "Mem-info:\n");
        show_free_areas(filter);
+       if (filter & SHOW_MEM_FILTER_PAGE_COUNT)
+               return;
 #ifndef CONFIG_DISCONTIGMEM
        i = max_mapnr;
        while (i-- > 0) {
index 3b379cddbc641cced14c4472a4d7838852a47935..d1af4ed5694d7ace35d453a3b699272952a59e19 100644 (file)
@@ -65,6 +65,9 @@ void show_mem(unsigned int filter)
        printk(KERN_DEFAULT "Mem-info:\n");
        show_free_areas(filter);
 
+       if (filter & SHOW_MEM_FILTER_PAGE_COUNT)
+               return;
+
        for_each_bank(i, mi) {
                struct membank *bank = &mi->bank[i];
                unsigned int pfn1, pfn2;
index d0493f6064f373e23e89b2fa6bddb35a17fd94a3..305fd756fc4fe01ca362d70f7c420242296b4191 100644 (file)
@@ -865,7 +865,8 @@ extern void pagefault_out_of_memory(void);
  * Flags passed to show_mem() and show_free_areas() to suppress output in
  * various contexts.
  */
-#define SHOW_MEM_FILTER_NODES  (0x0001u)       /* filter disallowed nodes */
+#define SHOW_MEM_FILTER_NODES          (0x0001u)       /* disallowed nodes */
+#define SHOW_MEM_FILTER_PAGE_COUNT     (0x0002u)       /* page type count */
 
 extern void show_free_areas(unsigned int flags);
 extern bool skip_free_areas_node(unsigned int flags, int nid);
index 4407f8c9b1f71046d8b4aec0519734491b8bdd2a..b7c72311ad0c88673546aa910c32cdc5214f96b2 100644 (file)
@@ -18,6 +18,9 @@ void show_mem(unsigned int filter)
        printk("Mem-Info:\n");
        show_free_areas(filter);
 
+       if (filter & SHOW_MEM_FILTER_PAGE_COUNT)
+               return;
+
        for_each_online_pgdat(pgdat) {
                unsigned long i, flags;
 
index b5afea28cf835f64001d610b69bd4960dce36c74..d8762b234d2a44c935bb33b9ea277d39df68161e 100644 (file)
@@ -1759,6 +1759,13 @@ void warn_alloc_failed(gfp_t gfp_mask, int order, const char *fmt, ...)
        if ((gfp_mask & __GFP_NOWARN) || !__ratelimit(&nopage_rs))
                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