From: Jaidev Shastri via B4 Relay <devnull+jaidevshastri.vt.edu@kernel.org>
To: John Stultz <jstultz@google.com>,
Thomas Gleixner <tglx@kernel.org>,
Stephen Boyd <sboyd@kernel.org>,
Miroslav Lichvar <mlichvar@redhat.com>
Cc: linux-kernel@vger.kernel.org, Jaidev Shastri <jaidevshastri@vt.edu>
Subject: [PATCH] clocksource: publish finished_booting with release semantics
Date: Mon, 21 Sep 2026 21:22:53 -0400 [thread overview]
Message-ID: <20260921-mb-clocksource-v1-1-3e1d1b43e90d@vt.edu> (raw)
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>
next reply other threads:[~2026-09-22 1:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 1:22 Jaidev Shastri via B4 Relay [this message]
2026-09-29 11:53 ` Thomas Gleixner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260921-mb-clocksource-v1-1-3e1d1b43e90d@vt.edu \
--to=devnull+jaidevshastri.vt.edu@kernel.org \
--cc=jaidevshastri@vt.edu \
--cc=jstultz@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mlichvar@redhat.com \
--cc=sboyd@kernel.org \
--cc=tglx@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®