Re: [PATCH] tick/broadcast-hrtimer: Prevent the timer device on broadcast duty CPU from being disabled

From: Thomas Gleixner
Date: Wed Jan 24 2024 - 14:19:52 EST


On Mon, Dec 18 2023 at 10:58, Yu Liao wrote:
> static int bc_set_next(ktime_t expires, struct clock_event_device *bc)
> {
> + ktime_t next_event = this_cpu_ptr(&tick_cpu_device)->evtdev->next_event;
> +
> /*
> - * This is called either from enter/exit idle code or from the
> - * broadcast handler. In all cases tick_broadcast_lock is held.
> - *
> + * This can be called from CPU offline operation to move broadcast
> + * assignment. If tick_broadcast_force_mask is set, the CPU local
> + * timer device may be disabled. And hrtimer_reprogram() will not
> + * called if the timer is not the first expiring timer. Reprogram
> + * the cpu local timer device to ensure we can take over the
> + * broadcast duty.
> + */
> + if (tick_check_broadcast_expired() && expires >= next_event)
> + tick_program_event(next_event, 1);

I'm not really enthused about another conditional here and that
condition is more than obscure.

The problem is that the local clockevent might be shut down, right?

So checking for that state is the right thing to do and the proper place
is in hotplug_cpu__broadcast_tick_pull(), no?

Thanks,

tglx