diff options
author | Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com> | 2013-02-12 16:17:16 +0530 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2013-03-05 11:11:03 +0900 |
commit | a69f5b5a432fc0abf6655a8b0bc667a900511f7d (patch) | |
tree | 11c38e63a4f5dcfb40afbd98aaa7a2dfbc41d2cb /kexec/arch/ppc/crashdump-powerpc.c | |
parent | e35aa29fb40b37bf86d980b2e19af5e01c2d2549 (diff) |
kexec: Respect memory limit while building crash memory ranges on ppc32.
So far powerpc kernel never exported memory limit information which is
reflected by mem= kernel cmdline option. Hence, kexec-tools always used
to build ELF header for entire system RAM generating a dump bigger than
the actual memory used by the first kernel.
This patch now reads the memory limit information from device-tree file and
limits the crash memory ranges accordingly.
Suzuki tested this patch on ppc32(ppc440) with a kernel patch by Suzuki.
The following are the upstream kernel commits that exports memory limit
information through /proc/device-tree file:
4bc77a5ed - powerpc: Export memory limit via device tree
a84fcd468 - powerpc: Change memory_limit from phys_addr_t to unsigned
long long
Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Tested-by: Suzuki K. Poulose <suzuki@in.ibm.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec/arch/ppc/crashdump-powerpc.c')
-rw-r--r-- | kexec/arch/ppc/crashdump-powerpc.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/kexec/arch/ppc/crashdump-powerpc.c b/kexec/arch/ppc/crashdump-powerpc.c index 4c8c75d..d367643 100644 --- a/kexec/arch/ppc/crashdump-powerpc.c +++ b/kexec/arch/ppc/crashdump-powerpc.c @@ -132,8 +132,9 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges) goto err; } n = read_memory_region_limits(fd, &start, &end); + /* We are done with fd, close it. */ + close(fd); if (n != 0) { - close(fd); closedir(dmem); closedir(dir); goto err; @@ -153,8 +154,16 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges) cstart = crash_base; cend = crash_base + crash_size; /* - * Exclude the region that lies within crashkernel + * Exclude the region that lies within crashkernel. + * If memory limit is set then exclude memory region + * above it. */ + if (memory_limit) { + if (start >= memory_limit) + continue; + if (end > memory_limit) + end = memory_limit; + } if (cstart < end && cend > start) { if (start < cstart && end > cend) { crash_memory_range[memory_ranges].start @@ -195,7 +204,6 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges) = RANGE_RAM; memory_ranges++; } - close(fd); } closedir(dmem); } |