mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] clocksource: publish finished_booting with release semantics
@ 2026-09-22  1:22 Jaidev Shastri via B4 Relay
  2026-09-29 11:53 ` Thomas Gleixner
  0 siblings, 1 reply; 2+ messages in thread
From: Jaidev Shastri via B4 Relay @ 2026-09-22  1:22 UTC (permalink / raw)
  To: John Stultz, Thomas Gleixner, Stephen Boyd, Miroslav Lichvar
  Cc: linux-kernel, Jaidev Shastri

From: Jaidev Shastri <jaidevshastri@vt.edu>

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@vt.edu>
---
 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@vt.edu>



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] clocksource: publish finished_booting with release semantics
  2026-09-22  1:22 [PATCH] clocksource: publish finished_booting with release semantics Jaidev Shastri via B4 Relay
@ 2026-09-29 11:53 ` Thomas Gleixner
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Gleixner @ 2026-09-29 11:53 UTC (permalink / raw)
  To: Jaidev Shastri via B4 Relay, John Stultz, Stephen Boyd, Miroslav Lichvar
  Cc: linux-kernel, Jaidev Shastri

On Mon, Sep 21 2026 at 21:22, Jaidev Shastri via wrote:
> From: Jaidev Shastri <jaidevshastri@vt.edu>
>
> 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.

Unfortunately your tool is missing the point. All callchains which end
up in clocksource_find_best() hold clocksource_mutex. So this
acquire/release is pointless.

Thanks,

        tglx

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-29 11:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-22  1:22 [PATCH] clocksource: publish finished_booting with release semantics Jaidev Shastri via B4 Relay
2026-09-29 11:53 ` Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®