From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753388AbcKSNuw (ORCPT ); Sat, 19 Nov 2016 08:50:52 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:53759 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753223AbcKSNuU (ORCPT ); Sat, 19 Nov 2016 08:50:20 -0500 Message-Id: <20161119134017.970859287@linutronix.de> User-Agent: quilt/0.63-1 Date: Sat, 19 Nov 2016 13:47:41 -0000 From: Thomas Gleixner To: LKML Cc: Ingo Molnar , Peter Zijlstra , x86@kernel.org, Borislav Petkov , Yinghai Lu Subject: [patch 7/8] x86/tsc: Prepare warp test for TSC adjustment References: <20161119133816.633700010@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=x86-tsc--Prepare-warp-test-for-TSC-adjustment.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To allow TSC compensation cross nodes its necessary to know in which direction the TSC warp was observed. Return the maximum observed value on the calling CPU so the caller can determine the direction later. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/tsc_sync.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/arch/x86/kernel/tsc_sync.c +++ b/arch/x86/kernel/tsc_sync.c @@ -151,9 +151,9 @@ static int random_warps; * TSC-warp measurement loop running on both CPUs. This is not called * if there is no TSC. */ -static void check_tsc_warp(unsigned int timeout) +static cycles_t check_tsc_warp(unsigned int timeout) { - cycles_t start, now, prev, end; + cycles_t start, now, prev, end, cur_max_warp = 0; int i, cur_warps = 0; start = rdtsc_ordered(); @@ -194,6 +194,7 @@ static void check_tsc_warp(unsigned int if (unlikely(prev > now)) { arch_spin_lock(&sync_lock); max_warp = max(max_warp, prev - now); + cur_max_warp = max_warp; /* * Check whether this bounces back and forth. Only * one CPU should observe time going backwards. @@ -208,6 +209,7 @@ static void check_tsc_warp(unsigned int WARN(!(now-start), "Warning: zero tsc calibration delta: %Ld [max: %Ld]\n", now-start, end-start); + return cur_max_warp; } /*