Re: [PATCH v5 11/18] timer: Split out "get next timer interrupt" functionality

From: Frederic Weisbecker
Date: Thu Mar 09 2023 - 11:41:22 EST


Le Wed, Mar 01, 2023 at 03:17:37PM +0100, Anna-Maria Behnsen a écrit :
> The functionallity for getting the next timer interrupt in
> get_next_timer_interrupt() is splitted into a separate function
> fetch_next_timer_interrupt() to be usable by other callsides.
>
> This is preparatory work for the conversion of the NOHZ timer
> placement to a pull at expiry time model. No functional change.
>
> Signed-off-by: Anna-Maria Behnsen <anna-maria@xxxxxxxxxxxxx>
[...]
> diff --git a/kernel/time/timer.c b/kernel/time/timer.c
> index ff41d978cb22..dfc744545159 100644
> --- a/kernel/time/timer.c
> +++ b/kernel/time/timer.c
> @@ -2040,31 +2071,9 @@ u64 get_next_timer_interrupt(unsigned long basej, u64 basem)
> if (time_before(nextevt, basej))
> nextevt = basej;
> tevt.local = basem + (u64)(nextevt - basej) * TICK_NSEC;
> - goto unlock;
> + tevt.global = KTIME_MAX;
> }
>
> - /*
> - * If the bases are marked idle, i.e. the next event on both the
> - * local and the global queue are farther away than a tick,
> - * evaluate both bases. No need to check whether one of the bases
> - * has an already expired timer as this is caught by the !is_idle
> - * condition above.
> - */
> - if (base_local->timers_pending)
> - tevt.local = basem + (u64)(nextevt_local - basej) * TICK_NSEC;
> -
> - /*
> - * If the local queue expires first, then the global event can be
> - * ignored. The CPU wakes up before that. If the global queue is
> - * empty, nothing to do either.
> - */
> - if (!local_first && base_global->timers_pending)
> - tevt.global = basem + (u64)(nextevt_global - basej) * TICK_NSEC;
> -
> -unlock:
> - raw_spin_unlock(&base_global->lock);
> - raw_spin_unlock(&base_local->lock);
> -
> tevt.local = min_t(u64, tevt.local, tevt.global);

So if you leave that last line, it means that the CPU will eventually
and unconditionally wake up for the next global timer if it's before the
next local timer. Am I understanding this right and, if so, is that intended?

Thanks.