Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp833740imm; Fri, 14 Sep 2018 07:04:42 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbBKW9AK4SB4gcR1Wf+6JfqMKQ6T9BPogc7E0J4sJnnOoMhQ7PixmKcW3yYMi9CKSMHJZWp X-Received: by 2002:a62:280a:: with SMTP id o10-v6mr12720217pfo.129.1536933882350; Fri, 14 Sep 2018 07:04:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536933882; cv=none; d=google.com; s=arc-20160816; b=ZzVH7BNC2mZb2wasyhk1PCagvXNuL6pkPrWbAmiy5JkuuLOOuUlHwtSrd6dyf4q7zh nvycHDV5lnFEtchMGr5wJPrf3eY7UFitMx7I8DsuBE2sfiNTTJqk5mhhgUxZJY3xi8Rb /DTfvszeMnoOWtEAsDZDwUBAxqJ/ABcQb7w1PFMic9pb6V4rIOG2pKLSDi6Rf3riOVem QLCkpjlB+D02ofyYOy8meaR0i9n+nk+gISSX2dyFilEHXkOudsStdx2ovGW5CoeciLAD h+jI4VVYLL6fy1iIQKnrHtMjBlxIoMBn5H+7jJm05Ifyx+SiqIdPXqjEdRvAOf/27/9C +LHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=QAiE/eKbkOat13BRz4fptI+M/Apebmd/oEEZ29NTEC4=; b=Nfr9KVkaFXDNkmkyZSvGV0PlPAxKX0NJtQznQwuKfbL8PpMqHEUwA7ERSwLYsZSGhb vbIQS/65+9B5zzI0cUzn6pPmAQAXscIAs2+aUFqfy89qw3HCAt6Vur3xAhXYb7lfiqbI RSTXWarHKX6qZRguXSEJg1hyhExi5AHI9iwHXZqDKuOkwGbsrHqprqN+I9dOVbV/ldr5 gEcXrenMGWCvwn9LSgGxqsFDAp+E45+hc0GsnDP1qExA0IBBVqwgQOD8vY7Xab7OYPPH nBxldUFv4yYvlZ5uwEFiVXRqjY0eQwHkVAlQJxGja5qozEmmvpMW++iuxZfyKFj2DQex TmjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=13gz6Scm; 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 g1-v6si6815019plt.77.2018.09.14.07.04.25; Fri, 14 Sep 2018 07:04:42 -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; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=13gz6Scm; 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 S1728010AbeINTSo (ORCPT + 99 others); Fri, 14 Sep 2018 15:18:44 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:44301 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727013AbeINTSo (ORCPT ); Fri, 14 Sep 2018 15:18:44 -0400 Received: by mail-pg1-f195.google.com with SMTP id r1-v6so4449324pgp.11 for ; Fri, 14 Sep 2018 07:04:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=QAiE/eKbkOat13BRz4fptI+M/Apebmd/oEEZ29NTEC4=; b=13gz6ScmzXw1Ek7Zc1O59cxv914cku+xzFCCI97/u0CSlp2s5ygBfNgMR5BdgouNeL EYvhf4LfdRqiwrNj3OSl3Ly6TG76o687zD+GpalsAj/wY2nPxUAXN3iJR2MqkNOc5Lnu JZNd1u75ZI3z5k1ahZpwLpDfvV1wgDsM0tKRHYrB5I4hAAwK2m+BvAonyz3A+A40psV5 SDiJTId9XL3DJX0QOIYODBlib/pTD3CTW8m8azGzHhEsuOQecR5FcS6Lj84CLBK7Rzfy kYYzyYDSFU/As6iovQBOxN/MF+yvhqy1dz8UoJjVNDTpS8RfDFISxQdjZxrWh+xK0HOg XMTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=QAiE/eKbkOat13BRz4fptI+M/Apebmd/oEEZ29NTEC4=; b=LdbCUmgOwHaGTgl+UaWqF0k4Q7ziX3izrisarLvsJOsx/Ho5+OuLpzzYMH0qH7rDV1 UWhQZ7fQ8LPTT/xKWvOmjLPmzGOX0q6O0JTXS/gCfE8Sgjp+f5bM1t4M1fbAu3+Yv7fl GELsdDybUNUFH2hqIthw+aO0dLVWeMgk1UeOJ36Q08KednTWmbggcqKBEjcZbhiLywFo uOzKbG1EYV1pCuCvMiv6hNTsmK0oJWVfhblNM2DM6yDGgUbTFbQNEOEBjx39ZJ6ok8UI 6wyxPl8I3qB0FOlR7VZChph0rPXHLW0iNmFWLx/THG8OEvGkcFwNb9hOfrAKKRmOrcI5 5uug== X-Gm-Message-State: APzg51A/EmAFR3kvMAI1qHN9HzurGmf/ooQC8Q9ug5hrA78Edx/NvQo0 86Aig2nPx242+9qXPXS2X4yFSz99fxU= X-Received: by 2002:a63:fd52:: with SMTP id m18-v6mr12144802pgj.304.1536933844727; Fri, 14 Sep 2018 07:04:04 -0700 (PDT) Received: from [192.168.0.239] (c-71-202-137-17.hsd1.ca.comcast.net. [71.202.137.17]) by smtp.gmail.com with ESMTPSA id p73-v6sm11595309pfk.186.2018.09.14.07.04.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 07:04:03 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (1.0) Subject: Re: [patch 11/11] x66/vdso: Add CLOCK_TAI support From: Andy Lutomirski X-Mailer: iPhone Mail (15G77) In-Reply-To: <20180914125119.081037164@linutronix.de> Date: Fri, 14 Sep 2018 07:04:02 -0700 Cc: LKML , 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 Content-Transfer-Encoding: quoted-printable Message-Id: References: <20180914125006.349747096@linutronix.de> <20180914125119.081037164@linutronix.de> To: Thomas Gleixner Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Sep 14, 2018, at 5:50 AM, Thomas Gleixner wrote: >=20 > 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: >=20 > - 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 >=20 > Add the mask to the basetime array lookup and set up the CLOCK_TAI base > time in update_vsyscall(). That=E2=80=99s... horrible. In an amazing way. Can you add BUILD_BUG_ON some= where to assert that this actually works? >=20 > The performance impact of the mask operation is within the noise. >=20 > 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(-) >=20 > --- 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 >=20 > notrace static int do_hres(clockid_t clk, struct timespec *ts) > { > - struct vgtod_ts *base =3D >od->basetime[clk]; > + struct vgtod_ts *base =3D >od->basetime[clk & VGTOD_HRES_MASK]; > u64 cycles, last, ns; > unsigned int seq; >=20 > --- 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 =3D tk->xtime_sec; > base->nsec =3D tk->tkr_mono.xtime_nsec; >=20 > + base =3D &vdata->basetime[VGTOD_TAI]; > + base->sec =3D tk->xtime_sec + (s64)tk->tai_offset; > + base->nsec =3D tk->tkr_mono.xtime_nsec; > + > base =3D &vdata->basetime[CLOCK_MONOTONIC]; > base->sec =3D tk->xtime_sec + tk->wall_to_monotonic.tv_sec; > nsec =3D 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 { > }; >=20 > #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(C= LOCK_TAI)) > #define VGTOD_COARSE (BIT(CLOCK_REALTIME_COARSE) | BIT(CLOCK_MONOTONIC_= COARSE)) >=20 > +/* 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 t= ime > * so be carefull by modifying this structure. >=20 >=20