[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <ABB53D42-2A06-41B9-8A8C-40B39CD0289D@amacapital.net>
Date: Fri, 14 Sep 2018 07:04:02 -0700
From: Andy Lutomirski <luto@...capital.net>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: LKML <linux-kernel@...r.kernel.org>,
Andy Lutomirski <luto@...nel.org>, x86@...nel.org,
Peter Zijlstra <peterz@...radead.org>,
Matt Rickard <matt@...trans.com.au>,
Stephen Boyd <sboyd@...nel.org>,
John Stultz <john.stultz@...aro.org>,
Florian Weimer <fweimer@...hat.com>,
"K. Y. Srinivasan" <kys@...rosoft.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
devel@...uxdriverproject.org,
virtualization@...ts.linux-foundation.org,
Paolo Bonzini <pbonzini@...hat.com>,
Arnd Bergmann <arnd@...db.de>, Juergen Gross <jgross@...e.com>
Subject: Re: [patch 11/11] x66/vdso: Add CLOCK_TAI support
> On Sep 14, 2018, at 5:50 AM, Thomas Gleixner <tglx@...utronix.de> wrote:
>
> With the storage array in place it's now trivial to support CLOCK_TAI in
> the vdso. Instead of extending the array to accomodate CLOCK_TAI, make use
> of the fact that:
>
> - CLOCK ids are set in stone
> - CLOCK_THREAD_CPUTIME is never going to be supported in the VDSO so
> the array slot 3 is unused
> - CLOCK_TAI is id 11 which results in 3 when masked with 0x3
>
> Add the mask to the basetime array lookup and set up the CLOCK_TAI base
> time in update_vsyscall().
That’s... horrible. In an amazing way. Can you add BUILD_BUG_ON somewhere to assert that this actually works?
>
> The performance impact of the mask operation is within the noise.
>
> Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
> ---
> arch/x86/entry/vdso/vclock_gettime.c | 2 +-
> arch/x86/entry/vsyscall/vsyscall_gtod.c | 4 ++++
> arch/x86/include/asm/vgtod.h | 6 +++++-
> 3 files changed, 10 insertions(+), 2 deletions(-)
>
> --- a/arch/x86/entry/vdso/vclock_gettime.c
> +++ b/arch/x86/entry/vdso/vclock_gettime.c
> @@ -140,7 +140,7 @@ notrace static inline u64 vgetcyc(int mo
>
> notrace static int do_hres(clockid_t clk, struct timespec *ts)
> {
> - struct vgtod_ts *base = >od->basetime[clk];
> + struct vgtod_ts *base = >od->basetime[clk & VGTOD_HRES_MASK];
> u64 cycles, last, ns;
> unsigned int seq;
>
> --- a/arch/x86/entry/vsyscall/vsyscall_gtod.c
> +++ b/arch/x86/entry/vsyscall/vsyscall_gtod.c
> @@ -51,6 +51,10 @@ void update_vsyscall(struct timekeeper *
> base->sec = tk->xtime_sec;
> base->nsec = tk->tkr_mono.xtime_nsec;
>
> + base = &vdata->basetime[VGTOD_TAI];
> + base->sec = tk->xtime_sec + (s64)tk->tai_offset;
> + base->nsec = tk->tkr_mono.xtime_nsec;
> +
> base = &vdata->basetime[CLOCK_MONOTONIC];
> base->sec = tk->xtime_sec + tk->wall_to_monotonic.tv_sec;
> nsec = tk->tkr_mono.xtime_nsec;
> --- a/arch/x86/include/asm/vgtod.h
> +++ b/arch/x86/include/asm/vgtod.h
> @@ -19,9 +19,13 @@ struct vgtod_ts {
> };
>
> #define VGTOD_BASES (CLOCK_MONOTONIC_COARSE + 1)
> -#define VGTOD_HRES (BIT(CLOCK_REALTIME) | BIT(CLOCK_MONOTONIC))
> +#define VGTOD_HRES (BIT(CLOCK_REALTIME) | BIT(CLOCK_MONOTONIC) | BIT(CLOCK_TAI))
> #define VGTOD_COARSE (BIT(CLOCK_REALTIME_COARSE) | BIT(CLOCK_MONOTONIC_COARSE))
>
> +/* Abuse CLOCK_THREAD_CPUTIME_ID for VGTOD CLOCK TAI */
> +#define VGTOD_HRES_MASK 0x3
> +#define VGTOD_TAI (CLOCK_TAI & VGTOD_HRES_MASK)
> +
> /*
> * vsyscall_gtod_data will be accessed by 32 and 64 bit code at the same time
> * so be carefull by modifying this structure.
>
>
Powered by blists - more mailing lists