Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp747857imm; Fri, 14 Sep 2018 05:52:47 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbKEJHsxxHEGNIs+5pTxKjAQvYCJ1fXW00oEGbxV29zesdgdDR67fQrPnKtuQ7ln/W1wyT8 X-Received: by 2002:a62:401:: with SMTP id 1-v6mr12389531pfe.28.1536929567595; Fri, 14 Sep 2018 05:52:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536929567; cv=none; d=google.com; s=arc-20160816; b=fB0hfEeAx1Yn2baUMMx1ihwM8KiyUi2BsLZYo2al5XWGX65GE+Pa+PDsXh9ouzZU4B ocY2QKlhF7ZXF7kJtDrDjFsnN4sXXUaapX55YAtSzf3ELby2gONPIVTq8EBbNVISj/TD ikDR9kJxWGM52VgqeWKbyLpSw0w0EV302rz1OanaBpBkcDnbkah+lkG0Ph1RjTw3VYJG 56Y4aBtqMWJnVTaqS2G8iIJnMLKmKErIrHFcYNDTyiR3r5cp3RVhhZ7VSEsY2N6YCirB AAija4sUhkS0cuXtwDcXCN2fhj8R9Jz5jjhAOCnJuMIt7II899Gc3k9sLW2e8b8Y75FR BFng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :references:subject:cc:to:from:date:user-agent:message-id; bh=4e0c6+GM5UzaCgmpQB//9gJwut/UV2P0cLjmbqG98fk=; b=A1yZycEp59S+0At4vsGUT1ZMIR3yCq94FOS6xEJK3ckr3lrxht2xrInKkMutJzt1Dr Uj9pZ4TS0Bh/LBjQDH9OA4gCP20J9Seyc4aXfA0GPLkIz4Vn5xN3rm9HEZa51pXtnPeU gtyE9fkj7P7qrvB7VrMW6t14BG3UcIlOgVm+3IO9vtcHi23iYZ73fR4BcKb4ywxo/c2b vepRNdwNL72Ojp2FnShSteiKJmKubCVo4LcvgcJK161eYLS5KHzvp4bk3hFD79/5SQYb HKzr+T8HekKF614n1IjMuLXCAjgIaNZLXHo6E/IpH0NP7AOlEt5N/js19CAzz0al4+DS kFzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g3-v6si6671761pgu.248.2018.09.14.05.52.31; Fri, 14 Sep 2018 05:52:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728378AbeINSGi (ORCPT + 99 others); Fri, 14 Sep 2018 14:06:38 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:49617 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728125AbeINSG1 (ORCPT ); Fri, 14 Sep 2018 14:06:27 -0400 Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1g0nZs-0005wt-Ds; Fri, 14 Sep 2018 14:52:04 +0200 Message-Id: <20180914125119.081037164@linutronix.de> User-Agent: quilt/0.65 Date: Fri, 14 Sep 2018 14:50:17 +0200 From: Thomas Gleixner To: LKML Cc: Andy Lutomirski , x86@kernel.org, Peter Zijlstra , Matt Rickard , Stephen Boyd , John Stultz , Florian Weimer , "K. Y. Srinivasan" , Vitaly Kuznetsov , devel@linuxdriverproject.org, virtualization@lists.linux-foundation.org, Paolo Bonzini , Arnd Bergmann , Juergen Gross Subject: [patch 11/11] x66/vdso: Add CLOCK_TAI support References: <20180914125006.349747096@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline; filename=x66-vdso--Add-CLOCK_TAI-support.patch Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(). The performance impact of the mask operation is within the noise. Signed-off-by: Thomas Gleixner --- 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.