Skip to content

Commit 9b7fc3f

Browse files
t-8chKAGA-KOKO
authored andcommitted
vdso: Introduce aux_clock_resolution_ns()
Move the constant resolution to a shared header, so the vDSO can use it and return it without going through a syscall. Signed-off-by: Thomas Weißschuh <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent 562f03e commit 9b7fc3f

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

include/vdso/auxclock.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _VDSO_AUXCLOCK_H
3+
#define _VDSO_AUXCLOCK_H
4+
5+
#include <uapi/linux/time.h>
6+
#include <uapi/linux/types.h>
7+
8+
static __always_inline u64 aux_clock_resolution_ns(void)
9+
{
10+
return 1;
11+
}
12+
13+
#endif /* _VDSO_AUXCLOCK_H */

kernel/time/timekeeping.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#include <linux/audit.h>
2727
#include <linux/random.h>
2828

29+
#include <vdso/auxclock.h>
30+
2931
#include "tick-internal.h"
3032
#include "ntp_internal.h"
3133
#include "timekeeping_internal.h"
@@ -2876,8 +2878,8 @@ static int aux_get_res(clockid_t id, struct timespec64 *tp)
28762878
if (!clockid_aux_valid(id))
28772879
return -ENODEV;
28782880

2879-
tp->tv_sec = 0;
2880-
tp->tv_nsec = 1;
2881+
tp->tv_sec = aux_clock_resolution_ns() / NSEC_PER_SEC;
2882+
tp->tv_nsec = aux_clock_resolution_ns() % NSEC_PER_SEC;
28812883
return 0;
28822884
}
28832885

0 commit comments

Comments
 (0)