Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752825AbdHBO5v (ORCPT ); Wed, 2 Aug 2017 10:57:51 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:23226 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752278AbdHBO5u (ORCPT ); Wed, 2 Aug 2017 10:57:50 -0400 X-Greylist: delayed 1099 seconds by postgrey-1.27 at vger.kernel.org; Wed, 02 Aug 2017 10:57:50 EDT From: Denis Plotnikov To: pbonzini@redhat.com, rkrcmar@redhat.com, kvm@vger.kernel.org, john.stultz@linaro.org, tglx@linutronix.de Cc: mingo@redhat.com, hpa@zytor.com, linux-kernel@vger.kernel.org, x86@kernel.org, rkagan@virtuozzo.com, den@virtuozzo.com Subject: [PATCH v4 04/10] tsc: implement the extended tsc reading function Date: Wed, 2 Aug 2017 17:38:04 +0300 Message-Id: <1501684690-211093-5-git-send-email-dplotnikov@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1501684690-211093-1-git-send-email-dplotnikov@virtuozzo.com> References: <1501684690-211093-1-git-send-email-dplotnikov@virtuozzo.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1276 Lines: 41 By doing that, add tsc clocksource to a list of KVM clocksources providing valid cycle values, meaning that KVM can use its masterclock. This is a part of the work aiming to move to a more simple scheme of masterclock related values calculation in KVM. Signed-off-by: Denis Plotnikov --- arch/x86/kernel/tsc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index 796d96b..8786454 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -1036,6 +1036,15 @@ static void tsc_cs_tick_stable(struct clocksource *cs) sched_clock_tick_stable(); } +static bool tsc_read_with_stamp(struct clocksource *cs, + u64 *cycles, u64 *cycles_stamp) +{ + u64 tsc = read_tsc(cs); + *cycles = tsc; + *cycles_stamp = tsc; + return true; +} + /* * .mask MUST be CLOCKSOURCE_MASK(64). See comment above read_tsc() */ @@ -1043,6 +1052,7 @@ static struct clocksource clocksource_tsc = { .name = "tsc", .rating = 300, .read = read_tsc, + .read_with_stamp = tsc_read_with_stamp, .mask = CLOCKSOURCE_MASK(64), .flags = CLOCK_SOURCE_IS_CONTINUOUS | CLOCK_SOURCE_MUST_VERIFY, -- 2.7.4