diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index 9c4f4f15a056fbccc7f36c9ba29181ca8b2c3a5b..04bdeba7b0721f0ca2b4c7c31f06327112f4a5b8 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -545,6 +545,7 @@ extern void __init hrtimers_init(void); extern void sysrq_timer_list_show(void); int hrtimers_prepare_cpu(unsigned int cpu); +int hrtimers_cpu_starting(unsigned int cpu); #ifdef CONFIG_HOTPLUG_CPU int hrtimers_cpu_dying(unsigned int cpu); #else diff --git a/kernel/cpu.c b/kernel/cpu.c index 137baebdeced4c35b9b29a8a37c2084958565df0..83e1bc2fafb129d759c3abbee563fe50c652b8ba 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -1713,9 +1713,16 @@ static struct cpuhp_step cpuhp_hp_states[] = { * Please ensure that there are no other steps with teardown handler * between smpcfd:dying and cpu:teardown. */ + /* + * In the past, the implementation of CPUHP_AP_HRTIMERS_DYING is deleted because + * the Kabi is fixed. The teardown operation and teardown of CPUHP_AP_SMPCFD_DYING + * are combined into smpcfd_and_hrtimer_dying_cpu. The startup operation of + * CPUHP_AP_SMPCFD_DYING is empty. Therefore, the startup operation of + * hrtimers_cpu_starting is set to the startup operation of CPUHP_AP_SMPCFD_DYING. + */ [CPUHP_AP_SMPCFD_DYING] = { .name = "smpcfd:dying", - .startup.single = NULL, + .startup.single = hrtimers_cpu_starting, .teardown.single = smpcfd_and_hrtimer_dying_cpu, }, diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 31d481da509e6efce09c2aea359cc085b39c8548..0831821d04c4b43403ddde2bdd618c955b4329e1 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -2136,6 +2136,15 @@ int hrtimers_prepare_cpu(unsigned int cpu) } cpu_base->cpu = cpu; + hrtimer_cpu_base_init_expiry_lock(cpu_base); + return 0; +} + +int hrtimers_cpu_starting(unsigned int cpu) +{ + struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(&hrtimer_bases); + + /* Clear out any left over state from a CPU down operation */ cpu_base->active_bases = 0; cpu_base->hres_active = 0; cpu_base->hang_detected = 0; @@ -2144,7 +2153,6 @@ int hrtimers_prepare_cpu(unsigned int cpu) cpu_base->expires_next = KTIME_MAX; cpu_base->softirq_expires_next = KTIME_MAX; cpu_base->online = 1; - hrtimer_cpu_base_init_expiry_lock(cpu_base); return 0; } @@ -2222,6 +2230,7 @@ int hrtimers_cpu_dying(unsigned int dying_cpu) void __init hrtimers_init(void) { hrtimers_prepare_cpu(smp_processor_id()); + hrtimers_cpu_starting(smp_processor_id()); open_softirq(HRTIMER_SOFTIRQ, hrtimer_run_softirq); }