From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [RFC PATCH V2 4/4] Utilize the vmx preemption timer for tsc deadline timer Date: Wed, 25 May 2016 15:45:53 +0200 Message-ID: <20160525134553.GC14795@potion> References: <1464128852-14138-1-git-send-email-yunhong.jiang@linux.intel.com> <1464128852-14138-5-git-send-email-yunhong.jiang@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, mtosatti@redhat.com, pbonzini@redhat.com, kernellwp@gmail.com To: Yunhong Jiang Return-path: Received: from mx1.redhat.com ([209.132.183.28]:39595 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753041AbcEYNp6 (ORCPT ); Wed, 25 May 2016 09:45:58 -0400 Content-Disposition: inline In-Reply-To: <1464128852-14138-5-git-send-email-yunhong.jiang@linux.intel.com> Sender: kvm-owner@vger.kernel.org List-ID: 2016-05-24 15:27-0700, Yunhong Jiang: > From: Yunhong Jiang > > Utilizing the VMX preemption timer for tsc deadline timer > virtualization. The VMX preemption timer is armed when the vCPU is > running, and a VMExit will happen if the virtual TSC deadline timer > expires. > > When the vCPU thread is scheduled out, the tsc deadline timer > virtualization will be switched to use the current solution, i.e. use > the timer for it. It's switched back to VMX preemption timer when the > vCPU thread is scheduled int. > > This solution avoids the complex OS's hrtimer system, and also the host > timer interrupt handling cost, with a preemption_timer VMexit. It fits > well for some NFV usage scenario, when the vCPU is bound to a pCPU and > the pCPU is isolated, or some similar scenario. > > However, it possibly has impact if the vCPU thread is scheduled in/out > very frequently, because it switches from/to the hrtimer emulation a lot. > > Signed-off-by: Yunhong Jiang > --- > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > static const int kvm_vmx_max_exit_handlers = > @@ -8678,6 +8684,8 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) > if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP) > vmx_set_interrupt_shadow(vcpu, 0); > > + kvm_lapic_arm_hv_timer(vcpu); > + Every cycle that the host spends in root mode after setting the timeout makes the preemtion timer delayed. Can't we move the setup closer to vmlaunch, i.e. after atomic_switch_perf_msrs()? > if (vmx->guest_pkru_valid) > __write_pkru(vmx->guest_pkru); >