aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Hocko <mhocko@suse.com>2017-05-12 18:46:41 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-05-12 18:57:15 -0400
commit8594a21cf7a8318baedbedc3fcd2967a17ddeec0 (patch)
tree05e5666d26e2b5f845797535a144e43d9721efcb
parent835152a25949dd5561819c2e3fcc4b2dd27f3e1e (diff)
mm, vmalloc: fix vmalloc users tracking properly
Commit 1f5307b1e094 ("mm, vmalloc: properly track vmalloc users") has pulled asm/pgtable.h include dependency to linux/vmalloc.h and that turned out to be a bad idea for some architectures. E.g. m68k fails with In file included from arch/m68k/include/asm/pgtable_mm.h:145:0, from arch/m68k/include/asm/pgtable.h:4, from include/linux/vmalloc.h:9, from arch/m68k/kernel/module.c:9: arch/m68k/include/asm/mcf_pgtable.h: In function 'nocache_page': >> arch/m68k/include/asm/mcf_pgtable.h:339:43: error: 'init_mm' undeclared (first use in this function) #define pgd_offset_k(address) pgd_offset(&init_mm, address) as spotted by kernel build bot. nios2 fails for other reason In file included from include/asm-generic/io.h:767:0, from arch/nios2/include/asm/io.h:61, from include/linux/io.h:25, from arch/nios2/include/asm/pgtable.h:18, from include/linux/mm.h:70, from include/linux/pid_namespace.h:6, from include/linux/ptrace.h:9, from arch/nios2/include/uapi/asm/elf.h:23, from arch/nios2/include/asm/elf.h:22, from include/linux/elf.h:4, from include/linux/module.h:15, from init/main.c:16: include/linux/vmalloc.h: In function '__vmalloc_node_flags': include/linux/vmalloc.h:99:40: error: 'PAGE_KERNEL' undeclared (first use in this function); did you mean 'GFP_KERNEL'? which is due to the newly added #include <asm/pgtable.h>, which on nios2 includes <linux/io.h> and thus <asm/io.h> and <asm-generic/io.h> which again includes <linux/vmalloc.h>. Tweaking that around just turns out a bigger headache than necessary. This patch reverts 1f5307b1e094 and reimplements the original fix in a different way. __vmalloc_node_flags can stay static inline which will cover vmalloc* functions. We only have one external user (kvmalloc_node) and we can export __vmalloc_node_flags_caller and provide the caller directly. This is much simpler and it doesn't really need any games with header files. [akpm@linux-foundation.org: coding-style fixes] [mhocko@kernel.org: revert old comment] Link: http://lkml.kernel.org/r/20170509211054.GB16325@dhcp22.suse.cz Fixes: 1f5307b1e094 ("mm, vmalloc: properly track vmalloc users") Link: http://lkml.kernel.org/r/20170509153702.GR6481@dhcp22.suse.cz Signed-off-by: Michal Hocko <mhocko@suse.com> Cc: Tobias Klauser <tklauser@distanz.ch> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/vmalloc.h21
-rw-r--r--mm/util.c3
-rw-r--r--mm/vmalloc.c19
3 files changed, 26 insertions, 17 deletions
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index 0328ce003992..2d92dd002abd 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -6,7 +6,6 @@
6#include <linux/list.h> 6#include <linux/list.h>
7#include <linux/llist.h> 7#include <linux/llist.h>
8#include <asm/page.h> /* pgprot_t */ 8#include <asm/page.h> /* pgprot_t */
9#include <asm/pgtable.h> /* PAGE_KERNEL */
10#include <linux/rbtree.h> 9#include <linux/rbtree.h>
11 10
12struct vm_area_struct; /* vma defining user mapping in mm_types.h */ 11struct vm_area_struct; /* vma defining user mapping in mm_types.h */
@@ -83,22 +82,14 @@ extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
83 const void *caller); 82 const void *caller);
84#ifndef CONFIG_MMU 83#ifndef CONFIG_MMU
85extern void *__vmalloc_node_flags(unsigned long size, int node, gfp_t flags); 84extern void *__vmalloc_node_flags(unsigned long size, int node, gfp_t flags);
86#else 85static inline void *__vmalloc_node_flags_caller(unsigned long size, int node,
87extern void *__vmalloc_node(unsigned long size, unsigned long align, 86 gfp_t flags, void *caller)
88 gfp_t gfp_mask, pgprot_t prot,
89 int node, const void *caller);
90
91/*
92 * We really want to have this inlined due to caller tracking. This
93 * function is used by the highlevel vmalloc apis and so we want to track
94 * their callers and inlining will achieve that.
95 */
96static inline void *__vmalloc_node_flags(unsigned long size,
97 int node, gfp_t flags)
98{ 87{
99 return __vmalloc_node(size, 1, flags, PAGE_KERNEL, 88 return __vmalloc_node_flags(size, node, flags);
100 node, __builtin_return_address(0));
101} 89}
90#else
91extern void *__vmalloc_node_flags_caller(unsigned long size,
92 int node, gfp_t flags, void *caller);
102#endif 93#endif
103 94
104extern void vfree(const void *addr); 95extern void vfree(const void *addr);
diff --git a/mm/util.c b/mm/util.c
index 718154debc87..464df3489903 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -382,7 +382,8 @@ void *kvmalloc_node(size_t size, gfp_t flags, int node)
382 if (ret || size <= PAGE_SIZE) 382 if (ret || size <= PAGE_SIZE)
383 return ret; 383 return ret;
384 384
385 return __vmalloc_node_flags(size, node, flags); 385 return __vmalloc_node_flags_caller(size, node, flags,
386 __builtin_return_address(0));
386} 387}
387EXPORT_SYMBOL(kvmalloc_node); 388EXPORT_SYMBOL(kvmalloc_node);
388 389
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 194c22eccb9d..34a1c3e46ed7 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -1649,6 +1649,9 @@ void *vmap(struct page **pages, unsigned int count,
1649} 1649}
1650EXPORT_SYMBOL(vmap); 1650EXPORT_SYMBOL(vmap);
1651 1651
1652static void *__vmalloc_node(unsigned long size, unsigned long align,
1653 gfp_t gfp_mask, pgprot_t prot,
1654 int node, const void *caller);
1652static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, 1655static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
1653 pgprot_t prot, int node) 1656 pgprot_t prot, int node)
1654{ 1657{
@@ -1791,7 +1794,7 @@ fail:
1791 * with mm people. 1794 * with mm people.
1792 * 1795 *
1793 */ 1796 */
1794void *__vmalloc_node(unsigned long size, unsigned long align, 1797static void *__vmalloc_node(unsigned long size, unsigned long align,
1795 gfp_t gfp_mask, pgprot_t prot, 1798 gfp_t gfp_mask, pgprot_t prot,
1796 int node, const void *caller) 1799 int node, const void *caller)
1797{ 1800{
@@ -1806,6 +1809,20 @@ void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot)
1806} 1809}
1807EXPORT_SYMBOL(__vmalloc); 1810EXPORT_SYMBOL(__vmalloc);
1808 1811
1812static inline void *__vmalloc_node_flags(unsigned long size,
1813 int node, gfp_t flags)
1814{
1815 return __vmalloc_node(size, 1, flags, PAGE_KERNEL,
1816 node, __builtin_return_address(0));
1817}
1818
1819
1820void *__vmalloc_node_flags_caller(unsigned long size, int node, gfp_t flags,
1821 void *caller)
1822{
1823 return __vmalloc_node(size, 1, flags, PAGE_KERNEL, node, caller);
1824}
1825
1809/** 1826/**
1810 * vmalloc - allocate virtually contiguous memory 1827 * vmalloc - allocate virtually contiguous memory
1811 * @size: allocation size 1828 * @size: allocation size