diff options
author | Yinghai Lu <yinghai@kernel.org> | 2010-10-05 19:05:14 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2010-10-06 00:43:14 -0400 |
commit | 9f4c13964b58608fbce05540743281ea3146c0e8 (patch) | |
tree | 94735fea950cba43958ecf13146a4d5a8b5b22d9 /arch/x86 | |
parent | 7c996361ef0d02ef8c1435902c909d14195adcdc (diff) |
x86, memblock: Fix crashkernel allocation
Cai Qian found crashkernel is broken with the x86 memblock changes.
1. crashkernel=128M@32M always reported that range is used, even if
the first kernel is small and does not usethat range
2. we always got following report when using "kexec -p"
Could not find a free area of memory of a000 bytes...
locate_hole failed
The root cause is that generic memblock_find_in_range() will try to
allocate from the top of the range, whereas the kexec code was written
assuming that allocation was always near the bottom and that it could
blindly extend memory upward. Unfortunately the kexec code doesn't
have a system for requesting the range that it really needs, so this
is subject to probabilistic failures.
This patch hacks around the problem by limiting the target range
heuristically to below the traditional bzImage max range. This number
is arbitrary and not always correct, and a much better result would be
obtained by having kexec communicate this number based on the kernel
header information and any appropriate command line options.
Reported-and-Bisected-by: CAI Qian <caiqian@redhat.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
LKML-Reference: <4CABAF2A.5090501@kernel.org>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kernel/setup.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index bf89e0a59b88..b11a238b2e35 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c | |||
@@ -502,6 +502,7 @@ static inline unsigned long long get_total_mem(void) | |||
502 | return total << PAGE_SHIFT; | 502 | return total << PAGE_SHIFT; |
503 | } | 503 | } |
504 | 504 | ||
505 | #define DEFAULT_BZIMAGE_ADDR_MAX 0x37FFFFFF | ||
505 | static void __init reserve_crashkernel(void) | 506 | static void __init reserve_crashkernel(void) |
506 | { | 507 | { |
507 | unsigned long long total_mem; | 508 | unsigned long long total_mem; |
@@ -519,8 +520,12 @@ static void __init reserve_crashkernel(void) | |||
519 | if (crash_base <= 0) { | 520 | if (crash_base <= 0) { |
520 | const unsigned long long alignment = 16<<20; /* 16M */ | 521 | const unsigned long long alignment = 16<<20; /* 16M */ |
521 | 522 | ||
522 | crash_base = memblock_find_in_range(alignment, ULONG_MAX, crash_size, | 523 | /* |
523 | alignment); | 524 | * kexec want bzImage is below DEFAULT_BZIMAGE_ADDR_MAX |
525 | */ | ||
526 | crash_base = memblock_find_in_range(alignment, | ||
527 | DEFAULT_BZIMAGE_ADDR_MAX, crash_size, alignment); | ||
528 | |||
524 | if (crash_base == MEMBLOCK_ERROR) { | 529 | if (crash_base == MEMBLOCK_ERROR) { |
525 | pr_info("crashkernel reservation failed - No suitable area found.\n"); | 530 | pr_info("crashkernel reservation failed - No suitable area found.\n"); |
526 | return; | 531 | return; |
@@ -528,8 +533,8 @@ static void __init reserve_crashkernel(void) | |||
528 | } else { | 533 | } else { |
529 | unsigned long long start; | 534 | unsigned long long start; |
530 | 535 | ||
531 | start = memblock_find_in_range(crash_base, ULONG_MAX, crash_size, | 536 | start = memblock_find_in_range(crash_base, |
532 | 1<<20); | 537 | crash_base + crash_size, crash_size, 1<<20); |
533 | if (start != crash_base) { | 538 | if (start != crash_base) { |
534 | pr_info("crashkernel reservation failed - memory is in use.\n"); | 539 | pr_info("crashkernel reservation failed - memory is in use.\n"); |
535 | return; | 540 | return; |