Re: [PATCH v9 23/32] timers: Retrieve next expiry of pinned/non-pinned timers separately

From: Sebastian Siewior
Date: Wed Dec 06 2023 - 04:47:58 EST


On 2023-12-01 10:26:45 [+0100], Anna-Maria Behnsen wrote:
> For the conversion of the NOHZ timer placement to a pull at expiry time
> model it's required to have separate expiry times for the pinned and the
> non-pinned (movable) timers. Therefore struct timer_events is introduced.
>
> No functional change
>
> Originally-by: Richard Cochran (linutronix GmbH) <richardcochran@xxxxxxxxx>
> Signed-off-by: Anna-Maria Behnsen <anna-maria@xxxxxxxxxxxxx>
> Reviewed-by: Frederic Weisbecker <frederic@xxxxxxxxxx>

> index 366ea26ce3ba..0d53d853ae22 100644
> --- a/kernel/time/timer.c
> +++ b/kernel/time/timer.c

> @@ -2022,13 +2028,31 @@ static inline u64 __get_next_timer_interrupt(unsigned long basej, u64 basem,
>
> nextevt = local_first ? nextevt_local : nextevt_global;
>
> - if (base_local->timers_pending || base_global->timers_pending) {
> + /*
> + * If the @nextevt is at max. one tick away, use @nextevt and store
> + * it in the local expiry value. The next global event is irrelevant in
> + * this case and can be left as KTIME_MAX.
> + */
> + if (time_before_eq(nextevt, basej + 1)) {
> /* If we missed a tick already, force 0 delta */
> if (time_before(nextevt, basej))
> nextevt = basej;
> - expires = basem + (u64)(nextevt - basej) * TICK_NSEC;
> + tevt.local = basem + (u64)(nextevt - basej) * TICK_NSEC;
> + goto unlock;

You claim "No functional change" in the patch description. However if
you take the shortcut here you don't update `idle' if set and you don't
__forward_timer_base(). The `idle` parameter doesn't matter because it
was false and will remain false as per current logic.

But what about the forward of the timer base? It is probably not real
problem since the next add/mod timer call will forward it.

Sebastian