Re: [PATCH v3 3/6] panic: sys_info: Replace struct sys_info_name with plain array of strings
From: Andy Shevchenko
Date: Fri Oct 31 2025 - 03:23:24 EST
On Thu, Oct 30, 2025 at 08:06:16PM -0700, Andrew Morton wrote:
> On Thu, 30 Oct 2025 12:44:19 +0100 Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
...
> > -static const struct sys_info_name si_names[] = {
> > - { SYS_INFO_TASKS, "tasks" },
> > - { SYS_INFO_MEM, "mem" },
> > - { SYS_INFO_TIMERS, "timers" },
> > - { SYS_INFO_LOCKS, "locks" },
> > - { SYS_INFO_FTRACE, "ftrace" },
> > - { SYS_INFO_ALL_BT, "all_bt" },
> > - { SYS_INFO_BLOCKED_TASKS, "blocked_tasks" },
> > +static const char * const si_names[] = {
> > + [ilog2(SYS_INFO_TASKS)] = "tasks",
> > + [ilog2(SYS_INFO_MEM)] = "mem",
> > + [ilog2(SYS_INFO_TIMERS)] = "timers",
> > + [ilog2(SYS_INFO_LOCKS)] = "locks",
> > + [ilog2(SYS_INFO_FTRACE)] = "ftrace",
> > + [ilog2(SYS_INFO_PANIC_CONSOLE_REPLAY)] = "",
> > + [ilog2(SYS_INFO_ALL_BT)] = "all_bt",
> > + [ilog2(SYS_INFO_BLOCKED_TASKS)] = "blocked_tasks",
> > };
>
> We have this const_ilog2() which appears to exist to work around a
> sparse shortcoming. But only net/ethtool/common.c uses it - plenty of
> other sites do what you've done.
>
> Which makes me wonder whether const_ilog2() can be removed, switch
> everything over to ilog2().
Good question. I haven't noticed sparse errors, I always use make W=1 C=1 for
my local builds.
--
With Best Regards,
Andy Shevchenko