Re: [GIT pull] timers/core for v7.2-rc1

From: Oleg Nesterov

Date: Mon Jun 15 2026 - 09:36:17 EST


On 06/13, Thomas Gleixner wrote:
>
> Linus,
>
> please pull the latest timers/core branch from:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git timers-core-2026-06-13
>
> up to: 87bd2ad568e1: posix-cpu-timers: Fix pid refcount leak in do_cpu_nanosleep() error path

...

> --- a/kernel/time/jiffies.c
> +++ b/kernel/time/jiffies.c
> @@ -60,15 +60,14 @@ EXPORT_SYMBOL(get_jiffies_64);
>
> EXPORT_SYMBOL(jiffies);
>
> -static int __init init_jiffies_clocksource(void)
> -{
> - return __clocksource_register(&clocksource_jiffies);
> -}
> -
> -core_initcall(init_jiffies_clocksource);
> +static bool cs_jiffies_registered __initdata;
>
> struct clocksource * __init __weak clocksource_default_clock(void)
> {
> + if (!cs_jiffies_registered) {
> + __clocksource_register(&clocksource_jiffies);
> + cs_jiffies_registered = true;
> + }
> return &clocksource_jiffies;
> }

It seems that this change is problematic...

timekeeping_init() does

guard(raw_spinlock_irqsave)(&tk_core.lock);

clock = clocksource_default_clock();

and __clocksource_register() -> __clocksource_register_scale() takes
clocksource_mutex.

So I got

=============================
[ BUG: Invalid wait context ]
7.1.0-00977-g7a78e6f6bb02 #237 Not tainted
-----------------------------
swapper/0/0 is trying to lock:
ffffffff820415e8 (clocksource_mutex){....}-{4:4}, at: __clocksource_register_scale+0x186/0x230
other info that might help us debug this:
context-{5:5}
1 lock held by swapper/0/0:
#0: ffffffff8327dfb8 (&tkd->lock){....}-{2:2}, at: timekeeping_init+0x159/0x1f0

at boot time after git pull.

Oleg.