From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753368AbcGFICT (ORCPT ); Wed, 6 Jul 2016 04:02:19 -0400 Received: from mga11.intel.com ([192.55.52.93]:8759 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751039AbcGFICL (ORCPT ); Wed, 6 Jul 2016 04:02:11 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,318,1464678000"; d="scan'208";a="1011655517" Date: Wed, 6 Jul 2016 16:01:46 +0800 From: Haozhong Zhang To: Paolo Bonzini Cc: Wanpeng Li , kvm , Radim Krcmar , Yunhong Jiang , Wanpeng Li , "linux-kernel@vger.kernel.org" , Jan Kiszka Subject: Re: [PATCH] KVM: VMX: switch to hrtimer for TSC deadline timer when L2 guest is running Message-ID: <20160706080146.fnsu3let5p6w7ofa@hz-desktop> Mail-Followup-To: Paolo Bonzini , Wanpeng Li , kvm , Radim Krcmar , Yunhong Jiang , Wanpeng Li , "linux-kernel@vger.kernel.org" , Jan Kiszka References: <20160706051051.7869-1-haozhong.zhang@intel.com> <20160706060558.sklnb3qso6tnmbrs@hz-desktop> <6d2cd9ce-da0e-8b61-e3a9-78be3b32a6e4@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6d2cd9ce-da0e-8b61-e3a9-78be3b32a6e4@redhat.com> User-Agent: Mutt/1.6.1-neo (2016-05-02) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/06/16 09:46, Paolo Bonzini wrote: > > > On 06/07/2016 08:05, Haozhong Zhang wrote: > >> > > >> > Nested preemption timer is emulated by hrtimer, so it doesn't > >> > influence vmcs02, why this is needed? > > Nested (L2) preemption timer is not affected for sure, and this patch > > is to fix another problem caused by using L1 preemption timer for L1 > > TSC deadline timer. When we use L1 VMX preemption timer for L1 TSC > > deadline timer, we intend to use the pin-based exec config and the VMX > > preemption timer value in vmcs01. However, when L2 guest is running, > > vmcs02 is loaded as the current VMCS so that a different VMX > > preemption timer config is used (i.e. VMX preemption timer is disabled > > in prepare_vmcs02()). If we still use preemption timer for L1 TSC > > deadline timer at this moment, then L1 TSC deadline timer will not be > > able to be triggered when L2 guest is running. > > The right fix then is to set the pin-based controls in prepare_vmcs02, > based on vcpu->arch.hv_deadline_tsc. Then KVM needs to distinguish L1 and L2 VMEXITs for preemption timer (or does KVM already have this?). The current implementation which uses a separate hrtimer for L2 preemption timer can easily distinguish them. Haozhong