panic: only warn about deprecated panic_print on write access
PATCH 1/1 panic: only warn about deprecated panic_print on write access
The panic_print_deprecated() warning is being triggered on both read and write operations to the panic_print parameter.
This causes spurious warnings when users run 'sysctl -a' to list all sysctl values, since that command reads /proc/sys/kernel/panic_print and triggers the deprecation notice.
Modify the handlers to only emit the deprecation warning when the parameter is actually being set:
- sysctl_panic_print_handler(): check 'write' flag before warning.
- panic_print_get(): remove the deprecation call entirely.
This way, users are only warned when they actively try to use the deprecated parameter, not when passively querying system state.
--- kernel/panic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/panic.c +2 -2
@@ -131,7 +131,8 @@ static int proc_taint(const struct ctl_table *table, int write,static int sysctl_panic_print_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) { -panic_print_deprecated (); +if (write) +panic_print_deprecated ();return proc_doulongvec_minmax (table, write, buffer, lenp, ppos); }
@@ -1014,7 +1015,6 @@ static int panic_print_set(const char *val, const struct kernel_param *kp)static int panic_print_get (char *val,const struct kernel_param *kp) { -panic_print_deprecated ();return param_get_ulong (val, kp); }
Signature · 1 line
2.40.1
Hi Gal,
Thanks for the fix!
Quoted 31 lines · Gal Pressman
The
panic_print_deprecated()warning is being triggered on both read and write operations to thepanic_printparameter.This causes spurious warnings when users run 'sysctl -a' to list all sysctl values, since that command reads
/proc/sys/kernel/panic_printand triggers the deprecation notice.Modify the handlers to only emit the deprecation warning when the parameter is actually being set:
-
sysctl_panic_print_handler(): check 'write' flag before warning.
-panic_print_get(): remove the deprecation call entirely.This way, users are only warned when they actively try to use the deprecated parameter, not when passively querying system state.
Fixes ee13240cd78b ("panic: add note that panic_print sysctl interface is deprecated")Fixes 2683df6539cb ("panic: add note that 'panic_print' parameter is deprecated")Cc Feng Tang <[email protected]>Reviewed-by Mark Bloch <[email protected]>Reviewed-by Nimrod Oren <[email protected]>Signed-off-by Gal Pressman <[email protected]>--- kernel/panic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)kernel/panic.c +0
-0
kernel/panic.c static int proc_taint(const struct ctl_table *table, int write, · line 135
Quoted 6 lines
kernel/panic.c +2
-1@@ -131,7 +131,8 @@ static int proc_taint(const struct ctl_table *table, int write,static int sysctl_panic_print_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) { -panic_print_deprecated (); +if (write) +panic_print_deprecated ();
This makes sense to me, as 'sysctl -a' is a very common usage.
kernel/panic.c static int panic_print_set(const char *val, const struct kernel_param *kp) · line 1017
Quoted 8 lines
kernel/panic.c +0
-1return proc_doulongvec_minmax (table, write, buffer, lenp, ppos); }@@ -1014,7 +1015,6 @@ static int panic_print_set(const char *val, const struct kernel_param *kp)static int panic_print_get (char *val,const struct kernel_param *kp) { -panic_print_deprecated ();
Actually this was intentional, in one of the patch version, this panic_print_get() was not there but reusing the param_get_ulong().
It was added later as sometimes developer do want to runtime check the current 'panic_print' setting through /sys/module/kernel/parameters/ interface, and I thought it may be better to give the warning.
Thanks,
Feng
Quoted 5 lines
kernel/panic.c +0
-0return param_get_ulong (val, kp); }Signature · 1 line
2.40.1
Quoted 9 lines · Feng Tang
kernel/panic.c static int panic_print_set(const char *val, const struct kernel_param *kp) · line 1017
Quoted 5 lines
kernel/panic.c +0
-1@@ -1014,7 +1015,6 @@ static int panic_print_set(const char *val, const struct kernel_param *kp)static int panic_print_get (char *val,const struct kernel_param *kp) { -panic_print_deprecated ();Actually this was intentional, in one of the patch version, this
panic_print_get()was not there but reusing theparam_get_ulong().
Quoted 3 lines
It was added later as sometimes developer do want to runtime check the current '
panic_print' setting through/sys/module/kernel/parameters/interface, and I thought it may be better to give the warning.
I figured it would make sense to keep the behaviors consistent.
Quoted 10 lines · Gal Pressman
Quoted 9 lines · Feng Tang
Review static int panic_print_set(const char *val, const struct kernel_param *kp) · line 1017
Quoted 5 lines
(quoted diff) +0
-1@@ -1014,7 +1015,6 @@ static int panic_print_set(const char *val, const struct kernel_param *kp) static int panic_print_get(char *val, const struct kernel_param *kp) { - panic_print_deprecated();Actually this was intentional, in one of the patch version, this
panic_print_get()was not there but reusing theparam_get_ulong().
Quoted 5 lines
Quoted 3 lines
It was added later as sometimes developer do want to runtime check the current '
panic_print' setting through/sys/module/kernel/parameters/interface, and I thought it may be better to give the warning.I figured it would make sense to keep the behaviors consistent.
When people run 'sysctl -a', in 99.9% cases, the users don't care 'panic_print' or even don't know what 'panic_print' is, that's why I think removing it makes sense.
But for a user running 'cat /sys/module/kernel/parameters/panic_rint', giving a warning is meaningful.
If you insist so, the cleaner way would be
kernel/panic.c +1 -7
@@ -1012,15 +1012,9 @@ static int panic_print_set(const char *val, const struct kernel_param *kp)return param_set_ulong (val, kp); } -static int panic_print_get (char *val,const struct kernel_param *kp) -{ -panic_print_deprecated (); -return param_get_ulong (val, kp); -} -static const struct kernel_param_ops panic_print_ops = { .set = panic_print_set, - .get = panic_print_get, + .get = param_get_ulong, };__core_param_cb (panic_print, &panic_print_ops, &panic_print,0644 );
Quoted 11 lines · Feng Tang
Quoted 10 lines · Gal Pressman
Quoted 9 lines · Feng Tang
kernel/panic.c static int panic_print_set(const char *val, const struct kernel_param *kp) · line 1017
Quoted 5 lines
kernel/panic.c +0
-1@@ -1014,7 +1015,6 @@ static int panic_print_set(const char *val, const struct kernel_param *kp)static int panic_print_get (char *val,const struct kernel_param *kp) { -panic_print_deprecated ();Actually this was intentional, in one of the patch version, this
panic_print_get()was not there but reusing theparam_get_ulong().
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
It was added later as sometimes developer do want to runtime check the current '
panic_print' setting through/sys/module/kernel/parameters/interface, and I thought it may be better to give the warning.I figured it would make sense to keep the behaviors consistent.
I see.
Quoted 6 lines
When people run 'sysctl -a', in 99.9% cases, the users don't care '
panic_print' or even don't know what 'panic_print' is, that's why I think removing it makes sense.But for a user running 'cat
/sys/module/kernel/parameters/panic_rint', giving a warning is meaningful.
Makes perfect sense.
We need to make people aware that "panic_print" will eventually go away. 'sysctl -a' is different because it prints all values and there is big chance that the caller is not interested in "panic_print" at all.
It makes sense to remove the warning from sysctl read. But I would keep it in sysfs read.
Best Regards,
Petr
Quoted 29 lines · Petr Mladek
Quoted 11 lines · Feng Tang
Quoted 10 lines · Gal Pressman
Quoted 9 lines · Feng Tang
kernel/panic.c static int panic_print_set(const char *val, const struct kernel_param *kp) · line 1017
Quoted 5 lines
kernel/panic.c +0
-1@@ -1014,7 +1015,6 @@ static int panic_print_set(const char *val, const struct kernel_param *kp)static int panic_print_get (char *val,const struct kernel_param *kp) { -panic_print_deprecated ();Actually this was intentional, in one of the patch version, this
panic_print_get()was not there but reusing theparam_get_ulong().Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
It was added later as sometimes developer do want to runtime check the current '
panic_print' setting through/sys/module/kernel/parameters/interface, and I thought it may be better to give the warning.I figured it would make sense to keep the behaviors consistent.
I see.
Quoted 6 lines
When people run 'sysctl -a', in 99.9% cases, the users don't care '
panic_print' or even don't know what 'panic_print' is, that's why I think removing it makes sense.But for a user running 'cat
/sys/module/kernel/parameters/panic_rint', giving a warning is meaningful.Makes perfect sense.
Quoted 7 lines
We need to make people aware that "
panic_print" will eventually go away. 'sysctl -a' is different because it prints all values and there is big chance that the caller is not interested in "panic_print" at all.It makes sense to remove the warning from sysctl read. But I would keep it in sysfs read.
The sysfs entry exhibits the same issue, just different command:
# systool -m kernel -v
Or:
# grep . /sys/module/kernel/parameters/*
Quoted 38 lines · Gal Pressman
Quoted 29 lines · Petr Mladek
Quoted 11 lines · Feng Tang
Quoted 10 lines · Gal Pressman
Quoted 9 lines · Feng Tang
kernel/panic.c static int panic_print_set(const char *val, const struct kernel_param *kp) · line 1017
Quoted 5 lines
kernel/panic.c +0
-1@@ -1014,7 +1015,6 @@ static int panic_print_set(const char *val, const struct kernel_param *kp)static int panic_print_get (char *val,const struct kernel_param *kp) { -panic_print_deprecated ();Actually this was intentional, in one of the patch version, this
panic_print_get()was not there but reusing theparam_get_ulong().Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
It was added later as sometimes developer do want to runtime check the current '
panic_print' setting through/sys/module/kernel/parameters/interface, and I thought it may be better to give the warning.I figured it would make sense to keep the behaviors consistent.
I see.
Quoted 6 lines
When people run 'sysctl -a', in 99.9% cases, the users don't care '
panic_print' or even don't know what 'panic_print' is, that's why I think removing it makes sense.But for a user running 'cat
/sys/module/kernel/parameters/panic_rint', giving a warning is meaningful.Makes perfect sense.
Quoted 7 lines
We need to make people aware that "
panic_print" will eventually go away. 'sysctl -a' is different because it prints all values and there is big chance that the caller is not interested in "panic_print" at all.It makes sense to remove the warning from sysctl read. But I would keep it in sysfs read.
Quoted 7 lines
The sysfs entry exhibits the same issue, just different command:
# systool -m kernel -vOr:
# grep . /sys/module/kernel/parameters/*
Yes, when user checks the kernel parameters, I think it's better to give them a notice (it's a pr_info_once(), which only prints once for the whole power cycle).
Thanks,
Feng
Quoted 43 lines · Feng Tang
Quoted 42 lines · Gal Pressman
Quoted 29 lines · Petr Mladek
Quoted 11 lines · Feng Tang
Quoted 10 lines · Gal Pressman
Quoted 9 lines · Feng Tang
kernel/panic.c static int panic_print_set(const char *val, const struct kernel_param *kp) · line 1017
Quoted 5 lines
kernel/panic.c +0
-1@@ -1014,7 +1015,6 @@ static int panic_print_set(const char *val, const struct kernel_param *kp)static int panic_print_get (char *val,const struct kernel_param *kp) { -panic_print_deprecated ();Actually this was intentional, in one of the patch version, this
panic_print_get()was not there but reusing theparam_get_ulong().Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
It was added later as sometimes developer do want to runtime check the current '
panic_print' setting through/sys/module/kernel/parameters/interface, and I thought it may be better to give the warning.I figured it would make sense to keep the behaviors consistent.
I see.
Quoted 6 lines
When people run 'sysctl -a', in 99.9% cases, the users don't care '
panic_print' or even don't know what 'panic_print' is, that's why I think removing it makes sense.But for a user running 'cat
/sys/module/kernel/parameters/panic_rint', giving a warning is meaningful.Makes perfect sense.
Quoted 7 lines
We need to make people aware that "
panic_print" will eventually go away. 'sysctl -a' is different because it prints all values and there is big chance that the caller is not interested in "panic_print" at all.It makes sense to remove the warning from sysctl read. But I would keep it in sysfs read.
The sysfs entry exhibits the same issue, just different command:
# systool -m kernel -v
Quoted 7 lines
Quoted 3 lines
Or:
# grep . /sys/module/kernel/parameters/*Yes, when user checks the kernel parameters, I think it's better to give them a notice (it's a
pr_info_once(), which only prints once for the whole power cycle).
This log message causes a lot of noise for people who have no idea what panic_print is.
We started seeing this print internally, and it took a long time and significant resources to figure out what changed and if we were doing anything wrong in our environments.
Seeing a deprecation notice is alarming, especially if you don't know what is being deprecated or how it affects you. In my opinion, we shouldn't print this unless someone actually uses panic_print.
Quoted 40 lines · Gal Pressman
Quoted 39 lines · Feng Tang
Quoted 38 lines · Gal Pressman
Quoted 36 lines · Petr Mladek
Quoted 11 lines · Feng Tang
Quoted 10 lines · Gal Pressman
Quoted 9 lines · Feng Tang
kernel/panic.c static int panic_print_set(const char *val, const struct kernel_param *kp) · line 1017
Quoted 5 lines
kernel/panic.c +0
-1@@ -1014,7 +1015,6 @@ static int panic_print_set(const char *val, const struct kernel_param *kp)static int panic_print_get (char *val,const struct kernel_param *kp) { -panic_print_deprecated ();Actually this was intentional, in one of the patch version, this
panic_print_get()was not there but reusing theparam_get_ulong().Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
It was added later as sometimes developer do want to runtime check the current '
panic_print' setting through/sys/module/kernel/parameters/interface, and I thought it may be better to give the warning.I figured it would make sense to keep the behaviors consistent.
I see.
Quoted 6 lines
When people run 'sysctl -a', in 99.9% cases, the users don't care '
panic_print' or even don't know what 'panic_print' is, that's why I think removing it makes sense.But for a user running 'cat
/sys/module/kernel/parameters/panic_rint', giving a warning is meaningful.Makes perfect sense.
We need to make people aware that "
panic_print" will eventually go away. 'sysctl -a' is different because it prints all values and there is big chance that the caller is not interested in "panic_print" at all.It makes sense to remove the warning from sysctl read. But I would keep it in sysfs read.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
The sysfs entry exhibits the same issue, just different command:
# systool -m kernel -vOr:
# grep . /sys/module/kernel/parameters/*
I see.
Quoted 9 lines
Quoted 3 lines
Yes, when user checks the kernel parameters, I think it's better to give them a notice (it's a
pr_info_once(), which only prints once for the whole power cycle).This log message causes a lot of noise for people who have no idea what
panic_printis.
We started seeing this print internally, and it took a long time and significant resources to figure out what changed and if we were doing anything wrong in our environments.
Quoted 3 lines
Seeing a deprecation notice is alarming, especially if you don't know what is being deprecated or how it affects you. In my opinion, we shouldn't print this unless someone actually uses
panic_print.
I am fine with printing the warning only when the value is modified (set/write).
Best Regards,
Petr
PS: Sigh, it is hard to change or remove an interface. It is always
better to think twice before introducing one.