[tip: timers/vdso] vdso/gettimeofday: Move the unlikely() into vdso_read_retry()

From: tip-bot2 for Thomas Weißschuh

Date: Wed Mar 11 2026 - 05:52:25 EST


The following commit has been merged into the timers/vdso branch of tip:

Commit-ID: 76970d39a0600e7432b4e4fb538ba0a81e8b4add
Gitweb: https://git.kernel.org/tip/76970d39a0600e7432b4e4fb538ba0a81e8b4add
Author: Thomas Weißschuh <thomas.weissschuh@xxxxxxxxxxxxx>
AuthorDate: Fri, 27 Feb 2026 07:43:23 +01:00
Committer: Thomas Gleixner <tglx@xxxxxxxxxx>
CommitterDate: Wed, 11 Mar 2026 10:27:35 +01:00

vdso/gettimeofday: Move the unlikely() into vdso_read_retry()

All callers of vdso_read_retry() test its return value with unlikely().
Move the unlikely into the helper to make the code easier to read.
This is equivalent to the retry function of non-vDSO seqlocks.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@xxxxxxxxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxx>
Link: https://patch.msgid.link/20260227-vdso-cleanups-v1-4-c848b4bc4850@xxxxxxxxxxxxx
---
include/vdso/helpers.h | 2 +-
lib/vdso/gettimeofday.c | 10 +++++-----
2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/vdso/helpers.h b/include/vdso/helpers.h
index a776554..403bb45 100644
--- a/include/vdso/helpers.h
+++ b/include/vdso/helpers.h
@@ -52,7 +52,7 @@ static __always_inline u32 vdso_read_retry(const struct vdso_clock *vc,

smp_rmb();
seq = READ_ONCE(vc->seq);
- return seq != start;
+ return unlikely(seq != start);
}

static __always_inline void vdso_write_seq_begin(struct vdso_clock *vc)
diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c
index 2faed78..efd1b82 100644
--- a/lib/vdso/gettimeofday.c
+++ b/lib/vdso/gettimeofday.c
@@ -135,7 +135,7 @@ bool do_hres_timens(const struct vdso_time_data *vdns, const struct vdso_clock *

if (!vdso_get_timestamp(vd, vc, clk, &sec, &ns))
return false;
- } while (unlikely(vdso_read_retry(vc, seq)));
+ } while (vdso_read_retry(vc, seq));

/* Add the namespace offset */
sec += offs->sec;
@@ -163,7 +163,7 @@ bool do_hres(const struct vdso_time_data *vd, const struct vdso_clock *vc,

if (!vdso_get_timestamp(vd, vc, clk, &sec, &ns))
return false;
- } while (unlikely(vdso_read_retry(vc, seq)));
+ } while (vdso_read_retry(vc, seq));

vdso_set_timespec(ts, sec, ns);

@@ -188,7 +188,7 @@ bool do_coarse_timens(const struct vdso_time_data *vdns, const struct vdso_clock
seq = vdso_read_begin(vc);
sec = vdso_ts->sec;
nsec = vdso_ts->nsec;
- } while (unlikely(vdso_read_retry(vc, seq)));
+ } while (vdso_read_retry(vc, seq));

/* Add the namespace offset */
sec += offs->sec;
@@ -212,7 +212,7 @@ bool do_coarse(const struct vdso_time_data *vd, const struct vdso_clock *vc,

ts->tv_sec = vdso_ts->sec;
ts->tv_nsec = vdso_ts->nsec;
- } while (unlikely(vdso_read_retry(vc, seq)));
+ } while (vdso_read_retry(vc, seq));

return true;
}
@@ -244,7 +244,7 @@ bool do_aux(const struct vdso_time_data *vd, clockid_t clock, struct __kernel_ti

if (!vdso_get_timestamp(vd, vc, VDSO_BASE_AUX, &sec, &ns))
return false;
- } while (unlikely(vdso_read_retry(vc, seq)));
+ } while (vdso_read_retry(vc, seq));

vdso_set_timespec(ts, sec, ns);