Commit ced1bf52 authored by Hari Bathini's avatar Hari Bathini Committed by Michael Ellerman

powerpc/fadump: merge adjacent memory ranges to reduce PT_LOAD segements

With dynamic memory allocation support for crash memory ranges array,
there is no hard limit on the no. of crash memory ranges kernel could
export, but program headers count could overflow in the /proc/vmcore
ELF file while exporting each memory range as PT_LOAD segment. Reduce
the likelihood of a such scenario, by folding adjacent crash memory
ranges which minimizes the total number of PT_LOAD segments.
Signed-off-by: default avatarHari Bathini <hbathini@linux.ibm.com>
Reviewed-by: default avatarMahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 1bd6a1c4
...@@ -908,22 +908,41 @@ static int allocate_crash_memory_ranges(void) ...@@ -908,22 +908,41 @@ static int allocate_crash_memory_ranges(void)
static inline int fadump_add_crash_memory(unsigned long long base, static inline int fadump_add_crash_memory(unsigned long long base,
unsigned long long end) unsigned long long end)
{ {
u64 start, size;
bool is_adjacent = false;
if (base == end) if (base == end)
return 0; return 0;
if (crash_mem_ranges == max_crash_mem_ranges) { /*
int ret; * Fold adjacent memory ranges to bring down the memory ranges/
* PT_LOAD segments count.
*/
if (crash_mem_ranges) {
start = crash_memory_ranges[crash_mem_ranges - 1].base;
size = crash_memory_ranges[crash_mem_ranges - 1].size;
ret = allocate_crash_memory_ranges(); if ((start + size) == base)
if (ret) is_adjacent = true;
return ret; }
if (!is_adjacent) {
/* resize the array on reaching the limit */
if (crash_mem_ranges == max_crash_mem_ranges) {
int ret;
ret = allocate_crash_memory_ranges();
if (ret)
return ret;
}
start = base;
crash_memory_ranges[crash_mem_ranges].base = start;
crash_mem_ranges++;
} }
crash_memory_ranges[crash_mem_ranges - 1].size = (end - start);
pr_debug("crash_memory_range[%d] [%#016llx-%#016llx], %#llx bytes\n", pr_debug("crash_memory_range[%d] [%#016llx-%#016llx], %#llx bytes\n",
crash_mem_ranges, base, end - 1, (end - base)); (crash_mem_ranges - 1), start, end - 1, (end - start));
crash_memory_ranges[crash_mem_ranges].base = base;
crash_memory_ranges[crash_mem_ranges].size = end - base;
crash_mem_ranges++;
return 0; return 0;
} }
...@@ -999,6 +1018,14 @@ static int fadump_setup_crash_memory_ranges(void) ...@@ -999,6 +1018,14 @@ static int fadump_setup_crash_memory_ranges(void)
pr_debug("Setup crash memory ranges.\n"); pr_debug("Setup crash memory ranges.\n");
crash_mem_ranges = 0; crash_mem_ranges = 0;
/* allocate memory for crash memory ranges for the first time */
if (!max_crash_mem_ranges) {
ret = allocate_crash_memory_ranges();
if (ret)
return ret;
}
/* /*
* add the first memory chunk (RMA_START through boot_memory_size) as * add the first memory chunk (RMA_START through boot_memory_size) as
* a separate memory chunk. The reason is, at the time crash firmware * a separate memory chunk. The reason is, at the time crash firmware
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment