Re: [PATCH] hrtimer: reset .hres_active and .online at appropriate points

From: Thomas Gleixner
Date: Thu Jan 16 2025 - 04:08:17 EST


On Fri, Dec 20 2024 at 22:44, Koichiro Den wrote:

> int hrtimers_prepare_cpu(unsigned int cpu);
> #ifdef CONFIG_HOTPLUG_CPU
> +int hrtimers_cpu_starting(unsigned int cpu);

This does not compile for CONFIG_HOTPLUG_CPU=n

> int hrtimers_cpu_dying(unsigned int cpu);
> #else
> #define hrtimers_cpu_dying NULL
> diff --git a/kernel/cpu.c b/kernel/cpu.c
> index 85fd7ac4561e..34f1a09349fc 100644
> --- a/kernel/cpu.c
> +++ b/kernel/cpu.c
> @@ -2180,7 +2180,7 @@ static struct cpuhp_step cpuhp_hp_states[] = {
> },
> [CPUHP_AP_HRTIMERS_DYING] = {
> .name = "hrtimers:dying",
> - .startup.single = NULL,
> + .startup.single = hrtimers_cpu_starting,
> .teardown.single = hrtimers_cpu_dying,
> },
> [CPUHP_AP_TICK_DYING] = {
> diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
> index 80fe3749d2db..98f23c9341f5 100644
> --- a/kernel/time/hrtimer.c
> +++ b/kernel/time/hrtimer.c
> @@ -2246,6 +2246,14 @@ static void migrate_hrtimer_list(struct hrtimer_clock_base *old_base,
> }
> }
>
> +int hrtimers_cpu_starting(unsigned int cpu)
> +{
> + struct hrtimer_cpu_base *cpu_base = &per_cpu(hrtimer_bases, cpu);

this_cpu_ptr()

> + cpu_base->online = 1;

With that setting cpu_base->online in the prepare_cpu() callback
does not make any sense.

I'll fix it up for you this time.

Thanks,

tglx