aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorDavid Rientjes <rientjes@google.com>2011-01-13 18:46:02 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2011-01-13 20:32:34 -0500
commitd0a21265dfb5fa8ae54e90d0fb6d1c215b10a28a (patch)
treea3bf2c96ad8e180f32a52e208667a40bb972275b /arch
parentec3f64fc9c196a304c4b7db3e1ff56d640628509 (diff)
mm: unify module_alloc code for vmalloc
Four architectures (arm, mips, sparc, x86) use __vmalloc_area() for module_init(). Much of the code is duplicated and can be generalized in a globally accessible function, __vmalloc_node_range(). __vmalloc_node() now calls into __vmalloc_node_range() with a range of [VMALLOC_START, VMALLOC_END) for functionally equivalent behavior. Each architecture may then use __vmalloc_node_range() directly to remove the duplication of code. Signed-off-by: David Rientjes <rientjes@google.com> Cc: Christoph Lameter <cl@linux.com> Cc: Russell King <linux@arm.linux.org.uk> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: "David S. Miller" <davem@davemloft.net> Cc: Ingo Molnar <mingo@redhat.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/kernel/module.c14
-rw-r--r--arch/mips/kernel/module.c14
-rw-r--r--arch/sparc/kernel/module.c14
-rw-r--r--arch/x86/kernel/module.c17
4 files changed, 14 insertions, 45 deletions
diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
index 0c1bb68ff4a8..2cfe8161b478 100644
--- a/arch/arm/kernel/module.c
+++ b/arch/arm/kernel/module.c
@@ -38,17 +38,9 @@
38#ifdef CONFIG_MMU 38#ifdef CONFIG_MMU
39void *module_alloc(unsigned long size) 39void *module_alloc(unsigned long size)
40{ 40{
41 struct vm_struct *area; 41 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
42 42 GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
43 size = PAGE_ALIGN(size); 43 __builtin_return_address(0));
44 if (!size)
45 return NULL;
46
47 area = __get_vm_area(size, VM_ALLOC, MODULES_VADDR, MODULES_END);
48 if (!area)
49 return NULL;
50
51 return __vmalloc_area(area, GFP_KERNEL, PAGE_KERNEL_EXEC);
52} 44}
53#else /* CONFIG_MMU */ 45#else /* CONFIG_MMU */
54void *module_alloc(unsigned long size) 46void *module_alloc(unsigned long size)
diff --git a/arch/mips/kernel/module.c b/arch/mips/kernel/module.c
index 6f51dda87fce..d87a72e9fac7 100644
--- a/arch/mips/kernel/module.c
+++ b/arch/mips/kernel/module.c
@@ -46,17 +46,9 @@ static DEFINE_SPINLOCK(dbe_lock);
46void *module_alloc(unsigned long size) 46void *module_alloc(unsigned long size)
47{ 47{
48#ifdef MODULE_START 48#ifdef MODULE_START
49 struct vm_struct *area; 49 return __vmalloc_node_range(size, 1, MODULE_START, MODULE_END,
50 50 GFP_KERNEL, PAGE_KERNEL, -1,
51 size = PAGE_ALIGN(size); 51 __builtin_return_address(0));
52 if (!size)
53 return NULL;
54
55 area = __get_vm_area(size, VM_ALLOC, MODULE_START, MODULE_END);
56 if (!area)
57 return NULL;
58
59 return __vmalloc_area(area, GFP_KERNEL, PAGE_KERNEL);
60#else 52#else
61 if (size == 0) 53 if (size == 0)
62 return NULL; 54 return NULL;
diff --git a/arch/sparc/kernel/module.c b/arch/sparc/kernel/module.c
index ee3c7dde8d9f..8d348c474a2f 100644
--- a/arch/sparc/kernel/module.c
+++ b/arch/sparc/kernel/module.c
@@ -23,17 +23,11 @@
23 23
24static void *module_map(unsigned long size) 24static void *module_map(unsigned long size)
25{ 25{
26 struct vm_struct *area; 26 if (PAGE_ALIGN(size) > MODULES_LEN)
27
28 size = PAGE_ALIGN(size);
29 if (!size || size > MODULES_LEN)
30 return NULL;
31
32 area = __get_vm_area(size, VM_ALLOC, MODULES_VADDR, MODULES_END);
33 if (!area)
34 return NULL; 27 return NULL;
35 28 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
36 return __vmalloc_area(area, GFP_KERNEL, PAGE_KERNEL); 29 GFP_KERNEL, PAGE_KERNEL, -1,
30 __builtin_return_address(0));
37} 31}
38 32
39static char *dot2underscore(char *name) 33static char *dot2underscore(char *name)
diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
index 8f2956091735..ab23f1ad4bf1 100644
--- a/arch/x86/kernel/module.c
+++ b/arch/x86/kernel/module.c
@@ -37,20 +37,11 @@
37 37
38void *module_alloc(unsigned long size) 38void *module_alloc(unsigned long size)
39{ 39{
40 struct vm_struct *area; 40 if (PAGE_ALIGN(size) > MODULES_LEN)
41
42 if (!size)
43 return NULL;
44 size = PAGE_ALIGN(size);
45 if (size > MODULES_LEN)
46 return NULL; 41 return NULL;
47 42 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
48 area = __get_vm_area(size, VM_ALLOC, MODULES_VADDR, MODULES_END); 43 GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
49 if (!area) 44 -1, __builtin_return_address(0));
50 return NULL;
51
52 return __vmalloc_area(area, GFP_KERNEL | __GFP_HIGHMEM,
53 PAGE_KERNEL_EXEC);
54} 45}
55 46
56/* Free memory returned from module_alloc */ 47/* Free memory returned from module_alloc */