2024-01-18 16:56:13

by Lucas Stach

[permalink] [raw]
Subject: [PATCH RFC] ARM: VDSO: don't drop clock_gettime when architected timer isn't available

Dropping the clock_gettime entry points when the architected timer is not
available is done to gain some efficiency, as it allows libc to fall back
to the syscall without dispatching through the vDSO.

The difference on a i.MX6 system using the vdso test utility [1]
looks like this:
$ vdsotest clock-gettime-monotonic bench -d 10

w/o vDSO entrypoint with vDSO entrypoint
syscall: 987 nsec/call 974 nsec/call
libc: 1095 nsec/call 1148 nsec/call
vdso: not available not available

Going through libc adds a ~100ns penalty compared to calling the syscall
directly. Dispatching through the vDSO adds another ~50ns, which isn't
negligible, but also not huge.

The downside of dropping the entry points is that now also the COARSE
versions of the clocks have to go through the syscall, while they can
be accelerated through the vDSO even without the architected timer when
the entry points are kept.

$ vdsotest clock-gettime-monotonic-coarse bench -d 10

w/o vDSO entrypoint with vDSO entrypoint
syscall: 659 nsec/call 662 nsec/call
libc: 772 nsec/call 137 nsec/call
vdso: not available 63 nsec/call

This is quite a nice speedup, but arguably coarse clocks are also not
as widely used as the high-res versions. Still, this patch proposes to
to take the hit on his-res clocks by dispatching through the vDSO to gain
the ability to accelerate coarse clocks.

[1] https://github.com/nlynch-mentor/vdsotest

Signed-off-by: Lucas Stach <[email protected]>
---
arch/arm/kernel/vdso.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/arm/kernel/vdso.c b/arch/arm/kernel/vdso.c
index f297d66a8a76..947f3d8144fc 100644
--- a/arch/arm/kernel/vdso.c
+++ b/arch/arm/kernel/vdso.c
@@ -172,11 +172,8 @@ static void __init patch_vdso(void *ehdr)
* want programs to incur the slight additional overhead of
* dispatching through the VDSO only to fall back to syscalls.
*/
- if (!cntvct_ok) {
+ if (!cntvct_ok)
vdso_nullpatch_one(&einfo, "__vdso_gettimeofday");
- vdso_nullpatch_one(&einfo, "__vdso_clock_gettime");
- vdso_nullpatch_one(&einfo, "__vdso_clock_gettime64");
- }
}

static int __init vdso_init(void)
--
2.43.0