linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 1/1] kernel/crash_core: Add crashkernel=auto for vmcore creation
@ 2021-02-11 18:08 Saeed Mirzamohammadi
  2021-02-17 18:40 ` john.p.donnelly
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Saeed Mirzamohammadi @ 2021-02-11 18:08 UTC (permalink / raw)
  Cc: saeed.mirzamohammadi, john.p.donnelly, Dave Young, Baoquan He,
	Vivek Goyal, Jonathan Corbet, Paul E. McKenney, Randy Dunlap,
	Andrew Morton, Thomas Gleixner, Mauro Carvalho Chehab,
	Mike Kravetz, Guilherme G. Piccoli, Kees Cook,
	Peter Zijlstra (Intel), Ingo Molnar, Steven Rostedt (VMware),
	Frederic Weisbecker, YiFei Zhu, Josh Poimboeuf, Mike Rapoport,
	Masahiro Yamada, Sami Tolvanen, Christian Brauner, Stephen Boyd,
	Andrey Konovalov, kexec, linux-doc, linux-kernel

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 <saeed.mirzamohammadi@oracle.com>
Signed-off-by: John Donnelly <john.p.donnelly@oracle.com>
Tested-by: John Donnelly <john.p.donnelly@oracle.com>
---
 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=<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
+
+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 <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
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 1/1] kernel/crash_core: Add crashkernel=auto for vmcore creation
  2021-02-11 18:08 [PATCH v3 1/1] kernel/crash_core: Add crashkernel=auto for vmcore creation Saeed Mirzamohammadi
@ 2021-02-17 18:40 ` john.p.donnelly
  2021-02-17 19:26   ` Steven Rostedt
  2021-02-18  1:20 ` Dave Young
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 13+ messages in thread
From: john.p.donnelly @ 2021-02-17 18:40 UTC (permalink / raw)
  To: Saeed Mirzamohammadi
  Cc: Dave Young, Baoquan He, Vivek Goyal, Jonathan Corbet,
	Paul E. McKenney, Randy Dunlap, Andrew Morton, Thomas Gleixner,
	Mauro Carvalho Chehab, Mike Kravetz, Guilherme G. Piccoli,
	Kees Cook, Peter Zijlstra (Intel),
	Ingo Molnar, Steven Rostedt (VMware),
	Frederic Weisbecker, YiFei Zhu, Josh Poimboeuf, Mike Rapoport,
	Masahiro Yamada, Sami Tolvanen, Christian Brauner, Stephen Boyd,
	Andrey Konovalov, kexec, linux-doc, linux-kernel

On 2/11/21 12:08 PM, Saeed Mirzamohammadi wrote:
> 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 <saeed.mirzamohammadi@oracle.com>
> Signed-off-by: John Donnelly <john.p.donnelly@oracle.com>
> Tested-by: John Donnelly <john.p.donnelly@oracle.com>
> ---
>   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=<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
> +
> +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 <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
> 


Hello.

Ping.

Can we get this reviewed and staged ?

Thank you.

John.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 1/1] kernel/crash_core: Add crashkernel=auto for vmcore creation
  2021-02-17 18:40 ` john.p.donnelly
@ 2021-02-17 19:26   ` Steven Rostedt
  2021-02-17 19:42     ` Vivek Goyal
  0 siblings, 1 reply; 13+ messages in thread
From: Steven Rostedt @ 2021-02-17 19:26 UTC (permalink / raw)
  To: john.p.donnelly, Andrew Morton
  Cc: Saeed Mirzamohammadi, Dave Young, Baoquan He, Vivek Goyal,
	Jonathan Corbet, Paul E. McKenney, Randy Dunlap, Thomas Gleixner,
	Mauro Carvalho Chehab, Mike Kravetz, Guilherme G. Piccoli,
	Kees Cook, Peter Zijlstra (Intel),
	Ingo Molnar, Frederic Weisbecker, YiFei Zhu, Josh Poimboeuf,
	Mike Rapoport, Masahiro Yamada, Sami Tolvanen, Christian Brauner,
	Stephen Boyd, Andrey Konovalov, kexec, linux-doc, linux-kernel

On Wed, 17 Feb 2021 12:40:43 -0600
john.p.donnelly@oracle.com wrote:

> Hello.
> 
> Ping.
> 
> Can we get this reviewed and staged ?
> 
> Thank you.

Andrew,

Seems you are the only one pushing patches in for kexec/crash. Is this
maintained by anyone?

-- Steve

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 1/1] kernel/crash_core: Add crashkernel=auto for vmcore creation
  2021-02-17 19:26   ` Steven Rostedt
@ 2021-02-17 19:42     ` Vivek Goyal
  2021-02-18  1:29       ` Dave Young
  0 siblings, 1 reply; 13+ messages in thread
From: Vivek Goyal @ 2021-02-17 19:42 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: john.p.donnelly, Andrew Morton, Saeed Mirzamohammadi, Dave Young,
	Baoquan He, Jonathan Corbet, Paul E. McKenney, Randy Dunlap,
	Thomas Gleixner, Mauro Carvalho Chehab, Mike Kravetz,
	Guilherme G. Piccoli, Kees Cook, Peter Zijlstra (Intel),
	Ingo Molnar, Frederic Weisbecker, YiFei Zhu, Josh Poimboeuf,
	Mike Rapoport, Masahiro Yamada, Sami Tolvanen, Christian Brauner,
	Stephen Boyd, Andrey Konovalov, kexec, linux-doc, linux-kernel

On Wed, Feb 17, 2021 at 02:26:53PM -0500, Steven Rostedt wrote:
> On Wed, 17 Feb 2021 12:40:43 -0600
> john.p.donnelly@oracle.com wrote:
> 
> > Hello.
> > 
> > Ping.
> > 
> > Can we get this reviewed and staged ?
> > 
> > Thank you.
> 
> Andrew,
> 
> Seems you are the only one pushing patches in for kexec/crash. Is this
> maintained by anyone?

Dave Young and Baoquan He still maintain kexec/kdump stuff, AFAIK. I
don't get time to look into this stuff now a days. 

Vivek


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 1/1] kernel/crash_core: Add crashkernel=auto for vmcore creation
  2021-02-11 18:08 [PATCH v3 1/1] kernel/crash_core: Add crashkernel=auto for vmcore creation Saeed Mirzamohammadi
  2021-02-17 18:40 ` john.p.donnelly
@ 2021-02-18  1:20 ` Dave Young
  2021-02-18  2:02 ` Baoquan He
  2021-02-24  1:54 ` Baoquan He
  3 siblings, 0 replies; 13+ messages in thread
From: Dave Young @ 2021-02-18  1:20 UTC (permalink / raw)
  To: Saeed Mirzamohammadi
  Cc: john.p.donnelly, Baoquan He, Vivek Goyal, Jonathan Corbet,
	Paul E. McKenney, Randy Dunlap, Andrew Morton, Thomas Gleixner,
	Mauro Carvalho Chehab, Mike Kravetz, Guilherme G. Piccoli,
	Kees Cook, Peter Zijlstra (Intel),
	Ingo Molnar, Steven Rostedt (VMware),
	Frederic Weisbecker, YiFei Zhu, Josh Poimboeuf, Mike Rapoport,
	Masahiro Yamada, Sami Tolvanen, Christian Brauner, Stephen Boyd,
	Andrey Konovalov, kexec, linux-doc, linux-kernel

On 02/11/21 at 10:08am, Saeed Mirzamohammadi wrote:
> 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 <saeed.mirzamohammadi@oracle.com>
> Signed-off-by: John Donnelly <john.p.donnelly@oracle.com>
> Tested-by: John Donnelly <john.p.donnelly@oracle.com>
> ---
>  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=<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
> +
> +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 <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
> -- 
> 2.27.0
> 

Acked-by: Dave Young <dyoung@redhat.com>

Thanks
Dave


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 1/1] kernel/crash_core: Add crashkernel=auto for vmcore creation
  2021-02-17 19:42     ` Vivek Goyal
@ 2021-02-18  1:29       ` Dave Young
  0 siblings, 0 replies; 13+ messages in thread
From: Dave Young @ 2021-02-18  1:29 UTC (permalink / raw)
  To: Vivek Goyal
  Cc: Steven Rostedt, john.p.donnelly, Andrew Morton,
	Saeed Mirzamohammadi, Baoquan He, Jonathan Corbet,
	Paul E. McKenney, Randy Dunlap, Thomas Gleixner,
	Mauro Carvalho Chehab, Mike Kravetz, Guilherme G. Piccoli,
	Kees Cook, Peter Zijlstra (Intel),
	Ingo Molnar, Frederic Weisbecker, YiFei Zhu, Josh Poimboeuf,
	Mike Rapoport, Masahiro Yamada, Sami Tolvanen, Christian Brauner,
	Stephen Boyd, Andrey Konovalov, kexec, linux-doc, linux-kernel

On 02/17/21 at 02:42pm, Vivek Goyal wrote:
> On Wed, Feb 17, 2021 at 02:26:53PM -0500, Steven Rostedt wrote:
> > On Wed, 17 Feb 2021 12:40:43 -0600
> > john.p.donnelly@oracle.com wrote:
> > 
> > > Hello.
> > > 
> > > Ping.
> > > 
> > > Can we get this reviewed and staged ?
> > > 
> > > Thank you.
> > 
> > Andrew,
> > 
> > Seems you are the only one pushing patches in for kexec/crash. Is this
> > maintained by anyone?
> 
> Dave Young and Baoquan He still maintain kexec/kdump stuff, AFAIK. I
> don't get time to look into this stuff now a days. 

Vivek, no problem, both Baoquan and me are on holiday leaves previously.

I'm fine with the change. 
This patch benefits distributions and those people who want to deploy a lot of
machines.  It is a good start and we can continue to improve the estimation later.

Thanks
Dave 


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 1/1] kernel/crash_core: Add crashkernel=auto for vmcore creation
  2021-02-11 18:08 [PATCH v3 1/1] kernel/crash_core: Add crashkernel=auto for vmcore creation Saeed Mirzamohammadi
  2021-02-17 18:40 ` john.p.donnelly
  2021-02-18  1:20 ` Dave Young
@ 2021-02-18  2:02 ` Baoquan He
  2021-02-23  2:03   ` john.p.donnelly
  2021-02-23 12:01   ` Kairui Song
  2021-02-24  1:54 ` Baoquan He
  3 siblings, 2 replies; 13+ messages in thread
From: Baoquan He @ 2021-02-18  2:02 UTC (permalink / raw)
  To: Saeed Mirzamohammadi
  Cc: john.p.donnelly, Dave Young, Vivek Goyal, Jonathan Corbet,
	Paul E. McKenney, Randy Dunlap, Andrew Morton, Thomas Gleixner,
	Mauro Carvalho Chehab, Mike Kravetz, Guilherme G. Piccoli,
	Kees Cook, Peter Zijlstra (Intel),
	Ingo Molnar, Steven Rostedt (VMware),
	Frederic Weisbecker, YiFei Zhu, Josh Poimboeuf, Mike Rapoport,
	Masahiro Yamada, Sami Tolvanen, Christian Brauner, Stephen Boyd,
	Andrey Konovalov, kexec, linux-doc, linux-kernel

On 02/11/21 at 10:08am, Saeed Mirzamohammadi wrote:
> 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 <saeed.mirzamohammadi@oracle.com>
> Signed-off-by: John Donnelly <john.p.donnelly@oracle.com>
> Tested-by: John Donnelly <john.p.donnelly@oracle.com>
> ---
>  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=<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
> +
> +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.


> +
>  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 <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
> -- 
> 2.27.0
> 


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 1/1] kernel/crash_core: Add crashkernel=auto for vmcore creation
  2021-02-18  2:02 ` Baoquan He
@ 2021-02-23  2:03   ` john.p.donnelly
  2021-02-23 12:01   ` Kairui Song
  1 sibling, 0 replies; 13+ messages in thread
From: john.p.donnelly @ 2021-02-23  2:03 UTC (permalink / raw)
  To: Baoquan He, Saeed Mirzamohammadi
  Cc: Dave Young, Vivek Goyal, Jonathan Corbet, Paul E. McKenney,
	Randy Dunlap, Andrew Morton, Thomas Gleixner,
	Mauro Carvalho Chehab, Mike Kravetz, Guilherme G. Piccoli,
	Kees Cook, Peter Zijlstra (Intel),
	Ingo Molnar, Steven Rostedt (VMware),
	Frederic Weisbecker, YiFei Zhu, Josh Poimboeuf, Mike Rapoport,
	Masahiro Yamada, Sami Tolvanen, Christian Brauner, Stephen Boyd,
	Andrey Konovalov, kexec, linux-doc, linux-kernel, John Donnelly

On 2/17/21 8:02 PM, Baoquan He wrote:
> On 02/11/21 at 10:08am, Saeed Mirzamohammadi wrote:
>> 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 <saeed.mirzamohammadi@oracle.com>
>> Signed-off-by: John Donnelly <john.p.donnelly@oracle.com>
>> Tested-by: John Donnelly <john.p.donnelly@oracle.com>
>> ---
>>   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=<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
>> +
>> +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.

Hi,

Are we good to move forward with this and apply it now?

Dave Young acked it.

Thank you,

John.

(Note - I am currently not on any vger.kernel.org dlist at the moment so 
please cc me ).



> 
> 
>> +
>>   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 <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
>> -- 
>> 2.27.0
>>
> 


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 1/1] kernel/crash_core: Add crashkernel=auto for vmcore creation
  2021-02-18  2:02 ` Baoquan He
  2021-02-23  2:03   ` john.p.donnelly
@ 2021-02-23 12:01   ` Kairui Song
  2021-02-23 13:56     ` Baoquan He
  1 sibling, 1 reply; 13+ messages in thread
From: Kairui Song @ 2021-02-23 12:01 UTC (permalink / raw)
  To: Baoquan He
  Cc: Saeed Mirzamohammadi, linux-doc, Peter Zijlstra (Intel),
	Christian Brauner, Ingo Molnar, Jonathan Corbet,
	Mauro Carvalho Chehab, Masahiro Yamada, Sami Tolvanen,
	Dave Young, Vivek Goyal, John Donnelly, Kees Cook,
	Paul E. McKenney, Andrey Konovalov, Frederic Weisbecker,
	Guilherme G. Piccoli, Steven Rostedt (VMware),
	Josh Poimboeuf, Thomas Gleixner, Stephen Boyd, Randy Dunlap,
	kexec, Linux Kernel Mailing List, YiFei Zhu, Andrew Morton,
	Mike Rapoport, Mike Kravetz

On Thu, Feb 18, 2021 at 10:03 AM Baoquan He <bhe@redhat.com> wrote:
>
> On 02/11/21 at 10:08am, Saeed Mirzamohammadi wrote:
> > 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 <saeed.mirzamohammadi@oracle.com>
> > Signed-off-by: John Donnelly <john.p.donnelly@oracle.com>
> > Tested-by: John Donnelly <john.p.donnelly@oracle.com>
> > ---
> >  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=<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
> > +
> > +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.

> > +
> >  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 <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
> > --
> > 2.27.0
> >
>
>
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec
>


-- 
Best Regards,
Kairui Song


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 1/1] kernel/crash_core: Add crashkernel=auto for vmcore creation
  2021-02-23 12:01   ` Kairui Song
@ 2021-02-23 13:56     ` Baoquan He
  2021-02-23 17:54       ` Saeed Mirzamohammadi
  0 siblings, 1 reply; 13+ messages in thread
From: Baoquan He @ 2021-02-23 13:56 UTC (permalink / raw)
  To: Saeed Mirzamohammadi, Kairui Song
  Cc: linux-doc, Peter Zijlstra (Intel),
	Christian Brauner, Ingo Molnar, Jonathan Corbet,
	Mauro Carvalho Chehab, Masahiro Yamada, Sami Tolvanen,
	Dave Young, Vivek Goyal, John Donnelly, Kees Cook,
	Paul E. McKenney, Andrey Konovalov, Frederic Weisbecker,
	Guilherme G. Piccoli, Steven Rostedt (VMware),
	Josh Poimboeuf, Thomas Gleixner, Stephen Boyd, Randy Dunlap,
	kexec, Linux Kernel Mailing List, YiFei Zhu, Andrew Morton,
	Mike Rapoport, Mike Kravetz

On 02/23/21 at 08:01pm, Kairui Song wrote:
> On Thu, Feb 18, 2021 at 10:03 AM Baoquan He <bhe@redhat.com> 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=<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
> > > +
> > > +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
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 <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
> > > --
> > > 2.27.0
> > >
> >
> >
> > _______________________________________________
> > kexec mailing list
> > kexec@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/kexec
> >
> 
> 
> -- 
> Best Regards,
> Kairui Song
> 


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 1/1] kernel/crash_core: Add crashkernel=auto for vmcore creation
  2021-02-23 13:56     ` Baoquan He
@ 2021-02-23 17:54       ` Saeed Mirzamohammadi
  0 siblings, 0 replies; 13+ messages in thread
From: Saeed Mirzamohammadi @ 2021-02-23 17:54 UTC (permalink / raw)
  To: Baoquan He, Kairui Song
  Cc: linux-doc, Peter Zijlstra (Intel),
	Christian Brauner, Ingo Molnar, Jonathan Corbet,
	Mauro Carvalho Chehab, Masahiro Yamada, Sami Tolvanen,
	Dave Young, Vivek Goyal, John Donnelly, Kees Cook,
	Paul E. McKenney, Andrey Konovalov, Frederic Weisbecker,
	Guilherme G. Piccoli, Steven Rostedt (VMware),
	Josh Poimboeuf, Thomas Gleixner, Stephen Boyd, Randy Dunlap,
	kexec mailing list, Linux Kernel Mailing List, YiFei Zhu,
	Andrew Morton, Mike Rapoport, Mike Kravetz



> On Feb 23, 2021, at 5:56 AM, Baoquan He <bhe@redhat.com> wrote:
> 
> On 02/23/21 at 08:01pm, Kairui Song wrote:
>> On Thu, Feb 18, 2021 at 10:03 AM Baoquan He <bhe@redhat.com> 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=<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
>>>> +
>>>> +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 <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
>>>> --
>>>> 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
>> 
> 


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 1/1] kernel/crash_core: Add crashkernel=auto for vmcore creation
  2021-02-11 18:08 [PATCH v3 1/1] kernel/crash_core: Add crashkernel=auto for vmcore creation Saeed Mirzamohammadi
                   ` (2 preceding siblings ...)
  2021-02-18  2:02 ` Baoquan He
@ 2021-02-24  1:54 ` Baoquan He
  2021-02-24  2:03   ` Baoquan He
  3 siblings, 1 reply; 13+ messages in thread
From: Baoquan He @ 2021-02-24  1:54 UTC (permalink / raw)
  To: Saeed Mirzamohammadi, Andrew Morton
  Cc: john.p.donnelly, Dave Young, Vivek Goyal, Jonathan Corbet,
	Paul E. McKenney, Randy Dunlap, Thomas Gleixner,
	Mauro Carvalho Chehab, Mike Kravetz, Guilherme G. Piccoli,
	Kees Cook, Peter Zijlstra (Intel),
	Ingo Molnar, Steven Rostedt (VMware),
	Frederic Weisbecker, YiFei Zhu, Josh Poimboeuf, Mike Rapoport,
	Masahiro Yamada, Sami Tolvanen, Christian Brauner, Stephen Boyd,
	Andrey Konovalov, kexec, linux-doc, linux-kernel

On 02/11/21 at 10:08am, Saeed Mirzamohammadi wrote:
> 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 <saeed.mirzamohammadi@oracle.com>
> Signed-off-by: John Donnelly <john.p.donnelly@oracle.com>
> Tested-by: John Donnelly <john.p.donnelly@oracle.com>
> ---
>  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(-)

Acked-by: Baoquan He <bhe@redhat.com>

> 
> 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=<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
> +
> +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 <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
> -- 
> 2.27.0
> 


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 1/1] kernel/crash_core: Add crashkernel=auto for vmcore creation
  2021-02-24  1:54 ` Baoquan He
@ 2021-02-24  2:03   ` Baoquan He
  0 siblings, 0 replies; 13+ messages in thread
From: Baoquan He @ 2021-02-24  2:03 UTC (permalink / raw)
  To: Saeed Mirzamohammadi, Andrew Morton
  Cc: john.p.donnelly, Dave Young, Vivek Goyal, Jonathan Corbet,
	Paul E. McKenney, Randy Dunlap, Thomas Gleixner,
	Mauro Carvalho Chehab, Mike Kravetz, Guilherme G. Piccoli,
	Kees Cook, Peter Zijlstra (Intel),
	Ingo Molnar, Steven Rostedt (VMware),
	Frederic Weisbecker, YiFei Zhu, Josh Poimboeuf, Mike Rapoport,
	Masahiro Yamada, Sami Tolvanen, Christian Brauner, Stephen Boyd,
	Andrey Konovalov, kexec, linux-doc, linux-kernel

On 02/24/21 at 09:54am, Baoquan He wrote:
> On 02/11/21 at 10:08am, Saeed Mirzamohammadi wrote:
> > 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 <saeed.mirzamohammadi@oracle.com>
> > Signed-off-by: John Donnelly <john.p.donnelly@oracle.com>
> > Tested-by: John Donnelly <john.p.donnelly@oracle.com>
> > ---
> >  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(-)
> 
> Acked-by: Baoquan He <bhe@redhat.com>

Sorry, I just acked on wrong version of patch, please ignore this.

> 
> > 
> > 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=<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
> > +
> > +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 <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
> > -- 
> > 2.27.0
> > 


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-02-24  2:05 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-11 18:08 [PATCH v3 1/1] kernel/crash_core: Add crashkernel=auto for vmcore creation Saeed Mirzamohammadi
2021-02-17 18:40 ` john.p.donnelly
2021-02-17 19:26   ` Steven Rostedt
2021-02-17 19:42     ` Vivek Goyal
2021-02-18  1:29       ` Dave Young
2021-02-18  1:20 ` Dave Young
2021-02-18  2:02 ` Baoquan He
2021-02-23  2:03   ` john.p.donnelly
2021-02-23 12:01   ` Kairui Song
2021-02-23 13:56     ` Baoquan He
2021-02-23 17:54       ` Saeed Mirzamohammadi
2021-02-24  1:54 ` Baoquan He
2021-02-24  2:03   ` Baoquan He

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).