Re: [PATCH 01/15] tick/nohz: Remove duplicate between tick_nohz_switch_to_nohz() and tick_setup_sched_timer()

From: Frederic Weisbecker
Date: Thu Jan 25 2024 - 09:36:15 EST


On Thu, Jan 25, 2024 at 02:34:06PM +0100, Thomas Gleixner wrote:
> On Thu, Jan 25 2024 at 12:57, Frederic Weisbecker wrote:
> > On Thu, Jan 25, 2024 at 10:12:20AM +0100, Thomas Gleixner wrote:
> >> Adding
> >>
> >> #define tick_nohz_highres_handler NULL
> >>
> >> for CONFIG_HIGH_RES_TIMERS=n somewhere allows you to write that as:
> >>
> >> if (IS_ENABLED(CONFIG_HIGH_RES_TIMERS) && mode == NOHZ_MODE_HIGHRES)
> >> ts->sched_timer.function = tick_nohz_highres_handler;
> >
> > So the next patch does:
> >
> > if (mode == NOHZ_MODE_HIGHRES)
> > ts->sched_timer.function = tick_nohz_highres_handler;
> >
> > Because that condition only happens in CONFIG_HIGH_RES_TIMERS anyway
> > and the function field exists in any case.
>
> Right, but the function does not exist for HRES=n, so you need the
> #define ... NULL. The IS_ENABLED() allows the compiler to eliminate the
> code for HRES=n completely.

Ah but the next patch moves tick_nohz_highres_handler out of CONFIG_HRES
(to soon become tick_nohz_handler()). But anyway I can add the IS_ENABLED()
to remove dead code.

Thanks.

>
> Thanks,
>
> tglx