]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
kernel/crash_core: add crashkernel=auto for vmcore creation
authorSaeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
Thu, 22 Apr 2021 06:43:03 +0000 (16:43 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 5 May 2021 22:09:24 +0000 (08:09 +1000)
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.

Link: https://lkml.kernel.org/r/20210223174153.72802-1-saeed.mirzamohammadi@oracle.com
Signed-off-by: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
Signed-off-by: John Donnelly <john.p.donnelly@oracle.com>
Tested-by: John Donnelly <john.p.donnelly@oracle.com>
ed-by: Dave Young <dyoung@redhat.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: "Paul E. McKenney" <paulmck@kernel.org>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: "Guilherme G. Piccoli" <gpiccoli@canonical.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
Cc: YiFei Zhu <yifeifz2@illinois.edu>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Sami Tolvanen <samitolvanen@google.com>
Cc: Frederic Weisbecker <frederic@kernel.org>
Cc: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: Andrey Konovalov <andreyknvl@google.com>
Cc: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Documentation/admin-guide/kdump/kdump.rst
Documentation/admin-guide/kernel-parameters.txt
arch/Kconfig
kernel/crash_core.c

index 75a9dd98e76eb301816775a3f3d545ed00292fed..ae030111e22a8b42c4ce20a0b4bc242c78220622 100644 (file)
@@ -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
 =======================
index d93fbc1c1917e08ef5fc372ca8e2f149f65c9793..cf3513e00b010aa0b0cdb97ac31d12cb612890e4 100644 (file)
                        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
index bf27159be4d9af7c7745ca4639ef0be11c4d3f4e..2e4625e3012e50fe290bc9613a8db80b01c5645b 100644 (file)
@@ -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=<range1>:<size1>[,<range2>:<size2>,...][@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
index 825284baaf4660bd3d724a757fd7c51945066ece..90f9e4bb670465494654d082d3905100c5080223 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/crash_core.h>
 #include <linux/utsname.h>
 #include <linux/vmalloc.h>
+#include <linux/kexec.h>
 
 #include <asm/page.h>
 #include <asm/sections.h>
@@ -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