[tip: timers/vdso] vdso/gettimeofday: Add support for CLOCK_BOOTTIME_ALARM

From: tip-bot2 for Thomas Weißschuh

Date: Mon Nov 30 2026 - 15:28:14 EST


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

Commit-ID: 4a01fe378e1aa596dbda7073ecb28f47acbb2b9f
Gitweb: https://git.kernel.org/tip/4a01fe378e1aa596dbda7073ecb28f47acbb2b9f
Author: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>
AuthorDate: Tue, 10 Nov 2026 13:19:34
Committer: Thomas Gleixner <tglx@xxxxxxxxxx>
CommitterDate: Mon, 30 Nov 2026 18:05:19 +01:00

vdso/gettimeofday: Add support for CLOCK_BOOTTIME_ALARM

CLOCK_BOOTTIME_ALARM behaves exactly as CLOCK_BOOTTIME as far as the
vDSO is concerned. The vDSO library can handle it automatically
correctly. Only the basetime needs to be maintained during the tick.

The namespace offset is already set correctly, although it was not
used before.

Reuse the CLOCK_BOOTTIME basetime for CLOCK_BOOTTIME_ALARM and update
the userspace hres clock mask to include CLOCK_BOOTTIME_ALARM.

Signed-off-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxx>
Link: https://patch.msgid.link/20261110-vdso-alarm-clocks-v3-3-8f3c0c5b5a11@xxxxxxxxxxxxxx
---
include/vdso/datapage.h | 2 +-
kernel/time/vsyscall.c | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/vdso/datapage.h b/include/vdso/datapage.h
index ac4172a..98084b4 100644
--- a/include/vdso/datapage.h
+++ b/include/vdso/datapage.h
@@ -40,7 +40,7 @@ struct vdso_arch_data {
BIT(CLOCK_MONOTONIC_COARSE))
#define VDSO_RAW (BIT(CLOCK_MONOTONIC_RAW))
#define VDSO_AUX __GENMASK(CLOCK_AUX_LAST, CLOCK_AUX)
-#define VDSO_ALARM 0
+#define VDSO_ALARM BIT(CLOCK_BOOTTIME_ALARM)

/**
* struct vdso_timestamp - basetime per clock_id
diff --git a/kernel/time/vsyscall.c b/kernel/time/vsyscall.c
index fc3313d..4231b04 100644
--- a/kernel/time/vsyscall.c
+++ b/kernel/time/vsyscall.c
@@ -69,6 +69,9 @@ static inline void update_vdso_time_data(struct vdso_time_data *vdata, struct ti
vdso_ts->sec += __iter_div64_u64_rem(nsec, (u64)NSEC_PER_SEC << tk->tkr_mono.shift,
&vdso_ts->nsec);

+ /* CLOCK_BOOTTIME_ALARM, copy of CLOCK_BOOTIME */
+ vdata->hres_coarse.basetime[CLOCK_BOOTTIME_ALARM] = *vdso_ts;
+
/* CLOCK_MONOTONIC_RAW */
vdso_ts = &vdata->raw.basetime[CLOCK_MONOTONIC_RAW];
vdso_ts->sec = tk->raw_sec;