From: Feng Tang <feng.tang@linux.alibaba.com>
To: Petr Mladek <pmladek@suse.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Steven Rostedt <rostedt@goodmis.org>,
Lance Yang <lance.yang@linux.dev>,
Jonathan Corbet <corbet@lwn.net>,
linux-kernel@vger.kernel.org, paulmck@kernel.org,
john.ogness@linutronix.de
Subject: Re: [PATCH V2 2/5] panic: generalize panic_print's function to show sys info
Date: Mon, 23 Jun 2025 11:07:03 +0800 [thread overview]
Message-ID: <aFjE121WcfADtbDo@U-2FWC9VHC-2323.local> (raw)
In-Reply-To: <aFV8ZFZ0Qy715hdR@pathway.suse.cz>
On Fri, Jun 20, 2025 at 05:21:08PM +0200, Petr Mladek wrote:
> On Mon 2025-06-16 09:08:37, Feng Tang wrote:
> > '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.
> >
> > --- a/include/linux/kernel.h
> > +++ b/include/linux/kernel.h
> > @@ -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.
Makes sense! WIll change.
> > #include <linux/panic.h>
> > #include <linux/printk.h>
> > #include <linux/build_bug.h>
>
> > --- /dev/null
> > +++ b/include/linux/sys_info.h
> > @@ -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.
OK.
> Also it would make sense to update the documentation (in 1st patch),
> something like:
>
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -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.
> > + */
> > +#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.
Thanks for the note!
> 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
Yeap, shorter and cleaner.
>
> 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
> > +#endif /* _LINUX_SYS_INFO_H */
>
> Best Regards,
> Petr
next prev parent reply other threads:[~2025-06-23 3:07 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-16 1:08 [PATCH V2 0/5] generalize panic_print's dump function to be used by other kernel parts Feng Tang
2025-06-16 1:08 ` [PATCH V2 1/5] panic: clean up code for console replay Feng Tang
2025-06-20 14:19 ` Petr Mladek
2025-06-16 1:08 ` [PATCH V2 2/5] panic: generalize panic_print's function to show sys info Feng Tang
2025-06-20 15:21 ` Petr Mladek
2025-06-23 3:07 ` Feng Tang [this message]
2025-06-16 1:08 ` [PATCH V2 3/5] sys_info: add help to translate sys_info string to bitmap Feng Tang
2025-06-16 4:25 ` kernel test robot
2025-06-16 15:08 ` Feng Tang
2025-06-23 14:04 ` Petr Mladek
2025-06-24 1:48 ` Feng Tang
2025-06-16 1:08 ` [PATCH V2 4/5] panic: add 'panic_sys_info=' setup option for sysctl and kernel cmdline Feng Tang
2025-06-23 15:04 ` Petr Mladek
2025-06-24 1:55 ` Feng Tang
2025-06-16 1:08 ` [PATCH V2 5/5] panic: add note that panic_print interface is deprecated Feng Tang
2025-06-16 1:45 ` Lance Yang
2025-06-16 2:39 ` Feng Tang
2025-06-23 15:13 ` Petr Mladek
2025-06-23 15:22 ` Petr Mladek
2025-06-24 1:58 ` Feng Tang
2025-06-25 9:30 ` Feng Tang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aFjE121WcfADtbDo@U-2FWC9VHC-2323.local \
--to=feng.tang@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=john.ogness@linutronix.de \
--cc=lance.yang@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@kernel.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®