Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH v2 0/3] vdso/gettimeofday: Add support for ALARM clocks
@ 2026-09-29 20:24 Thomas Weißschuh
  2026-09-29 20:24 ` [PATCH v2 1/3] selftests: vDSO: vdso_test_abi: Also test " Thomas Weißschuh
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Thomas Weißschuh @ 2026-09-29 20:24 UTC (permalink / raw)
  To: Andy Lutomirski, Thomas Gleixner, Vincenzo Frascino, Shuah Khan
  Cc: linux-kernel, linux-kselftest, Thomas Weißschuh

Extend the generic vDSO library to also handle CLOCK_BOOTTIME_ALARM
and CLOCK_REALTIME_ALARM. This does not introduce any runtime overhead
in the userspace fast path and only memory copies in the tick update
path.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
Changes in v2:
- Rebase on tip/timers/vdso.
- Add Signed-off-by tags.
- Link to v1: https://patch.msgid.link/20260921-vdso-alarm-clocks-v1-0-617abb5271c7@weissschuh.net

---
Thomas Weißschuh (3):
      selftests: vDSO: vdso_test_abi: Also test ALARM clocks
      vdso/gettimeofday: Add support for CLOCK_BOOTTIME_ALARM
      vdso/gettimeofday: Add support for CLOCK_REALTIME_ALARM

 include/vdso/datapage.h                      | 2 ++
 kernel/time/vsyscall.c                       | 7 +++++++
 tools/testing/selftests/vDSO/vdso_test_abi.c | 4 +++-
 3 files changed, 12 insertions(+), 1 deletion(-)
---
base-commit: ca46a07c4b68246c4e400ce3649ab7228a878d8f
change-id: 20260921-vdso-alarm-clocks-6502a551ad5c

Best regards,
--  
Thomas Weißschuh <linux@weissschuh.net>


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

* [PATCH v2 1/3] selftests: vDSO: vdso_test_abi: Also test ALARM clocks
  2026-09-29 20:24 [PATCH v2 0/3] vdso/gettimeofday: Add support for ALARM clocks Thomas Weißschuh
@ 2026-09-29 20:24 ` Thomas Weißschuh
  2026-09-29 20:24 ` [PATCH v2 2/3] vdso/gettimeofday: Add support for CLOCK_BOOTTIME_ALARM Thomas Weißschuh
  2026-09-29 20:24 ` [PATCH v2 3/3] vdso/gettimeofday: Add support for CLOCK_REALTIME_ALARM Thomas Weißschuh
  2 siblings, 0 replies; 5+ messages in thread
From: Thomas Weißschuh @ 2026-09-29 20:24 UTC (permalink / raw)
  To: Andy Lutomirski, Thomas Gleixner, Vincenzo Frascino, Shuah Khan
  Cc: linux-kernel, linux-kselftest, Thomas Weißschuh

Extend the tests to also handle CLOCK_REALTIME_ALARM and
CLOCK_BOOTTIME_ALARM. These are currently not handled by the vDSO,
so will fall through to the system call and succeed.

The tests will become useful when the vDSO will start handling these
clocks in later patches.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 tools/testing/selftests/vDSO/vdso_test_abi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/vDSO/vdso_test_abi.c b/tools/testing/selftests/vDSO/vdso_test_abi.c
index b162a4ba9c4f..4f538928e1d4 100644
--- a/tools/testing/selftests/vDSO/vdso_test_abi.c
+++ b/tools/testing/selftests/vDSO/vdso_test_abi.c
@@ -261,7 +261,7 @@ static inline void vdso_test_clock(clockid_t clock_id)
 	vdso_test_clock_getres_time64(clock_id);
 }
 
-#define VDSO_TEST_PLAN	38
+#define VDSO_TEST_PLAN	46
 
 int main(int argc, char **argv)
 {
@@ -284,7 +284,9 @@ int main(int argc, char **argv)
 	vdso_test_gettimeofday();
 
 	vdso_test_clock(CLOCK_REALTIME);
+	vdso_test_clock(CLOCK_REALTIME_ALARM);
 	vdso_test_clock(CLOCK_BOOTTIME);
+	vdso_test_clock(CLOCK_BOOTTIME_ALARM);
 	vdso_test_clock(CLOCK_TAI);
 	vdso_test_clock(CLOCK_REALTIME_COARSE);
 	vdso_test_clock(CLOCK_MONOTONIC);

-- 
2.55.0


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

* [PATCH v2 2/3] vdso/gettimeofday: Add support for CLOCK_BOOTTIME_ALARM
  2026-09-29 20:24 [PATCH v2 0/3] vdso/gettimeofday: Add support for ALARM clocks Thomas Weißschuh
  2026-09-29 20:24 ` [PATCH v2 1/3] selftests: vDSO: vdso_test_abi: Also test " Thomas Weißschuh
@ 2026-09-29 20:24 ` Thomas Weißschuh
  2026-10-15 13:43   ` Thomas Gleixner
  2026-09-29 20:24 ` [PATCH v2 3/3] vdso/gettimeofday: Add support for CLOCK_REALTIME_ALARM Thomas Weißschuh
  2 siblings, 1 reply; 5+ messages in thread
From: Thomas Weißschuh @ 2026-09-29 20:24 UTC (permalink / raw)
  To: Andy Lutomirski, Thomas Gleixner, Vincenzo Frascino, Shuah Khan
  Cc: linux-kernel, linux-kselftest, Thomas Weißschuh

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@weissschuh.net>
---
 include/vdso/datapage.h | 1 +
 kernel/time/vsyscall.c  | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/include/vdso/datapage.h b/include/vdso/datapage.h
index 09897f76ae07..33297b5e2521 100644
--- a/include/vdso/datapage.h
+++ b/include/vdso/datapage.h
@@ -35,6 +35,7 @@ struct vdso_arch_data {
 #define VDSO_HRES	(BIT(CLOCK_REALTIME)		| \
 			 BIT(CLOCK_MONOTONIC)		| \
 			 BIT(CLOCK_BOOTTIME)		| \
+			 BIT(CLOCK_BOOTTIME_ALARM)	| \
 			 BIT(CLOCK_TAI))
 #define VDSO_COARSE	(BIT(CLOCK_REALTIME_COARSE)	| \
 			 BIT(CLOCK_MONOTONIC_COARSE))
diff --git a/kernel/time/vsyscall.c b/kernel/time/vsyscall.c
index 0e4b499328c0..bb412ad1782f 100644
--- a/kernel/time/vsyscall.c
+++ b/kernel/time/vsyscall.c
@@ -57,6 +57,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 */
+	vc[CS_HRES_COARSE].basetime[CLOCK_BOOTTIME_ALARM] = *vdso_ts;
+
 	/* CLOCK_MONOTONIC_RAW */
 	vdso_ts		= &vc[CS_RAW].basetime[CLOCK_MONOTONIC_RAW];
 	vdso_ts->sec	= tk->raw_sec;

-- 
2.55.0


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

* [PATCH v2 3/3] vdso/gettimeofday: Add support for CLOCK_REALTIME_ALARM
  2026-09-29 20:24 [PATCH v2 0/3] vdso/gettimeofday: Add support for ALARM clocks Thomas Weißschuh
  2026-09-29 20:24 ` [PATCH v2 1/3] selftests: vDSO: vdso_test_abi: Also test " Thomas Weißschuh
  2026-09-29 20:24 ` [PATCH v2 2/3] vdso/gettimeofday: Add support for CLOCK_BOOTTIME_ALARM Thomas Weißschuh
@ 2026-09-29 20:24 ` Thomas Weißschuh
  2 siblings, 0 replies; 5+ messages in thread
From: Thomas Weißschuh @ 2026-09-29 20:24 UTC (permalink / raw)
  To: Andy Lutomirski, Thomas Gleixner, Vincenzo Frascino, Shuah Khan
  Cc: linux-kernel, linux-kselftest, Thomas Weißschuh

CLOCK_REALTIME_ALARM behaves exactly as CLOCK_REALTIME 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.

Reuse the CLOCK_REALTIME basetime for CLOCK_REALTIME_ALARM and update
the userspace hres clock mask to include CLOCK_REALTIME_ALARM.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 include/vdso/datapage.h | 1 +
 kernel/time/vsyscall.c  | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/include/vdso/datapage.h b/include/vdso/datapage.h
index 33297b5e2521..0aa28a484dcd 100644
--- a/include/vdso/datapage.h
+++ b/include/vdso/datapage.h
@@ -33,6 +33,7 @@ struct vdso_arch_data {
 #define VDSO_BASES	(CLOCK_TAI + 1)
 #define VDSO_BASE_AUX	0
 #define VDSO_HRES	(BIT(CLOCK_REALTIME)		| \
+			 BIT(CLOCK_REALTIME_ALARM)	| \
 			 BIT(CLOCK_MONOTONIC)		| \
 			 BIT(CLOCK_BOOTTIME)		| \
 			 BIT(CLOCK_BOOTTIME_ALARM)	| \
diff --git a/kernel/time/vsyscall.c b/kernel/time/vsyscall.c
index bb412ad1782f..0cf4eadf6996 100644
--- a/kernel/time/vsyscall.c
+++ b/kernel/time/vsyscall.c
@@ -69,6 +69,10 @@ static inline void update_vdso_time_data(struct vdso_time_data *vdata, struct ti
 	vdso_ts		= &vc[CS_HRES_COARSE].basetime[CLOCK_TAI];
 	vdso_ts->sec	= tk->xtime_sec + (s64)tk->tai_offset;
 	vdso_ts->nsec	= tk->tkr_mono.xtime_nsec;
+
+	/* CLOCK_REALTIME_ALARM, copy of CLOCK_REALTIME */
+	vdso_ts		= &vc[CS_HRES_COARSE].basetime[CLOCK_REALTIME_ALARM];
+	*vdso_ts	= vc[CS_HRES_COARSE].basetime[CLOCK_REALTIME];
 }
 
 void update_vsyscall(struct timekeeper *tk)

-- 
2.55.0


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

* Re: [PATCH v2 2/3] vdso/gettimeofday: Add support for CLOCK_BOOTTIME_ALARM
  2026-09-29 20:24 ` [PATCH v2 2/3] vdso/gettimeofday: Add support for CLOCK_BOOTTIME_ALARM Thomas Weißschuh
@ 2026-10-15 13:43   ` Thomas Gleixner
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Gleixner @ 2026-10-15 13:43 UTC (permalink / raw)
  To: Thomas Weißschuh, Andy Lutomirski, Vincenzo Frascino,
	Shuah Khan
  Cc: linux-kernel, linux-kselftest, Thomas Weißschuh

On Tue, Sep 29 2026 at 22:24, Thomas Weißschuh wrote:

> 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.

It behaves the same way, but ALARM clock IDs require a RTC device. See
alarm_clock_get_timespec().

So the VDSO and the syscall will disagree when there is no RTC
available...

Thanks,

        tglx

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

end of thread, other threads:[~2026-10-15 13:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-29 20:24 [PATCH v2 0/3] vdso/gettimeofday: Add support for ALARM clocks Thomas Weißschuh
2026-09-29 20:24 ` [PATCH v2 1/3] selftests: vDSO: vdso_test_abi: Also test " Thomas Weißschuh
2026-09-29 20:24 ` [PATCH v2 2/3] vdso/gettimeofday: Add support for CLOCK_BOOTTIME_ALARM Thomas Weißschuh
2026-10-15 13:43   ` Thomas Gleixner
2026-09-29 20:24 ` [PATCH v2 3/3] vdso/gettimeofday: Add support for CLOCK_REALTIME_ALARM Thomas Weißschuh

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