Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp8740imm; Tue, 17 Jul 2018 19:25:53 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfOv2UzgtfifJ+jf5lgqVeTMoyaMA2ZXHywVzduUYLt098O7IxbdrkRkeDfeTRwdmfXkaP7 X-Received: by 2002:a17:902:381:: with SMTP id d1-v6mr3976524pld.309.1531880753437; Tue, 17 Jul 2018 19:25:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531880753; cv=none; d=google.com; s=arc-20160816; b=Iz6bH3Da5fWgMgu5GpaTMyhae/+fYLbpUs2I8NP8vzGq5jxq9jnrrX49eocyKMyYnd zh1YYqAbq9/mduwLvCfFEur2Gs4IRbAdIIGusdO43eLJam86al/1ZXnr8fOQUiAMvuPr z1DR+75VWkGRfAAhd3qCOl3mM8ULhxjg1keqf9KN3jrJ+wGo74/y7wttzTPomJNZS9ne GS+34fJZce+MPYwmR/XJDUEsXb/MJZ1ZMdeju7L3U75MG9RofE2vnwPUHJRpvUM2ew16 8xhfZU5SuEZZfplmGu3Lxim06K6uZ+lydbZTSes5Cq1h3vhUeHj8+tvxOAcIO8QqUP/1 khlw== 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=QGTfLXRZ8s8MxzXmfGkUt2oqmOKmVimI/Iy4TcehjgQ=; b=Xza8oGHnkJ8FiZkzrVMGKc3sX5M1pLVw4Wn7Tmy1Pt2DC/Knqe0Ig8CzBgus1Xfhzu qb4IdiLwkqoZUoF9/4bMfjXuMUCF4FAKV1dlECqU0u9R/sAW1fc+m8VvVzFYMEIcXvsk SVToKGHK+4C2qQ18eswgyI/pMVKXFWxljFTzTPDHqP68SMGQkxeFMVe+19uBPxhUnvnQ 508/URwEOiUSC510lJgk9vxIFSIuagmWjKFiawxRPu0mrJxxTV34ZIxRs3MfMTlZDZV1 7wRr9nuo/x01kKAiCnLwLGqSmxNzqSgrQElbmKIalQm8SA91SwXYEf9dgoA9b/YOY4i0 9/9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=nT0+FCPi; 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 v2-v6si2138090pgt.228.2018.07.17.19.25.38; Tue, 17 Jul 2018 19:25:53 -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=nT0+FCPi; 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 S1732037AbeGRDAM (ORCPT + 99 others); Tue, 17 Jul 2018 23:00:12 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:42492 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731889AbeGRC7n (ORCPT ); Tue, 17 Jul 2018 22:59:43 -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 w6I2K2aC007743; Wed, 18 Jul 2018 02:22:56 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=QGTfLXRZ8s8MxzXmfGkUt2oqmOKmVimI/Iy4TcehjgQ=; b=nT0+FCPiBVjUsrNz7HKFM/MhzS8g37brUaDbJraf71jc1ofBrK5K6rlf8XWDC0AowypH s3pCbwRZmJ+p2SAUHWCe5/70u8pqFAYOPGprJtIwW/ktjcMnuo3Rk9kUwqHgadC4xro5 JAzCA6ZwPYn7zS7hpmWMbiVVu+C6tWzeYzeAn/YkvvS/L6Vgr8nqH7gT0fUUVwDEMuGJ koZtqOdXASUroU55d5594p5qLtPu1PunWNt6+jpH7M8hTrGI595GpDviFHFXnv4cIai6 e3P7HW9qgO6X7h8R+uySV46P5TO25aN5Xb+dfhmDg3PuNkI22BNFnrdoVJb7Cf3ykkYR GA== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2k7a3432sv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Jul 2018 02:22:56 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w6I2MtUi027997 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Jul 2018 02:22:55 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w6I2Ms2Q017601; Wed, 18 Jul 2018 02:22:54 GMT Received: from localhost.localdomain (/73.69.118.222) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 17 Jul 2018 19:22:54 -0700 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 v14 14/25] x86/xen/time: output xen sched_clock time from 0 Date: Tue, 17 Jul 2018 22:22:00 -0400 Message-Id: <20180718022211.6259-15-pasha.tatashin@oracle.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180718022211.6259-1-pasha.tatashin@oracle.com> References: <20180718022211.6259-1-pasha.tatashin@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8957 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-1807180026 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 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c index 53bb7a8d10b5..25a780d89b7a 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; -- 2.18.0