Add sysctl entry for controlling crash_kexec_post_notifiers
Subsystems (3)
cover Add sysctl entry for controlling crash_kexec_post_notifiers
I noticed that in contrast to other kernel core parameters (e.g. kernel.panic, kernel.panic_on_warn, kernel.panic_print) crash_kexec_post_notifiers is not available as a sysctl tunable. I am aware that because it is a kernel core parameter, there is already an entry under:
/sys/module/kernel/parameters/crash_kexec_post_notifiers
and that allows us to read/modify it at runtime. However, I thought it should also be available via sysctl, since users that want to read/set this value at runtime might look there first.
I believe there is an ongoing effort to clean up kernel/sysctl.c, but it wasn't clear to me if this entry (and perhaps the other panic related entries too) should be placed on kernel/panic.c. I wanted to verify first that this change would be welcomed before doing additional refactoring work.
I'd appreciate any comments or suggestions.
Thank you,
Alejandro
Alejandro Jimenez (1):
kernel/sysctl: Add sysctl entry for crash_kexec_post_notifiers
Documentation/admin-guide/sysctl/kernel.rst | 8 ++++++++ include/uapi/linux/sysctl.h | 1 + kernel/sysctl.c | 7 +++++++ 3 files changed, 16 insertions(+)
Signature · 1 line
2.34.1
RFC 1/1 kernel/sysctl: Add sysctl entry for crash_kexec_post_notifiers
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.
--- Documentation/admin-guide/sysctl/kernel.rst | 8 ++++++++ include/uapi/linux/sysctl.h | 1 + kernel/sysctl.c | 7 +++++++ 3 files changed, 16 insertions(+)
Documentation/admin-guide/sysctl/kernel.rst +8 -0
@@ -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 ============
include/uapi/linux/sysctl.h +1 -0
@@ -154,6 +154,7 @@ enumKERN_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 */ };
kernel/sysctl.c +7 -0
@@ -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, + }, { } };
Signature · 1 line
2.34.1
Re: [RFC 1/1] kernel/sysctl: Add sysctl entry for crash_kexec_post_notifiers
Quoted 6 lines · Alejandro Jimenez
kernel/sysctl.c +0
-0@@ -2339,6 +2339,13 @@ static struct ctl_table kern_table[] = { .extra2 = SYSCTL_INT_MAX,
kernel/sysctl.c static struct ctl_table kern_table[] = { · line 2349
Quoted 10 lines
kernel/sysctl.c +7
-0},#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
Quoted 16 lines · Alejandro Jimenez
I noticed that in contrast to other kernel core parameters (e.g. kernel.panic, kernel.panic_on_warn, kernel.panic_print)
crash_kexec_post_notifiersis not available as a sysctl tunable. I am aware that because it is a kernel core parameter, there is already an entry under:
/sys/module/kernel/parameters/crash_kexec_post_notifiersand that allows us to read/modify it at runtime. However, I thought it should also be available via sysctl, since users that want to read/set this value at runtime might look there first.
I believe there is an ongoing effort to clean up
kernel/sysctl.c, but it wasn't clear to me if this entry (and perhaps the other panic related entries too) should be placed onkernel/panic.c. I wanted to verify first that this change would be welcomed before doing additional refactoring work.
Quoted 4 lines
I'd appreciate any comments or suggestions.
Thank you,
Alejandro
Hi Alejandro, thanks for you patch. I have a "selfish" concern though, I'll expose it here.
I'm working a panic refactor, in order to split the panic notifiers in more lists - good summary of this discussion at [0].
I'm in the half of the patches, hopefully next 2 weeks I have something ready to submit (I'll be out next week).
As part of this effort, I plan to have a more fine-grained control of this parameter, and it's going to be a sysctl, but not "crash_kexec_post_notifiers" - this one should be kept I guess due to retro-compatibility, but it'd be a layer on top oh the new one. With that said, unless you have urgent needs for this patch to be reviewed/merged , I'd like to ask you to wait the series and I can loop you there, so you may review/comment and see if it fits your use case.
Thanks,
Guilherme
Hi Guilherme,
Quoted 29 lines · Guilherme G. Piccoli
Quoted 16 lines · Alejandro Jimenez
I noticed that in contrast to other kernel core parameters (e.g. kernel.panic, kernel.panic_on_warn, kernel.panic_print)
crash_kexec_post_notifiersis not available as a sysctl tunable. I am aware that because it is a kernel core parameter, there is already an entry under:
/sys/module/kernel/parameters/crash_kexec_post_notifiersand that allows us to read/modify it at runtime. However, I thought it should also be available via sysctl, since users that want to read/set this value at runtime might look there first.
I believe there is an ongoing effort to clean up
kernel/sysctl.c, but it wasn't clear to me if this entry (and perhaps the other panic related entries too) should be placed onkernel/panic.c. I wanted to verify first that this change would be welcomed before doing additional refactoring work.Quoted 4 lines
I'd appreciate any comments or suggestions.
Thank you,
AlejandroHi Alejandro, thanks for you patch. I have a "selfish" concern though, I'll expose it here.
I'm working a panic refactor, in order to split the panic notifiers in more lists - good summary of this discussion at [0].
I'm in the half of the patches, hopefully next 2 weeks I have something ready to submit (I'll be out next week).
Quoted 4 lines
As part of this effort, I plan to have a more fine-grained control of this parameter, and it's going to be a sysctl, but not "
crash_kexec_post_notifiers" - this one should be kept I guess due to retro-compatibility, but it'd be a layer on top oh the new one.
It would be great to provide finer control and isolate the riskier modifiers.
I am using crash_kexec_post_notifiers to control behavior of pvpanic and pstore and there is not an urgent need for my change, so I don't mind waiting for the new interface to evolve. Please copy me if possible on future submissions.
Thank you,
Alejandro
Quoted 11 lines
With that said, unless you have urgent needs for this patch to be reviewed/merged , I'd like to ask you to wait the series and I can loop you there, so you may review/comment and see if it fits your use case.
Thanks,
Guilherme