Re: [PATCH v7 26/27] x86: add Crash kernel low reservation
On Wed, Dec 19, 2012 at 9:22 AM, Borislav Petkov wrote: > On Mon, Dec 17, 2012 at 11:15:58PM -0800, Yinghai Lu wrote: >> +static u64 __init get_mem_size(unsigned long limit_pfn) >> +{ >> + int i; >> + u64 pages = 0; >> + unsigned long start_pfn, end_pfn; >> + >> + for_each_mem_pfn_range(i, MAX_NUMNODES, _pfn, _pfn, NULL) { >> + start_pfn = min_t(unsigned long, start_pfn, limit_pfn); >> + end_pfn = min_t(unsigned long, end_pfn, limit_pfn); >> + pages += end_pfn - start_pfn; >> + } >> + >> + return pages << PAGE_SHIFT; >> +} > > This needs an empty function prototype for the .config variant where both > > # CONFIG_BLK_DEV_INITRD is not set > # CONFIG_KEXEC is not set > > otherwise: > > arch/x86/kernel/setup.c:295:19: warning: ‘get_mem_size’ defined but not used > [-Wunused-function] > > At a second glance though, a better fix might be if that whole > if-deffery in setup.c could be cleaned up a bit. > ok, will move the function into e820.c or memblock.c Thanks Yinghai -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v7 26/27] x86: add Crash kernel low reservation
On Mon, Dec 17, 2012 at 11:15:58PM -0800, Yinghai Lu wrote: > +static u64 __init get_mem_size(unsigned long limit_pfn) > +{ > + int i; > + u64 pages = 0; > + unsigned long start_pfn, end_pfn; > + > + for_each_mem_pfn_range(i, MAX_NUMNODES, _pfn, _pfn, NULL) { > + start_pfn = min_t(unsigned long, start_pfn, limit_pfn); > + end_pfn = min_t(unsigned long, end_pfn, limit_pfn); > + pages += end_pfn - start_pfn; > + } > + > + return pages << PAGE_SHIFT; > +} This needs an empty function prototype for the .config variant where both # CONFIG_BLK_DEV_INITRD is not set # CONFIG_KEXEC is not set otherwise: arch/x86/kernel/setup.c:295:19: warning: ‘get_mem_size’ defined but not used [-Wunused-function] At a second glance though, a better fix might be if that whole if-deffery in setup.c could be cleaned up a bit. Thanks. -- Regards/Gruss, Boris. Sent from a fat crate under my desk. Formatting is fine. -- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v7 26/27] x86: add Crash kernel low reservation
On Mon, Dec 17, 2012 at 11:15:58PM -0800, Yinghai Lu wrote: +static u64 __init get_mem_size(unsigned long limit_pfn) +{ + int i; + u64 pages = 0; + unsigned long start_pfn, end_pfn; + + for_each_mem_pfn_range(i, MAX_NUMNODES, start_pfn, end_pfn, NULL) { + start_pfn = min_t(unsigned long, start_pfn, limit_pfn); + end_pfn = min_t(unsigned long, end_pfn, limit_pfn); + pages += end_pfn - start_pfn; + } + + return pages PAGE_SHIFT; +} This needs an empty function prototype for the .config variant where both # CONFIG_BLK_DEV_INITRD is not set # CONFIG_KEXEC is not set otherwise: arch/x86/kernel/setup.c:295:19: warning: ‘get_mem_size’ defined but not used [-Wunused-function] At a second glance though, a better fix might be if that whole if-deffery in setup.c could be cleaned up a bit. Thanks. -- Regards/Gruss, Boris. Sent from a fat crate under my desk. Formatting is fine. -- -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v7 26/27] x86: add Crash kernel low reservation
On Wed, Dec 19, 2012 at 9:22 AM, Borislav Petkov b...@alien8.de wrote: On Mon, Dec 17, 2012 at 11:15:58PM -0800, Yinghai Lu wrote: +static u64 __init get_mem_size(unsigned long limit_pfn) +{ + int i; + u64 pages = 0; + unsigned long start_pfn, end_pfn; + + for_each_mem_pfn_range(i, MAX_NUMNODES, start_pfn, end_pfn, NULL) { + start_pfn = min_t(unsigned long, start_pfn, limit_pfn); + end_pfn = min_t(unsigned long, end_pfn, limit_pfn); + pages += end_pfn - start_pfn; + } + + return pages PAGE_SHIFT; +} This needs an empty function prototype for the .config variant where both # CONFIG_BLK_DEV_INITRD is not set # CONFIG_KEXEC is not set otherwise: arch/x86/kernel/setup.c:295:19: warning: ‘get_mem_size’ defined but not used [-Wunused-function] At a second glance though, a better fix might be if that whole if-deffery in setup.c could be cleaned up a bit. ok, will move the function into e820.c or memblock.c Thanks Yinghai -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v7 26/27] x86: add Crash kernel low reservation
During kdump kernel's booting stage, it need to find low ram for swiotlb buffer when system does not support intel iommu/dmar remapping. kexed-tools is appending memmap=exactmap and range from /proc/iomem with "Crash kernel", and that range is above 4G for 64bit after boot protocol 2.12. We need to add another range in /proc/iomem like "Crash kernel low", so kexec-tools could find that info and append to kdump kernel command line. Try to reserve some under 4G if the normal "Crash kernel" is above 4G. User could specify the size with crashkernel_low=XX[KMG]. If the user does not specify that, will use 72M instead. -v2: fix warning that is found by Fengguang's test robot. Signed-off-by: Yinghai Lu --- Documentation/kernel-parameters.txt |3 ++ arch/x86/kernel/setup.c | 70 +++ include/linux/kexec.h |3 ++ kernel/kexec.c | 34 ++--- 4 files changed, 89 insertions(+), 21 deletions(-) diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 2b37020..e8c48e9 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -600,6 +600,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted. is selected automatically. Check Documentation/kdump/kdump.txt for further details. + crashkernel_low=size[KMG] + [KNL, x86] parts under 4G. + crashkernel=range1:size1[,range2:size2,...][@offset] [KNL] Same as above, but depends on the memory in the running system. The syntax of range is diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 2631008..5373a71 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -292,6 +292,21 @@ static void __init reserve_brk(void) _brk_start = 0; } +static u64 __init get_mem_size(unsigned long limit_pfn) +{ + int i; + u64 pages = 0; + unsigned long start_pfn, end_pfn; + + for_each_mem_pfn_range(i, MAX_NUMNODES, _pfn, _pfn, NULL) { + start_pfn = min_t(unsigned long, start_pfn, limit_pfn); + end_pfn = min_t(unsigned long, end_pfn, limit_pfn); + pages += end_pfn - start_pfn; + } + + return pages << PAGE_SHIFT; +} + #ifdef CONFIG_BLK_DEV_INITRD static u64 __init get_ramdisk_image(void) @@ -363,20 +378,6 @@ static void __init relocate_initrd(void) ramdisk_here, ramdisk_here + ramdisk_size - 1); } -static u64 __init get_mem_size(unsigned long limit_pfn) -{ - int i; - u64 mapped_pages = 0; - unsigned long start_pfn, end_pfn; - - for_each_mem_pfn_range(i, MAX_NUMNODES, _pfn, _pfn, NULL) { - start_pfn = min_t(unsigned long, start_pfn, limit_pfn); - end_pfn = min_t(unsigned long, end_pfn, limit_pfn); - mapped_pages += end_pfn - start_pfn; - } - - return mapped_pages << PAGE_SHIFT; -} static void __init early_reserve_initrd(void) { /* Assume only end is not page aligned */ @@ -522,8 +523,43 @@ static void __init memblock_x86_reserve_range_setup_data(void) # define CRASH_KERNEL_ADDR_MAX MAXMEM #endif +static void __init reserve_crashkernel_low(void) +{ +#ifdef CONFIG_X86_64 + const unsigned long long alignment = 16<<20;/* 16M */ + unsigned long long low_base = 0, low_size = 0; + unsigned long total_low_mem; + unsigned long long base; + int ret; + + total_low_mem = get_mem_size(1UL<<(32-PAGE_SHIFT)); + ret = parse_crashkernel_low(boot_command_line, total_low_mem, + _size, ); + if (ret != 0 || low_size <= 0) + low_size = (72UL<<20); /* 72M */ + low_base = memblock_find_in_range(low_size, (1ULL<<32), + low_size, alignment); + + if (!low_base) { + pr_info("crashkernel low reservation failed - No suitable area found.\n"); + + return; + } + + memblock_reserve(low_base, low_size); + pr_info("Reserving %ldMB of low memory at %ldMB for crashkernel (System low RAM: %ldMB)\n", + (unsigned long)(low_size >> 20), + (unsigned long)(low_base >> 20), + (unsigned long)(total_low_mem >> 20)); + crashk_low_res.start = low_base; + crashk_low_res.end = low_base + low_size - 1; + insert_resource(_resource, _low_res); +#endif +} + static void __init reserve_crashkernel(void) { + const unsigned long long alignment = 16<<20;/* 16M */ unsigned long long total_mem; unsigned long long crash_size, crash_base; int ret; @@ -537,8 +573,6 @@ static void __init reserve_crashkernel(void) /* 0 means: find the address automatically */ if
[PATCH v7 26/27] x86: add Crash kernel low reservation
During kdump kernel's booting stage, it need to find low ram for swiotlb buffer when system does not support intel iommu/dmar remapping. kexed-tools is appending memmap=exactmap and range from /proc/iomem with Crash kernel, and that range is above 4G for 64bit after boot protocol 2.12. We need to add another range in /proc/iomem like Crash kernel low, so kexec-tools could find that info and append to kdump kernel command line. Try to reserve some under 4G if the normal Crash kernel is above 4G. User could specify the size with crashkernel_low=XX[KMG]. If the user does not specify that, will use 72M instead. -v2: fix warning that is found by Fengguang's test robot. Signed-off-by: Yinghai Lu ying...@kernel.org --- Documentation/kernel-parameters.txt |3 ++ arch/x86/kernel/setup.c | 70 +++ include/linux/kexec.h |3 ++ kernel/kexec.c | 34 ++--- 4 files changed, 89 insertions(+), 21 deletions(-) diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 2b37020..e8c48e9 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -600,6 +600,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted. is selected automatically. Check Documentation/kdump/kdump.txt for further details. + crashkernel_low=size[KMG] + [KNL, x86] parts under 4G. + crashkernel=range1:size1[,range2:size2,...][@offset] [KNL] Same as above, but depends on the memory in the running system. The syntax of range is diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 2631008..5373a71 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -292,6 +292,21 @@ static void __init reserve_brk(void) _brk_start = 0; } +static u64 __init get_mem_size(unsigned long limit_pfn) +{ + int i; + u64 pages = 0; + unsigned long start_pfn, end_pfn; + + for_each_mem_pfn_range(i, MAX_NUMNODES, start_pfn, end_pfn, NULL) { + start_pfn = min_t(unsigned long, start_pfn, limit_pfn); + end_pfn = min_t(unsigned long, end_pfn, limit_pfn); + pages += end_pfn - start_pfn; + } + + return pages PAGE_SHIFT; +} + #ifdef CONFIG_BLK_DEV_INITRD static u64 __init get_ramdisk_image(void) @@ -363,20 +378,6 @@ static void __init relocate_initrd(void) ramdisk_here, ramdisk_here + ramdisk_size - 1); } -static u64 __init get_mem_size(unsigned long limit_pfn) -{ - int i; - u64 mapped_pages = 0; - unsigned long start_pfn, end_pfn; - - for_each_mem_pfn_range(i, MAX_NUMNODES, start_pfn, end_pfn, NULL) { - start_pfn = min_t(unsigned long, start_pfn, limit_pfn); - end_pfn = min_t(unsigned long, end_pfn, limit_pfn); - mapped_pages += end_pfn - start_pfn; - } - - return mapped_pages PAGE_SHIFT; -} static void __init early_reserve_initrd(void) { /* Assume only end is not page aligned */ @@ -522,8 +523,43 @@ static void __init memblock_x86_reserve_range_setup_data(void) # define CRASH_KERNEL_ADDR_MAX MAXMEM #endif +static void __init reserve_crashkernel_low(void) +{ +#ifdef CONFIG_X86_64 + const unsigned long long alignment = 1620;/* 16M */ + unsigned long long low_base = 0, low_size = 0; + unsigned long total_low_mem; + unsigned long long base; + int ret; + + total_low_mem = get_mem_size(1UL(32-PAGE_SHIFT)); + ret = parse_crashkernel_low(boot_command_line, total_low_mem, + low_size, base); + if (ret != 0 || low_size = 0) + low_size = (72UL20); /* 72M */ + low_base = memblock_find_in_range(low_size, (1ULL32), + low_size, alignment); + + if (!low_base) { + pr_info(crashkernel low reservation failed - No suitable area found.\n); + + return; + } + + memblock_reserve(low_base, low_size); + pr_info(Reserving %ldMB of low memory at %ldMB for crashkernel (System low RAM: %ldMB)\n, + (unsigned long)(low_size 20), + (unsigned long)(low_base 20), + (unsigned long)(total_low_mem 20)); + crashk_low_res.start = low_base; + crashk_low_res.end = low_base + low_size - 1; + insert_resource(iomem_resource, crashk_low_res); +#endif +} + static void __init reserve_crashkernel(void) { + const unsigned long long alignment = 1620;/* 16M */ unsigned long long total_mem; unsigned long long crash_size, crash_base; int ret; @@ -537,8 +573,6 @@ static void __init reserve_crashkernel(void) /* 0 means: find the address