Skip to content

Commit 3a0562d

Browse files
committed
Merge tag 'timers-urgent-2025-02-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer fixes from Ingo Molnar: "Fix a PREEMPT_RT bug in the clocksource verification code that caused false positive warnings. Also fix a timer migration setup bug when new CPUs are added" * tag 'timers-urgent-2025-02-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: timers/migration: Fix off-by-one root mis-connection clocksource: Use migrate_disable() to avoid calling get_random_u32() in atomic context
2 parents c7b92e8 + 868c903 commit 3a0562d

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

kernel/time/clocksource.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,17 +373,18 @@ void clocksource_verify_percpu(struct clocksource *cs)
373373
cpumask_clear(&cpus_ahead);
374374
cpumask_clear(&cpus_behind);
375375
cpus_read_lock();
376-
preempt_disable();
376+
migrate_disable();
377377
clocksource_verify_choose_cpus();
378378
if (cpumask_empty(&cpus_chosen)) {
379-
preempt_enable();
379+
migrate_enable();
380380
cpus_read_unlock();
381381
pr_warn("Not enough CPUs to check clocksource '%s'.\n", cs->name);
382382
return;
383383
}
384384
testcpu = smp_processor_id();
385385
pr_info("Checking clocksource %s synchronization from CPU %d to CPUs %*pbl.\n",
386386
cs->name, testcpu, cpumask_pr_args(&cpus_chosen));
387+
preempt_disable();
387388
for_each_cpu(cpu, &cpus_chosen) {
388389
if (cpu == testcpu)
389390
continue;
@@ -403,6 +404,7 @@ void clocksource_verify_percpu(struct clocksource *cs)
403404
cs_nsec_min = cs_nsec;
404405
}
405406
preempt_enable();
407+
migrate_enable();
406408
cpus_read_unlock();
407409
if (!cpumask_empty(&cpus_ahead))
408410
pr_warn(" CPUs %*pbl ahead of CPU %d for clocksource %s.\n",

kernel/time/timer_migration.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1675,6 +1675,9 @@ static int tmigr_setup_groups(unsigned int cpu, unsigned int node)
16751675

16761676
} while (i < tmigr_hierarchy_levels);
16771677

1678+
/* Assert single root */
1679+
WARN_ON_ONCE(!err && !group->parent && !list_is_singular(&tmigr_level_list[top]));
1680+
16781681
while (i > 0) {
16791682
group = stack[--i];
16801683

@@ -1716,7 +1719,12 @@ static int tmigr_setup_groups(unsigned int cpu, unsigned int node)
17161719
WARN_ON_ONCE(top == 0);
17171720

17181721
lvllist = &tmigr_level_list[top];
1719-
if (group->num_children == 1 && list_is_singular(lvllist)) {
1722+
1723+
/*
1724+
* Newly created root level should have accounted the upcoming
1725+
* CPU's child group and pre-accounted the old root.
1726+
*/
1727+
if (group->num_children == 2 && list_is_singular(lvllist)) {
17201728
/*
17211729
* The target CPU must never do the prepare work, except
17221730
* on early boot when the boot CPU is the target. Otherwise

0 commit comments

Comments
 (0)