Long term wise, the 'panic_sys_info' should be the only controlling
interface, which can be referred by other modules.
Suggested-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Feng Tang <feng.tang@linux.alibaba.com>
---
kernel/panic.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/kernel/panic.c b/kernel/panic.c
index ea238f7d4b54..e8a05fc6b733 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -76,6 +76,13 @@ ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
EXPORT_SYMBOL(panic_notifier_list);
#ifdef CONFIG_SYSCTL
+static int sysctl_panic_print_handler(const struct ctl_table *table, int write,
+ void *buffer, size_t *lenp, loff_t *ppos)
+{
+ printk_once("panic: 'panic_print' sysctl interface will be obsoleted by 'panic_sys_info' interface.\n");
+ return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
+}
+
static const struct ctl_table kern_panic_table[] = {
#ifdef CONFIG_SMP
{
@@ -107,7 +114,7 @@ static const struct ctl_table kern_panic_table[] = {
.data = &panic_print,
.maxlen = sizeof(unsigned long),
.mode = 0644,
- .proc_handler = proc_doulongvec_minmax,
+ .proc_handler = sysctl_panic_print_handler,
},
{
.procname = "panic_on_warn",
--
2.39.5 (Apple Git-154)
On Mon 2025-06-16 09:08:40, Feng Tang wrote:
> Long term wise, the 'panic_sys_info' should be the only controlling
> interface, which can be referred by other modules.
Strictly speaking, 'panic_sys_info' is not a complete
replacement for 'panic_print' because it does not allow
replaying the log buffer during panic.
I suggest to add a separate parameter "panic_console_replay"
for the missing functionality first. And 'panic_print' will
be obsoleted by both 'panic_sys_info' and 'panic_console_replay'.
> --- a/kernel/panic.c
> +++ b/kernel/panic.c
> @@ -76,6 +76,13 @@ ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
> EXPORT_SYMBOL(panic_notifier_list);
>
> #ifdef CONFIG_SYSCTL
> +static int sysctl_panic_print_handler(const struct ctl_table *table, int write,
> + void *buffer, size_t *lenp, loff_t *ppos)
> +{
> + printk_once("panic: 'panic_print' sysctl interface will be obsoleted by 'panic_sys_info' interface.\n");
> + return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
> +}
> +
> static const struct ctl_table kern_panic_table[] = {
> #ifdef CONFIG_SMP
> {
> @@ -107,7 +114,7 @@ static const struct ctl_table kern_panic_table[] = {
> .data = &panic_print,
> .maxlen = sizeof(unsigned long),
> .mode = 0644,
> - .proc_handler = proc_doulongvec_minmax,
> + .proc_handler = sysctl_panic_print_handler,
This handles only the sysctl interface. We should do something similar
also for the "panic_print" command line parameter. It would require
using core_param_cb() instead of core_param().
> },
> {
> .procname = "panic_on_warn",
Best Regards,
Petr
On Mon, Jun 23, 2025 at 05:22:20PM +0200, Petr Mladek wrote:
> On Mon 2025-06-16 09:08:40, Feng Tang wrote:
> > Long term wise, the 'panic_sys_info' should be the only controlling
> > interface, which can be referred by other modules.
>
> Strictly speaking, 'panic_sys_info' is not a complete
> replacement for 'panic_print' because it does not allow
> replaying the log buffer during panic.
>
> I suggest to add a separate parameter "panic_console_replay"
> for the missing functionality first. And 'panic_print' will
> be obsoleted by both 'panic_sys_info' and 'panic_console_replay'.
>
> > --- a/kernel/panic.c
> > +++ b/kernel/panic.c
> > @@ -76,6 +76,13 @@ ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
> > EXPORT_SYMBOL(panic_notifier_list);
> >
> > #ifdef CONFIG_SYSCTL
> > +static int sysctl_panic_print_handler(const struct ctl_table *table, int write,
> > + void *buffer, size_t *lenp, loff_t *ppos)
> > +{
> > + printk_once("panic: 'panic_print' sysctl interface will be obsoleted by 'panic_sys_info' interface.\n");
> > + return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
> > +}
> > +
> > static const struct ctl_table kern_panic_table[] = {
> > #ifdef CONFIG_SMP
> > {
> > @@ -107,7 +114,7 @@ static const struct ctl_table kern_panic_table[] = {
> > .data = &panic_print,
> > .maxlen = sizeof(unsigned long),
> > .mode = 0644,
> > - .proc_handler = proc_doulongvec_minmax,
> > + .proc_handler = sysctl_panic_print_handler,
>
> This handles only the sysctl interface. We should do something similar
> also for the "panic_print" command line parameter. It would require
> using core_param_cb() instead of core_param().
When testing the change, I found a problem: 'core_param_cb' is not
the real counterpart of 'core_param', that it is a module parameter
instead of kernel/core parameter, and adds the module.prefix to the
parameter, say, the effective cmdline parameter is changed to
'panic.panic_print=' instead of 'panic_print='.
While below patch of 'kernel_param_cb' works fine, but I'm not sure if
it is worth the change:
---
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index bfb85fd13e1f..71053d078cea 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -194,6 +194,9 @@ struct kparam_array
#define core_param_cb(name, ops, arg, perm) \
__level_param_cb(name, ops, arg, perm, 1)
+#define kernel_param_cb(name, ops, arg, perm) \
+ __module_param_call("", name, ops, arg, perm, -1, 0)
+
/**
* postcore_param_cb - general callback for a module/cmdline parameter
* to be evaluated before postcore initcall level
Or should we change the 'core_param_cb' to what 'kernel_param_cb' is
doing.
Thanks,
Feng
On Mon, Jun 23, 2025 at 05:22:20PM +0200, Petr Mladek wrote:
> On Mon 2025-06-16 09:08:40, Feng Tang wrote:
> > Long term wise, the 'panic_sys_info' should be the only controlling
> > interface, which can be referred by other modules.
>
> Strictly speaking, 'panic_sys_info' is not a complete
> replacement for 'panic_print' because it does not allow
> replaying the log buffer during panic.
Indeed, I forgot this part.
> I suggest to add a separate parameter "panic_console_replay"
> for the missing functionality first. And 'panic_print' will
> be obsoleted by both 'panic_sys_info' and 'panic_console_replay'.
Will do.
> > --- a/kernel/panic.c
> > +++ b/kernel/panic.c
> > @@ -76,6 +76,13 @@ ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
> > EXPORT_SYMBOL(panic_notifier_list);
> >
> > #ifdef CONFIG_SYSCTL
> > +static int sysctl_panic_print_handler(const struct ctl_table *table, int write,
> > + void *buffer, size_t *lenp, loff_t *ppos)
> > +{
> > + printk_once("panic: 'panic_print' sysctl interface will be obsoleted by 'panic_sys_info' interface.\n");
> > + return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
> > +}
> > +
> > static const struct ctl_table kern_panic_table[] = {
> > #ifdef CONFIG_SMP
> > {
> > @@ -107,7 +114,7 @@ static const struct ctl_table kern_panic_table[] = {
> > .data = &panic_print,
> > .maxlen = sizeof(unsigned long),
> > .mode = 0644,
> > - .proc_handler = proc_doulongvec_minmax,
> > + .proc_handler = sysctl_panic_print_handler,
>
> This handles only the sysctl interface. We should do something similar
> also for the "panic_print" command line parameter. It would require
> using core_param_cb() instead of core_param().
OK, thanks!
- Feng
> > },
> > {
> > .procname = "panic_on_warn",
>
> Best Regards,
> Petr
On 2025/6/16 09:08, Feng Tang wrote:
> Long term wise, the 'panic_sys_info' should be the only controlling
> interface, which can be referred by other modules.
>
> Suggested-by: Petr Mladek <pmladek@suse.com>
> Signed-off-by: Feng Tang <feng.tang@linux.alibaba.com>
> ---
> kernel/panic.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/panic.c b/kernel/panic.c
> index ea238f7d4b54..e8a05fc6b733 100644
> --- a/kernel/panic.c
> +++ b/kernel/panic.c
> @@ -76,6 +76,13 @@ ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
> EXPORT_SYMBOL(panic_notifier_list);
>
> #ifdef CONFIG_SYSCTL
> +static int sysctl_panic_print_handler(const struct ctl_table *table, int write,
> + void *buffer, size_t *lenp, loff_t *ppos)
> +{
> + printk_once("panic: 'panic_print' sysctl interface will be obsoleted by 'panic_sys_info' interface.\n");
Hmm... I would get scared for a second when I read messages prefixed
with "panic:"
from dmesg. That prefix should have a very specific meaning ;)
Well, we can just change the prefix to something more neutral:
printk_once("Kernel: 'panic_print' sysctl interface will be obsoleted by
'panic_sys_info' interface.\n");
Thanks,
Lance
> + return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
> +}
> +
> static const struct ctl_table kern_panic_table[] = {
> #ifdef CONFIG_SMP
> {
> @@ -107,7 +114,7 @@ static const struct ctl_table kern_panic_table[] = {
> .data = &panic_print,
> .maxlen = sizeof(unsigned long),
> .mode = 0644,
> - .proc_handler = proc_doulongvec_minmax,
> + .proc_handler = sysctl_panic_print_handler,
> },
> {
> .procname = "panic_on_warn",
On Mon 2025-06-16 09:45:16, Lance Yang wrote:
>
>
> On 2025/6/16 09:08, Feng Tang wrote:
> > Long term wise, the 'panic_sys_info' should be the only controlling
> > interface, which can be referred by other modules.
> >
> > Suggested-by: Petr Mladek <pmladek@suse.com>
> > Signed-off-by: Feng Tang <feng.tang@linux.alibaba.com>
> > ---
> > kernel/panic.c | 9 ++++++++-
> > 1 file changed, 8 insertions(+), 1 deletion(-)
> >
> > diff --git a/kernel/panic.c b/kernel/panic.c
> > index ea238f7d4b54..e8a05fc6b733 100644
> > --- a/kernel/panic.c
> > +++ b/kernel/panic.c
> > @@ -76,6 +76,13 @@ ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
> > EXPORT_SYMBOL(panic_notifier_list);
> > #ifdef CONFIG_SYSCTL
> > +static int sysctl_panic_print_handler(const struct ctl_table *table, int write,
> > + void *buffer, size_t *lenp, loff_t *ppos)
> > +{
> > + printk_once("panic: 'panic_print' sysctl interface will be obsoleted by 'panic_sys_info' interface.\n");
>
> Hmm... I would get scared for a second when I read messages prefixed with
> "panic:"
> from dmesg. That prefix should have a very specific meaning ;)
>
> Well, we can just change the prefix to something more neutral:
>
> printk_once("Kernel: 'panic_print' sysctl interface will be obsoleted by
> 'panic_sys_info' interface.\n");
I agree that this looks better.
That said, I am not a native speaker but I think the "will be
obsoleted" is not correct. I would use "has been obsoleted" instead.
Also the messages should use a particular loglevel, e.g. KERN_INFO.
I would do:
pr_info_once("Kernel: 'panic_print' sysctl interface has been obsoleted by 'panic_sys_info' interface.\n");
>
> > + return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
> > +}
> > +
Best Regards,
Petr
On Mon, Jun 16, 2025 at 09:45:16AM +0800, Lance Yang wrote:
>
>
> On 2025/6/16 09:08, Feng Tang wrote:
> > Long term wise, the 'panic_sys_info' should be the only controlling
> > interface, which can be referred by other modules.
> >
> > Suggested-by: Petr Mladek <pmladek@suse.com>
> > Signed-off-by: Feng Tang <feng.tang@linux.alibaba.com>
> > ---
> > kernel/panic.c | 9 ++++++++-
> > 1 file changed, 8 insertions(+), 1 deletion(-)
> >
> > diff --git a/kernel/panic.c b/kernel/panic.c
> > index ea238f7d4b54..e8a05fc6b733 100644
> > --- a/kernel/panic.c
> > +++ b/kernel/panic.c
> > @@ -76,6 +76,13 @@ ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
> > EXPORT_SYMBOL(panic_notifier_list);
> > #ifdef CONFIG_SYSCTL
> > +static int sysctl_panic_print_handler(const struct ctl_table *table, int write,
> > + void *buffer, size_t *lenp, loff_t *ppos)
> > +{
> > + printk_once("panic: 'panic_print' sysctl interface will be obsoleted by 'panic_sys_info' interface.\n");
>
> Hmm... I would get scared for a second when I read messages prefixed with
> "panic:"
> from dmesg. That prefix should have a very specific meaning ;)
>
> Well, we can just change the prefix to something more neutral:
>
> printk_once("Kernel: 'panic_print' sysctl interface will be obsoleted by
> 'panic_sys_info' interface.\n");
Yes. I tried to give the module name, but forgot the name is too scary
for normal users :)
Thanks,
Feng
> Thanks,
> Lance
© 2016 - 2026 Red Hat, Inc.