diff options
author | Jay Lan <jlan@sgi.com> | 2007-02-02 16:34:39 -0800 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2007-02-03 12:23:31 +0900 |
commit | 49c5c5b662774e91ecebd95e4f7650e6567a6624 (patch) | |
tree | 0f93f8d76cb5a95b55fc1fb1928d4d11991479ab | |
parent | 02e6bd686d64abd747e17c268dc1b913e14b5c91 (diff) |
IA64 kexec-tools: memory_ranges arrays scalability issue
There are two memory_ranges arrays declared in the IA64 kexec code.
One in kexec-ia64.c and the other one in crashdump-ia64.c.
They currently were allocated as a hard-coded size of array. Since
SN systems may scale to hunders of nodes and each node may contain
up to 12 DIMMs, the hard-coded size of 1024 is not enough for very
large systems.
The size of either array can not be greater than the number of
entries in /proc/iomem, which is saved as "max_memory_ranges"
and is used to dynamically allocate the two arrays.
Signed-off-by: Jay Lan <jlan@sgi.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
-rw-r--r-- | kexec/arch/ia64/crashdump-ia64.c | 12 | ||||
-rw-r--r-- | kexec/arch/ia64/crashdump-ia64.h | 1 | ||||
-rw-r--r-- | kexec/arch/ia64/kexec-ia64.c | 15 | ||||
-rw-r--r-- | kexec/arch/ia64/kexec-ia64.h | 4 |
4 files changed, 22 insertions, 10 deletions
diff --git a/kexec/arch/ia64/crashdump-ia64.c b/kexec/arch/ia64/crashdump-ia64.c index d41eb04..14e95a6 100644 --- a/kexec/arch/ia64/crashdump-ia64.c +++ b/kexec/arch/ia64/crashdump-ia64.c @@ -42,8 +42,10 @@ static struct crash_elf_info elf_info = #define MAX_LINE 160 /* Stores a sorted list of RAM memory ranges for which to create elf headers. - * A separate program header is created for backup region */ -static struct memory_range crash_memory_range[CRASH_MAX_MEMORY_RANGES]; + * A separate program header is created for backup region. + * The number of entries in memory_range array is always smaller than + * the number of entries in /proc/iomem, stored in max_memory_ranges. */ +static struct memory_range *crash_memory_range; /* Memory region reserved for storing panic kernel and other data. */ static struct memory_range crash_reserved_mem; unsigned long elfcorehdr; @@ -125,7 +127,7 @@ static int exclude_crash_reserve_region(int *nr_ranges) } /* Insert split memory region, if any. */ if (tidx >= 0) { - if (*nr_ranges == CRASH_MAX_MEMORY_RANGES) { + if (*nr_ranges == max_memory_ranges) { /* No space to insert another element. */ fprintf(stderr, "Error: Number of crash memory ranges" " excedeed the max limit\n"); @@ -148,6 +150,8 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges) FILE *fp; unsigned long start, end; + crash_memory_range = xmalloc(sizeof(struct memory_range) * + max_memory_ranges); fp = fopen(iomem, "r"); if (!fp) { fprintf(stderr, "Cannot open %s: %s\n", @@ -157,7 +161,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges) while(fgets(line, sizeof(line), fp) != 0) { char *str; int type, consumed, count; - if (memory_ranges >= CRASH_MAX_MEMORY_RANGES) + if (memory_ranges >= max_memory_ranges) break; count = sscanf(line, "%lx-%lx : %n", &start, &end, &consumed); diff --git a/kexec/arch/ia64/crashdump-ia64.h b/kexec/arch/ia64/crashdump-ia64.h index f2f43e3..72ba054 100644 --- a/kexec/arch/ia64/crashdump-ia64.h +++ b/kexec/arch/ia64/crashdump-ia64.h @@ -8,6 +8,5 @@ extern int load_crashdump_segments(struct kexec_info *info, unsigned long min_base, const char **cmdline); #define CRASH_MAX_MEMMAP_NR (KEXEC_MAX_SEGMENTS + 1) -#define CRASH_MAX_MEMORY_RANGES (MAX_MEMORY_RANGES + 2) #endif diff --git a/kexec/arch/ia64/kexec-ia64.c b/kexec/arch/ia64/kexec-ia64.c index 8969fc5..87c7c8b 100644 --- a/kexec/arch/ia64/kexec-ia64.c +++ b/kexec/arch/ia64/kexec-ia64.c @@ -36,7 +36,10 @@ #include "kexec-ia64.h" #include <arch/options.h> -static struct memory_range memory_range[MAX_MEMORY_RANGES]; +/* The number of entries in memory_range array is always smaller than + the number of entries in /proc/iomem, stored in max_memory_ranges. */ +static struct memory_range *memory_range; +int max_memory_ranges; static int memory_ranges; unsigned long saved_efi_memmap_size; @@ -86,13 +89,21 @@ int get_memory_ranges(struct memory_range **range, int *ranges, return -1; } + /* allocate memory_range dynamically */ + while(fgets(line, sizeof(line), fp) != 0) { + max_memory_ranges++; + } + memory_range = xmalloc(sizeof(struct memory_range) * + max_memory_ranges); + rewind(fp); + while(fgets(line, sizeof(line), fp) != 0) { unsigned long start, end; char *str; int type; int consumed; int count; - if (memory_ranges >= MAX_MEMORY_RANGES) + if (memory_ranges >= max_memory_ranges) break; count = sscanf(line, "%lx-%lx : %n", &start, &end, &consumed); diff --git a/kexec/arch/ia64/kexec-ia64.h b/kexec/arch/ia64/kexec-ia64.h index 7995307..176d5f9 100644 --- a/kexec/arch/ia64/kexec-ia64.h +++ b/kexec/arch/ia64/kexec-ia64.h @@ -1,8 +1,7 @@ #ifndef KEXEC_IA64_H #define KEXEC_IA64_H -#define MAX_MEMORY_RANGES 1024 - +extern int max_memory_ranges; int elf_ia64_probe(const char *buf, off_t len); int elf_ia64_load(int argc, char **argv, const char *buf, off_t len, struct kexec_info *info); @@ -11,7 +10,6 @@ int update_loaded_segments(struct kexec_info *info, struct mem_ehdr *ehdr); void move_loaded_segments(struct kexec_info *info, struct mem_ehdr *ehdr, unsigned long addr); -#define MAX_MEMORY_RANGES 1024 #define EFI_PAGE_SIZE (1UL<<12) #define ELF_PAGE_SIZE (1UL<<16) #endif /* KEXEC_IA64_H */ |