[PATCH] clocksource: publish finished_booting with release semantics

From: Jaidev Shastri via B4 Relay

Date: Mon Sep 21 2026 - 21:26:10 EST


From: Jaidev Shastri <jaidevshastri@xxxxxx>

clocksource_done_booting() sets curr_clocksource and then
finished_booting, both with plain stores under clocksource_mutex.
clocksource_find_best() tests finished_booting with a plain load before
it walks clocksource_list.

Set the flag with smp_store_release() and read it with
smp_load_acquire().

Found with MBCheck, a static herd7-based memory consistency checker.

Signed-off-by: Jaidev Shastri <jaidevshastri@xxxxxx>
---
kernel/time/clocksource.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index f1253f579..f683a787c 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -1086,7 +1086,8 @@ static struct clocksource *clocksource_find_best(bool oneshot, bool skipcur)
{
struct clocksource *cs;

- if (!finished_booting || list_empty(&clocksource_list))
+ /* Pairs with the smp_store_release() in clocksource_done_booting(). */
+ if (!smp_load_acquire(&finished_booting) || list_empty(&clocksource_list))
return NULL;

/*
@@ -1188,7 +1189,8 @@ static int __init clocksource_done_booting(void)
{
mutex_lock(&clocksource_mutex);
curr_clocksource = clocksource_default_clock();
- finished_booting = 1;
+ /* Pairs with the smp_load_acquire() in clocksource_find_best(). */
+ smp_store_release(&finished_booting, 1);
/*
* Run the watchdog first to eliminate unstable clock sources
*/

---
base-commit: 93f51579e7df248780214094418f205253383cc5
change-id: 20260921-mb-clocksource-49cd0b246a89

Best regards,
--
Jaidev Shastri <jaidevshastri@xxxxxx>