From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932195AbcGFNDN (ORCPT ); Wed, 6 Jul 2016 09:03:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54618 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754415AbcGFNDG (ORCPT ); Wed, 6 Jul 2016 09:03:06 -0400 Subject: Re: [RFC PATCH] x86, kvm: use kvmclock to compute TSC deadline value To: Andy Lutomirski References: <1467740167-87171-1-git-send-email-pbonzini@redhat.com> Cc: Eduardo Habkost , Radim Krcmar , Peter Hornyack , David Matlack , "linux-kernel@vger.kernel.org" , kvm list From: Paolo Bonzini Message-ID: <023f49ec-df7a-f196-86da-976a8a22d77e@redhat.com> Date: Wed, 6 Jul 2016 15:03:01 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 06 Jul 2016 13:03:05 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/07/2016 15:01, Andy Lutomirski wrote: > On Jul 5, 2016 1:36 PM, "Paolo Bonzini" wrote: >> >> Bad things happen if a guest using the TSC deadline timer is migrated. >> The guest doesn't re-calibrate the TSC after migration, and the >> TSC frequency can and will change unless your processor supports TSC >> scaling (on Intel this is only Skylake) or your data center is perfectly >> homogeneous. >> >> The solution in this patch is to skip tsc_khz, and instead derive the >> frequency from kvmclock's (mult, shift) pair. Because kvmclock >> parameters convert from tsc to nanoseconds, this needs a division >> but that's the least of our problems when the TSC_DEADLINE_MSR write >> costs 2000 clock cycles. Luckily tsc_khz is really used by very little >> outside the tsc clocksource (which kvmclock replaces) and the TSC >> deadline timer. > > I'm wondering if it would be more straightforward to blacklist the > APIC timer entirely (on KVM guests that have the TSC deadline > capability) and to instead offer a paravirt clockevent that still uses > the deadline timer under the hood. After all, these systems should be > mostly quirk-free, so I imagine that the whole implementation would > only be a few lines of code. Very good idea! Paolo