Re: [PATCH v10 20/20] timers: Always queue timers on the local CPU

From: Anna-Maria Behnsen
Date: Thu Feb 01 2024 - 15:58:46 EST


Frederic Weisbecker <frederic@xxxxxxxxxx> writes:

> Le Mon, Jan 15, 2024 at 03:37:43PM +0100, Anna-Maria Behnsen a écrit :
>> The timer pull model is in place so we can remove the heuristics which try
>> to guess the best target CPU at enqueue/modification time.
>>
>> All non pinned timers are queued on the local CPU in the separate storage
>> and eventually pulled at expiry time to a remote CPU.
>>
>> Originally-by: Richard Cochran (linutronix GmbH) <richardcochran@xxxxxxxxx>
>> Signed-off-by: Anna-Maria Behnsen <anna-maria@xxxxxxxxxxxxx>
>
> Reviewed-by: Frederic Weisbecker <frederic@xxxxxxxxxx>
>
> Just one detail below:
>
>> @@ -590,10 +590,13 @@ trigger_dyntick_cpu(struct timer_base *base, struct timer_list *timer)
>>
>> /*
>> * We might have to IPI the remote CPU if the base is idle and the
>> - * timer is not deferrable. If the other CPU is on the way to idle
>> - * then it can't set base->is_idle as we hold the base lock:
>> + * timer is pinned. If it is a non pinned timer, it is only queued
>> + * on the remote CPU, when timer was running during queueing. Then
>> + * everything is handled by remote CPU anyway. If the other CPU is
>> + * on the way to idle then it can't set base->is_idle as we hold
>> + * the base lock:
>> */
>> - if (base->is_idle)
>> + if (base->is_idle && timer->flags & TIMER_PINNED)
>
> Is the TIMER_PINNED test necessary? If base->is_idle, then the timer
> is now guaranteed to be TIMER_PINNED, right?
>

Yes, you are right. Should I drop it? To clarify it, I could add a

WARN_ON_ONCE(!timer->flags & TIMER_PINNED)

instead.

Thanks,

Anna-Maria