diff mbox series

[RFC,1/1] kernel/sysctl: Add sysctl entry for crash_kexec_post_notifiers

Message ID 20220401202300.12660-2-alejandro.j.jimenez@oracle.com (mailing list archive)
State New, archived
Headers show
Series Add sysctl entry for controlling crash_kexec_post_notifiers | expand

Commit Message

Alejandro Jimenez April 1, 2022, 8:23 p.m. UTC
Introduce a new sysctl:

  /proc/sys/kernel/crash_kexec_post_notifiers

that allows the crash_kexec_post_notifiers tunable to be listed, read, and
modified via sysctl(8) at runtime.

crash_kexec_post_notifiers can now be set via sysctl:

  # sysctl -w kernel.crash_kexec_post_notifiers=1

or using the sysfs entry:

 #  echo 0 > /sys/module/kernel/parameters/crash_kexec_post_notifiers

which is also available for other core kernel parameters like panic,
panic_print, and panic_on_warn.

Signed-off-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
Reviewed-by: Stephen Brennan <stephen.s.brennan@oracle.com>
---
 Documentation/admin-guide/sysctl/kernel.rst | 8 ++++++++
 include/uapi/linux/sysctl.h                 | 1 +
 kernel/sysctl.c                             | 7 +++++++
 3 files changed, 16 insertions(+)

Comments

Luis Chamberlain April 1, 2022, 9:35 p.m. UTC | #1
On Fri, Apr 01, 2022 at 04:23:00PM -0400, Alejandro Jimenez wrote:
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index 830aaf8ca08e..8e0be72b5fba 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -2339,6 +2339,13 @@ static struct ctl_table kern_table[] = {
>  		.extra2		= SYSCTL_INT_MAX,
>  	},
>  #endif
> +	{
> +		.procname	= "crash_kexec_post_notifiers",
> +		.data		= &crash_kexec_post_notifiers,
> +		.maxlen		= sizeof(int),
> +		.mode		= 0644,
> +		.proc_handler	= proc_dobool,
> +	},
>  	{ }

Please don't add any new sysctls to this file anymore. See
sysctl-testing which trims its uses. Plenty of examples for you
to see what to do, hopefully [0].

[0] https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git/log/?h=sysctl-testing

  Luis
diff mbox series

Patch

diff --git a/Documentation/admin-guide/sysctl/kernel.rst b/Documentation/admin-guide/sysctl/kernel.rst
index 1144ea3229a3..8e07121e2a58 100644
--- a/Documentation/admin-guide/sysctl/kernel.rst
+++ b/Documentation/admin-guide/sysctl/kernel.rst
@@ -213,6 +213,14 @@  If `core_pattern`_ does not include "%p" (default does not)
 and ``core_uses_pid`` is set, then .PID will be appended to
 the filename.
 
+crash_kexec_post_notifiers
+============
+
+Allow the callbacks in panic notifier list to be called before kdump and dumping
+kmsg.
+
+0 Do not call panic notifier list callbacks before kdump (default).
+1 Call panic notifier list callbacks before kdump.
 
 ctrl-alt-del
 ============
diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
index 6a3b194c50fe..921e3ea01881 100644
--- a/include/uapi/linux/sysctl.h
+++ b/include/uapi/linux/sysctl.h
@@ -154,6 +154,7 @@  enum
 	KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
 	KERN_PANIC_ON_WARN=77, /* int: call panic() in WARN() functions */
 	KERN_PANIC_PRINT=78, /* ulong: bitmask to print system info on panic */
+	KERN_CRASH_KEXEC_POST_NOTIFIERS=79, /* bool: call panic notifier list before kdump */
 };
 
 
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 830aaf8ca08e..8e0be72b5fba 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2339,6 +2339,13 @@  static struct ctl_table kern_table[] = {
 		.extra2		= SYSCTL_INT_MAX,
 	},
 #endif
+	{
+		.procname	= "crash_kexec_post_notifiers",
+		.data		= &crash_kexec_post_notifiers,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dobool,
+	},
 	{ }
 };