Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 41d7072

Browse files
committed
Merge tag 'timers-urgent-2024-06-15' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer fix from Ingo Molnar: "Fix boot-time warning in tick_setup_device()" * tag 'timers-urgent-2024-06-15' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: tick/nohz_full: Don't abuse smp_call_function_single() in tick_setup_device()
2 parents 44ef20b + 07c54cc commit 41d7072

File tree

1 file changed

+14
-28
lines changed

1 file changed

+14
-28
lines changed

kernel/time/tick-common.c

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -178,26 +178,6 @@ void tick_setup_periodic(struct clock_event_device *dev, int broadcast)
178178
}
179179
}
180180

181-
#ifdef CONFIG_NO_HZ_FULL
182-
static void giveup_do_timer(void *info)
183-
{
184-
int cpu = *(unsigned int *)info;
185-
186-
WARN_ON(tick_do_timer_cpu != smp_processor_id());
187-
188-
tick_do_timer_cpu = cpu;
189-
}
190-
191-
static void tick_take_do_timer_from_boot(void)
192-
{
193-
int cpu = smp_processor_id();
194-
int from = tick_do_timer_boot_cpu;
195-
196-
if (from >= 0 && from != cpu)
197-
smp_call_function_single(from, giveup_do_timer, &cpu, 1);
198-
}
199-
#endif
200-
201181
/*
202182
* Setup the tick device
203183
*/
@@ -221,19 +201,25 @@ static void tick_setup_device(struct tick_device *td,
221201
tick_next_period = ktime_get();
222202
#ifdef CONFIG_NO_HZ_FULL
223203
/*
224-
* The boot CPU may be nohz_full, in which case set
225-
* tick_do_timer_boot_cpu so the first housekeeping
226-
* secondary that comes up will take do_timer from
227-
* us.
204+
* The boot CPU may be nohz_full, in which case the
205+
* first housekeeping secondary will take do_timer()
206+
* from it.
228207
*/
229208
if (tick_nohz_full_cpu(cpu))
230209
tick_do_timer_boot_cpu = cpu;
231210

232-
} else if (tick_do_timer_boot_cpu != -1 &&
233-
!tick_nohz_full_cpu(cpu)) {
234-
tick_take_do_timer_from_boot();
211+
} else if (tick_do_timer_boot_cpu != -1 && !tick_nohz_full_cpu(cpu)) {
235212
tick_do_timer_boot_cpu = -1;
236-
WARN_ON(READ_ONCE(tick_do_timer_cpu) != cpu);
213+
/*
214+
* The boot CPU will stay in periodic (NOHZ disabled)
215+
* mode until clocksource_done_booting() called after
216+
* smp_init() selects a high resolution clocksource and
217+
* timekeeping_notify() kicks the NOHZ stuff alive.
218+
*
219+
* So this WRITE_ONCE can only race with the READ_ONCE
220+
* check in tick_periodic() but this race is harmless.
221+
*/
222+
WRITE_ONCE(tick_do_timer_cpu, cpu);
237223
#endif
238224
}
239225

0 commit comments

Comments
 (0)