Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752137AbbKIAGa (ORCPT ); Sun, 8 Nov 2015 19:06:30 -0500 Received: from mga14.intel.com ([192.55.52.115]:44704 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750849AbbKIAG2 (ORCPT ); Sun, 8 Nov 2015 19:06:28 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,264,1444719600"; d="scan'208";a="596513322" Date: Mon, 9 Nov 2015 08:06:23 +0800 From: haozhong.zhang@intel.com To: Paolo Bonzini Cc: , Gleb Natapov , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , , Joerg Roedel , Wanpeng Li , Xiao Guangrong , , Kai Huang , "Andy Lutomirski" , Subject: Re: [PATCH v2 00/12] KVM: x86: add support for VMX TSC scaling Message-ID: <20151109000623.GB27132@hzzhang-OptiPlex-9020.sh.intel.com> Mail-Followup-To: Paolo Bonzini , , Gleb Natapov , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , , Joerg Roedel , Wanpeng Li , Xiao Guangrong , , Kai Huang , "Andy Lutomirski" , References: <1445326752-8926-1-git-send-email-haozhong.zhang@intel.com> <563C85A4.1080006@redhat.com> <20151106124251.GA15818@hzzhang-OptiPlex-9020.sh.intel.com> <563D1022.9050100@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <563D1022.9050100@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3203 Lines: 78 On 11/06/15 21:40, Paolo Bonzini wrote: > > > On 06/11/2015 13:42, Haozhong Zhang wrote: > > On 11/06/15 11:49, Paolo Bonzini wrote: > >> > >> > >> On 20/10/2015 09:39, Haozhong Zhang wrote: > >>> This patchset adds support for VMX TSC scaling feature which is > >>> available on Intel Skylake CPU. The specification of VMX TSC scaling > >>> can be found at > >>> http://www.intel.com/content/www/us/en/processors/timestamp-counter-scaling-virtualization-white-paper.html > >>> > >>> VMX TSC scaling allows guest TSC which is read by guest rdtsc(p) > >>> instructions increases in a rate that is customized by the hypervisor > >>> and can be different than the host TSC rate. Basically, VMX TSC > >>> scaling adds a 64-bit field called TSC multiplier in VMCS so that, if > >>> VMX TSC scaling is enabled, TSC read by guest rdtsc(p) instructions > >>> will be calculated by the following formula: > >>> > >>> guest EDX:EAX = (Host TSC * TSC multiplier) >> 48 + VMX TSC Offset > >>> > >>> where, Host TSC = Host MSR_IA32_TSC + Host MSR_IA32_TSC_ADJUST. > >>> > >>> This patchset, when cooperating with another QEMU patchset (sent in > >>> another email "target-i386: save/restore vcpu's TSC rate during > >>> migration"), allows guest programs observe a consistent TSC rate even > >>> though they are migrated among machines with different host TSC rates. > >>> > >>> VMX TSC scaling shares some common logics with SVM TSC ratio which > >>> is already supported by KVM. Patch 1 ~ 8 move those common logics from > >>> SVM code to the common code. Upon them, patch 9 ~ 12 add VMX-specific > >>> support for VMX TSC scaling. > >>> > >>> Changes in v2: > >>> * Remove the duplicated variable 'kvm_tsc_scaling_ratio_rsvd'. > >>> * Remove an unnecessary error check in original patch 2. > >>> * Do 64-bit arithmetic by functions recommended by Paolo. > >>> * Make kvm_set_tsc_khz() returns an error number so that ioctl > >>> KVM_SET_TSC_KHZ does not return 0 if errors happen. > >>> > >>> Reviewed-by: Eric Northup > >> > >> Thanks for the patches. There are a couple changes that I can do myself: > >> > >> 1) kvm_default_tsc_scaling_ratio can be initialized in > >> kvm_arch_hardware_setup, since it's just 1ULL << > >> kvm_tsc_scaling_ratio_frac_bits > >> > > Agree > > > >> 2) things that you are adding to include/linux/kvm_host.h should instead > >> go in arch/x86/include/linux/kvm_host.h > >> > > Agree, because they are x86 specific. > > > >> That's it. I'll commit it as soon as I test on AMD (today hopefully). > > It tested fine. I'll give it a shot with the 32-bit mul_u64_u64_shr on > Monday as well, but I don't expect any issue. > > Thanks, the patches are neat! > > Paolo Thank you for the test! Haozhong > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/