generalize panic_print's dump function to be used by other kernel parts
Subsystems (4)
v2 cover generalize panic_print's dump function to be used by other kernel parts
When working on kernel stability issues, panic, task-hung and software/hardware lockup are frequently met. And to debug them, user may need lots of system information at that time, like task call stacks, lock info, memory info etc.
panic case already has panic_print_sys_info() for this purpose, and has a 'panic_print' bitmask to control what kinds of information is needed, which is also helpful to debug other task-hung and lockup cases.
So this patchset extract the function out to a new file 'lib/sys_info.c', and make it usable for other cases which also need system info for debugging.
Also as suggested by Petr Mladek, add 'panic_sys_info=' interface to take human readable string like "tasks,mem,lock,timer,ftrace,....", and eventually obsolete the current 'panic_print' bitmap interface.
In RFC and V1 version, hung_task and SW/HW watchdog modules are enabled with the new sys_info dump interface. In v2, they are kept out for better review of current change, and will be posted later.
Locally these have been used in our bug chasing for stabilility issues and was helpful.
Please help to review, thanks!
- Feng
Changelog:
Sinc V1:
* Separate the 'sys_show_info' related code to new file sys_info.[ch] (Petr Mladek)
* Clean up the code for panic console replay (Petr Mladek)
* Add 'panic_sys_info=' cmdline and sysctl interface for taking human readable parameters (Petr Mladek)
* Add note about the obsoleting of 'panic_print' (Petr Mladek)
* Hold the changes to hungtask/watchdog
Since RFC:
* Don't print all cpu backtrace if 'sysctl_hung_task_all_cpu_backtracemay' is 'false' (Lance Yang)
* Change the name of 2 new kernel control knob to have 'mask' inside, and add kernel document and code comments for them (Lance Yang)
* Make the sys_show_info() support printk msg replay and all CPU backtrace.
Feng Tang (5):
panic: clean up code for console replay
panic: generalize panic_print's function to show sys info
sys_info: add help to translate sys_info string to bitmap
panic: add 'panic_sys_info=' setup option for sysctl and kernel
cmdline
panic: add note that panic_print interface is deprecated
.../admin-guide/kernel-parameters.txt | 13 ++ Documentation/admin-guide/sysctl/kernel.rst | 18 +++ include/linux/kernel.h | 1 + include/linux/sys_info.h | 27 ++++ kernel/panic.c | 66 +++++---- lib/Makefile | 2 +- lib/sys_info.c | 127 ++++++++++++++++++ 7 files changed, 217 insertions(+), 37 deletions(-) create mode 100644 include/linux/sys_info.h create mode 100644 lib/sys_info.c
Signature · 1 line
2.39.5 (Apple Git-154)
PATCH v2 1/5 panic: clean up code for console replay
Currently the panic_print_sys_info() was called twice with different parameters to handle console replay case, which is kind of confusing.
Add panic_console_replay() explicitly to make the code straightforward.
--- kernel/panic.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
kernel/panic.c +8 -8
@@ -238,14 +238,14 @@ void nmi_panic(struct pt_regs *regs, const char *msg) }EXPORT_SYMBOL (nmi_panic); -static void panic_print_sys_info (bool console_flush) +static void panic_console_replay (void ) { -if (console_flush) { -if (panic_print &PANIC_PRINT_ALL_PRINTK_MSG ) -console_flush_on_panic (CONSOLE_REPLAY_ALL ); -return ; - } +if (panic_print &PANIC_PRINT_ALL_PRINTK_MSG ) +console_flush_on_panic (CONSOLE_REPLAY_ALL ); +} +static void panic_print_sys_info (void ) +{if (panic_print &PANIC_PRINT_TASK_INFO )show_state ();
@@ -410,7 +410,7 @@ void panic(const char *fmt, ...)*/ atomic_notifier_call_chain (&panic_notifier_list,0 , buf); -panic_print_sys_info (false); +panic_print_sys_info ();kmsg_dump_desc (KMSG_DUMP_PANIC , buf);
@@ -439,7 +439,7 @@ void panic(const char *fmt, ...)debug_locks_off ();console_flush_on_panic (CONSOLE_FLUSH_PENDING ); -panic_print_sys_info (true); +panic_console_replay ();if (!panic_blink) panic_blink = no_blink;
Signature · 1 line
2.39.5 (Apple Git-154)
Re: [PATCH V2 1/5] panic: clean up code for console replay
Quoted 7 lines · Feng Tang
Currently the
panic_print_sys_info()was called twice with different parameters to handle console replay case, which is kind of confusing.Add
panic_console_replay()explicitly to make the code straightforward.Suggested-by Petr Mladek <[email protected]>Signed-off-by Feng Tang <[email protected]>
Looks good to me:
Best Regards,
Petr
PATCH v2 2/5 panic: generalize panic_print's function to show sys info
In reply to Feng Tang'panic_print' was introduced to help debugging kernel panic by dumping different kinds of system information like tasks' call stack, memory, ftrace buffer, etc. Acutually this function could also help debugging cases like task-hung, soft/hard lockup, and other cases , where user may need the snapshot of system info at that time.
Extract sys_show_info() function out of panic code to be used by other kernel parts for debugging.
--- include/linux/kernel.h | 1 + include/linux/sys_info.h | 20 ++++++++++++++++++++ kernel/panic.c | 35 +++-------------------------------- lib/Makefile | 2 +- lib/sys_info.c | 30 ++++++++++++++++++++++++++++++ 5 files changed, 55 insertions(+), 33 deletions(-) create mode 100644 include/linux/sys_info.h create mode 100644 lib/sys_info.c
include/linux/kernel.h +1 -0
@@ -27,6 +27,7 @@#include <linux/math.h> #include <linux/minmax.h> #include <linux/typecheck.h> +#include <linux/sys_info.h> #include <linux/panic.h> #include <linux/printk.h> #include <linux/build_bug.h>
include/linux/sys_info.h new file +20 -0
@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_SYS_INFO_H +#define _LINUX_SYS_INFO_H + +/* +* SYS_SHOW_ALL_PRINTK_MSG is for panic case only, as it needs special +* handling which only fits panic case. +*/ +#define SYS_SHOW_TASK_INFO 0x00000001 +#define SYS_SHOW_MEM_INFO 0x00000002 +#define SYS_SHOW_TIMER_INFO 0x00000004 +#define SYS_SHOW_LOCK_INFO 0x00000008 +#define SYS_SHOW_FTRACE_INFO 0x00000010 +#define SYS_SHOW_ALL_PRINTK_MSG 0x00000020 +#define SYS_SHOW_ALL_CPU_BT 0x00000040 +#define SYS_SHOW_BLOCKED_TASKS 0x00000080 + +extern void sys_show_info (unsigned long info_mask); + +#endif /* _LINUX_SYS_INFO_H */
kernel/panic.c +3 -32
@@ -69,14 +69,6 @@ bool panic_triggering_all_cpu_backtrace;int panic_timeout =CONFIG_PANIC_TIMEOUT ;EXPORT_SYMBOL_GPL (panic_timeout); -#define PANIC_PRINT_TASK_INFO 0x00000001 -#define PANIC_PRINT_MEM_INFO 0x00000002 -#define PANIC_PRINT_TIMER_INFO 0x00000004 -#define PANIC_PRINT_LOCK_INFO 0x00000008 -#define PANIC_PRINT_FTRACE_INFO 0x00000010 -#define PANIC_PRINT_ALL_PRINTK_MSG 0x00000020 -#define PANIC_PRINT_ALL_CPU_BT 0x00000040 -#define PANIC_PRINT_BLOCKED_TASKS 0x00000080unsigned long panic_print;ATOMIC_NOTIFIER_HEAD (panic_notifier_list);
@@ -240,31 +232,10 @@ EXPORT_SYMBOL(nmi_panic);static void panic_console_replay (void ) { -if (panic_print &PANIC_PRINT_ALL_PRINTK_MSG ) +if (panic_print &SYS_SHOW_ALL_PRINTK_MSG )console_flush_on_panic (CONSOLE_REPLAY_ALL ); } -static void panic_print_sys_info (void ) -{ -if (panic_print &PANIC_PRINT_TASK_INFO ) -show_state (); - -if (panic_print &PANIC_PRINT_MEM_INFO ) -show_mem (); - -if (panic_print &PANIC_PRINT_TIMER_INFO ) -sysrq_timer_list_show (); - -if (panic_print &PANIC_PRINT_LOCK_INFO ) -debug_show_all_locks (); - -if (panic_print &PANIC_PRINT_FTRACE_INFO ) -ftrace_dump (DUMP_ALL ); - -if (panic_print &PANIC_PRINT_BLOCKED_TASKS ) -show_state_filter (TASK_UNINTERRUPTIBLE ); -} -void check_panic_on_warn (const char *origin) {unsigned int limit;
@@ -285,7 +256,7 @@ void check_panic_on_warn(const char *origin)*/ static void panic_other_cpus_shutdown (bool crash_kexec) { -if (panic_print &PANIC_PRINT_ALL_CPU_BT ) { +if (panic_print &SYS_SHOW_ALL_CPU_BT ) {/* Temporary allow non-panic CPUs to write their backtraces. */ panic_triggering_all_cpu_backtrace = true;trigger_all_cpu_backtrace ();
@@ -410,7 +381,7 @@ void panic(const char *fmt, ...)*/ atomic_notifier_call_chain (&panic_notifier_list,0 , buf); -panic_print_sys_info (); +sys_show_info (panic_print);kmsg_dump_desc (KMSG_DUMP_PANIC , buf);
lib/Makefile +1 -1
@@ -40,7 +40,7 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \ is_single_threaded.o plist.o decompress.o kobject_uevent.o \ earlycpio.o seq_buf.o siphash.o dec_and_lock.o \ nmi_backtrace.o win_minmax.o memcat_p.o \ - buildid.o objpool.o iomem_copy.o + buildid.o objpool.o iomem_copy.o sys_info.o lib-$(CONFIG_UNION_FIND) += union_find.o lib-$(CONFIG_PRINTK) += dump_stack.o
lib/sys_info.c new file +30 -0
@@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include <linux/sched/debug.h> +#include <linux/kernel.h> +#include <linux/ftrace.h> +#include <linux/console.h> +#include <linux/nmi.h> + +void sys_show_info (unsigned long info_flag) +{ +if (info_flag &SYS_SHOW_TASK_INFO ) +show_state (); + +if (info_flag &SYS_SHOW_MEM_INFO ) +show_mem (); + +if (info_flag &SYS_SHOW_TIMER_INFO ) +sysrq_timer_list_show (); + +if (info_flag &SYS_SHOW_LOCK_INFO ) +debug_show_all_locks (); + +if (info_flag &SYS_SHOW_FTRACE_INFO ) +ftrace_dump (DUMP_ALL ); + +if (info_flag &SYS_SHOW_ALL_CPU_BT ) +trigger_all_cpu_backtrace (); + +if (info_flag &SYS_SHOW_BLOCKED_TASKS ) +show_state_filter (TASK_UNINTERRUPTIBLE ); +}
Signature · 1 line
2.39.5 (Apple Git-154)
Re: [PATCH V2 2/5] panic: generalize panic_print's function to show sys info
Quoted 12 lines · Feng Tang
'
panic_print' was introduced to help debugging kernel panic by dumping different kinds of system information like tasks' call stack, memory, ftrace buffer, etc. Acutually this function could also help debugging cases like task-hung, soft/hard lockup, and other cases , where user may need the snapshot of system info at that time.Extract
sys_show_info()function out of panic code to be used by other kernel parts for debugging.
include/linux/kernel.h line 30
Quoted 4 lines
include/linux/kernel.h +1
-0@@ -27,6 +27,7 @@#include <linux/math.h> #include <linux/minmax.h> #include <linux/typecheck.h> +#include <linux/sys_info.h>
There will be only few users of this API. There is no need to include it via this generic header which is included almost everywhere.
Some people are working hard on getting rid of this header file, see the comment at the beginning:
* This header has combined a lot of unrelated to each other stuff.
* The process of splitting its content is in progress while keeping
* backward compatibility. That's why it's highly recommended NOT to
* include this header inside another header file, especially under
* generic or architectural include/ directory.
Instead, please include the new linux/sys_info.h in panic.c directly.
Quoted 7 lines
include/linux/kernel.h +0
-0#include <linux/panic.h> #include <linux/printk.h> #include <linux/build_bug.h>
include/linux/sys_info.h line 7
Quoted 7 lines
include/linux/sys_info.h new file +7
-0@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_SYS_INFO_H +#define _LINUX_SYS_INFO_H + +/* +* SYS_SHOW_ALL_PRINTK_MSG is for panic case only, as it needs special +* handling which only fits panic case.
This flags is really special. I would even rename it to match the function where it is used:
#define PANIC_CONSOLE_REPLAY 0x00000020
And it would be better to do the rename (ALL_PRINTK_MSG -> CONSOLE_REPLAY) already in the 1st patch where panic_console_replay() was introduced.
Also it would make sense to update the documentation (in 1st patch), something like:
Documentation/admin-guide/kernel-parameters.txt +1 -1
@@ -4533,7 +4533,7 @@ bit 2: print timer info bit 3: print locks info if CONFIG_LOCKDEP is on bit 4: print ftrace buffer - bit 5: print all printk messages in buffer + bit 5: replay all messages on consoles at the end of panic bit 6: print all CPUs backtrace (if available in the arch) bit 7: print only tasks in uninterruptible (blocked) state *Be aware* that this option may print a _lot_ of lines,
include/linux/sys_info.h line 18
Quoted 11 lines
include/linux/sys_info.h new file +11
-0+*/ +#define SYS_SHOW_TASK_INFO 0x00000001 +#define SYS_SHOW_MEM_INFO 0x00000002 +#define SYS_SHOW_TIMER_INFO 0x00000004 +#define SYS_SHOW_LOCK_INFO 0x00000008 +#define SYS_SHOW_FTRACE_INFO 0x00000010 +#define SYS_SHOW_ALL_PRINTK_MSG 0x00000020 +#define SYS_SHOW_ALL_CPU_BT 0x00000040 +#define SYS_SHOW_BLOCKED_TASKS 0x00000080 + +extern void sys_show_info (unsigned long info_mask);
Please, do not use "extern" in new header files. This is from Documentation/process/coding-style.rst:
Do not use the ``extern`` keyword with function declarations as this makes lines longer and isn't strictly necessary.
Also the header file is named "sys_info" but the API is "sys_show_*info". It would be more user friendly to consistently use the same prefix for the entire API, for example:
#define SYS_INFO_TASK 0x00000001
#define SYS_INFO_MEM 0x00000002
#define SYS_INFO_TIMER 0x00000004
void sys_info(unsigned long si_mask);
I am sorry that I did not tell your this in the RFC. I focused on the bigger picture at that time.
include/linux/sys_info.h line 19
Quoted 1 line
include/linux/sys_info.h new file +1
-0+#endif /* _LINUX_SYS_INFO_H */
Best Regards,
Petr
Re: [PATCH V2 2/5] panic: generalize panic_print's function to show sys info
Quoted 25 lines · Petr Mladek
Quoted 12 lines · Feng Tang
'
panic_print' was introduced to help debugging kernel panic by dumping different kinds of system information like tasks' call stack, memory, ftrace buffer, etc. Acutually this function could also help debugging cases like task-hung, soft/hard lockup, and other cases , where user may need the snapshot of system info at that time.Extract
sys_show_info()function out of panic code to be used by other kernel parts for debugging.include/linux/kernel.h line 30
Quoted 4 lines
include/linux/kernel.h +1
-0@@ -27,6 +27,7 @@#include <linux/math.h> #include <linux/minmax.h> #include <linux/typecheck.h> +#include <linux/sys_info.h> There will be only few users of this API. There is no need to include it via this generic header which is included almost everywhere.
Some people are working hard on getting rid of this header file, see the comment at the beginning:
Quoted 7 lines
* This header has combined a lot of unrelated to each other stuff.
* The process of splitting its content is in progress while keeping
* backward compatibility. That's why it's highly recommended NOT to
* include this header inside another header file, especially under
* generic or architecturalinclude/directory.Instead, please include the new
linux/sys_info.hinpanic.cdirectly.
Makes sense! WIll change.
Quoted 18 lines
Quoted 7 lines
include/linux/kernel.h +0
-0#include <linux/panic.h> #include <linux/printk.h> #include <linux/build_bug.h> include/linux/sys_info.h line 7
Quoted 7 lines
include/linux/sys_info.h new file +7
-0@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_SYS_INFO_H +#define _LINUX_SYS_INFO_H + +/* +* SYS_SHOW_ALL_PRINTK_MSG is for panic case only, as it needs special +* handling which only fits panic case. This flags is really special. I would even rename it to match the function where it is used:
Quoted 5 lines
#define
PANIC_CONSOLE_REPLAY0x00000020And it would be better to do the rename (
ALL_PRINTK_MSG->CONSOLE_REPLAY) already in the 1st patch wherepanic_console_replay()was introduced.
OK.
Quoted 6 lines
Also it would make sense to update the documentation (in 1st patch), something like:
Documentation/admin-guide/kernel-parameters.txt line 4539
Quoted 8 lines
Documentation/admin-guide/kernel-parameters.txt +1
-1@@ -4533,7 +4533,7 @@ bit 2: print timer info bit 3: print locks info if CONFIG_LOCKDEP is on bit 4: print ftrace buffer - bit 5: print all printk messages in buffer + bit 5: replay all messages on consoles at the end of panic bit 6: print all CPUs backtrace (if available in the arch) bit 7: print only tasks in uninterruptible (blocked) state *Be aware* that this option may print a _lot_ of lines,
Will change.
Quoted 15 lines
include/linux/sys_info.h line 18
Quoted 11 lines
include/linux/sys_info.h new file +11
-0+*/ +#define SYS_SHOW_TASK_INFO 0x00000001 +#define SYS_SHOW_MEM_INFO 0x00000002 +#define SYS_SHOW_TIMER_INFO 0x00000004 +#define SYS_SHOW_LOCK_INFO 0x00000008 +#define SYS_SHOW_FTRACE_INFO 0x00000010 +#define SYS_SHOW_ALL_PRINTK_MSG 0x00000020 +#define SYS_SHOW_ALL_CPU_BT 0x00000040 +#define SYS_SHOW_BLOCKED_TASKS 0x00000080 + +extern void sys_show_info (unsigned long info_mask);Please, do not use "extern" in new header files. This is from
Documentation/process/coding-style.rst:
Quoted 2 lines
Do not use the ``extern`` keyword with function declarations as this makes lines longer and isn't strictly necessary.
Thanks for the note!
Quoted 7 lines
Also the header file is named "
sys_info" but the API is "sys_show_*info". It would be more user friendly to consistently use the same prefix for the entire API, for example:#define
SYS_INFO_TASK0x00000001
#defineSYS_INFO_MEM0x00000002
#defineSYS_INFO_TIMER0x00000004
Yeap, shorter and cleaner.
Quoted 5 lines
void
sys_info(unsigned long si_mask);I am sorry that I did not tell your this in the RFC. I focused on the bigger picture at that time.
No problem. Thanks for the review!
- Feng
Quoted 4 lines
include/linux/sys_info.h line 19
Quoted 1 line
include/linux/sys_info.h new file +1
-0+#endif /* _LINUX_SYS_INFO_H */ Best Regards,
Petr
PATCH v2 3/5 sys_info: add help to translate sys_info string to bitmap
In reply to Feng TangBitmap definition is hard to remember and decode. Add sysctl interface to translate human readable string like "tasks,mem,timer,lock,ftrace,..." to bitmap.
--- include/linux/sys_info.h | 7 +++ lib/sys_info.c | 97 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+)
include/linux/sys_info.h +7 -0
@@ -16,5 +16,12 @@#define SYS_SHOW_BLOCKED_TASKS 0x00000080extern void sys_show_info (unsigned long info_mask); +extern unsigned long sys_info_parse_param (char *str); +#ifdef CONFIG_SYSCTL +struct ctl_table ; +extern int sysctl_sys_info_handler (const struct ctl_table *ro_table,int write, +void *buffer,size_t *lenp, +loff_t *ppos); +#endif #endif /* _LINUX_SYS_INFO_H */
lib/sys_info.c +97 -0
103 lines not on this page · raw message
Signature · 1 line
2.39.5 (Apple Git-154)
kernel test robot
build botRe: [PATCH V2 3/5] sys_info: add help to translate sys_info string to bitmap
kernel test robot noticed the following build warnings:
Hi Feng,
kernel test robot noticed the following build warnings:
[auto build test WARNING on akpm-mm/mm-nonmm-unstable]
[also build test WARNING on akpm-mm/mm-everything linus/master v6.16-rc2 next-20250613] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Feng-Tang/panic-clean-up-code-for-console-replay/20250616-091042 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-nonmm-unstable patch link: https://lore.kernel.org/r/20250616010840.38258-4-feng.tang%40linux.alibaba.com patch subject: [PATCH V2 3/5] sys_info: add help to translate sys_info string to bitmap config: x86_64-buildonly-randconfig-001-20250616 (https://download.01.org/0day-ci/archive/20250616/[email protected]/config) compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247) rustc: rustc 1.78.0 (9b00956e5 2024-04-29) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250616/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> lib/sys_info.c:13:19: warning: unused variable 'sys_info_avail' [-Wunused-const-variable]
13 | static const char sys_info_avail[] = "tasks,mem,timer,lock,ftrace,all_bt,blocked_tasks";
| ^~~~~~~~~~~~~~1 warning generated.
vim +/sys_info_avail +13 lib/sys_info.c
12
> 13 static const char sys_info_avail[] = "tasks,mem,timer,lock,ftrace,all_bt,blocked_tasks";
14 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH V2 3/5] sys_info: add help to translate sys_info string to bitmap
Quoted 24 lines · kernel test robot
Hi Feng,
kernel test robot noticed the following build warnings:
[auto build test WARNING on akpm-mm/mm-nonmm-unstable]
[also build test WARNING on akpm-mm/mm-everything linus/master v6.16-rc2 next-20250613] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]url: https://github.com/intel-lab-lkp/linux/commits/Feng-Tang/panic-clean-up-code-for-console-replay/20250616-091042 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-nonmm-unstable patch link: https://lore.kernel.org/r/20250616010840.38258-4-feng.tang%40linux.alibaba.com patch subject: [PATCH V2 3/5] sys_info: add help to translate sys_info string to bitmap config: x86_64-buildonly-randconfig-001-20250616 (https://download.01.org/0day-ci/archive/20250616/[email protected]/config) compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247) rustc: rustc 1.78.0 (9b00956e5 2024-04-29) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250616/[email protected]/reproduce)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Quoted 6 lines
All warnings (new ones prefixed by >>):
Quoted 1 line
Quoted 1 line
lib/sys_info.c:13:19: warning: unused variable 'sys_info_avail' [-Wunused-const-variable]13 | static const char sys_info_avail[] = "tasks,mem,timer,lock,ftrace,all_bt,blocked_tasks"; | ^~~~~~~~~~~~~~1 warning generated.
Thanks for the reporting! This is related with CONFIG_SYSCTL=n, and should be fixed by below patch:
---
lib/sys_info.c +2 -2
@@ -10,8 +10,6 @@ struct sys_info_name {const char *name; }; -static const char sys_info_avail[] ="tasks,mem,timer,lock,ftrace,all_bt,blocked_tasks" ; -static const struct sys_info_name si_names[] = { {SYS_SHOW_TASK_INFO ,"tasks" }, {SYS_SHOW_MEM_INFO ,"mem" },
@@ -43,6 +41,8 @@ unsigned long sys_info_parse_param(char *str) }#ifdef CONFIG_SYSCTL +static const char sys_info_avail[] ="tasks,mem,timer,lock,ftrace,all_bt,blocked_tasks" ; +int sysctl_sys_info_handler (const struct ctl_table *ro_table,int write,void *buffer,size_t *lenp,loff_t *ppos)
Re: [PATCH V2 3/5] sys_info: add help to translate sys_info string to bitmap
In reply to Feng TangQuoted 37 lines · Feng Tang
Bitmap definition is hard to remember and decode. Add sysctl interface to translate human readable string like "tasks,mem,timer,lock,ftrace,..." to bitmap.
Suggested-by Petr Mladek <[email protected]>Signed-off-by Feng Tang <[email protected]>--- include/linux/sys_info.h | 7 +++ lib/sys_info.c | 97 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+)include/linux/sys_info.h +7
-0@@ -16,5 +16,12 @@#define SYS_SHOW_BLOCKED_TASKS 0x00000080extern void sys_show_info (unsigned long info_mask); +extern unsigned long sys_info_parse_param (char *str); +#ifdef CONFIG_SYSCTL +struct ctl_table ; +extern int sysctl_sys_info_handler (const struct ctl_table *ro_table,int write, +void *buffer,size_t *lenp, +loff_t *ppos); +#endif #endif /* _LINUX_SYS_INFO_H */ lib/sys_info.c +1
-0@@ -5,6 +5,103 @@#include <linux/console.h> #include <linux/nmi.h> +struct sys_info_name {
lib/sys_info.c line 18
Quoted 10 lines
lib/sys_info.c +10
-0+unsigned long bit; +const char *name; +}; + +static const char sys_info_avail[] ="tasks,mem,timer,lock,ftrace,all_bt,blocked_tasks" ; + +static const struct sys_info_name si_names[] = { + {SYS_SHOW_TASK_INFO ,"tasks" }, + {SYS_SHOW_MEM_INFO ,"mem" }, + {SYS_SHOW_TIMER_INFO ,"timer" },
I see that the naming is a bit inconsistent in using singulars vs. plurals. I suggest to use plulars when it makes sense. It means here:
{ SYS_SHOW_TIMERS_INFO, "timers" },lib/sys_info.c line 19
Quoted 1 line
lib/sys_info.c +1
-0+ { SYS_SHOW_LOCK_INFO, "lock" },
and here
{ SYS_SHOW_LOCKS_INFO, "locks" },Quoted 4 lines
lib/sys_info.c +4
-0+ { SYS_SHOW_FTRACE_INFO, "ftrace" }, + { SYS_SHOW_ALL_CPU_BT, "all_bt" }, + { SYS_SHOW_BLOCKED_TASKS, "blocked_tasks" }, +};
[...]
Quoted 16 lines
lib/sys_info.c +16
-0+#ifdef CONFIG_SYSCTL +int sysctl_sys_info_handler (const struct ctl_table *ro_table,int write, +void *buffer,size_t *lenp, +loff_t *ppos) +{ +char names[sizeof (sys_info_avail) +1 ]; +struct ctl_table table; +unsigned long *si_bits_global; +int i, ret, len; + + si_bits_global = ro_table->data; + +if (write) { +unsigned long si_bits; + + table = *ro_table;
lib/sys_info.c
Quoted 10 lines
lib/sys_info.c +10
-0+ table.data = names; + table.maxlen =sizeof (names); + ret =proc_dostring (&table, write, buffer, lenp, ppos); +if (ret) +return ret; + + si_bits =sys_info_parse_param (names); +/* +* The access to the global value is not synchronized. +*/
Nit, the comment fits on a single line. I would use:
/* The access to the global value is not synchronized. */
Quoted 10 lines
lib/sys_info.c +10
-0+WRITE_ONCE (*si_bits_global, si_bits); +return 0 ; + }else { +/* for 'read' operation */ +bool first = true; +char *buf; + + buf = names; +for (i =0 ; i <ARRAY_SIZE (si_names); i++) { +if (*si_bits_global & si_names[i].bit) {
lib/sys_info.c
Quoted 10 lines
lib/sys_info.c +10
-0+ +if (first) { + first = false; + }else { + *buf =',' ; + buf++; + } + + len =strlen (si_names[i].name); +strncpy (buf, si_names[i].name, len);
I am afraid of a buffer overflow when people add new entry into si_names[] table but they forget to update sys_info_avail[] string. I would prefer to limit the write to the buffer by the size of the buffer.
Something like (on top of this patch):
lib/sys_info.c +7 -16
@@ -50,7 +50,7 @@ int sysctl_sys_info_handler(const struct ctl_table *ro_table, int write,char names[sizeof (sys_info_avail) +1 ];struct ctl_table table;unsigned long *si_bits_global; -int i, ret, len; +int i, ret; si_bits_global = ro_table->data;
@@ -72,27 +72,18 @@ int sysctl_sys_info_handler(const struct ctl_table *ro_table, int write,return 0 ; }else {/* for 'read' operation */ -bool first = true; -char *buf; +char *delim ="" ; +int len =0 ; - buf = names; + names[0 ] ='\0' ;for (i =0 ; i <ARRAY_SIZE (si_names); i++) {if (*si_bits_global & si_names[i].bit) { - -if (first) { - first = false; - }else { - *buf =',' ; - buf++; - } - - len =strlen (si_names[i].name); -strncpy (buf, si_names[i].name, len); - buf += len; + len +=scnprintf (names + len,sizeof (names) - len, +"%s%s" , delim, si_names[i].name); + delim ="," ; } } - *buf ='\0' ; table = *ro_table; table.data = names;
Best Regards,
Petr
Re: [PATCH V2 3/5] sys_info: add help to translate sys_info string to bitmap
Quoted 53 lines · Petr Mladek
Quoted 37 lines · Feng Tang
Bitmap definition is hard to remember and decode. Add sysctl interface to translate human readable string like "tasks,mem,timer,lock,ftrace,..." to bitmap.
Suggested-by Petr Mladek <[email protected]>Signed-off-by Feng Tang <[email protected]>--- include/linux/sys_info.h | 7 +++ lib/sys_info.c | 97 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+)include/linux/sys_info.h +7
-0@@ -16,5 +16,12 @@#define SYS_SHOW_BLOCKED_TASKS 0x00000080extern void sys_show_info (unsigned long info_mask); +extern unsigned long sys_info_parse_param (char *str); +#ifdef CONFIG_SYSCTL +struct ctl_table ; +extern int sysctl_sys_info_handler (const struct ctl_table *ro_table,int write, +void *buffer,size_t *lenp, +loff_t *ppos); +#endif #endif /* _LINUX_SYS_INFO_H */ lib/sys_info.c +1
-0@@ -5,6 +5,103 @@#include <linux/console.h> #include <linux/nmi.h> +struct sys_info_name {lib/sys_info.c line 18
Quoted 10 lines
lib/sys_info.c +10
-0+unsigned long bit; +const char *name; +}; + +static const char sys_info_avail[] ="tasks,mem,timer,lock,ftrace,all_bt,blocked_tasks" ; + +static const struct sys_info_name si_names[] = { + {SYS_SHOW_TASK_INFO ,"tasks" }, + {SYS_SHOW_MEM_INFO ,"mem" }, + {SYS_SHOW_TIMER_INFO ,"timer" },I see that the naming is a bit inconsistent in using singulars vs. plurals. I suggest to use plulars when it makes sense. It means here:
Quoted 7 lines
{ SYS_SHOW_TIMERS_INFO, "timers" },lib/sys_info.c line 19
Quoted 1 line
lib/sys_info.c +1
-0+ { SYS_SHOW_LOCK_INFO, "lock" },and here
{ SYS_SHOW_LOCKS_INFO, "locks" },
Will change.
Quoted 36 lines
Quoted 4 lines
lib/sys_info.c +4
-0+ { SYS_SHOW_FTRACE_INFO, "ftrace" }, + { SYS_SHOW_ALL_CPU_BT, "all_bt" }, + { SYS_SHOW_BLOCKED_TASKS, "blocked_tasks" }, +};[...]
Quoted 16 lines
lib/sys_info.c +16
-0+#ifdef CONFIG_SYSCTL +int sysctl_sys_info_handler (const struct ctl_table *ro_table,int write, +void *buffer,size_t *lenp, +loff_t *ppos) +{ +char names[sizeof (sys_info_avail) +1 ]; +struct ctl_table table; +unsigned long *si_bits_global; +int i, ret, len; + + si_bits_global = ro_table->data; + +if (write) { +unsigned long si_bits; + + table = *ro_table;lib/sys_info.c
Quoted 10 lines
lib/sys_info.c +10
-0+ table.data = names; + table.maxlen =sizeof (names); + ret =proc_dostring (&table, write, buffer, lenp, ppos); +if (ret) +return ret; + + si_bits =sys_info_parse_param (names); +/* +* The access to the global value is not synchronized. +*/ Nit, the comment fits on a single line. I would use:
Quoted 1 line
/* The access to the global value is not synchronized. */
Yes.
Quoted 16 lines
Quoted 16 lines
lib/sys_info.c +16
-0+WRITE_ONCE (*si_bits_global, si_bits); +return 0 ; + }else { +/* for 'read' operation */ +bool first = true; +char *buf; + + buf = names; +for (i =0 ; i <ARRAY_SIZE (si_names); i++) { +if (*si_bits_global & si_names[i].bit) { + +if (first) { + first = false; + }else { + *buf =',' ; + buf++;
Quoted 8 lines
lib/sys_info.c
Quoted 4 lines
lib/sys_info.c +4
-0+ } + + len =strlen (si_names[i].name); +strncpy (buf, si_names[i].name, len);I am afraid of a buffer overflow when people add new entry into si_names[] table but they forget to update sys_info_avail[] string. I would prefer to limit the write to the buffer by the size of the buffer.
Indeed. In my v3 branch, I have also added a line to warn about it:
/*
* When 'si_names' gets updated, please make sure the 'sys_info_avail'
* below is updated accordingly.
*/
static const struct sys_info_name si_names[] = {But still, better to do some handling in code as you suggested.
Quoted 37 lines
Something like (on top of this patch):
lib/sys_info.c +4
-15@@ -50,7 +50,7 @@ int sysctl_sys_info_handler(const struct ctl_table *ro_table, int write,char names[sizeof (sys_info_avail) +1 ];struct ctl_table table;unsigned long *si_bits_global; -int i, ret, len; +int i, ret; si_bits_global = ro_table->data;@@ -72,27 +72,18 @@ int sysctl_sys_info_handler(const struct ctl_table *ro_table, int write,return 0 ; }else {/* for 'read' operation */ -bool first = true; -char *buf; +char *delim ="" ; +int len =0 ; - buf = names; + names[0 ] ='\0' ;for (i =0 ; i <ARRAY_SIZE (si_names); i++) {if (*si_bits_global & si_names[i].bit) { - -if (first) { - first = false; - }else { - *buf =',' ; - buf++; - } - - len =strlen (si_names[i].name); -strncpy (buf, si_names[i].name, len); - buf += len;
lib/sys_info.c int sysctl_sys_info_handler(const struct ctl_table *ro_table, int write, · line 89
Quoted 10 lines
lib/sys_info.c +3
-1+ len +=scnprintf (names + len,sizeof (names) - len, +"%s%s" , delim, si_names[i].name); + delim ="," ; } } - *buf ='\0' ; table = *ro_table; table.data = names;
Thanks!
- Feng
Quoted 2 lines
Best Regards,
Petr
PATCH v2 4/5 panic: add 'panic_sys_info=' setup option for sysctl and kernel cmdline
In reply to Feng TangAdd 'panic_sys_info=' setup which expects string like "tasks,mem,lock,...". It supports both runtime sysctl control and boot time kernel cmdline setup, and could be seen as human readable string version of 'panic_print'.
The detail mapping is:
SYS_SHOW_TASK_INFO "tasks" SYS_SHOW_MEM_INFO "mem" SYS_SHOW_TIMER_INFO "timer" SYS_SHOW_LOCK_INFO "lock" SYS_SHOW_FTRACE_INFO "ftrace" SYS_SHOW_ALL_CPU_BT "all_bt" SYS_SHOW_BLOCKED_TASKS "blocked_tasks"
--- .../admin-guide/kernel-parameters.txt | 13 +++++++++++++ Documentation/admin-guide/sysctl/kernel.rst | 18 ++++++++++++++++++ kernel/panic.c | 16 ++++++++++++++++ 3 files changed, 47 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +13 -0
@@ -4541,6 +4541,19 @@ Use this option carefully, maybe worth to setup a bigger log buffer with "log_buf_len" along with this. + panic_sys_info= + String of subsystem info to be dumped on panic. + It expects string of comma-separated words like + "tasks,mem,timer,...", which is a human readable string + version of 'panic_print': + tasks: print all tasks info + mem: print system memory info + timer: print timer info + lock: print locks info if CONFIG_LOCKDEP is on + ftrace: print ftrace buffer + all_bt: print all CPUs backtrace (if available in the arch) + blocked_tasks: print only tasks in uninterruptible (blocked) state + parkbd.port= [HW] Parallel port number the keyboard adapter is connected to, default is 0. Format: <parport#>
Documentation/admin-guide/sysctl/kernel.rst +18 -0
@@ -899,6 +899,24 @@ So for example to print tasks and memory info on panic, user can:: echo 3 > /proc/sys/kernel/panic_print +panic_sys_info +============== + +String of subsystem info to be dumped on panic. It expects string of +comma-separated words like "tasks,mem,timer,...", which is a human +readable string version of 'panic_print': + +============= =================================================== +tasks print all tasks info +mem print system memory info +timer print timer info +lock print locks info if CONFIG_LOCKDEP is on +ftrace print ftrace buffer +all_bt print all CPUs backtrace (if available in the arch) +blocked_tasks print only tasks in uninterruptible (blocked) state +============= =================================================== + + panic_on_rcu_stall ==================
kernel/panic.c +16 -0
@@ -125,6 +125,13 @@ static const struct ctl_table kern_panic_table[] = { .mode = 0644, .proc_handler = proc_douintvec, }, + { + .procname = "panic_sys_info", + .data = &panic_print, + .maxlen = sizeof(panic_print), + .mode = 0644, + .proc_handler = sysctl_sys_info_handler, + }, };static __init int kernel_panic_sysctls_init (void )
@@ -135,6 +142,15 @@ static __init int kernel_panic_sysctls_init(void)late_initcall (kernel_panic_sysctls_init);#endif +/* The format is "panic_sys_info=task,mem,ftrace,..." */ +static int __init setup_panic_sys_info (char *buf) +{ +/* There is no risk of race in kernel boot phase */ + panic_print =sys_info_parse_param (buf); +return 1 ; +} +__setup ("panic_sys_info=" , setup_panic_sys_info); +static atomic_t warn_count =ATOMIC_INIT (0 );#ifdef CONFIG_SYSFS
Signature · 1 line
2.39.5 (Apple Git-154)
Re: [PATCH V2 4/5] panic: add 'panic_sys_info=' setup option for sysctl and kernel cmdline
Quoted 1 line · Feng Tang
Add 'panic_sys_info=' setup which expects string like "tasks,mem,lock,...".
This patch actually adds also the sysctl interface. It should be mentioned in the "Subject" and here.
That said, it might be better to add the sysctl interface in the previous patch and add just the setup() here.
Documentation/admin-guide/kernel-parameters.txt line 4547
Quoted 10 lines
Documentation/admin-guide/kernel-parameters.txt +2
-0@@ -4541,6 +4541,19 @@ Use this option carefully, maybe worth to setup a bigger log buffer with "log_buf_len" along with this. + panic_sys_info= + String of subsystem info to be dumped on panic.
I am not a native speaker but I have troubles to parse the above sentence. See below.
Documentation/admin-guide/kernel-parameters.txt line 4555
Quoted 10 lines
Documentation/admin-guide/kernel-parameters.txt +10
-0+ It expects string of comma-separated words like + "tasks,mem,timer,...", which is a human readable string + version of 'panic_print': + tasks: print all tasks info + mem: print system memory info + timer: print timer info + lock: print locks info if CONFIG_LOCKDEP is on + ftrace: print ftrace buffer + all_bt: print all CPUs backtrace (if available in the arch) + blocked_tasks: print only tasks in uninterruptible (blocked) state
This blob is hard to parse. I suggest to replace it with something like:
<proposal>
panic_sys_info= A comma separated list of extra information to be dumped
on panic.
Format: val[,val...]
Where @val can be any of the following:
tasks: print all tasks info
mem: print system memory info
timers: print timers info
locks: print locks info if CONFIG_LOCKDEP is on
ftrace: print ftrace buffer
all_bt: print all CPUs backtrace (if available in the arch)
blocked_tasks: print only tasks in uninterruptible (blocked) state
This is a human readable alternative to the 'panic_print' option.
</proposal>
Quoted 9 lines
Documentation/admin-guide/kernel-parameters.txt +1
-0+ parkbd.port= [HW] Parallel port number the keyboard adapter isDocumentation/admin-guide/kernel-parameters.txt +0
-0connected to, default is 0. Format: <parport#>Documentation/admin-guide/sysctl/kernel.rst +0
-0
Documentation/admin-guide/sysctl/kernel.rst So for example to print tasks and memory info on panic, user can:: · line 905
Quoted 7 lines
Documentation/admin-guide/sysctl/kernel.rst +4
-0@@ -899,6 +899,24 @@ So for example to print tasks and memory info on panic, user can:: echo 3 > /proc/sys/kernel/panic_print +panic_sys_info +============== + +String of subsystem info to be dumped on panic. It expects string of
Same here.
Documentation/admin-guide/sysctl/kernel.rst So for example to print tasks and memory info on panic, user can:: · line 907
Quoted 2 lines
Documentation/admin-guide/sysctl/kernel.rst +2
-0+comma-separated words like "tasks,mem,timer,...", which is a human +readable string version of 'panic_print':
I would replace it with:
<proposal>
A comma separated list of extra information to be dumped on panic, for example, "tasks,mem,timers,...". It is a human readable alternative to 'panic_print'. Possible values are:
</proposal>
Quoted 4 lines
Documentation/admin-guide/sysctl/kernel.rst +4
-0+ +============= =================================================== +tasks print all tasks info +mem print system memory info
Documentation/admin-guide/sysctl/kernel.rst So for example to print tasks and memory info on panic, user can:: · line 921
Quoted 10 lines
Documentation/admin-guide/sysctl/kernel.rst +8
-0+timer print timer info +lock print locks info if CONFIG_LOCKDEP is on +ftrace print ftrace buffer +all_bt print all CPUs backtrace (if available in the arch) +blocked_tasks print only tasks in uninterruptible (blocked) state +============= =================================================== + + panic_on_rcu_stall ==================
The rest looks good.
Best Regards,
Petr
Re: [PATCH V2 4/5] panic: add 'panic_sys_info=' setup option for sysctl and kernel cmdline
Quoted 5 lines · Petr Mladek
Quoted 1 line · Feng Tang
Add 'panic_sys_info=' setup which expects string like "tasks,mem,lock,...".
This patch actually adds also the sysctl interface. It should be mentioned in the "Subject" and here.
I mentioned 'sysctl' in the subjec line, but maybe it's not obvious :)
Quoted 2 lines
That said, it might be better to add the sysctl interface in the previous patch and add just the
setup()here.
OK.
Quoted 42 lines
Documentation/admin-guide/kernel-parameters.txt line 4547
Quoted 11 lines
Documentation/admin-guide/kernel-parameters.txt +2
-0@@ -4541,6 +4541,19 @@ Use this option carefully, maybe worth to setup a bigger log buffer with "log_buf_len" along with this. + panic_sys_info= + String of subsystem info to be dumped on panic.I am not a native speaker but I have troubles to parse the above sentence. See below.
Documentation/admin-guide/kernel-parameters.txt line 4555
Quoted 10 lines
Documentation/admin-guide/kernel-parameters.txt +10
-0+ It expects string of comma-separated words like + "tasks,mem,timer,...", which is a human readable string + version of 'panic_print': + tasks: print all tasks info + mem: print system memory info + timer: print timer info + lock: print locks info if CONFIG_LOCKDEP is on + ftrace: print ftrace buffer + all_bt: print all CPUs backtrace (if available in the arch) + blocked_tasks: print only tasks in uninterruptible (blocked) stateThis blob is hard to parse. I suggest to replace it with something like:
<proposal>
panic_sys_info= A comma separated list of extra information to be dumped
on panic.
Format: val[,val...]
Where @val can be any of the following:tasks: print all tasks info
mem: print system memory info
timers: print timers info
locks: print locks info ifCONFIG_LOCKDEPis on
ftrace: print ftrace buffer
all_bt: print all CPUs backtrace (if available in the arch)
blocked_tasks: print only tasks in uninterruptible (blocked) state
Quoted 2 lines
This is a human readable alternative to the '
panic_print' option.
</proposal>
Thanks! It's much better.
Quoted 24 lines
Quoted 9 lines
Documentation/admin-guide/kernel-parameters.txt +1
-0+ parkbd.port= [HW] Parallel port number the keyboard adapter isDocumentation/admin-guide/kernel-parameters.txt +0
-0connected to, default is 0. Format: <parport#>Documentation/admin-guide/sysctl/kernel.rst +0
-0Documentation/admin-guide/sysctl/kernel.rst So for example to print tasks and memory info on panic, user can:: · line 905
Quoted 7 lines
Documentation/admin-guide/sysctl/kernel.rst +4
-0@@ -899,6 +899,24 @@ So for example to print tasks and memory info on panic, user can:: echo 3 > /proc/sys/kernel/panic_print +panic_sys_info +============== + +String of subsystem info to be dumped on panic. It expects string ofSame here.
Documentation/admin-guide/sysctl/kernel.rst So for example to print tasks and memory info on panic, user can:: · line 907
Quoted 2 lines
Documentation/admin-guide/sysctl/kernel.rst +2
-0+comma-separated words like "tasks,mem,timer,...", which is a human +readable string version of 'panic_print':I would replace it with:
Quoted 5 lines
<proposal>
A comma separated list of extra information to be dumped on panic, for example, "tasks,mem,timers,...". It is a human readable alternative to 'panic_print'. Possible values are:
</proposal>
Will change.
Quoted 8 lines
Quoted 8 lines
Documentation/admin-guide/sysctl/kernel.rst +8
-0+ +============= =================================================== +tasks print all tasks info +mem print system memory info +timer print timer info +lock print locks info if CONFIG_LOCKDEP is on +ftrace print ftrace buffer +all_bt print all CPUs backtrace (if available in the arch)
Quoted 8 lines
Documentation/admin-guide/sysctl/kernel.rst So for example to print tasks and memory info on panic, user can:: · line 921
Quoted 6 lines
Documentation/admin-guide/sysctl/kernel.rst +4
-0+blocked_tasks print only tasks in uninterruptible (blocked) state +============= =================================================== + + panic_on_rcu_stall ==================The rest looks good.
Thanks!
- Feng
Quoted 2 lines
Best Regards,
Petr
PATCH v2 5/5 panic: add note that panic_print interface is deprecated
In reply to Feng TangLong term wise, the 'panic_sys_info' should be the only controlling interface, which can be referred by other modules.
--- kernel/panic.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
kernel/panic.c +8 -1
@@ -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",
Signature · 1 line
2.39.5 (Apple Git-154)
Re: [PATCH V2 5/5] panic: add note that panic_print interface is deprecated
Quoted 14 lines · Feng Tang
Long term wise, the '
panic_sys_info' should be the only controlling interface, which can be referred by other modules.Suggested-by Petr Mladek <[email protected]>Signed-off-by Feng Tang <[email protected]>--- kernel/panic.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)kernel/panic.c +0
-0
kernel/panic.c ATOMIC_NOTIFIER_HEAD(panic_notifier_list); · line 82
Quoted 7 lines
kernel/panic.c +4
-0@@ -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
Quoted 15 lines
kernel/panic.c +4
-1+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",
Re: [PATCH V2 5/5] panic: add note that panic_print interface is deprecated
Quoted 28 lines · Lance Yang
Quoted 14 lines · Feng Tang
Long term wise, the '
panic_sys_info' should be the only controlling interface, which can be referred by other modules.Suggested-by Petr Mladek <[email protected]>Signed-off-by Feng Tang <[email protected]>--- kernel/panic.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)kernel/panic.c +0
-0kernel/panic.c ATOMIC_NOTIFIER_HEAD(panic_notifier_list); · line 81
Quoted 6 lines
kernel/panic.c +4
-0@@ -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 ;)
Quoted 4 lines
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
Quoted 2 lines
Thanks,
Lance
Re: [PATCH V2 5/5] panic: add note that panic_print interface is deprecated
In reply to Lance YangQuoted 28 lines · Lance Yang
Quoted 14 lines · Feng Tang
Long term wise, the '
panic_sys_info' should be the only controlling interface, which can be referred by other modules.Suggested-by Petr Mladek <[email protected]>Signed-off-by Feng Tang <[email protected]>--- kernel/panic.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)kernel/panic.c +0
-0kernel/panic.c ATOMIC_NOTIFIER_HEAD(panic_notifier_list); · line 81
Quoted 6 lines
kernel/panic.c +4
-0@@ -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 ;)
Quoted 4 lines
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");Quoted 4 lines
kernel/panic.c ATOMIC_NOTIFIER_HEAD(panic_notifier_list); · line 85
Quoted 4 lines
kernel/panic.c +3
-0+return proc_doulongvec_minmax (table, write, buffer, lenp, ppos); +} +
Best Regards,
Petr
Re: [PATCH V2 5/5] panic: add note that panic_print interface is deprecated
In reply to Feng TangQuoted 2 lines · Feng Tang
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'.
Quoted 17 lines
kernel/panic.c +7
-0@@ -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 {
kernel/panic.c static const struct ctl_table kern_panic_table[] = { · line 117
Quoted 5 lines
kernel/panic.c +1
-1@@ -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().
kernel/panic.c static const struct ctl_table kern_panic_table[] = { · line 120
Quoted 3 lines
kernel/panic.c +0
-0}, { .procname = "panic_on_warn",
Best Regards,
Petr
Re: [PATCH V2 5/5] panic: add note that panic_print interface is deprecated
Quoted 7 lines · Petr Mladek
Quoted 2 lines · Feng Tang
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.
Quoted 3 lines
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.
Quoted 18 lines
Quoted 18 lines
kernel/panic.c +7
-0@@ -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,
Quoted 8 lines
kernel/panic.c static const struct ctl_table kern_panic_table[] = { · line 117
Quoted 4 lines
kernel/panic.c +1
-1.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 usingcore_param_cb()instead ofcore_param().
OK, thanks!
- Feng
Quoted 6 lines
kernel/panic.c static const struct ctl_table kern_panic_table[] = { · line 120
Quoted 3 lines
kernel/panic.c +0
-0}, { .procname = "panic_on_warn",Best Regards,
Petr
Re: [PATCH V2 5/5] panic: add note that panic_print interface is deprecated
In reply to Petr MladekQuoted 30 lines · Petr Mladek
Quoted 2 lines · Feng Tang
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'.Quoted 18 lines
kernel/panic.c +7
-0@@ -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,
Quoted 8 lines
kernel/panic.c static const struct ctl_table kern_panic_table[] = { · line 117
Quoted 4 lines
kernel/panic.c +1
-1.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 usingcore_param_cb()instead ofcore_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:
---
include/linux/moduleparam.h +3 -0
@@ -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