]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
time/jiffies: Register jiffies clocksource before usage
authorThomas Gleixner <tglx@kernel.org>
Tue, 9 Jun 2026 15:14:45 +0000 (17:14 +0200)
committerThomas Gleixner <tglx@kernel.org>
Sat, 13 Jun 2026 13:22:40 +0000 (15:22 +0200)
Teddy reported that a XEN HVM has a long boot delay, which was bisected to
the recent enhancements to the negative motion detection. It turned out
that the jiffies clocksource is used in early boot before it is registered,
which leaves the max_delta_raw field at zero. That causes the read out to
be clamped to the max delta of 0, which means time is not making progress.

Cure it by ensuring that it is initialized before its first usage in
timekeeping_init().

Fixes: 76031d9536a0 ("clocksource: Make negative motion detection more robust")
Reported-by: Teddy Astie <teddy.astie@vates.tech>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Tested-by: Teddy Astie <teddy.astie@vates.tech>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/87y0gn3fve.ffs@fw13
Closes: https://lore.kernel.org/all/1780914594.8631fc262581453bbf619ec5b2062170.19ea6c8227b000701b@vates.tech
kernel/time/jiffies.c

index 1c954f330dfe781d0274e38225b503c106fb5775..d51428867a3392b8f5927f84870e9995ec58e34b 100644 (file)
@@ -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;
 }