From: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
To: Andy Lutomirski <luto@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Vincenzo Frascino <vincenzo.frascino@arm.com>,
Shuah Khan <shuah@kernel.org>,
Anna-Maria Behnsen <anna-maria@linutronix.de>,
Frederic Weisbecker <frederic@kernel.org>,
John Stultz <jstultz@google.com>,
Stephen Boyd <sboyd@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, Arnd Bergmann <arnd@arndb.de>
Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org,
"Richard Cochran" <richardcochran@gmail.com>,
"Christopher Hall" <christopher.s.hall@intel.com>,
"Frederic Weisbecker" <frederic@kernel.org>,
"Anna-Maria Behnsen" <anna-maria@linutronix.de>,
"Miroslav Lichvar" <mlichvar@redhat.com>,
"Werner Abt" <werner.abt@meinberg-usa.com>,
"David Woodhouse" <dwmw2@infradead.org>,
"Stephen Boyd" <sboyd@kernel.org>,
"Kurt Kanzenbach" <kurt@linutronix.de>,
"Nam Cao" <namcao@linutronix.de>,
"Antoine Tenart" <atenart@kernel.org>,
"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Subject: [PATCH 14/14] selftests/timers/auxclock: Test vDSO functionality
Date: Tue, 01 Jul 2025 10:58:08 +0200 [thread overview]
Message-ID: <20250701-vdso-auxclock-v1-14-df7d9f87b9b8@linutronix.de> (raw)
In-Reply-To: <20250701-vdso-auxclock-v1-0-df7d9f87b9b8@linutronix.de>
Extend the auxclock test to also cover the vDSO.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
tools/testing/selftests/timers/auxclock.c | 95 +++++++++++++++++++++++++++++--
1 file changed, 91 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/timers/auxclock.c b/tools/testing/selftests/timers/auxclock.c
index 0ba2f9996114ade3147f0f3aec49904556a23cd4..314037839c1c7dd32ca32722231c67bc408a2ea3 100644
--- a/tools/testing/selftests/timers/auxclock.c
+++ b/tools/testing/selftests/timers/auxclock.c
@@ -10,11 +10,16 @@
#include <linux/timex.h>
#include <sched.h>
#include <stdio.h>
+#include <sys/auxv.h>
#include <sys/syscall.h>
#include <unistd.h>
#include "../kselftest_harness.h"
+#include "../vDSO/parse_vdso.c"
+#include "../vDSO/vdso_config.h"
+#include "../vDSO/vdso_call.h"
+
#ifndef CLOCK_AUX
#define CLOCK_AUX 16
#endif
@@ -133,7 +138,45 @@ static int sys_clock_adjtime64(__kernel_clockid_t clockid, struct __kernel_timex
#endif
}
-FIXTURE(auxclock) {};
+FIXTURE(auxclock) {
+ int (*vdso_clock_gettime)(__kernel_clockid_t clockid, struct timespec *ts);
+ int (*vdso_clock_gettime64)(__kernel_clockid_t clockid, struct __kernel_timespec *ts);
+ int (*vdso_clock_getres)(__kernel_clockid_t clockid, struct timespec *ts);
+};
+
+static int vdso_clock_gettime64(FIXTURE_DATA(auxclock) *self, __kernel_clockid_t clockid,
+ struct __kernel_timespec *ts)
+{
+ struct timespec _ts;
+ int ret;
+
+ if (self->vdso_clock_gettime64) {
+ return VDSO_CALL(self->vdso_clock_gettime64, 2, clockid, ts);
+ } else if (self->vdso_clock_gettime) {
+ ret = VDSO_CALL(self->vdso_clock_gettime, 2, clockid, &_ts);
+ if (!ret)
+ timespec_to_kernel_timespec(&_ts, ts);
+ return ret;
+ } else {
+ return -ENOSYS;
+ }
+}
+
+static int vdso_clock_getres_time64(FIXTURE_DATA(auxclock) *self, __kernel_clockid_t clockid,
+ struct __kernel_timespec *ts)
+{
+ struct timespec _ts;
+ int ret;
+
+ if (self->vdso_clock_getres) {
+ ret = VDSO_CALL(self->vdso_clock_getres, 2, clockid, &_ts);
+ if (!ret)
+ timespec_to_kernel_timespec(&_ts, ts);
+ return ret;
+ } else {
+ return -ENOSYS;
+ }
+}
FIXTURE_VARIANT(auxclock) {
__kernel_clockid_t clock;
@@ -193,6 +236,18 @@ static void enter_timens(struct __test_metadata *_metadata)
FIXTURE_SETUP(auxclock) {
int ret;
+#ifdef AT_SYSINFO_EHDR
+ unsigned long sysinfo_ehdr;
+
+ sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR);
+ if (sysinfo_ehdr)
+ vdso_init_from_sysinfo_ehdr(sysinfo_ehdr);
+
+ self->vdso_clock_gettime = vdso_sym(versions[VDSO_VERSION], names[VDSO_NAMES][1]);
+ self->vdso_clock_gettime64 = vdso_sym(versions[VDSO_VERSION], names[VDSO_NAMES][5]);
+ self->vdso_clock_getres = vdso_sym(versions[VDSO_VERSION], names[VDSO_NAMES][3]);
+#endif /* !AT_SYSINFO_EHDR */
+
ret = configure_auxclock(variant->clock, variant->clock_enabled);
if (ret == -ENOENT)
SKIP(return, "auxclocks not enabled");
@@ -220,6 +275,20 @@ TEST_F(auxclock, sys_clock_getres) {
ASSERT_EQ(1, ts.tv_nsec);
}
+TEST_F(auxclock, vdso_clock_getres) {
+ struct __kernel_timespec ts;
+ int ret;
+
+ ret = vdso_clock_getres_time64(self, variant->clock, &ts);
+ if (ret == -ENOSYS) {
+ SKIP(return, "no clock_getres() in vDSO");
+ } else {
+ ASSERT_EQ(0, ret);
+ ASSERT_EQ(0, ts.tv_sec);
+ ASSERT_EQ(1, ts.tv_nsec);
+ }
+}
+
TEST_F(auxclock, sys_clock_gettime) {
struct __kernel_timespec ts;
int ret;
@@ -233,6 +302,20 @@ TEST_F(auxclock, sys_clock_gettime) {
}
}
+TEST_F(auxclock, vdso_clock_gettime) {
+ struct __kernel_timespec ts;
+ int ret;
+
+ ret = vdso_clock_gettime64(self, variant->clock, &ts);
+ if (ret == -ENOSYS) {
+ SKIP(return, "no clock_gettime() in vDSO");
+ } else if (variant->clock_enabled) {
+ ASSERT_EQ(0, ret);
+ } else {
+ ASSERT_EQ(-ENODEV, ret);
+ }
+}
+
static void auxclock_validate_progression(struct __test_metadata *_metadata,
const struct __kernel_timespec *a,
const struct __kernel_timespec *b)
@@ -310,9 +393,13 @@ TEST_F(auxclock, progression) {
auxclock_validate_progression(_metadata, &a, &b);
memset(&a, 0, sizeof(a));
- ret = sys_clock_gettime64(variant->clock, &a);
- ASSERT_EQ(0, ret);
- auxclock_validate_progression(_metadata, &b, &a);
+ ret = vdso_clock_gettime64(self, variant->clock, &a);
+ if (ret == -ENOSYS) {
+ a = b;
+ } else {
+ ASSERT_EQ(0, ret);
+ auxclock_validate_progression(_metadata, &b, &a);
+ }
}
}
--
2.50.0
next prev parent reply other threads:[~2025-07-01 8:58 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-01 8:57 [PATCH 00/14] vdso: Add support for auxiliary clocks Thomas Weißschuh
2025-07-01 8:57 ` [PATCH 01/14] selftests/timers: Add testcase " Thomas Weißschuh
2025-07-01 8:57 ` [PATCH 02/14] vdso/vsyscall: Introduce a helper to fill clock configurations Thomas Weißschuh
2025-07-01 8:57 ` [PATCH 03/14] vdso/vsyscall: Split up __arch_update_vsyscall() into __arch_update_vdso_clock() Thomas Weißschuh
2025-07-01 8:57 ` [PATCH 04/14] vdso/helpers: Add helpers for seqlocks of single vdso_clock Thomas Weißschuh
2025-07-01 8:57 ` [PATCH 05/14] vdso/gettimeofday: Return bool from clock_getres() helpers Thomas Weißschuh
2025-07-01 8:58 ` [PATCH 06/14] vdso/gettimeofday: Return bool from clock_gettime() helpers Thomas Weißschuh
[not found] ` <CGME20250708151720eucas1p260f984fd95d3460d3e9f6c9b48e0e25c@eucas1p2.samsung.com>
2025-07-08 15:17 ` Marek Szyprowski
[not found] ` <CGME20250708154921eucas1p1fd8fa4374610a991ca5c67bd612ca0c2@eucas1p1.samsung.com>
2025-07-08 15:49 ` Marek Szyprowski
2025-07-09 7:34 ` Thomas Weißschuh
2025-07-09 8:04 ` Marek Szyprowski
2025-07-16 12:25 ` Mark Brown
2025-07-16 12:34 ` Thomas Weißschuh
2025-07-16 12:50 ` Mark Brown
2025-07-16 13:23 ` Thomas Weißschuh
2025-07-16 14:35 ` Mark Brown
2025-07-18 12:02 ` Thomas Weißschuh
2025-07-19 11:16 ` David Laight
2025-07-09 8:29 ` Mark Brown
2025-07-01 8:58 ` [PATCH 07/14] vdso/gettimeofday: Introduce vdso_clockid_valid() Thomas Weißschuh
2025-07-01 8:58 ` [PATCH 08/14] vdso/gettimeofday: Introduce vdso_set_timespec() Thomas Weißschuh
2025-07-01 8:58 ` [PATCH 09/14] vdso/gettimeofday: Introduce vdso_get_timestamp() Thomas Weißschuh
2025-07-01 8:58 ` [PATCH 10/14] vdso: Introduce aux_clock_resolution_ns() Thomas Weißschuh
2025-07-01 8:58 ` [PATCH 11/14] vdso/vsyscall: Update auxiliary clock data in the datapage Thomas Weißschuh
2025-07-07 6:57 ` Thomas Gleixner
2025-07-07 11:34 ` Arnd Bergmann
2025-07-07 13:16 ` Thomas Gleixner
2025-07-07 14:48 ` Arnd Bergmann
2025-07-01 8:58 ` [PATCH 12/14] vdso/gettimeofday: Add support for auxiliary clocks Thomas Weißschuh
2025-07-06 19:31 ` Thomas Gleixner
2025-08-20 8:03 ` John Stultz
2025-08-20 10:15 ` Thomas Weißschuh
2025-07-01 8:58 ` [PATCH 13/14] Revert "selftests: vDSO: parse_vdso: Use UAPI headers instead of libc headers" Thomas Weißschuh
2025-07-06 20:43 ` Thomas Gleixner
2025-07-07 6:21 ` Thomas Weißschuh
2025-07-01 8:58 ` Thomas Weißschuh [this message]
2025-07-06 20:26 ` [PATCH 14/14] selftests/timers/auxclock: Test vDSO functionality Thomas Gleixner
2025-07-07 7:17 ` Thomas Weißschuh
2025-07-07 13:18 ` 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=20250701-vdso-auxclock-v1-14-df7d9f87b9b8@linutronix.de \
--to=thomas.weissschuh@linutronix.de \
--cc=anna-maria@linutronix.de \
--cc=arnd@arndb.de \
--cc=atenart@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=christopher.s.hall@intel.com \
--cc=dwmw2@infradead.org \
--cc=frederic@kernel.org \
--cc=jstultz@google.com \
--cc=kurt@linutronix.de \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mlichvar@redhat.com \
--cc=namcao@linutronix.de \
--cc=richardcochran@gmail.com \
--cc=sboyd@kernel.org \
--cc=shuah@kernel.org \
--cc=tglx@linutronix.de \
--cc=vincenzo.frascino@arm.com \
--cc=werner.abt@meinberg-usa.com \
--cc=will@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;
as well as URLs for NNTP newsgroup(s).