Introducing the memmap= kernel command line option
RFC 1/1 Introducing the memmap= kernel command line option
Hi Andi,
In order to port kdump to x86_64, we need to have the memmap= kernel command line option available. This is so that the dump-capture kernel can be booted with a custom memory map.
The attached patch adds the memmap= functionality to the x86_64 kernel. It is against 2.6.12-rc2-mm3. I have done some amount of testing and it is working fine.
Could you kindly review this patch and let me know your thoughts on it.
Thanks and Regards,
Hari
This patch adds the 'memmap=' kernel command line option for the x86_64 kernel.
---
linux-2.6.12-rc2-hari/Documentation/kernel-parameters.txt | 2 - linux-2.6.12-rc2-hari/arch/x86_64/kernel/e820.c | 25 ++++++++++++++ linux-2.6.12-rc2-hari/arch/x86_64/kernel/setup.c | 3 + linux-2.6.12-rc2-hari/include/asm-x86_64/e820.h | 2 + 4 files changed, 31 insertions(+), 1 deletion(-)
arch/x86_64/kernel/e820.c renamed from arch/x86_64/kernel/e820.c~x8664-memmap-command-line-option +25 -0
@@ -513,6 +513,31 @@ void __init parse_memopt(char *p, char * end_user_pfn >>=PAGE_SHIFT ; } +void __init parse_memmapopt (char *p,char **from) +{ +if (!memcmp (p,"exactmap" ,8 )) { + p +=8 ; + e820.nr_map =0 ; + }else { +unsigned long long start_at, mem_size; + + mem_size =memparse (p, from); + p = *from; +if (*p =='@' ) { + start_at =memparse (p+1 , from); +add_memory_region (start_at, mem_size,E820_RAM ); + }else if (*p =='#' ) { + start_at =memparse (p+1 , from); +add_memory_region (start_at, mem_size,E820_ACPI ); + }else if (*p =='$' ) { + start_at =memparse (p+1 , from); +add_memory_region (start_at, mem_size,E820_RESERVED ); + }else { + end_user_pfn = (mem_size >>PAGE_SHIFT ); + } + } +} +unsigned long pci_mem_start =0xaeedbabe ;/*
arch/x86_64/kernel/setup.c renamed from arch/x86_64/kernel/setup.c~x8664-memmap-command-line-option +3 -0
@@ -349,6 +349,9 @@ static __init void parse_cmdline_early (if (!memcmp (from,"mem=" ,4 ))parse_memopt (from+4 , &from); +if (!memcmp (from,"memmap=" ,7 )) +parse_memmapopt (from+7 , &from); +#ifdef CONFIG_DISCONTIGMEM if (!memcmp (from,"numa=" ,5 ))numa_setup (from+5 );
include/asm-x86_64/e820.h renamed from include/asm-x86_64/e820.h~x8664-memmap-command-line-option +2 -0
@@ -54,6 +54,8 @@ extern void e820_setup_gap(void);extern void __init parse_memopt (char *p,char **end); +extern void __init parse_memmapopt (char *p,char **end); +extern struct e820map e820;#endif /*!__ASSEMBLY__*/
Documentation/kernel-parameters.txt renamed from Documentation/kernel-parameters.txt~x8664-memmap-command-line-option +1 -1
@@ -794,7 +794,7 @@ running once the system is up. mem=nopentium [BUGS=IA-32] Disable usage of 4MB pages for kernel memory. - memmap=exactmap [KNL,IA-32] Enable setting of an exact + memmap=exactmap [KNL,IA-32,X86-64] Enable setting of an exact E820 memory map, as specified by the user. Such memmap=exactmap lines can be constructed based on BIOS output or other requirements. See the memmap=nn@ss
_
Quoted 7 lines · Hariprasad Nellitheertha
Hi Andi,
In order to port kdump to
x86_64, we need to have the memmap= kernel command line option available. This is so that the dump-capture kernel can be booted with a custom memory map.
Quoted 6 lines
The attached patch adds the memmap= functionality to the
x86_64kernel. It is against 2.6.12-rc2-mm3. I have done some amount of testing and it is working fine.Could you kindly review this patch and let me know your thoughts on it.
You should add a __setup somewhere, otherwise the kernel will complain about unknown arguments or generate a memmap variable in inits environment.
Comma parsing would be nice.
Otherwise it looks ok.
-Andi
Quoted 6 lines · Andi Kleen
Quoted 4 lines · Hariprasad Nellitheertha
Hi Andi,
In order to port kdump to
x86_64, we need to have the memmap= kernel command line option available. This is so that the dump-capture kernel can be booted with a custom memory map.
Quoted 8 lines
Quoted 3 lines
The attached patch adds the memmap= functionality to the
x86_64kernel. It is against 2.6.12-rc2-mm3. I have done some amount of testing and it is working fine.Could you kindly review this patch and let me know your thoughts on it.
You should add a
__setupsomewhere, otherwise the kernel will complain about unknown arguments or generate a memmap variable in inits environment.
Sure. Will add that.
Quoted 2 lines
Comma parsing would be nice.
Will add this for i386 as well and send out another patch
Quoted 2 lines
Otherwise it looks ok.
Thanks!
- Hari
Hi Andi,
Quoted 6 lines · Andi Kleen
Quoted 4 lines · Hariprasad Nellitheertha
Hi Andi,
In order to port kdump to
x86_64, we need to have the memmap= kernel command line option available. This is so that the dump-capture kernel can be booted with a custom memory map.
Quoted 8 lines
Quoted 3 lines
The attached patch adds the memmap= functionality to the
x86_64kernel. It is against 2.6.12-rc2-mm3. I have done some amount of testing and it is working fine.Could you kindly review this patch and let me know your thoughts on it.
You should add a
__setupsomewhere, otherwise the kernel will complain about unknown arguments or generate a memmap variable in inits environment.
The memmap= option does not introduce any new variables that we would need at a later point of time. Its very similar in the way it handles the maps to the "mem=" option. Hence I have not added the __setup in the attached patch.
Quoted 2 lines
Comma parsing would be nice.
I have introduced comma parsing. The patch for doing the same in i386 follows in a separate patch.
Please review and let me know your comments.
Regards, Hari
This patch adds the 'memmap=' kernel command line option for the x86_64 kernel.
---
linux-2.6.12-rc2-hari/Documentation/kernel-parameters.txt | 2 linux-2.6.12-rc2-hari/arch/x86_64/kernel/e820.c | 32 ++++++++++++++ linux-2.6.12-rc2-hari/arch/x86_64/kernel/setup.c | 3 + linux-2.6.12-rc2-hari/include/asm-x86_64/e820.h | 2 4 files changed, 38 insertions(+), 1 deletion(-)
arch/x86_64/kernel/e820.c renamed from arch/x86_64/kernel/e820.c~x8664-memmap-command-line-option +32 -0
@@ -513,6 +513,38 @@ void __init parse_memopt(char *p, char * end_user_pfn >>=PAGE_SHIFT ; } +void __init parse_memmapopt (char *p,char **from) +{ +do { +if (!memcmp (p,"exactmap" ,8 )) { + p +=8 ; + e820.nr_map =0 ; + }else { +unsigned long long start_at, mem_size; + + mem_size =memparse (p, from); + p = *from; +if (*p =='@' ) { + start_at =memparse (p+1 , from); +add_memory_region (start_at, mem_size,E820_RAM ); + }else if (*p =='#' ) { + start_at =memparse (p+1 , from); +add_memory_region (start_at, mem_size,E820_ACPI ); + }else if (*p =='$' ) { + start_at =memparse (p+1 , from); +add_memory_region (start_at, mem_size,E820_RESERVED ); + }else { + end_user_pfn = (mem_size >>PAGE_SHIFT ); + } + p = *from; + } +if (*p !=',' ) +break ; +else + p +=1 ; + }while (1 ); +} +unsigned long pci_mem_start =0xaeedbabe ;/*
arch/x86_64/kernel/setup.c renamed from arch/x86_64/kernel/setup.c~x8664-memmap-command-line-option +3 -0
@@ -349,6 +349,9 @@ static __init void parse_cmdline_early (if (!memcmp (from,"mem=" ,4 ))parse_memopt (from+4 , &from); +if (!memcmp (from,"memmap=" ,7 )) +parse_memmapopt (from+7 , &from); +#ifdef CONFIG_DISCONTIGMEM if (!memcmp (from,"numa=" ,5 ))numa_setup (from+5 );
include/asm-x86_64/e820.h renamed from include/asm-x86_64/e820.h~x8664-memmap-command-line-option +2 -0
@@ -54,6 +54,8 @@ extern void e820_setup_gap(void);extern void __init parse_memopt (char *p,char **end); +extern void __init parse_memmapopt (char *p,char **end); +extern struct e820map e820;#endif /*!__ASSEMBLY__*/
Documentation/kernel-parameters.txt renamed from Documentation/kernel-parameters.txt~x8664-memmap-command-line-option +1 -1
@@ -794,7 +794,7 @@ running once the system is up. mem=nopentium [BUGS=IA-32] Disable usage of 4MB pages for kernel memory. - memmap=exactmap [KNL,IA-32] Enable setting of an exact + memmap=exactmap [KNL,IA-32,X86-64] Enable setting of an exact E820 memory map, as specified by the user. Such memmap=exactmap lines can be constructed based on BIOS output or other requirements. See the memmap=nn@ss
_
Re: [RFC][i386] Comma parsing for the memmap= kernel command line option
Regards, Hari
This patch adds comma parsing ability to the i386 memmap= kernel command line option. With this, multiple entries to memmap can be separated by a comma instead of separate entries.
For example, memmap=exactmap,640k@0M,1024M@1M
---
linux-2.6.12-rc2-hari/arch/i386/kernel/setup.c | 79 +++++++++++++------------ 1 files changed, 43 insertions(+), 36 deletions(-)
arch/i386/kernel/setup.c renamed from arch/i386/kernel/setup.c~i386-memmap-comma-parsing +43 -36
@@ -716,45 +716,52 @@ static void __init parse_cmdline_early ( }else if (!memcmp (from,"memmap=" ,7 )) { -if (to != command_line) - to--; -if (!memcmp (from+7 ,"exactmap" ,8 )) { + from +=7 ; +do { +if (to != command_line) + to--; +if (!memcmp (from,"exactmap" ,8 )) {#ifdef CONFIG_CRASH_DUMP -/* If we are doing a crash dump, we -* still need to know the real mem -* size before original memory map is -* reset. -*/ -find_max_pfn (); - saved_max_pfn = max_pfn; -#endif - from +=8 +7 ; - e820.nr_map =0 ; - userdef =1 ; - }else { -/* If the user specifies memory size, we -* limit the BIOS-provided memory map to -* that size. exactmap can be used to specify -* the exact map. mem=number can be used to -* trim the existing memory map. -*/ -unsigned long long start_at, mem_size; - - mem_size =memparse (from+7 , &from); -if (*from =='@' ) { - start_at =memparse (from+1 , &from); -add_memory_region (start_at, mem_size,E820_RAM ); - }else if (*from =='#' ) { - start_at =memparse (from+1 , &from); -add_memory_region (start_at, mem_size,E820_ACPI ); - }else if (*from =='$' ) { - start_at =memparse (from+1 , &from); -add_memory_region (start_at, mem_size,E820_RESERVED ); +/* If we are doing a crash dump, we +* still need to know the real mem +* size before original memory map is +* reset. +*/ +find_max_pfn (); + saved_max_pfn = max_pfn; +#endif + from +=8 ; + e820.nr_map =0 ; + userdef =1 ; }else { -limit_regions (mem_size); - userdef=1 ; +/* If the user specifies memory size, we +* limit the BIOS-provided memory map to +* that size. exactmap can be used to specify +* the exact map. mem=number can be used to +* trim the existing memory map. +*/ +unsigned long long start_at, mem_size; + + mem_size =memparse (from, &from); +if (*from =='@' ) { + start_at =memparse (from+1 , &from); +add_memory_region (start_at, mem_size,E820_RAM ); + }else if (*from =='#' ) { + start_at =memparse (from+1 , &from); +add_memory_region (start_at, mem_size,E820_ACPI ); + }else if (*from =='$' ) { + start_at =memparse (from+1 , &from); +add_memory_region (start_at, mem_size,E820_RESERVED ); + }else { +limit_regions (mem_size); + userdef=1 ; + } } - } +if (*from !=',' ) +break ; +else + from +=1 ; + }while (1 ); }else if (!memcmp (from,"noexec=" ,7 ))
_