[PATCH] timekeeping: publish suspend_timing_needed with release semantics

From: Jaidev Shastri via B4 Relay

Date: Mon Sep 21 2026 - 21:24:48 EST


From: Jaidev Shastri <jaidevshastri@xxxxxx>

timekeeping_suspend() sets suspend_timing_needed with a plain store
after it has read the persistent clock. timekeeping_rtc_skipresume()
reads it with a plain load on behalf of the RTC class during resume.

Set it 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/timekeeping.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index ea2e6e55f..2b15268c3 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -2141,7 +2141,8 @@ static void __timekeeping_inject_sleeptime(struct timekeeper *tk,
*/
bool timekeeping_rtc_skipresume(void)
{
- return !suspend_timing_needed;
+ /* Pairs with the smp_store_release() in timekeeping_suspend(). */
+ return !smp_load_acquire(&suspend_timing_needed);
}

/*
@@ -2272,7 +2273,8 @@ int timekeeping_suspend(void)
if (timekeeping_suspend_time.tv_sec || timekeeping_suspend_time.tv_nsec)
persistent_clock_exists = true;

- suspend_timing_needed = true;
+ /* Pairs with the smp_load_acquire() in timekeeping_rtc_skipresume(). */
+ smp_store_release(&suspend_timing_needed, true);

raw_spin_lock_irqsave(&tk_core.lock, flags);
timekeeping_forward_now(tks);

---
base-commit: 93f51579e7df248780214094418f205253383cc5
change-id: 20260921-mb-timekeeping-ab8fe52810ec

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