linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/5] generalize panic_print's dump function to be used by other kernel parts
@ 2025-07-03  2:09 Feng Tang
  2025-07-03  2:10 ` [PATCH v3 1/5] panic: clean up code for console replay Feng Tang
                   ` (5 more replies)
  0 siblings, 6 replies; 31+ messages in thread
From: Feng Tang @ 2025-07-03  2:09 UTC (permalink / raw)
  To: Andrew Morton, Petr Mladek, Steven Rostedt, Lance Yang,
	Jonathan Corbet, linux-kernel
  Cc: paulmck, john.ogness, Feng Tang

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 available for other cases which also need to dump system info
for debugging. 

Also as suggested by Petr Mladek, add 'panic_sys_info=' interface to
take human readable string like "tasks,mem,locks,timers,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 stability issues
and was proven helpful.

Many thanks to Petr Mladek for great suggestions on both the code and
architectures!

- Feng

One to do left is about adding note for obsoleting 'panic_print' cmdline
as discussed in https://lore.kernel.org/lkml/aFvBuOnD0cAEWJfl@U-2FWC9VHC-2323.local/
and will be posted later.

Changelog:

  Since v2:
     * Rename to PANIC_CONSOLE_REPLAY (Petr Mladek) 
     * Don't let kernel.h include sys_info.h (Petr Mladek)
     * Improve documents and coding style (Petr Mladek/Lance Yang)
     * Add 'panic_console_replay' parameter (Petr Mladek)
     * Fix compiling problem (0Day bot)
     * Add reviewed-by tag from Petr for patch 1/5

  Since 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
  panic: add 'panic_sys_info' sysctl to take human readable string
    parameter
  panic: add 'panic_sys_info=' setup option for kernel cmdline
  panic: add note that panic_print sysctl interface is deprecated

 .../admin-guide/kernel-parameters.txt         |  21 ++-
 Documentation/admin-guide/sysctl/kernel.rst   |  20 ++-
 include/linux/sys_info.h                      |  27 ++++
 kernel/panic.c                                |  71 +++++-----
 lib/Makefile                                  |   2 +-
 lib/sys_info.c                                | 122 ++++++++++++++++++
 6 files changed, 221 insertions(+), 42 deletions(-)
 create mode 100644 include/linux/sys_info.h
 create mode 100644 lib/sys_info.c

-- 
2.43.5


^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [PATCH 3/5] panic: add 'panic_sys_info' sysctl to take human readable string parameter
@ 2025-07-09  2:29 Sergey Senozhatsky
  2025-07-09  3:27 ` Feng Tang
  0 siblings, 1 reply; 31+ messages in thread
From: Sergey Senozhatsky @ 2025-07-09  2:29 UTC (permalink / raw)
  To: Feng Tang; +Cc: Andrew Morton, linux-kernel

Hi,

[..]
>+#ifdef CONFIG_SYSCTL
> +
> +static const char sys_info_avail[] = "tasks,mem,timers,locks,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)
> +{
> +       char names[sizeof(sys_info_avail) + 1];
> +       struct ctl_table table;
> +       unsigned long *si_bits_global;
> +
> +       si_bits_global = ro_table->data;
[..]

Somehow this breaks the build with:

lib/sys_info.c:52:19: error: variable 'sys_info_avail' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration]
   52 | static const char sys_info_avail[] = "tasks,mem,timers,locks,ftrace,all_bt,blocked_tasks";
      |                   ^~~~~~~~~~~~~~

Moving sys_info_avail[] inside sysctl_sys_info_handler() seems to help.

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2025-08-14 15:21 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-03  2:09 [PATCH v3 0/5] generalize panic_print's dump function to be used by other kernel parts Feng Tang
2025-07-03  2:10 ` [PATCH v3 1/5] panic: clean up code for console replay Feng Tang
2025-07-14 21:09   ` Askar Safin
2025-07-15  0:49     ` Feng Tang
2025-07-15  1:18       ` Askar Safin
2025-07-15  1:34         ` Feng Tang
2025-07-15  2:48           ` Askar Safin
2025-07-15  3:27             ` Feng Tang
2025-08-12 11:59               ` Petr Mladek
2025-08-13  0:43                 ` Feng Tang
2025-07-03  2:10 ` [PATCH v3 2/5] panic: generalize panic_print's function to show sys info Feng Tang
2025-08-12 10:12   ` Petr Mladek
2025-07-03  2:10 ` [PATCH 3/5] panic: add 'panic_sys_info' sysctl to take human readable string parameter Feng Tang
2025-07-03  2:56   ` Lance Yang
2025-07-03  3:18     ` Feng Tang
2025-08-12 10:23   ` Petr Mladek
2025-08-13  0:39     ` Feng Tang
2025-07-03  2:10 ` [PATCH v3 4/5] panic: add 'panic_sys_info=' setup option for kernel cmdline Feng Tang
2025-08-12 10:31   ` Petr Mladek
2025-07-03  2:10 ` [PATCH v3 5/5] panic: add note that panic_print sysctl interface is deprecated Feng Tang
2025-08-12 11:52   ` Petr Mladek
2025-08-13  1:05     ` Feng Tang
2025-08-14 15:21       ` Petr Mladek
2025-07-03  3:23 ` [PATCH v3 0/5] generalize panic_print's dump function to be used by other kernel parts Lance Yang
2025-07-03  4:56   ` Lance Yang
2025-07-03  5:54     ` Feng Tang
  -- strict thread matches above, loose matches on Subject: below --
2025-07-09  2:29 [PATCH 3/5] panic: add 'panic_sys_info' sysctl to take human readable string parameter Sergey Senozhatsky
2025-07-09  3:27 ` Feng Tang
2025-07-09  3:35   ` Sergey Senozhatsky
2025-07-09  3:58     ` Feng Tang
2025-07-10  3:27       ` Sergey Senozhatsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).