From: Jay Lan <jlan@sgi.com>
To: linux-ia64@vger.kernel.org
Subject: [PATCH] IA64 kexec-tools: memory_ranges arrays scalability issue
Date: Sat, 03 Feb 2007 00:34:39 +0000 [thread overview]
Message-ID: <45C3D89F.1060301@sgi.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 564 bytes --]
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>
[-- Attachment #2: max-memory-ranges --]
[-- Type: text/plain, Size: 4794 bytes --]
Index: kexec-tools-1.101/kexec/arch/ia64/kexec-ia64.c
===================================================================
--- kexec-tools-1.101.orig/kexec/arch/ia64/kexec-ia64.c 2007-02-02 18:02:44.000000000 -0600
+++ kexec-tools-1.101/kexec/arch/ia64/kexec-ia64.c 2007-02-02 18:11:49.000000000 -0600
@@ -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_rang
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);
Index: kexec-tools-1.101/kexec/arch/ia64/crashdump-ia64.c
===================================================================
--- kexec-tools-1.101.orig/kexec/arch/ia64/crashdump-ia64.c 2007-02-02 18:02:44.000000000 -0600
+++ kexec-tools-1.101/kexec/arch/ia64/crashdump-ia64.c 2007-02-02 18:14:57.000000000 -0600
@@ -31,8 +31,10 @@ int memory_ranges = 0;
#define LOAD_OFFSET (0xa000000000000000UL + 0x100000000UL - kernel_code_start)
#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;
@@ -133,7 +135,7 @@ static int exclude_crash_reserve_region(
}
/* 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");
@@ -250,6 +252,8 @@ static int get_crash_memory_ranges(struc
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",
@@ -259,7 +263,7 @@ static int get_crash_memory_ranges(struc
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);
Index: kexec-tools-1.101/kexec/arch/ia64/kexec-ia64.h
===================================================================
--- kexec-tools-1.101.orig/kexec/arch/ia64/kexec-ia64.h 2007-02-02 18:02:44.000000000 -0600
+++ kexec-tools-1.101/kexec/arch/ia64/kexec-ia64.h 2007-02-02 18:03:44.000000000 -0600
@@ -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_
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 */
Index: kexec-tools-1.101/kexec/arch/ia64/crashdump-ia64.h
===================================================================
--- kexec-tools-1.101.orig/kexec/arch/ia64/crashdump-ia64.h 2007-02-02 18:02:44.000000000 -0600
+++ kexec-tools-1.101/kexec/arch/ia64/crashdump-ia64.h 2007-02-02 18:03:44.000000000 -0600
@@ -8,6 +8,5 @@ extern int load_crashdump_segments(struc
unsigned long min_base, char **cmdline);
#define CRASH_MAX_MEMMAP_NR (KEXEC_MAX_SEGMENTS + 1)
-#define CRASH_MAX_MEMORY_RANGES (MAX_MEMORY_RANGES + 2)
#endif
next reply other threads:[~2007-02-03 0:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-03 0:34 Jay Lan [this message]
2007-02-03 3:24 ` [PATCH] IA64 kexec-tools: memory_ranges arrays scalability issue Horms
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=45C3D89F.1060301@sgi.com \
--to=jlan@sgi.com \
--cc=linux-ia64@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox