Re: [PATCH] sched/cputime: Don't warn when the tick period starts after idle exit
From: Frederic Weisbecker
Date: Wed Oct 28 2026 - 10:19:04 EST
Le Tue, Oct 27, 2026 at 08:05:49PM +0100, Stian Halseth a écrit :
> Hi Frederic,
>
> On Tue, 2026-10-27 at 18:06 +0100, Frederic Weisbecker wrote:
>
> > Ok let me try to picture this:
> >
> > Initially, jiffies or tsc-early, not sure, is the clocksource:
> >
> > - tick_setup_device() sets tick_next_period to ktime_get()
> > - tick_periodic() adds TICK_NSEC to tick_next_period right before updating
> > jiffies. So as you said tick_next_period == ktime_get()
> > - Note last_tick is not involved in that mode
> >
> > Then later on boot comes a oneshot device:
>
> The clocksource is initially jiffies, and I believe there is a step missing
> before the oneshot switch: the clocksource switch, while the tick is still
> periodic.
>
> Please let me know where I lose you
If I knew where I was, I wouldn't be lost. But don't worry I was already
"there" way before you arrived :-)
> or if/when you disagree with
> my analysis. Not sure if you're more confused about my attempt of an
> explanation, or by what's really happening ;)
>
> Here we go...
>
> The oneshot switch can only happen inside a tick, so at the earliest
> in the first tick after the clocksource switch. In the guest it came
> 0.7s later since tsc-early waits for the watchdog in the guest.
>
> So...for a while tick_periodic() runs on tsc-early. ktime now moves
> between ticks too, but the next tick still adds a full TICK_NSEC, so
> tick_next_period gets ahead of ktime_get() by the part of the period
> that had passed at the switch. Still here? :)
So let me depict that:
// clocksource = jiffies ?
// clockevent = lapic ?
tick_setup_device()
tick_next_period = ktime_get() // jiffies_to_nsecs(jiffies)
tick_periodic()
tick_next_period += TICK_NSECS
jiffies++ // ktime_get() == tick_next_period
// jiffies > tsc_early
clocksource_select()
tick_periodic()
//one tick has passed, so ktime_get() == jiffies + 1
tick_next_period += TICK_NSECS
jiffies++ // ktime_get() == tick_next_period == jiffies
No?
Thanks.
--
Frederic Weisbecker
SUSE Labs