diff options
author | Tejun Heo <tj@kernel.org> | 2009-02-23 21:57:20 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2009-02-23 21:57:20 -0500 |
commit | c132937556f56ee4b831ef4b23f1846e05fde102 (patch) | |
tree | 0f93037ff2ebbdc321ebd0bbfc4752823c8d6a0e | |
parent | cb83b42e23bd6c4bf91793a320fbe83787c13596 (diff) |
bootmem: clean up arch-specific bootmem wrapping
Impact: cleaner and consistent bootmem wrapping
By setting CONFIG_HAVE_ARCH_BOOTMEM_NODE, archs can define
arch-specific wrappers for bootmem allocation. However, this is done
a bit strangely in that only the high level convenience macros can be
changed while lower level, but still exported, interface functions
can't be wrapped. This not only is messy but also leads to strange
situation where alloc_bootmem() does what the arch wants it to do but
the equivalent __alloc_bootmem() call doesn't although they should be
able to be used interchangeably.
This patch updates bootmem such that archs can override / wrap the
backend function - alloc_bootmem_core() instead of the highlevel
interface functions to allow simpler and consistent wrapping. Also,
HAVE_ARCH_BOOTMEM_NODE is renamed to HAVE_ARCH_BOOTMEM.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Johannes Weiner <hannes@saeurebad.de>
-rw-r--r-- | arch/avr32/Kconfig | 2 | ||||
-rw-r--r-- | arch/x86/Kconfig | 2 | ||||
-rw-r--r-- | arch/x86/include/asm/mmzone_32.h | 43 | ||||
-rw-r--r-- | include/linux/bootmem.h | 10 | ||||
-rw-r--r-- | mm/bootmem.c | 14 |
5 files changed, 22 insertions, 49 deletions
diff --git a/arch/avr32/Kconfig b/arch/avr32/Kconfig index b189680d18b0..05fe3053dcae 100644 --- a/arch/avr32/Kconfig +++ b/arch/avr32/Kconfig | |||
@@ -181,7 +181,7 @@ source "kernel/Kconfig.preempt" | |||
181 | config QUICKLIST | 181 | config QUICKLIST |
182 | def_bool y | 182 | def_bool y |
183 | 183 | ||
184 | config HAVE_ARCH_BOOTMEM_NODE | 184 | config HAVE_ARCH_BOOTMEM |
185 | def_bool n | 185 | def_bool n |
186 | 186 | ||
187 | config ARCH_HAVE_MEMORY_PRESENT | 187 | config ARCH_HAVE_MEMORY_PRESENT |
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index d3f6eadfd4ba..6fd3b2302ed9 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
@@ -1111,7 +1111,7 @@ config NODES_SHIFT | |||
1111 | Specify the maximum number of NUMA Nodes available on the target | 1111 | Specify the maximum number of NUMA Nodes available on the target |
1112 | system. Increases memory reserved to accomodate various tables. | 1112 | system. Increases memory reserved to accomodate various tables. |
1113 | 1113 | ||
1114 | config HAVE_ARCH_BOOTMEM_NODE | 1114 | config HAVE_ARCH_BOOTMEM |
1115 | def_bool y | 1115 | def_bool y |
1116 | depends on X86_32 && NUMA | 1116 | depends on X86_32 && NUMA |
1117 | 1117 | ||
diff --git a/arch/x86/include/asm/mmzone_32.h b/arch/x86/include/asm/mmzone_32.h index 07f1af494ca5..1e0fa9e63afa 100644 --- a/arch/x86/include/asm/mmzone_32.h +++ b/arch/x86/include/asm/mmzone_32.h | |||
@@ -93,45 +93,12 @@ static inline int pfn_valid(int pfn) | |||
93 | #endif /* CONFIG_DISCONTIGMEM */ | 93 | #endif /* CONFIG_DISCONTIGMEM */ |
94 | 94 | ||
95 | #ifdef CONFIG_NEED_MULTIPLE_NODES | 95 | #ifdef CONFIG_NEED_MULTIPLE_NODES |
96 | 96 | /* always use node 0 for bootmem on this numa platform */ | |
97 | /* | 97 | #define alloc_bootmem_core(__bdata, size, align, goal, limit) \ |
98 | * Following are macros that are specific to this numa platform. | ||
99 | */ | ||
100 | #define reserve_bootmem(addr, size, flags) \ | ||
101 | reserve_bootmem_node(NODE_DATA(0), (addr), (size), (flags)) | ||
102 | #define alloc_bootmem(x) \ | ||
103 | __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS)) | ||
104 | #define alloc_bootmem_nopanic(x) \ | ||
105 | __alloc_bootmem_node_nopanic(NODE_DATA(0), (x), SMP_CACHE_BYTES, \ | ||
106 | __pa(MAX_DMA_ADDRESS)) | ||
107 | #define alloc_bootmem_low(x) \ | ||
108 | __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, 0) | ||
109 | #define alloc_bootmem_pages(x) \ | ||
110 | __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) | ||
111 | #define alloc_bootmem_pages_nopanic(x) \ | ||
112 | __alloc_bootmem_node_nopanic(NODE_DATA(0), (x), PAGE_SIZE, \ | ||
113 | __pa(MAX_DMA_ADDRESS)) | ||
114 | #define alloc_bootmem_low_pages(x) \ | ||
115 | __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0) | ||
116 | #define alloc_bootmem_node(pgdat, x) \ | ||
117 | ({ \ | ||
118 | struct pglist_data __maybe_unused \ | ||
119 | *__alloc_bootmem_node__pgdat = (pgdat); \ | ||
120 | __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, \ | ||
121 | __pa(MAX_DMA_ADDRESS)); \ | ||
122 | }) | ||
123 | #define alloc_bootmem_pages_node(pgdat, x) \ | ||
124 | ({ \ | ||
125 | struct pglist_data __maybe_unused \ | ||
126 | *__alloc_bootmem_node__pgdat = (pgdat); \ | ||
127 | __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, \ | ||
128 | __pa(MAX_DMA_ADDRESS)); \ | ||
129 | }) | ||
130 | #define alloc_bootmem_low_pages_node(pgdat, x) \ | ||
131 | ({ \ | 98 | ({ \ |
132 | struct pglist_data __maybe_unused \ | 99 | bootmem_data_t __maybe_unused * __abm_bdata_dummy = (__bdata); \ |
133 | *__alloc_bootmem_node__pgdat = (pgdat); \ | 100 | __alloc_bootmem_core(NODE_DATA(0)->bdata, \ |
134 | __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0); \ | 101 | (size), (align), (goal), (limit)); \ |
135 | }) | 102 | }) |
136 | #endif /* CONFIG_NEED_MULTIPLE_NODES */ | 103 | #endif /* CONFIG_NEED_MULTIPLE_NODES */ |
137 | 104 | ||
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h index 95837bfb5256..3a87f93081ed 100644 --- a/include/linux/bootmem.h +++ b/include/linux/bootmem.h | |||
@@ -69,10 +69,9 @@ extern int reserve_bootmem_node(pg_data_t *pgdat, | |||
69 | unsigned long physaddr, | 69 | unsigned long physaddr, |
70 | unsigned long size, | 70 | unsigned long size, |
71 | int flags); | 71 | int flags); |
72 | #ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE | 72 | extern int reserve_bootmem(unsigned long addr, |
73 | extern int reserve_bootmem(unsigned long addr, unsigned long size, int flags); | 73 | unsigned long size, |
74 | #endif | 74 | int flags); |
75 | |||
76 | extern void *__alloc_bootmem_nopanic(unsigned long size, | 75 | extern void *__alloc_bootmem_nopanic(unsigned long size, |
77 | unsigned long align, | 76 | unsigned long align, |
78 | unsigned long goal); | 77 | unsigned long goal); |
@@ -94,7 +93,7 @@ extern void *__alloc_bootmem_low_node(pg_data_t *pgdat, | |||
94 | unsigned long size, | 93 | unsigned long size, |
95 | unsigned long align, | 94 | unsigned long align, |
96 | unsigned long goal); | 95 | unsigned long goal); |
97 | #ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE | 96 | |
98 | #define alloc_bootmem(x) \ | 97 | #define alloc_bootmem(x) \ |
99 | __alloc_bootmem(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS)) | 98 | __alloc_bootmem(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS)) |
100 | #define alloc_bootmem_nopanic(x) \ | 99 | #define alloc_bootmem_nopanic(x) \ |
@@ -113,7 +112,6 @@ extern void *__alloc_bootmem_low_node(pg_data_t *pgdat, | |||
113 | __alloc_bootmem_node(pgdat, x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) | 112 | __alloc_bootmem_node(pgdat, x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) |
114 | #define alloc_bootmem_low_pages_node(pgdat, x) \ | 113 | #define alloc_bootmem_low_pages_node(pgdat, x) \ |
115 | __alloc_bootmem_low_node(pgdat, x, PAGE_SIZE, 0) | 114 | __alloc_bootmem_low_node(pgdat, x, PAGE_SIZE, 0) |
116 | #endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */ | ||
117 | 115 | ||
118 | extern int reserve_bootmem_generic(unsigned long addr, unsigned long size, | 116 | extern int reserve_bootmem_generic(unsigned long addr, unsigned long size, |
119 | int flags); | 117 | int flags); |
diff --git a/mm/bootmem.c b/mm/bootmem.c index 51a0ccf61e0e..d7140c008ba8 100644 --- a/mm/bootmem.c +++ b/mm/bootmem.c | |||
@@ -37,6 +37,16 @@ static struct list_head bdata_list __initdata = LIST_HEAD_INIT(bdata_list); | |||
37 | 37 | ||
38 | static int bootmem_debug; | 38 | static int bootmem_debug; |
39 | 39 | ||
40 | /* | ||
41 | * If an arch needs to apply workarounds to bootmem allocation, it can | ||
42 | * set CONFIG_HAVE_ARCH_BOOTMEM and define a wrapper around | ||
43 | * __alloc_bootmem_core(). | ||
44 | */ | ||
45 | #ifndef CONFIG_HAVE_ARCH_BOOTMEM | ||
46 | #define alloc_bootmem_core(bdata, size, align, goal, limit) \ | ||
47 | __alloc_bootmem_core((bdata), (size), (align), (goal), (limit)) | ||
48 | #endif | ||
49 | |||
40 | static int __init bootmem_debug_setup(char *buf) | 50 | static int __init bootmem_debug_setup(char *buf) |
41 | { | 51 | { |
42 | bootmem_debug = 1; | 52 | bootmem_debug = 1; |
@@ -382,7 +392,6 @@ int __init reserve_bootmem_node(pg_data_t *pgdat, unsigned long physaddr, | |||
382 | return mark_bootmem_node(pgdat->bdata, start, end, 1, flags); | 392 | return mark_bootmem_node(pgdat->bdata, start, end, 1, flags); |
383 | } | 393 | } |
384 | 394 | ||
385 | #ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE | ||
386 | /** | 395 | /** |
387 | * reserve_bootmem - mark a page range as usable | 396 | * reserve_bootmem - mark a page range as usable |
388 | * @addr: starting address of the range | 397 | * @addr: starting address of the range |
@@ -403,7 +412,6 @@ int __init reserve_bootmem(unsigned long addr, unsigned long size, | |||
403 | 412 | ||
404 | return mark_bootmem(start, end, 1, flags); | 413 | return mark_bootmem(start, end, 1, flags); |
405 | } | 414 | } |
406 | #endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */ | ||
407 | 415 | ||
408 | static unsigned long align_idx(struct bootmem_data *bdata, unsigned long idx, | 416 | static unsigned long align_idx(struct bootmem_data *bdata, unsigned long idx, |
409 | unsigned long step) | 417 | unsigned long step) |
@@ -428,7 +436,7 @@ static unsigned long align_off(struct bootmem_data *bdata, unsigned long off, | |||
428 | return ALIGN(base + off, align) - base; | 436 | return ALIGN(base + off, align) - base; |
429 | } | 437 | } |
430 | 438 | ||
431 | static void * __init alloc_bootmem_core(struct bootmem_data *bdata, | 439 | static void * __init __alloc_bootmem_core(struct bootmem_data *bdata, |
432 | unsigned long size, unsigned long align, | 440 | unsigned long size, unsigned long align, |
433 | unsigned long goal, unsigned long limit) | 441 | unsigned long goal, unsigned long limit) |
434 | { | 442 | { |