Re: [RFC][PATCH 2/3] time/tick: Introduce a dyn_hz boot option

From: Peter Zijlstra
Date: Tue Jan 28 2025 - 14:30:37 EST


On Tue, Jan 28, 2025 at 09:29:30AM -0800, John Stultz wrote:
> On Tue, Jan 28, 2025 at 1:07 AM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> > On Mon, Jan 27, 2025 at 10:32:54PM -0800, John Stultz wrote:
> > > +#ifdef CONFIG_DYN_HZ
> > > +extern long long dyn_tick_nsec;
> > > +#define DYN_TICK_NSEC (dyn_tick_nsec)
> > > +#else
> > > +#define DYN_TICK_NSEC TICK_NSEC
> > > +#endif
> >
> > My git-grep TICK_NSEC spies a whole bunch of TICK_NSEC users that seem
> > sad now.
> >
> > That is, why don't they all need updating?
>
> Thanks for taking a look, Peter!
>
> So TICK_NSEC is still the length of the HZ tick. The idea with this
> series is we're leaving HZ as a high frequency, but then just
> programming the interrupt to come in at a lower frequency.

That's word salad. Either the timer is slower, as alluded to below, or
it is not. It can't be both.

> So it's only the logic involved in setting the next interrupt, where
> we need to use DYN_TICK_NSEC.

In other words, the actual interrupts will happen dyn_tick_nsec apart,
not TICK_NSEC.

This means that pretty much every TICK_NSEC user in kernel/events/ is
now wrong. They're assuming the time between interrupts is TICK_NSEC --
we even inhibit NOHZ for perf to ensure this.

Really, you need to audit each and every TICK_NSEC users at the very
least.