diff options
author | Joe Perches <joe@perches.com> | 2011-10-31 20:08:35 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-10-31 20:30:48 -0400 |
commit | 3ee9a4f086716d792219c021e8509f91165a4128 (patch) | |
tree | f85162b8e024624f07909eaba4e85b89df924ebb /mm | |
parent | 06d5e032adcbc7d50c606a1396f00e2474e4213e (diff) |
mm: neaten warn_alloc_failed
Add __attribute__((format (printf...) to the function to validate format
and arguments. Use vsprintf extension %pV to avoid any possible message
interleaving. Coalesce format string. Convert printks/pr_warning to
pr_warn.
[akpm@linux-foundation.org: use the __printf() macro]
Signed-off-by: Joe Perches <joe@perches.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.c | 16 | ||||
-rw-r--r-- | mm/vmalloc.c | 4 |
2 files changed, 13 insertions, 7 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 83a02052bce4..9dd443d89d8b 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -1754,7 +1754,6 @@ static DEFINE_RATELIMIT_STATE(nopage_rs, | |||
1754 | 1754 | ||
1755 | void warn_alloc_failed(gfp_t gfp_mask, int order, const char *fmt, ...) | 1755 | void warn_alloc_failed(gfp_t gfp_mask, int order, const char *fmt, ...) |
1756 | { | 1756 | { |
1757 | va_list args; | ||
1758 | unsigned int filter = SHOW_MEM_FILTER_NODES; | 1757 | unsigned int filter = SHOW_MEM_FILTER_NODES; |
1759 | 1758 | ||
1760 | if ((gfp_mask & __GFP_NOWARN) || !__ratelimit(&nopage_rs)) | 1759 | if ((gfp_mask & __GFP_NOWARN) || !__ratelimit(&nopage_rs)) |
@@ -1773,14 +1772,21 @@ void warn_alloc_failed(gfp_t gfp_mask, int order, const char *fmt, ...) | |||
1773 | filter &= ~SHOW_MEM_FILTER_NODES; | 1772 | filter &= ~SHOW_MEM_FILTER_NODES; |
1774 | 1773 | ||
1775 | if (fmt) { | 1774 | if (fmt) { |
1776 | printk(KERN_WARNING); | 1775 | struct va_format vaf; |
1776 | va_list args; | ||
1777 | |||
1777 | va_start(args, fmt); | 1778 | va_start(args, fmt); |
1778 | vprintk(fmt, args); | 1779 | |
1780 | vaf.fmt = fmt; | ||
1781 | vaf.va = &args; | ||
1782 | |||
1783 | pr_warn("%pV", &vaf); | ||
1784 | |||
1779 | va_end(args); | 1785 | va_end(args); |
1780 | } | 1786 | } |
1781 | 1787 | ||
1782 | pr_warning("%s: page allocation failure: order:%d, mode:0x%x\n", | 1788 | pr_warn("%s: page allocation failure: order:%d, mode:0x%x\n", |
1783 | current->comm, order, gfp_mask); | 1789 | current->comm, order, gfp_mask); |
1784 | 1790 | ||
1785 | dump_stack(); | 1791 | dump_stack(); |
1786 | if (!should_suppress_show_mem()) | 1792 | if (!should_suppress_show_mem()) |
diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 56faf3163ee2..08ab0aa1406c 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c | |||
@@ -1593,8 +1593,8 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, | |||
1593 | return area->addr; | 1593 | return area->addr; |
1594 | 1594 | ||
1595 | fail: | 1595 | fail: |
1596 | warn_alloc_failed(gfp_mask, order, "vmalloc: allocation failure, " | 1596 | warn_alloc_failed(gfp_mask, order, |
1597 | "allocated %ld of %ld bytes\n", | 1597 | "vmalloc: allocation failure, allocated %ld of %ld bytes\n", |
1598 | (area->nr_pages*PAGE_SIZE), area->size); | 1598 | (area->nr_pages*PAGE_SIZE), area->size); |
1599 | vfree(area->addr); | 1599 | vfree(area->addr); |
1600 | return NULL; | 1600 | return NULL; |