From patchwork Thu Jun 9 12:01:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9166901 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 570B160467 for ; Thu, 9 Jun 2016 12:04:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4660F20855 for ; Thu, 9 Jun 2016 12:04:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3ABB728345; Thu, 9 Jun 2016 12:04:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D96AE20855 for ; Thu, 9 Jun 2016 12:04:04 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bAyeL-0002qE-2L; Thu, 09 Jun 2016 12:01:25 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bAyeK-0002q6-3M for xen-devel@lists.xenproject.org; Thu, 09 Jun 2016 12:01:24 +0000 Received: from [85.158.139.211] by server-3.bemta-5.messagelabs.com id 0F/2A-15735-39A59575; Thu, 09 Jun 2016 12:01:23 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrAIsWRWlGSWpSXmKPExsXS6fjDS3dSVGS 4weEXahbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8baTWuZCnapVXz8eJytgXG9QhcjJ4eQQJ5E 9/OrLCA2r4CdxI7TW5hAbAkBQ4l981exgdgsAqoSj2bMZgSx2QTUJdqebWftYuTgEBEwkDh3N KmLkYuDWWADo8Ti/g/sIDXCAgkS1z49ZwKp4RUQlPi7QxgkzAw0/urZFuYJjFyzEDKzkGQgbC 2Jh79usUDY2hLLFr5mBilnFpCWWP6PAyJsL/GgYQozphIvie9nnRYwcqxiVC9OLSpLLdI11Es qykzPKMlNzMzRNTQw1ctNLS5OTE/NSUwq1kvOz93ECAy9egYGxh2MTb3OhxglOZiURHmfWEeG C/El5adUZiQWZ8QXleakFh9i1ODgENi2a/UFRimWvPy8VCUJ3p2RQHWCRanpqRVpmTnA6IApl eDgURLhTQRJ8xYXJOYWZ6ZDpE4xKkqJ85aDJARAEhmleXBtsIi8xCgrJczLyMDAIMRTkFqUm1 mCKv+KUZyDUUmYdzHIFJ7MvBK46a+AFjMBLV5+JBxkcUkiQkqqgbH9r0dFfMHJuo+XX32cq8u R9qT1yhF1kdCy4ilsxy6kXXjZrM9lJr9I9neUxJabeyS3fL9Ve+dS5yyt18fVfp9vZj7d8arz lFKy1WkH44PFJyeeFBPy+M5oWnah3WT2jD0xzwu1T99f6Jz9n8H+oZhE4Pbc5P0qLJyFVyR2c 31VkFjxMLVy7X8lluKMREMt5qLiRACqrv86wwIAAA== X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-13.tower-206.messagelabs.com!1465473680!34832237!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31401 invoked from network); 9 Jun 2016 12:01:22 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-13.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 9 Jun 2016 12:01:22 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Thu, 09 Jun 2016 06:01:19 -0600 Message-Id: <575976AE02000078000F3695@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.0 Date: Thu, 09 Jun 2016 06:01:18 -0600 From: "Jan Beulich" To: "xen-devel" Mime-Version: 1.0 Cc: Andrew Cooper , Joao Martins , Wei Liu , Dario Faggioli Subject: [Xen-devel] [PATCH] x86/time: use correct (local) time stamp in constant-TSC calibration fast path X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This looks like a copy and paste mistake in commit 1b6a99892d ("x86: Simpler time handling when TSC is constant across all power saving states"), responsible for occasional many-microsecond cross-CPU skew of what NOW() returns. Also improve the correlation between local TSC and stime stamps obtained at the end of the two calibration handlers: Compute the stime one from the TSC one, instead of doing another rdtsc() for that compuation. Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper --- As to 4.7 inclusion: This of course looks like a pretty blatant mistake that has been there for many years (and hence many releases). There's certainly non-zero risk that I'm overlooking something here (despite Joao apparently having come to the same conclusion), so I can't really make up my mind on whether to request this patch to be put there right away, or rather having linger in -unstable for a while. x86/time: use correct (local) time stamp in constant-TSC calibration fast path This looks like a copy and paste mistake in commit 1b6a99892d ("x86: Simpler time handling when TSC is constant across all power saving states"), responsible for occasional many-microsecond cross-CPU skew of what NOW() returns. Also improve the correlation between local TSC and stime stamps obtained at the end of the two calibration handlers: Compute the stime one from the TSC one, instead of doing another rdtsc() for that compuation. Signed-off-by: Jan Beulich --- As to 4.7 inclusion: This of course looks like a pretty blatant mistake that has been there for many years (and hence many releases). There's certainly non-zero risk that I'm overlooking something here (despite Joao apparently having come to the same conclusion), so I can't really make up my mind on whether to request this patch to be put there right away, or rather having linger in -unstable for a while. --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -998,7 +998,7 @@ static void local_time_calibration(void) /* Atomically read cpu_calibration struct and write cpu_time struct. */ local_irq_disable(); t->local_tsc_stamp = c->local_tsc_stamp; - t->stime_local_stamp = c->stime_master_stamp; + t->stime_local_stamp = c->stime_local_stamp; t->stime_master_stamp = c->stime_master_stamp; local_irq_enable(); update_vcpu_system_time(current); @@ -1275,7 +1275,7 @@ static void time_calibration_tsc_rendezv } c->local_tsc_stamp = rdtsc(); - c->stime_local_stamp = get_s_time(); + c->stime_local_stamp = get_s_time_fixed(c->local_tsc_stamp); c->stime_master_stamp = r->master_stime; raise_softirq(TIME_CALIBRATE_SOFTIRQ); @@ -1305,7 +1305,7 @@ static void time_calibration_std_rendezv } c->local_tsc_stamp = rdtsc(); - c->stime_local_stamp = get_s_time(); + c->stime_local_stamp = get_s_time_fixed(c->local_tsc_stamp); c->stime_master_stamp = r->master_stime; raise_softirq(TIME_CALIBRATE_SOFTIRQ); --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -998,7 +998,7 @@ static void local_time_calibration(void) /* Atomically read cpu_calibration struct and write cpu_time struct. */ local_irq_disable(); t->local_tsc_stamp = c->local_tsc_stamp; - t->stime_local_stamp = c->stime_master_stamp; + t->stime_local_stamp = c->stime_local_stamp; t->stime_master_stamp = c->stime_master_stamp; local_irq_enable(); update_vcpu_system_time(current); @@ -1275,7 +1275,7 @@ static void time_calibration_tsc_rendezv } c->local_tsc_stamp = rdtsc(); - c->stime_local_stamp = get_s_time(); + c->stime_local_stamp = get_s_time_fixed(c->local_tsc_stamp); c->stime_master_stamp = r->master_stime; raise_softirq(TIME_CALIBRATE_SOFTIRQ); @@ -1305,7 +1305,7 @@ static void time_calibration_std_rendezv } c->local_tsc_stamp = rdtsc(); - c->stime_local_stamp = get_s_time(); + c->stime_local_stamp = get_s_time_fixed(c->local_tsc_stamp); c->stime_master_stamp = r->master_stime; raise_softirq(TIME_CALIBRATE_SOFTIRQ);