Re: [PATCH v2 3/6] panic: sys_info: Replace struct sys_info_name with plain array of strings

From: Feng Tang

Date: Thu Oct 30 2025 - 04:45:33 EST


On Thu, Oct 30, 2025 at 09:36:42AM +0200, Andy Shevchenko wrote:
> On Thu, Oct 30, 2025 at 10:01:49AM +0800, Feng Tang wrote:
> > On Wed, Oct 29, 2025 at 12:07:38PM +0100, Andy Shevchenko wrote:
> > > There is no need to keep a custom structure just for the need of
> > > a plain array of strings. Replace struct sys_info_name with plain
> > > array of strings.
> > >
> > > With that done, simplify the code, in particular, naturally use
> > > for_each_set_bit() when iterating over si_bits_global bitmap.
>
> ...
>
> > > names[0] = '\0';
> > > - for (i = 0; i < ARRAY_SIZE(si_names); i++) {
> > > - if (si_bits & si_names[i].bit) {
> > > - len += scnprintf(names + len, sizeof(names) - len,
> > > - "%s%s", delim, si_names[i].name);
> > > - delim = ",";
> > > - }
> > > + for_each_set_bit(i, &si_bits, ARRAY_SIZE(si_names)) {
> > > + len += scnprintf(names + len, sizeof(names) - len,
> > > + "%s%s", delim, si_names[i]);
> > > + delim = ",";
> >
> > For SYS_INFO_PANIC_CONSOLE_REPLAY bit, it is a NULL string, no need for
> > an extra ','?
>
> If you look closer to the original code, the behaviour is the same. Feel free
> to update behaviour separately as I tried to keep the functionality to be not
> changed with my series (with the exceptions of the fetching issue).

I gave the comment by code-reading.

And to double check it, I just run a simple test by adding "panic_print=0xff"
to cmdline, with the current kernel, by running "sysctl kernel.panic_sys_info"
on current kernel, it will get:

'kernel.panic_sys_info = tasks,mem,timers,locks,ftrace,all_bt,blocked_tasks'

And after applying your first 3 patches, it will show:

'kernel.panic_sys_info = tasks,mem,timers,locks,ftrace,,all_bt,blocked_task'

Thanks,
Feng