diff options
author | Mel Gorman <mel@csn.ul.ie> | 2007-11-28 19:21:13 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-11-29 12:24:51 -0500 |
commit | ba72cb8cb0cdc0a65b3abe9a387f1a26bfd49b8a (patch) | |
tree | c0617d342aba6525d7dbc9d607da754468385383 | |
parent | ee592a5bd5180cc1ffaf5acd7bf1e91e0d854a08 (diff) |
Fix boot problem with iSeries lacking hugepage support
Ordinarily the size of a pageblock is determined at compile-time based on the
hugepage size. On PPC64, the hugepage size is determined at runtime based on
what is supported by the machine. With legacy machines such as iSeries that
do not support hugepages, HPAGE_SHIFT is 0. This results in pageblock_order
being set to -PAGE_SHIFT and a crash results shortly afterwards.
This patch adds a function to select a sensible value for pageblock order by
default when HUGETLB_PAGE_SIZE_VARIABLE is set. It checks that HPAGE_SHIFT
is a sensible value before using the hugepage size; if it is not MAX_ORDER-1
is used.
This is a fix for 2.6.24.
Credit goes to Stephen Rothwell for identifying the bug and testing candidate
patches. Additional credit goes to Andy Whitcroft for spotting a problem
with respects to IA-64 before releasing. Additional credit to David Gibson
for testing with the libhugetlbfs test suite.
Signed-off-by: Mel Gorman <mel@csn.ul.ie>
Tested-by: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | arch/powerpc/Kconfig | 5 | ||||
-rw-r--r-- | mm/page_alloc.c | 23 |
2 files changed, 26 insertions, 2 deletions
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 18f397ca05ef..232c298c933f 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig | |||
@@ -187,6 +187,11 @@ config FORCE_MAX_ZONEORDER | |||
187 | default "9" if PPC_64K_PAGES | 187 | default "9" if PPC_64K_PAGES |
188 | default "13" | 188 | default "13" |
189 | 189 | ||
190 | config HUGETLB_PAGE_SIZE_VARIABLE | ||
191 | bool | ||
192 | depends on HUGETLB_PAGE | ||
193 | default y | ||
194 | |||
190 | config MATH_EMULATION | 195 | config MATH_EMULATION |
191 | bool "Math emulation" | 196 | bool "Math emulation" |
192 | depends on 4xx || 8xx || E200 || PPC_MPC832x || E500 | 197 | depends on 4xx || 8xx || E200 || PPC_MPC832x || E500 |
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 4ffed1cd158b..b5a58d476c1a 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -3265,6 +3265,16 @@ static void inline setup_usemap(struct pglist_data *pgdat, | |||
3265 | #endif /* CONFIG_SPARSEMEM */ | 3265 | #endif /* CONFIG_SPARSEMEM */ |
3266 | 3266 | ||
3267 | #ifdef CONFIG_HUGETLB_PAGE_SIZE_VARIABLE | 3267 | #ifdef CONFIG_HUGETLB_PAGE_SIZE_VARIABLE |
3268 | |||
3269 | /* Return a sensible default order for the pageblock size. */ | ||
3270 | static inline int pageblock_default_order(void) | ||
3271 | { | ||
3272 | if (HPAGE_SHIFT > PAGE_SHIFT) | ||
3273 | return HUGETLB_PAGE_ORDER; | ||
3274 | |||
3275 | return MAX_ORDER-1; | ||
3276 | } | ||
3277 | |||
3268 | /* Initialise the number of pages represented by NR_PAGEBLOCK_BITS */ | 3278 | /* Initialise the number of pages represented by NR_PAGEBLOCK_BITS */ |
3269 | static inline void __init set_pageblock_order(unsigned int order) | 3279 | static inline void __init set_pageblock_order(unsigned int order) |
3270 | { | 3280 | { |
@@ -3280,7 +3290,16 @@ static inline void __init set_pageblock_order(unsigned int order) | |||
3280 | } | 3290 | } |
3281 | #else /* CONFIG_HUGETLB_PAGE_SIZE_VARIABLE */ | 3291 | #else /* CONFIG_HUGETLB_PAGE_SIZE_VARIABLE */ |
3282 | 3292 | ||
3283 | /* Defined this way to avoid accidently referencing HUGETLB_PAGE_ORDER */ | 3293 | /* |
3294 | * When CONFIG_HUGETLB_PAGE_SIZE_VARIABLE is not set, set_pageblock_order() | ||
3295 | * and pageblock_default_order() are unused as pageblock_order is set | ||
3296 | * at compile-time. See include/linux/pageblock-flags.h for the values of | ||
3297 | * pageblock_order based on the kernel config | ||
3298 | */ | ||
3299 | static inline int pageblock_default_order(unsigned int order) | ||
3300 | { | ||
3301 | return MAX_ORDER-1; | ||
3302 | } | ||
3284 | #define set_pageblock_order(x) do {} while (0) | 3303 | #define set_pageblock_order(x) do {} while (0) |
3285 | 3304 | ||
3286 | #endif /* CONFIG_HUGETLB_PAGE_SIZE_VARIABLE */ | 3305 | #endif /* CONFIG_HUGETLB_PAGE_SIZE_VARIABLE */ |
@@ -3365,7 +3384,7 @@ static void __meminit free_area_init_core(struct pglist_data *pgdat, | |||
3365 | if (!size) | 3384 | if (!size) |
3366 | continue; | 3385 | continue; |
3367 | 3386 | ||
3368 | set_pageblock_order(HUGETLB_PAGE_ORDER); | 3387 | set_pageblock_order(pageblock_default_order()); |
3369 | setup_usemap(pgdat, zone, size); | 3388 | setup_usemap(pgdat, zone, size); |
3370 | ret = init_currently_empty_zone(zone, zone_start_pfn, | 3389 | ret = init_currently_empty_zone(zone, zone_start_pfn, |
3371 | size, MEMMAP_EARLY); | 3390 | size, MEMMAP_EARLY); |