From patchwork Wed Sep 14 17:37:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 9332187 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 1D151607FD for ; Wed, 14 Sep 2016 17:39:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 127A22A246 for ; Wed, 14 Sep 2016 17:39:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0753F2A24F; Wed, 14 Sep 2016 17:39:16 +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, UNPARSEABLE_RELAY 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 ED4902A246 for ; Wed, 14 Sep 2016 17:39:14 +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 1bkE7S-00018y-ND; Wed, 14 Sep 2016 17:37:10 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bkE7R-00017a-6D for xen-devel@lists.xenproject.org; Wed, 14 Sep 2016 17:37:09 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id 4D/03-21406-4CA89D75; Wed, 14 Sep 2016 17:37:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDLMWRWlGSWpSXmKPExsUyZ7p8oO7hrpv hBncPm1p83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBmzu16xFnySqvi68yFTA+M+0S5GLg4hgYlM EldPHGWGcL4wSizoWswE4WxklFg+aRc7hNPIKDFhUSNbFyMnB5uAnkTr+c/MILaIgJLEvVWTw TqYBToYJb6cP8UEkhAWcJA41vuUpYuRg4NFQFXixGVJkDCvgIfE768z2UFsCQE5ifPHf4LN4R TwlPhx4zMLiC0EVHPgwS1miBpDic8blzJPYORbwMiwilG9OLWoLLVI11QvqSgzPaMkNzEzR9f QwEwvN7W4ODE9NScxqVgvOT93EyMwVBiAYAfj9Mv+hxglOZiURHlLg2+GC/El5adUZiQWZ8QX leakFh9ilOHgUJLgndAJlBMsSk1PrUjLzAEGLUxagoNHSYT3PEiat7ggMbc4Mx0idYpRUUqc9 xFIQgAkkVGaB9cGi5RLjLJSwryMQIcI8RSkFuVmlqDKv2IU52BUEubdBDKFJzOvBG76K6DFTE CLt6y5DrK4JBEhJdXAqGW1wTh8pkg3/6UXtYd3Vqv6OhZN0KpLWTH39u+WOwt+z53IcvGjmGp Ca9t+512pV7Rfbv96Ktm1xOvG4vgVk3c39s0K+b3lX92HxEqLhU33ppfmrDyxLVV/7QT9S5ca C6qY9hreydi7rVRkw08efquZXYxrLXVjdM4zZO59mN6yMTjmX8SMv0osxRmJhlrMRcWJAH8eY pCPAgAA X-Env-Sender: joao.m.martins@oracle.com X-Msg-Ref: server-2.tower-21.messagelabs.com!1473874626!19376158!1 X-Originating-IP: [156.151.31.81] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTU2LjE1MS4zMS44MSA9PiAyODgzMzk=\n X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 6877 invoked from network); 14 Sep 2016 17:37:07 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-2.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 14 Sep 2016 17:37:07 -0000 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u8EHb35W020416 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Sep 2016 17:37:04 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.13.8) with ESMTP id u8EHb3D1020128 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 14 Sep 2016 17:37:03 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u8EHaqdN006141; Wed, 14 Sep 2016 17:36:58 GMT Received: from paddy.lan (/89.114.92.174) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 14 Sep 2016 10:36:52 -0700 From: Joao Martins To: xen-devel@lists.xenproject.org Date: Wed, 14 Sep 2016 18:37:48 +0100 Message-Id: <1473874670-4986-4-git-send-email-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1473874670-4986-1-git-send-email-joao.m.martins@oracle.com> References: <1473874670-4986-1-git-send-email-joao.m.martins@oracle.com> X-Source-IP: userv0022.oracle.com [156.151.31.74] Cc: Andrew Cooper , Joao Martins , Jan Beulich Subject: [Xen-devel] [PATCH v4 3/5] x86/time: refactor read_platform_stime() 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP To allow the caller to fetch the last read from the clocksource which was used to calculate system_time. This is a prerequisite for a subsequent patch that will use this last read. Signed-off-by: Joao Martins Acked-by: Jan Beulich --- Cc: Jan Beulich Cc: Andrew Cooper Changes since v3: - Add mention of this being a prerequisite to a later patch. --- xen/arch/x86/time.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index e5001d5..af9e31f 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -581,18 +581,22 @@ static void plt_overflow(void *unused) set_timer(&plt_overflow_timer, NOW() + plt_overflow_period); } -static s_time_t read_platform_stime(void) +static s_time_t read_platform_stime(u64 *stamp) { - u64 count; + u64 plt_counter, count; s_time_t stime; ASSERT(!local_irq_is_enabled()); spin_lock(&platform_timer_lock); - count = plt_stamp64 + ((plt_src.read_counter() - plt_stamp) & plt_mask); + plt_counter = plt_src.read_counter(); + count = plt_stamp64 + ((plt_counter - plt_stamp) & plt_mask); stime = __read_platform_stime(count); spin_unlock(&platform_timer_lock); + if ( stamp ) + *stamp = plt_counter; + return stime; } @@ -726,7 +730,7 @@ void cstate_restore_tsc(void) if ( boot_cpu_has(X86_FEATURE_NONSTOP_TSC) ) return; - write_tsc(stime2tsc(read_platform_stime())); + write_tsc(stime2tsc(read_platform_stime(NULL))); } /*************************************************************************** @@ -1045,7 +1049,7 @@ int cpu_frequency_change(u64 freq) local_irq_disable(); /* Platform time /first/, as we may be delayed by platform_timer_lock. */ - t->stamp.master_stime = read_platform_stime(); + t->stamp.master_stime = read_platform_stime(NULL); curr_tsc = rdtsc_ordered(); /* TSC-extrapolated time may be bogus after frequency change. */ /*t->stamp.local_stime = get_s_time_fixed(curr_tsc);*/ @@ -1350,7 +1354,7 @@ static void time_calibration_tsc_rendezvous(void *_r) if ( r->master_stime == 0 ) { - r->master_stime = read_platform_stime(); + r->master_stime = read_platform_stime(NULL); r->master_tsc_stamp = rdtsc_ordered(); } atomic_inc(&r->semaphore); @@ -1390,7 +1394,7 @@ static void time_calibration_std_rendezvous(void *_r) { while ( atomic_read(&r->semaphore) != (total_cpus - 1) ) cpu_relax(); - r->master_stime = read_platform_stime(); + r->master_stime = read_platform_stime(NULL); smp_wmb(); /* write r->master_stime /then/ signal */ atomic_inc(&r->semaphore); } @@ -1429,7 +1433,7 @@ void time_latch_stamps(void) unsigned long flags; local_irq_save(flags); - ap_bringup_ref.master_stime = read_platform_stime(); + ap_bringup_ref.master_stime = read_platform_stime(NULL); ap_bringup_ref.local_tsc = rdtsc_ordered(); local_irq_restore(flags); @@ -1447,7 +1451,7 @@ void init_percpu_time(void) t->tsc_scale = per_cpu(cpu_time, 0).tsc_scale; local_irq_save(flags); - now = read_platform_stime(); + now = read_platform_stime(NULL); tsc = rdtsc_ordered(); local_irq_restore(flags);