Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5681085yba; Thu, 11 Apr 2019 03:31:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6nZf2FZgLSOah9VP2ot4KnccnNSj8pW6R2M+6YQxqz74OgYl52yGvovf1IK0qw1Y93VBN X-Received: by 2002:a63:2aca:: with SMTP id q193mr45938886pgq.269.1554978707069; Thu, 11 Apr 2019 03:31:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554978707; cv=none; d=google.com; s=arc-20160816; b=Ni1OpzimR+S6MVDewLMWDrFLPFISejtzccPbvym5byCB5HAHxrDpZMX14kikpaC8n9 +IE3sje8d+e00d6nFhYmCn0zWXrbobOpCeg2noroCjqpoDx4ksMfe4p+ljDtkp9cZbXd z4oqVvmREdC3bfojuB7LPJ9VIc5/fkOO88VFxbWTpzNjJ0jhieqCraQYNcpXVYJJjW5w jBB5xReIGZ+pAm9FcIXoZ+IrY0O4gH1V1lu7fVIpvwRG0m9XNUmb1mx+VLCftKX+xUx2 7RQmQx/3HMEfOef/9duRg0+u/6Lrl+cLisaQVf25b7R6klhS/SrJGFWnOj+Z5Ihq732P RliA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=fiZwMOxZNP1T8poRh7ieIncoauGMz7Ca4oi6t3rzcg8=; b=DVzrw2jkPVBXjNRoezqCRyCxmzcteBEjnwNLwarf2rS5XOZ+Qx050CVgIcJ5se/8q8 hErVO01eCoRACfRtZxCBMLb1qtEWHxYdoN8Uox2g2g9k+5Vkw1A7dJjeV5XvUk8yFUTa ygLrrbdJ9jQghF9I2a3uUJ5cPL8voOXgu74jghtY09gZpQiPIIFWuarWNMZebexwxMRK utAshTqIczIYl+Eu4nxVIKP7a6s51PWa+QgXzRPHgGjEuE33t3DQvvdX1/LugZi9mDGf n0cT9XMjT/lkwp4FE8kh/mrFXRSH8pA7dzwJp+T8OBRKm5sr4ReBxzIUvDZoRq1A6xXr AwSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@codeweavers.com header.s=6377696661 header.b="elk2/kKB"; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codeweavers.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u8si12436356pgn.456.2019.04.11.03.31.30; Thu, 11 Apr 2019 03:31: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; dkim=fail (test mode) header.i=@codeweavers.com header.s=6377696661 header.b="elk2/kKB"; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codeweavers.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726716AbfDKKav (ORCPT + 99 others); Thu, 11 Apr 2019 06:30:51 -0400 Received: from mail.codeweavers.com ([173.240.25.211]:55692 "EHLO mail.codeweavers.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726391AbfDKKat (ORCPT ); Thu, 11 Apr 2019 06:30:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codeweavers.com; s=6377696661; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=fiZwMOxZNP1T8poRh7ieIncoauGMz7Ca4oi6t3rzcg8=; b=elk2/kKBI9Nmr+IbPOGs8UQQT 7agj4B27liDCjJUHzqYU5RmJQIWzEbucuYkLb7MWsjj+ZQBpHb/Jur4Zok0VUwpeg44VFlAFhUIl8 Q8/HKrKRBzw6AoyMi7wt0418rW4UbDumgsX30D+ISSY1aMRWkTW7xirGfCR1VBIHlPagE=; Received: from vpn42.vpn.mn.codeweavers.com ([10.69.139.42] helo=merlot) by mail.codeweavers.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hEWgi-0000mx-TY; Thu, 11 Apr 2019 05:12:10 -0500 Received: from daviesh by merlot with local (Exim 4.90_1) (envelope-from ) id 1hEWgf-0002cu-9K; Thu, 11 Apr 2019 11:12:05 +0100 From: Huw Davies To: linux kernel Cc: Thomas Gleixner , Andy Lutomirski Subject: [PATCH 2/3] x86/vdso: Allow clock specific mult and shift values Date: Thu, 11 Apr 2019 11:12:04 +0100 Message-Id: <20190411101205.10006-3-huw@codeweavers.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190411101205.10006-1-huw@codeweavers.com> References: <20190411101205.10006-1-huw@codeweavers.com> X-Spam-Score: -106.0 X-Spam-Report: Spam detection software, running on the system "mail.codeweavers.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: This will allow clocks with different mult and shift values, e.g. CLOCK_MONOTONIC_RAW, to be supported in the vDSO. The coarse clocks do not require these data so the values are not copied for these clocks. Content analysis details: (-106.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -100 USER_IN_WHITELIST From: address is in the user's white-list -6.0 ALL_TRUSTED Passed through trusted hosts only via SMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This will allow clocks with different mult and shift values, e.g. CLOCK_MONOTONIC_RAW, to be supported in the vDSO. The coarse clocks do not require these data so the values are not copied for these clocks. One could add potential new values of mult and shift alongside the existing values in struct vsyscall_gtod_data, but it seems more natural to group them with the actual clock data in the basetime array at the expense of a few more cycles in update_vsyscall(). Cc: Thomas Gleixner Cc: Andy Lutomirski Signed-off-by: Huw Davies --- arch/x86/entry/vdso/vclock_gettime.c | 4 ++-- arch/x86/entry/vsyscall/vsyscall_gtod.c | 8 ++++++-- arch/x86/include/asm/vgtod.h | 6 +++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/arch/x86/entry/vdso/vclock_gettime.c b/arch/x86/entry/vdso/vclock_gettime.c index 007b3fe9d727..a4199b846d77 100644 --- a/arch/x86/entry/vdso/vclock_gettime.c +++ b/arch/x86/entry/vdso/vclock_gettime.c @@ -153,8 +153,8 @@ notrace static int do_hres(clockid_t clk, struct timespec *ts) if (unlikely((s64)cycles < 0)) return vdso_fallback_gettime(clk, ts); if (cycles > last) - ns += (cycles - last) * gtod->mult; - ns >>= gtod->shift; + ns += (cycles - last) * base->mult; + ns >>= base->shift; sec = base->sec; } while (unlikely(gtod_read_retry(gtod, seq))); diff --git a/arch/x86/entry/vsyscall/vsyscall_gtod.c b/arch/x86/entry/vsyscall/vsyscall_gtod.c index e4ee83018279..ddc6a71df87c 100644 --- a/arch/x86/entry/vsyscall/vsyscall_gtod.c +++ b/arch/x86/entry/vsyscall/vsyscall_gtod.c @@ -43,16 +43,18 @@ void update_vsyscall(struct timekeeper *tk) /* copy vsyscall data */ vdata->vclock_mode = vclock_mode; vdata->cycle_last = tk->tkr_mono.cycle_last; - vdata->mult = tk->tkr_mono.mult; - vdata->shift = tk->tkr_mono.shift; base = &vdata->basetime[CLOCK_REALTIME]; base->sec = tk->xtime_sec; base->nsec = tk->tkr_mono.xtime_nsec; + base->mult = tk->tkr_mono.mult; + base->shift = tk->tkr_mono.shift; base = &vdata->basetime[CLOCK_TAI]; base->sec = tk->xtime_sec + (s64)tk->tai_offset; base->nsec = tk->tkr_mono.xtime_nsec; + base->mult = tk->tkr_mono.mult; + base->shift = tk->tkr_mono.shift; base = &vdata->basetime[CLOCK_MONOTONIC]; base->sec = tk->xtime_sec + tk->wall_to_monotonic.tv_sec; @@ -63,6 +65,8 @@ void update_vsyscall(struct timekeeper *tk) base->sec++; } base->nsec = nsec; + base->mult = tk->tkr_mono.mult; + base->shift = tk->tkr_mono.shift; base = &vdata->basetime[CLOCK_REALTIME_COARSE]; base->sec = tk->xtime_sec; diff --git a/arch/x86/include/asm/vgtod.h b/arch/x86/include/asm/vgtod.h index daf69a25e46b..ae0d76491595 100644 --- a/arch/x86/include/asm/vgtod.h +++ b/arch/x86/include/asm/vgtod.h @@ -20,11 +20,13 @@ typedef unsigned long gtod_long_t; * clocks, this encodes the actual time. * * To confuse the reader, for high-resolution clocks, nsec is left-shifted - * by vsyscall_gtod_data.shift. + * by shift. */ struct vgtod_ts { u64 sec; u64 nsec; + u32 mult; + u32 shift; }; #define VGTOD_BASES (CLOCK_TAI + 1) @@ -40,8 +42,6 @@ struct vsyscall_gtod_data { int vclock_mode; u64 cycle_last; - u32 mult; - u32 shift; struct vgtod_ts basetime[VGTOD_BASES]; -- 2.17.1