Re: sched/isolation: tick_take_do_timer_from_boot() calls smp_call_function_single() with irqs disabled

From: Oleg Nesterov
Date: Sat May 25 2024 - 09:53:03 EST


Thomas, thanks a lot!

Let me grep a bit more to better understand your explanations.

Just one note for now.

On 05/25, Thomas Gleixner wrote:
>
> --- a/kernel/time/tick-common.c
> +++ b/kernel/time/tick-common.c
> @@ -229,11 +209,9 @@ static void tick_setup_device(struct tick_device *td,
> if (tick_nohz_full_cpu(cpu))
> tick_do_timer_boot_cpu = cpu;
>
> - } else if (tick_do_timer_boot_cpu != -1 &&
> - !tick_nohz_full_cpu(cpu)) {
> - tick_take_do_timer_from_boot();
> + } else if (tick_do_timer_boot_cpu != -1 && !tick_nohz_full_cpu(cpu)) {
> + WRITE_ONCE(tick_do_timer_cpu, cpu);
> tick_do_timer_boot_cpu = -1;
> - WARN_ON(READ_ONCE(tick_do_timer_cpu) != cpu);
> #endif
> }
>
> along with the removal of the SMP function call voodoo programming gunk,

Yes,

> Changing the horribly lazy and incomprehensible '-1' to an actual
> meaningful define, e.g. TICK_DO_TIMER_NONE, would definitely help along
> with renaming the variable to tick_do_timer_nohz_full_boot_cpu.

Better yet, we can make it a boolean, we do not need cpu number. And
perhaps we can simply kill it along with #ifdef CONFIG_NO_HZ_FULL ?

if (!td->evtdev) {
tick_cpu = READ_ONCE(tick_do_timer_cpu);
/*
* If no cpu took the do_timer update, assign it to
* this cpu:
*/
if (tick_cpu == TICK_DO_TIMER_BOOT) {
WRITE_ONCE(tick_do_timer_cpu, cpu);
tick_next_period = ktime_get();
/*
* The boot CPU may be nohz_full, in which case the
* first housekeeping secondary will take do_timer
* from us.
*/
} else if (tick_nohz_full_cpu(tick_cpu) &&
!tick_nohz_full_cpu(cpu)) {
WRITE_ONCE(tick_do_timer_cpu, cpu);
}

Oleg.