aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorMichal Hocko <mhocko@suse.com>2016-10-07 20:01:55 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-10-07 21:46:29 -0400
commit7877cdcc3893c1bd9a833b2f0398e7320794c6e6 (patch)
treeab2c1885303f60c534a981d42eac6e035c7acd04 /mm
parentc2a9737f45e27d8263ff9643f994bda9bac0b944 (diff)
mm: consolidate warn_alloc_failed users
warn_alloc_failed is currently used from the page and vmalloc allocators. This is a good reuse of the code except that vmalloc would appreciate a slightly different warning message. This is already handled by the fmt parameter except that "%s: page allocation failure: order:%u, mode:%#x(%pGg)" is printed anyway. This might be quite misleading because it might be a vmalloc failure which leads to the warning while the page allocator is not the culprit here. Fix this by always using the fmt string and only print the context that makes sense for the particular context (e.g. order makes only very little sense for the vmalloc context). Rename the function to not miss any user and also because a later patch will reuse it also for !failure cases. Link: http://lkml.kernel.org/r/20160929084407.7004-2-mhocko@kernel.org Signed-off-by: Michal Hocko <mhocko@suse.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Mel Gorman <mgorman@suse.de> Cc: Dave Hansen <dave.hansen@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/page_alloc.c27
-rw-r--r--mm/vmalloc.c14
2 files changed, 18 insertions, 23 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index bcfa647c1752..5ab2e30a1006 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2979,9 +2979,11 @@ static DEFINE_RATELIMIT_STATE(nopage_rs,
2979 DEFAULT_RATELIMIT_INTERVAL, 2979 DEFAULT_RATELIMIT_INTERVAL,
2980 DEFAULT_RATELIMIT_BURST); 2980 DEFAULT_RATELIMIT_BURST);
2981 2981
2982void warn_alloc_failed(gfp_t gfp_mask, unsigned int order, const char *fmt, ...) 2982void warn_alloc(gfp_t gfp_mask, const char *fmt, ...)
2983{ 2983{
2984 unsigned int filter = SHOW_MEM_FILTER_NODES; 2984 unsigned int filter = SHOW_MEM_FILTER_NODES;
2985 struct va_format vaf;
2986 va_list args;
2985 2987
2986 if ((gfp_mask & __GFP_NOWARN) || !__ratelimit(&nopage_rs) || 2988 if ((gfp_mask & __GFP_NOWARN) || !__ratelimit(&nopage_rs) ||
2987 debug_guardpage_minorder() > 0) 2989 debug_guardpage_minorder() > 0)
@@ -2999,22 +3001,16 @@ void warn_alloc_failed(gfp_t gfp_mask, unsigned int order, const char *fmt, ...)
2999 if (in_interrupt() || !(gfp_mask & __GFP_DIRECT_RECLAIM)) 3001 if (in_interrupt() || !(gfp_mask & __GFP_DIRECT_RECLAIM))
3000 filter &= ~SHOW_MEM_FILTER_NODES; 3002 filter &= ~SHOW_MEM_FILTER_NODES;
3001 3003
3002 if (fmt) { 3004 pr_warn("%s: ", current->comm);
3003 struct va_format vaf;
3004 va_list args;
3005 3005
3006 va_start(args, fmt); 3006 va_start(args, fmt);
3007 vaf.fmt = fmt;
3008 vaf.va = &args;
3009 pr_cont("%pV", &vaf);
3010 va_end(args);
3007 3011
3008 vaf.fmt = fmt; 3012 pr_cont(", mode:%#x(%pGg)\n", gfp_mask, &gfp_mask);
3009 vaf.va = &args;
3010 3013
3011 pr_warn("%pV", &vaf);
3012
3013 va_end(args);
3014 }
3015
3016 pr_warn("%s: page allocation failure: order:%u, mode:%#x(%pGg)\n",
3017 current->comm, order, gfp_mask, &gfp_mask);
3018 dump_stack(); 3014 dump_stack();
3019 if (!should_suppress_show_mem()) 3015 if (!should_suppress_show_mem())
3020 show_mem(filter); 3016 show_mem(filter);
@@ -3680,7 +3676,8 @@ retry:
3680 } 3676 }
3681 3677
3682nopage: 3678nopage:
3683 warn_alloc_failed(gfp_mask, order, NULL); 3679 warn_alloc(gfp_mask,
3680 "page allocation failure: order:%u", order);
3684got_pg: 3681got_pg:
3685 return page; 3682 return page;
3686} 3683}
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 80660a0f989b..f2481cb4e6b2 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -1601,7 +1601,6 @@ static void *__vmalloc_node(unsigned long size, unsigned long align,
1601static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, 1601static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
1602 pgprot_t prot, int node) 1602 pgprot_t prot, int node)
1603{ 1603{
1604 const int order = 0;
1605 struct page **pages; 1604 struct page **pages;
1606 unsigned int nr_pages, array_size, i; 1605 unsigned int nr_pages, array_size, i;
1607 const gfp_t nested_gfp = (gfp_mask & GFP_RECLAIM_MASK) | __GFP_ZERO; 1606 const gfp_t nested_gfp = (gfp_mask & GFP_RECLAIM_MASK) | __GFP_ZERO;
@@ -1629,9 +1628,9 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
1629 struct page *page; 1628 struct page *page;
1630 1629
1631 if (node == NUMA_NO_NODE) 1630 if (node == NUMA_NO_NODE)
1632 page = alloc_pages(alloc_mask, order); 1631 page = alloc_page(alloc_mask);
1633 else 1632 else
1634 page = alloc_pages_node(node, alloc_mask, order); 1633 page = alloc_pages_node(node, alloc_mask, 0);
1635 1634
1636 if (unlikely(!page)) { 1635 if (unlikely(!page)) {
1637 /* Successfully allocated i pages, free them in __vunmap() */ 1636 /* Successfully allocated i pages, free them in __vunmap() */
@@ -1648,8 +1647,8 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
1648 return area->addr; 1647 return area->addr;
1649 1648
1650fail: 1649fail:
1651 warn_alloc_failed(gfp_mask, order, 1650 warn_alloc(gfp_mask,
1652 "vmalloc: allocation failure, allocated %ld of %ld bytes\n", 1651 "vmalloc: allocation failure, allocated %ld of %ld bytes",
1653 (area->nr_pages*PAGE_SIZE), area->size); 1652 (area->nr_pages*PAGE_SIZE), area->size);
1654 vfree(area->addr); 1653 vfree(area->addr);
1655 return NULL; 1654 return NULL;
@@ -1710,9 +1709,8 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
1710 return addr; 1709 return addr;
1711 1710
1712fail: 1711fail:
1713 warn_alloc_failed(gfp_mask, 0, 1712 warn_alloc(gfp_mask,
1714 "vmalloc: allocation failure: %lu bytes\n", 1713 "vmalloc: allocation failure: %lu bytes", real_size);
1715 real_size);
1716 return NULL; 1714 return NULL;
1717} 1715}
1718 1716