Re: [PATCH v3 1/1] kernel/crash_core: Add crashkernel=auto for vmcore creation
> On Feb 23, 2021, at 5:56 AM, Baoquan He wrote: > > On 02/23/21 at 08:01pm, Kairui Song wrote: >> On Thu, Feb 18, 2021 at 10:03 AM Baoquan He wrote: >>> >>> On 02/11/21 at 10:08am, Saeed Mirzamohammadi wrote: > ... >>>> diff --git a/arch/Kconfig b/arch/Kconfig >>>> index af14a567b493..f87c88ffa2f8 100644 >>>> --- a/arch/Kconfig >>>> +++ b/arch/Kconfig >>>> @@ -14,6 +14,30 @@ menu "General architecture-dependent options" >>>> config CRASH_CORE >>>> bool >>>> >>>> +if CRASH_CORE >>>> + >>>> +config CRASH_AUTO_STR >>>> + string "Memory reserved for crash kernel" >>>> + depends on CRASH_CORE >>>> + default "1G-64G:128M,64G-1T:256M,1T-:512M" >>>> + help >>>> + This configures the reserved memory dependent >>>> + on the value of System RAM. The syntax is: >>>> + crashkernel=:[,:,...][@offset] >>>> + range=start-[end] >>>> + >>>> + For example: >>>> + crashkernel=512M-2G:64M,2G-:128M >>>> + >>>> + This would mean: >>>> + >>>> + 1) if the RAM is smaller than 512M, then don't reserve anything >>>> + (this is the "rescue" case) >>>> + 2) if the RAM size is between 512M and 2G (exclusive), then >>>> reserve 64M >>>> + 3) if the RAM size is larger than 2G, then reserve 128M >>>> + >>>> +endif # CRASH_CORE >>> >>> Wondering if this CRASH_CORE ifdeffery is a little redundent here >>> since CRASH_CORE dependency has been added. Except of this, I like this >>> patch. As we discussed in private threads, we can try to push it into >>> mainline and continue improving later. >>> >> >> I believe "if CRASH_CORE" is not needed as it already "depends on >> CRASH_CORE", tested with CRASH_CORE=y or 'not set', it just works. > > Thanks for testing and confirmation, Kairui. > > Saeed, can you post a v4 with CRASH_CORE ifdeffery removed? Maybe this > week? Thanks Kairui and Baoquan for testing and review. I just sent the v4. Hope we move forward and apply this week. Saeed > > Thanks > Baoquan > >> >>>> + >>>> config KEXEC_CORE >>>> select CRASH_CORE >>>> bool >>>> diff --git a/kernel/crash_core.c b/kernel/crash_core.c >>>> index 106e4500fd53..ab0a2b4b1ffa 100644 >>>> --- a/kernel/crash_core.c >>>> +++ b/kernel/crash_core.c >>>> @@ -7,6 +7,7 @@ >>>> #include >>>> #include >>>> #include >>>> +#include >>>> >>>> #include >>>> #include >>>> @@ -250,6 +251,12 @@ static int __init __parse_crashkernel(char *cmdline, >>>> if (suffix) >>>> return parse_crashkernel_suffix(ck_cmdline, crash_size, >>>> suffix); >>>> +#ifdef CONFIG_CRASH_AUTO_STR >>>> + if (strncmp(ck_cmdline, "auto", 4) == 0) { >>>> + ck_cmdline = CONFIG_CRASH_AUTO_STR; >>>> + pr_info("Using crashkernel=auto, the size chosen is a best >>>> effort estimation.\n"); >>>> + } >>>> +#endif >>>> /* >>>> * if the commandline contains a ':', then that's the extended >>>> * syntax -- if not, it must be the classic syntax >>>> -- >>>> 2.27.0 >>>> >>> >>> >>> ___ >>> kexec mailing list >>> kexec@lists.infradead.org >>> https://urldefense.com/v3/__http://lists.infradead.org/mailman/listinfo/kexec__;!!GqivPVa7Brio!MaBAPZr-j_WcNPodmosfVOyl0ipO6u22Ex-7gSi--wlwbmTgmkhsf-0yftioew3jnkS5WV5v$ >>> >>> >> >> >> -- >> Best Regards, >> Kairui Song >> > ___ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec
[PATCH v4 1/1] kernel/crash_core: Add crashkernel=auto for vmcore creation
This adds crashkernel=auto feature to configure reserved memory for vmcore creation. CONFIG_CRASH_AUTO_STR is defined to be set for different kernel distributions and different archs based on their needs. Signed-off-by: Saeed Mirzamohammadi Signed-off-by: John Donnelly Tested-by: John Donnelly --- Documentation/admin-guide/kdump/kdump.rst | 3 ++- .../admin-guide/kernel-parameters.txt | 6 ++ arch/Kconfig | 20 +++ kernel/crash_core.c | 7 +++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kdump/kdump.rst b/Documentation/admin-guide/kdump/kdump.rst index 75a9dd98e76e..ae030111e22a 100644 --- a/Documentation/admin-guide/kdump/kdump.rst +++ b/Documentation/admin-guide/kdump/kdump.rst @@ -285,7 +285,8 @@ This would mean: 2) if the RAM size is between 512M and 2G (exclusive), then reserve 64M 3) if the RAM size is larger than 2G, then reserve 128M - +Or you can use crashkernel=auto to choose the crash kernel memory size +based on the recommended configuration set for each arch. Boot into System Kernel === diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 9e3cdb271d06..a5deda5c85fe 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -747,6 +747,12 @@ a memory unit (amount[KMG]). See also Documentation/admin-guide/kdump/kdump.rst for an example. + crashkernel=auto + [KNL] This parameter will set the reserved memory for + the crash kernel based on the value of the CRASH_AUTO_STR + that is the best effort estimation for each arch. See also + arch/Kconfig for further details. + crashkernel=size[KMG],high [KNL, X86-64] range could be above 4G. Allow kernel to allocate physical memory region from top, so could diff --git a/arch/Kconfig b/arch/Kconfig index 24862d15f3a3..23d047548772 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -14,6 +14,26 @@ menu "General architecture-dependent options" config CRASH_CORE bool +config CRASH_AUTO_STR + string "Memory reserved for crash kernel" + depends on CRASH_CORE + default "1G-64G:128M,64G-1T:256M,1T-:512M" + help + This configures the reserved memory dependent + on the value of System RAM. The syntax is: + crashkernel=:[,:,...][@offset] + range=start-[end] + + For example: + crashkernel=512M-2G:64M,2G-:128M + + This would mean: + + 1) if the RAM is smaller than 512M, then don't reserve anything +(this is the "rescue" case) + 2) if the RAM size is between 512M and 2G (exclusive), then reserve 64M + 3) if the RAM size is larger than 2G, then reserve 128M + config KEXEC_CORE select CRASH_CORE bool diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 825284baaf46..90f9e4bb6704 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -250,6 +251,12 @@ static int __init __parse_crashkernel(char *cmdline, if (suffix) return parse_crashkernel_suffix(ck_cmdline, crash_size, suffix); +#ifdef CONFIG_CRASH_AUTO_STR + if (strncmp(ck_cmdline, "auto", 4) == 0) { + ck_cmdline = CONFIG_CRASH_AUTO_STR; + pr_info("Using crashkernel=auto, the size chosen is a best effort estimation.\n"); + } +#endif /* * if the commandline contains a ':', then that's the extended * syntax -- if not, it must be the classic syntax -- 2.27.0 ___ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec
[PATCH v3 1/1] kernel/crash_core: Add crashkernel=auto for vmcore creation
This adds crashkernel=auto feature to configure reserved memory for vmcore creation. CONFIG_CRASH_AUTO_STR is defined to be set for different kernel distributions and different archs based on their needs. Signed-off-by: Saeed Mirzamohammadi Signed-off-by: John Donnelly Tested-by: John Donnelly --- Documentation/admin-guide/kdump/kdump.rst | 3 ++- .../admin-guide/kernel-parameters.txt | 6 + arch/Kconfig | 24 +++ kernel/crash_core.c | 7 ++ 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kdump/kdump.rst b/Documentation/admin-guide/kdump/kdump.rst index 2da65fef2a1c..e55cdc404c6b 100644 --- a/Documentation/admin-guide/kdump/kdump.rst +++ b/Documentation/admin-guide/kdump/kdump.rst @@ -285,7 +285,8 @@ This would mean: 2) if the RAM size is between 512M and 2G (exclusive), then reserve 64M 3) if the RAM size is larger than 2G, then reserve 128M - +Or you can use crashkernel=auto to choose the crash kernel memory size +based on the recommended configuration set for each arch. Boot into System Kernel === diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 7d4e523646c3..aa2099465458 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -736,6 +736,12 @@ a memory unit (amount[KMG]). See also Documentation/admin-guide/kdump/kdump.rst for an example. + crashkernel=auto + [KNL] This parameter will set the reserved memory for + the crash kernel based on the value of the CRASH_AUTO_STR + that is the best effort estimation for each arch. See also + arch/Kconfig for further details. + crashkernel=size[KMG],high [KNL, X86-64] range could be above 4G. Allow kernel to allocate physical memory region from top, so could diff --git a/arch/Kconfig b/arch/Kconfig index af14a567b493..f87c88ffa2f8 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -14,6 +14,30 @@ menu "General architecture-dependent options" config CRASH_CORE bool +if CRASH_CORE + +config CRASH_AUTO_STR + string "Memory reserved for crash kernel" + depends on CRASH_CORE + default "1G-64G:128M,64G-1T:256M,1T-:512M" + help + This configures the reserved memory dependent + on the value of System RAM. The syntax is: + crashkernel=:[,:,...][@offset] + range=start-[end] + + For example: + crashkernel=512M-2G:64M,2G-:128M + + This would mean: + + 1) if the RAM is smaller than 512M, then don't reserve anything +(this is the "rescue" case) + 2) if the RAM size is between 512M and 2G (exclusive), then reserve 64M + 3) if the RAM size is larger than 2G, then reserve 128M + +endif # CRASH_CORE + config KEXEC_CORE select CRASH_CORE bool diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 106e4500fd53..ab0a2b4b1ffa 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -250,6 +251,12 @@ static int __init __parse_crashkernel(char *cmdline, if (suffix) return parse_crashkernel_suffix(ck_cmdline, crash_size, suffix); +#ifdef CONFIG_CRASH_AUTO_STR + if (strncmp(ck_cmdline, "auto", 4) == 0) { + ck_cmdline = CONFIG_CRASH_AUTO_STR; + pr_info("Using crashkernel=auto, the size chosen is a best effort estimation.\n"); + } +#endif /* * if the commandline contains a ':', then that's the extended * syntax -- if not, it must be the classic syntax -- 2.27.0 ___ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec
[PATCH v2 1/1] kernel/crash_core: Add crashkernel=auto for vmcore creation
This adds crashkernel=auto feature to configure reserved memory for vmcore creation. CONFIG_CRASH_AUTO_STR is defined to be set for different kernel distributions and different archs based on their needs. Signed-off-by: Saeed Mirzamohammadi Signed-off-by: John Donnelly Tested-by: John Donnelly --- Documentation/admin-guide/kdump/kdump.rst | 5 + arch/Kconfig | 24 +++ kernel/crash_core.c | 7 +++ 3 files changed, 36 insertions(+) diff --git a/Documentation/admin-guide/kdump/kdump.rst b/Documentation/admin-guide/kdump/kdump.rst index 75a9dd98e76e..f95a2af64f59 100644 --- a/Documentation/admin-guide/kdump/kdump.rst +++ b/Documentation/admin-guide/kdump/kdump.rst @@ -285,7 +285,12 @@ This would mean: 2) if the RAM size is between 512M and 2G (exclusive), then reserve 64M 3) if the RAM size is larger than 2G, then reserve 128M +Or you can use crashkernel=auto if you have enough memory. The threshold +is 1G on x86_64 and arm64. If your system memory is less than the threshold, +crashkernel=auto will not reserve memory. The size changes according to +the system memory size like below: +x86_64/arm64: 1G-64G:128M,64G-1T:256M,1T-:512M Boot into System Kernel === diff --git a/arch/Kconfig b/arch/Kconfig index 56b6ccc0e32d..a772eb397d73 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -14,6 +14,30 @@ menu "General architecture-dependent options" config CRASH_CORE bool +if CRASH_CORE + +config CRASH_AUTO_STR + string "Memory reserved for crash kernel" + depends on CRASH_CORE + default "1G-64G:128M,64G-1T:256M,1T-:512M" + help + This configures the reserved memory dependent + on the value of System RAM. The syntax is: + crashkernel=:[,:,...][@offset] + range=start-[end] + + For example: + crashkernel=512M-2G:64M,2G-:128M + + This would mean: + + 1) if the RAM is smaller than 512M, then don't reserve anything +(this is the "rescue" case) + 2) if the RAM size is between 512M and 2G (exclusive), then reserve 64M + 3) if the RAM size is larger than 2G, then reserve 128M + +endif # CRASH_CORE + config KEXEC_CORE select CRASH_CORE bool diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 106e4500fd53..ab0a2b4b1ffa 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -250,6 +251,12 @@ static int __init __parse_crashkernel(char *cmdline, if (suffix) return parse_crashkernel_suffix(ck_cmdline, crash_size, suffix); +#ifdef CONFIG_CRASH_AUTO_STR + if (strncmp(ck_cmdline, "auto", 4) == 0) { + ck_cmdline = CONFIG_CRASH_AUTO_STR; + pr_info("Using crashkernel=auto, the size chosen is a best effort estimation.\n"); + } +#endif /* * if the commandline contains a ':', then that's the extended * syntax -- if not, it must be the classic syntax -- 2.27.0 ___ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 1/1] kernel/crash_core.c - Add crashkernel=auto for x86 and ARM
Hi, [I’m resending this email as it failed to be sent to certain emails.] > And I think crashkernel=auto could be used as an indicator that user > want the kernel to control the crashkernel size, so some further work > could be done to adjust the crashkernel more accordingly. eg. when > memory encryption is enabled, increase the crashkernel value for the > auto estimation, as it's known to consume more crashkernel memory. > Thanks for the suggestion! I tried to keep it simple and leave it to the user to change Kconfig in case a different range is needed. Based on experience, these ranges work well for most of the regular cases. > > But why not make it arch-independent? This crashkernel=auto idea > should simply work with every arch. Thanks! I’ll be making it arch-independent in the v2 patch. > > I think this rounding may be better moved to the arch specified part > where parse_crashkernel is called? Thanks for the suggestion. Could you please elaborate why do we need to do that? Thanks, Saeed ___ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 1/1] kernel/crash_core.c - Add crashkernel=auto for x86 and ARM
> >> @@ -1135,6 +1135,30 @@ config CRASH_DUMP >> >>For more details see Documentation/admin-guide/kdump/kdump.rst >> >> +if CRASH_DUMP >> + >> +config CRASH_AUTO_STR >> +string "Memory reserved for crash kernel" > > use tab instead of spaces above. > Thanks, Randy. I’ll be fixing the them in the v2. I’ll be removing the ‘CC: stable’ as well. Saeed ___ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec
[PATCH 1/1] kernel/crash_core.c - Add crashkernel=auto for x86 and ARM
This adds crashkernel=auto feature to configure reserved memory for vmcore creation to both x86 and ARM platforms based on the total memory size. Cc: sta...@vger.kernel.org Signed-off-by: John Donnelly Signed-off-by: Saeed Mirzamohammadi --- Documentation/admin-guide/kdump/kdump.rst | 5 + arch/arm64/Kconfig| 26 ++- arch/arm64/configs/defconfig | 1 + arch/x86/Kconfig | 26 ++- arch/x86/configs/x86_64_defconfig | 1 + kernel/crash_core.c | 20 +++-- 6 files changed, 75 insertions(+), 4 deletions(-) diff --git a/Documentation/admin-guide/kdump/kdump.rst b/Documentation/admin-guide/kdump/kdump.rst index 75a9dd98e76e..f95a2af64f59 100644 --- a/Documentation/admin-guide/kdump/kdump.rst +++ b/Documentation/admin-guide/kdump/kdump.rst @@ -285,7 +285,12 @@ This would mean: 2) if the RAM size is between 512M and 2G (exclusive), then reserve 64M 3) if the RAM size is larger than 2G, then reserve 128M +Or you can use crashkernel=auto if you have enough memory. The threshold +is 1G on x86_64 and arm64. If your system memory is less than the threshold, +crashkernel=auto will not reserve memory. The size changes according to +the system memory size like below: +x86_64/arm64: 1G-64G:128M,64G-1T:256M,1T-:512M Boot into System Kernel === diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 1515f6f153a0..d359dcffa80e 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1124,7 +1124,7 @@ comment "Support for PE file signature verification disabled" depends on KEXEC_SIG depends on !EFI || !SIGNED_PE_FILE_VERIFICATION -config CRASH_DUMP +menuconfig CRASH_DUMP bool "Build kdump crash kernel" help Generate crash dump after being started by kexec. This should @@ -1135,6 +1135,30 @@ config CRASH_DUMP For more details see Documentation/admin-guide/kdump/kdump.rst +if CRASH_DUMP + +config CRASH_AUTO_STR +string "Memory reserved for crash kernel" + depends on CRASH_DUMP +default "1G-64G:128M,64G-1T:256M,1T-:512M" + help + This configures the reserved memory dependent + on the value of System RAM. The syntax is: + crashkernel=:[,:,...][@offset] + range=start-[end] + + For example: + crashkernel=512M-2G:64M,2G-:128M + + This would mean: + + 1) if the RAM is smaller than 512M, then don't reserve anything +(this is the "rescue" case) + 2) if the RAM size is between 512M and 2G (exclusive), then reserve 64M + 3) if the RAM size is larger than 2G, then reserve 128M + +endif # CRASH_DUMP + config XEN_DOM0 def_bool y depends on XEN diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig index 5cfe3cf6f2ac..899ef3b6a78f 100644 --- a/arch/arm64/configs/defconfig +++ b/arch/arm64/configs/defconfig @@ -69,6 +69,7 @@ CONFIG_SECCOMP=y CONFIG_KEXEC=y CONFIG_KEXEC_FILE=y CONFIG_CRASH_DUMP=y +# CONFIG_CRASH_AUTO_STR is not set CONFIG_XEN=y CONFIG_COMPAT=y CONFIG_RANDOMIZE_BASE=y diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index f6946b81f74a..bacd17312bb1 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2035,7 +2035,7 @@ config KEXEC_BZIMAGE_VERIFY_SIG help Enable bzImage signature verification support. -config CRASH_DUMP +menuconfig CRASH_DUMP bool "kernel crash dumps" depends on X86_64 || (X86_32 && HIGHMEM) help @@ -2049,6 +2049,30 @@ config CRASH_DUMP (CONFIG_RELOCATABLE=y). For more details see Documentation/admin-guide/kdump/kdump.rst +if CRASH_DUMP + +config CRASH_AUTO_STR +string "Memory reserved for crash kernel" if X86_64 + depends on CRASH_DUMP +default "1G-64G:128M,64G-1T:256M,1T-:512M" + help + This configures the reserved memory dependent + on the value of System RAM. The syntax is: + crashkernel=:[,:,...][@offset] + range=start-[end] + + For example: + crashkernel=512M-2G:64M,2G-:128M + + This would mean: + + 1) if the RAM is smaller than 512M, then don't reserve anything +(this is the "rescue" case) + 2) if the RAM size is between 512M and 2G (exclusive), then reserve 64M + 3) if the RAM size is larger than 2G, then reserve 128M + +endif # CRASH_DUMP + config KEXEC_JUMP bool "kexec jump" depends on KEXEC && HIBERNATION diff --git a/arch/x86/configs/x86_64_defconfig b/arch/x86/configs/x86_64_defconfig index 9936528e1939..7a87fbecf40b 100644 --- a/arch/x86/configs/x86_64_defconfig +++ b