From 4318924054905109cfd6457dfecf60dd88c6c1a2 Mon Sep 17 00:00:00 2001 From: Chen Hui Date: Wed, 14 Sep 2022 15:04:34 +0800 Subject: [PATCH] vdso: support more flags for clock_gettime() vdso interface Current vdso(implemented by sentry, and used by the real application) is a partial implimentation. More specifically, the clock_gettime() vdso interface only works for CLOCK_REALTIME, CLOCK_BOOTTIME, and CLOCK_MONOTONIC. So we support more flags for clock_gettime() vdso interface here, like CLOCK_REALTIME_COARSE, CLOCK_MONOTONIC_RAW, and CLOCK_MONOTONIC_COARSE, to accelerate clock_gettime() call of real application. And their implementations refer to the internal syscall of gvisor. See function getClock() in pkg/sentry/syscalls/linux/sys_time.go. Signed-off-by: Chen Hui --- vdso/vdso.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vdso/vdso.cc b/vdso/vdso.cc index 3b6653b5d..524c32989 100644 --- a/vdso/vdso.cc +++ b/vdso/vdso.cc @@ -29,12 +29,18 @@ int __common_clock_gettime(clockid_t clock, struct timespec* ts) { int ret; switch (clock) { + case CLOCK_REALTIME_COARSE: + // Fallthrough, CLOCK_REALTIME_COARSE is an alias for CLOCK_REALTIME case CLOCK_REALTIME: ret = ClockRealtime(ts); break; case CLOCK_BOOTTIME: // Fallthrough, CLOCK_BOOTTIME is an alias for CLOCK_MONOTONIC + case CLOCK_MONOTONIC_RAW: + // Fallthrough, CLOCK_MONOTONIC_RAW is an alias for CLOCK_MONOTONIC + case CLOCK_MONOTONIC_COARSE: + // Fallthrough, CLOCK_MONOTONIC_COARSE is an alias for CLOCK_MONOTONIC case CLOCK_MONOTONIC: ret = ClockMonotonic(ts); break;