Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2140712imm; Thu, 19 Jul 2018 14:01:18 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeG0yBKDFRQUcBu5ahFNIgM0mUM6kSxRkJpe8reoCYJsyGtWUkZDvm6BPOzv+HP8fxOQJD6 X-Received: by 2002:a63:f756:: with SMTP id f22-v6mr11221532pgk.289.1532034078809; Thu, 19 Jul 2018 14:01:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532034078; cv=none; d=google.com; s=arc-20160816; b=K0LrP/dwwULjTbGPgT2stUXyn2CqHqtVffoF3aaESIBV0ZOz610N6NBTshcRrOi4rp xuvcIglzjjonVmT7S2h137QPlDkDx4jHiwNmMSjTx5fd2e79BudjgUla53wR5WBdiUg2 AQnMeM/7gGHq9GUku6IutxY8Y0v5KChysfXzCchxiqhdaUHBd+qk3Kz2ZeyC8xUTWYXZ op8E84v3jpfq40jTyTo5yk8ruvP08hwiThLc2W1sJJtvWcrw/jJP6WYGBiOOvgsx9gbF /B4fi+4bOCFUUMGuBtGDHpF5sDxOLaqp2xYjbrr3gYUBVDbHZotOvlIWlZc7YBZhx1Xn 3A8Q== 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:to:from:dkim-signature:arc-authentication-results; bh=tshUoFr4CF2/YIpccNrLunFVFRAcabeC66sl3Y0agWU=; b=dAR4m9+8g8scmK04KnyraGlaTS3523EGo2AKTvzbY3BAUkHuFYIgXEhHQg1TkUqhvh N9ZdR/iXaXaON/MhSmM/Kk+6/fUnhx2J3Z959A+nSLD3acieZ8hu9HmGddwd9HhfZrVA Kptb+8241hsd2En694ZsG7kM0NFtQ9+6+/xBOJBDtB0R6C0Vkzyne5qpbWLnSso2BNSY jpYsEdJHeXbStDjl7cdQ86GFEtQPxQgUgna0OIwtLxvjg0QYtY1CGvK0tzQ8GrwcY+GS itQoXuaRScMb4GqCowUp18+7DG06XkfaFu/OCYUpk9jZ8JGzJdzkYv6f/z1ugDS/NIqt 97bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=0NXMM0dM; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n34-v6si146006pld.99.2018.07.19.14.01.03; Thu, 19 Jul 2018 14:01:18 -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=@oracle.com header.s=corp-2018-07-02 header.b=0NXMM0dM; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731356AbeGSVmS (ORCPT + 99 others); Thu, 19 Jul 2018 17:42:18 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:45274 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731069AbeGSVmR (ORCPT ); Thu, 19 Jul 2018 17:42:17 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w6JKs6hR191519; Thu, 19 Jul 2018 20:56:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=tshUoFr4CF2/YIpccNrLunFVFRAcabeC66sl3Y0agWU=; b=0NXMM0dMba1EZtG1toxZkcNH0cuZwAU+YJjX296r7OyHyMsJmmnsDSyao2kP3xFRpPcj O4A4QR4B3ya5CnJlu1fkm+7djqiMkhCzmYFBKPyqjGBfDB2Z0VEx/vbpUfCcFjZB0sv0 y9GWDaS/Rei1BIpzH2rdKio9+RaNDrAM9N0Ihysi7fs43KehAMFMxn41+i+7/U4JxhaO nqFuuCNNWP7wAa2K0ihZDjL8DU40jMC/dkdVZdqQluJQwc4d2hcnywMkT7AOGu0gDRmz p4pRsJmqqIFtAWnhB1R9TH/96XyddAod+d0V4JzVWv/4klDuSp5pKQ6FKSwRSUThJJdy Kg== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2k9yjgrufn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 19 Jul 2018 20:56:38 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w6JKubtq013293 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 19 Jul 2018 20:56:37 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w6JKuaqO027519; Thu, 19 Jul 2018 20:56:36 GMT Received: from localhost.localdomain (/73.69.118.222) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 19 Jul 2018 20:56:35 +0000 From: Pavel Tatashin To: steven.sistare@oracle.com, daniel.m.jordan@oracle.com, linux@armlinux.org.uk, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, john.stultz@linaro.org, sboyd@codeaurora.org, x86@kernel.org, linux-kernel@vger.kernel.org, mingo@redhat.com, tglx@linutronix.de, hpa@zytor.com, douly.fnst@cn.fujitsu.com, peterz@infradead.org, prarit@redhat.com, feng.tang@intel.com, pmladek@suse.com, gnomes@lxorguk.ukuu.org.uk, linux-s390@vger.kernel.org, pasha.tatashin@oracle.com, boris.ostrovsky@oracle.com, jgross@suse.com, pbonzini@redhat.com Subject: [PATCH v15 13/26] x86/xen/time: output xen sched_clock time from 0 Date: Thu, 19 Jul 2018 16:55:32 -0400 Message-Id: <20180719205545.16512-14-pasha.tatashin@oracle.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180719205545.16512-1-pasha.tatashin@oracle.com> References: <20180719205545.16512-1-pasha.tatashin@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8959 signatures=668706 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807190218 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; -- 2.18.0