Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751805AbdH3PZU (ORCPT ); Wed, 30 Aug 2017 11:25:20 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:20863 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751435AbdH3PZN (ORCPT ); Wed, 30 Aug 2017 11:25:13 -0400 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 v5 4/6] tsc: implement the extended tsc reading function Date: Wed, 30 Aug 2017 18:23:46 +0300 Message-Id: <1504106628-172372-5-git-send-email-dplotnikov@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1504106628-172372-1-git-send-email-dplotnikov@virtuozzo.com> References: <1504106628-172372-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