Re: [PATCH v4 1/9] sched: Add a generic function to return the preemption string.
From: Sebastian Andrzej Siewior
Date: Mon Mar 17 2025 - 05:26:30 EST
On 2025-03-17 10:12:31 [+0100], Ingo Molnar wrote:
>
> * Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> wrote:
>
> > On 2025-03-16 12:15:47 [+0100], Ingo Molnar wrote:
> > >
> > > * Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> wrote:
> > >
> > > > +const char *preempt_modes[] = {
> > > > + "none", "voluntary", "full", "lazy", NULL,
> > > > +};
> > >
> > > > + /* Count entries in NULL terminated preempt_modes */
> > > > + for (j = 0; preempt_modes[j]; j++)
> > > > + ;
> > >
> > > I'm pretty sure the build-time ARRAY_SIZE() primitive is superior here. ;-)
> >
> > It would be but it is not an option.
> > That array is defined in core.c where it is "always" required while
> > debug.c needs it optionally. core.c is its one compile unit while
> > debug.c is included by build_utility.c. So I don't see how this can work
> > unless we shift things:
>
> Why not have it all in debug.c?
The debug.c include is behind CONFIG_SCHED_DEBUG. This needs to be moved
into debug.c itself so that code can be added regardless of
CONFIG_SCHED_DEBUG. It is not only sched-debug after that.
Then we have `preempt_dynamic_mode' logic which is in core.c but it is
exported and used in debug.c
So if all this is not a concern then I can move it.
> Thanks,
>
> Ingo
Sebastian