Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2209837imm; Thu, 19 Jul 2018 15:29:24 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfvBVNR7VYXvYDbwB5S647jQSdyENOjKaj4FgVCDNt8e4dgj4DyGlJMmhtvH4YYdAb+NPP9 X-Received: by 2002:a63:e452:: with SMTP id i18-v6mr11525954pgk.185.1532039364034; Thu, 19 Jul 2018 15:29:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532039364; cv=none; d=google.com; s=arc-20160816; b=mqNqu+hJjEpfg9GfKm2KrPDiHKU0fcuF1IfOtSm/w9llPPTEZWcAUcPSKee0PZlO+g yubWdkTa5K+KGAnr7bY8+WJITD0hk0gTiqnHi4awPMiSXI3sLT9fBxB8XKgm1o0CgR00 vX9eF6kUgtMcGKVscJHssdd9EhPrZwE6RNh0auhB4iahNdYBPrTBbta9/zXz65YO2XRK XNuOKuzd0w7UdCzXlrleCaPIrbg+IRoIX1biM3vd/9jYu7meePNKOxMKKZuDvzvkfoz2 OVy1weX2nybiqvUCsEBdXek9fN54Lv8DhT2QuUrY2v4RHd1UPUUtD0ruzjsAT7lwpzue S8eQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=g24WFiayLHLrVCz8cERDktaeNq2zb8xN7SlhK6wa/QE=; b=DirAozf4v8+laZZ2mCiqXa7OM0HP7JsCnsRr4PSuEkgxQTScVx6Pd7dHwFzx2vc7or E81FT1xZbnRWw+zr+z2FsUcd/N1xqN7K7yxzFaLlkfP9OYs0DNGMz2C+W8yFmeZt23hd ClNEDhpj4gnXcobhaejf3ww3Nunb12xw7UyR1jk3jF8RCWWihzNiEMKJezxvHOXD+eI3 +gmWEM/hqbUChyCqQBvBCIbkmGGfukBvSn7PC+RaxXor5zI4zm0CFp6l6iunqImnC57A AWr3tkFiFD53y7YmuhShVv4mqvZo5IyCkBO/Lgq3pePmI0g4IP8MurnnjcG/mMn1Hw8H yyqQ== 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 n59-v6si257009plb.198.2018.07.19.15.29.09; Thu, 19 Jul 2018 15:29:23 -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 S1731442AbeGSXN2 (ORCPT + 99 others); Thu, 19 Jul 2018 19:13:28 -0400 Received: from terminus.zytor.com ([198.137.202.136]:43521 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727772AbeGSXN2 (ORCPT ); Thu, 19 Jul 2018 19:13:28 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w6JMSD972439185 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 19 Jul 2018 15:28:13 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w6JMSD2R2439182; Thu, 19 Jul 2018 15:28:13 -0700 Date: Thu, 19 Jul 2018 15:28:13 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Pavel Tatashin Message-ID: Cc: hpa@zytor.com, pasha.tatashin@oracle.com, linux-kernel@vger.kernel.org, mingo@kernel.org, tglx@linutronix.de Reply-To: hpa@zytor.com, pasha.tatashin@oracle.com, linux-kernel@vger.kernel.org, mingo@kernel.org, tglx@linutronix.de In-Reply-To: <20180719205545.16512-14-pasha.tatashin@oracle.com> References: <20180719205545.16512-14-pasha.tatashin@oracle.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/timers] x86/xen/time: Output xen sched_clock time from 0 Git-Commit-ID: 38669ba205d178d2d38bfd194a196d65a44d5af2 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 38669ba205d178d2d38bfd194a196d65a44d5af2 Gitweb: https://git.kernel.org/tip/38669ba205d178d2d38bfd194a196d65a44d5af2 Author: Pavel Tatashin AuthorDate: Thu, 19 Jul 2018 16:55:32 -0400 Committer: Thomas Gleixner CommitDate: Fri, 20 Jul 2018 00:02:40 +0200 x86/xen/time: Output xen sched_clock time from 0 It is expected for sched_clock() to output data from 0, when system boots. Add an offset xen_sched_clock_offset (similarly how it is done in other hypervisors i.e. kvm_sched_clock_offset) to count sched_clock() from 0, when time is first initialized. Signed-off-by: Pavel Tatashin Signed-off-by: Thomas Gleixner Cc: steven.sistare@oracle.com Cc: daniel.m.jordan@oracle.com Cc: linux@armlinux.org.uk Cc: schwidefsky@de.ibm.com Cc: heiko.carstens@de.ibm.com Cc: john.stultz@linaro.org Cc: sboyd@codeaurora.org Cc: hpa@zytor.com Cc: douly.fnst@cn.fujitsu.com Cc: peterz@infradead.org Cc: prarit@redhat.com Cc: feng.tang@intel.com Cc: pmladek@suse.com Cc: gnomes@lxorguk.ukuu.org.uk Cc: linux-s390@vger.kernel.org Cc: boris.ostrovsky@oracle.com Cc: jgross@suse.com Cc: pbonzini@redhat.com Link: https://lkml.kernel.org/r/20180719205545.16512-14-pasha.tatashin@oracle.com --- arch/x86/xen/time.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c index 53bb7a8d10b5..c84f1e039d84 100644 --- a/arch/x86/xen/time.c +++ b/arch/x86/xen/time.c @@ -31,6 +31,8 @@ /* Xen may fire a timer up to this many ns early */ #define TIMER_SLOP 100000 +static u64 xen_sched_clock_offset __read_mostly; + /* Get the TSC speed from Xen */ static unsigned long xen_tsc_khz(void) { @@ -57,6 +59,11 @@ static u64 xen_clocksource_get_cycles(struct clocksource *cs) return xen_clocksource_read(); } +static u64 xen_sched_clock(void) +{ + return xen_clocksource_read() - xen_sched_clock_offset; +} + static void xen_read_wallclock(struct timespec64 *ts) { struct shared_info *s = HYPERVISOR_shared_info; @@ -367,7 +374,7 @@ void xen_timer_resume(void) } static const struct pv_time_ops xen_time_ops __initconst = { - .sched_clock = xen_clocksource_read, + .sched_clock = xen_sched_clock, .steal_clock = xen_steal_clock, }; @@ -505,6 +512,7 @@ static void __init xen_time_init(void) void __init xen_init_time_ops(void) { + xen_sched_clock_offset = xen_clocksource_read(); pv_time_ops = xen_time_ops; x86_init.timers.timer_init = xen_time_init; @@ -546,6 +554,7 @@ void __init xen_hvm_init_time_ops(void) return; } + xen_sched_clock_offset = xen_clocksource_read(); pv_time_ops = xen_time_ops; x86_init.timers.setup_percpu_clockev = xen_time_init; x86_cpuinit.setup_percpu_clockev = xen_hvm_setup_cpu_clockevents;