From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753926AbbCBJOR (ORCPT ); Mon, 2 Mar 2015 04:14:17 -0500 Received: from mga14.intel.com ([192.55.52.115]:55136 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752159AbbCBJOM convert rfc822-to-8bit (ORCPT ); Mon, 2 Mar 2015 04:14:12 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,674,1418112000"; d="scan'208";a="659098294" From: "Wu, Feng" To: Marcelo Tosatti CC: "tglx@linutronix.de" , "mingo@redhat.com" , "hpa@zytor.com" , "x86@kernel.org" , "gleb@kernel.org" , "pbonzini@redhat.com" , "dwmw2@infradead.org" , "joro@8bytes.org" , "alex.williamson@redhat.com" , "jiang.liu@linux.intel.com" , "eric.auger@linaro.org" , "linux-kernel@vger.kernel.org" , "iommu@lists.linux-foundation.org" , "kvm@vger.kernel.org" , "Wu, Feng" Subject: RE: [v3 23/26] KVM: Update Posted-Interrupts Descriptor when vCPU is preempted Thread-Topic: [v3 23/26] KVM: Update Posted-Interrupts Descriptor when vCPU is preempted Thread-Index: AQHQT7c1/pf8pjfnG0yYEBFa6AlaPZ0I27OQ Date: Mon, 2 Mar 2015 09:12:53 +0000 Message-ID: References: <1418397300-10870-1-git-send-email-feng.wu@intel.com> <1418397300-10870-24-git-send-email-feng.wu@intel.com> <20150223222138.GB9544@amt.cnet> In-Reply-To: <20150223222138.GB9544@amt.cnet> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: Marcelo Tosatti [mailto:mtosatti@redhat.com] > Sent: Tuesday, February 24, 2015 6:22 AM > To: Wu, Feng > Cc: tglx@linutronix.de; mingo@redhat.com; hpa@zytor.com; x86@kernel.org; > gleb@kernel.org; pbonzini@redhat.com; dwmw2@infradead.org; > joro@8bytes.org; alex.williamson@redhat.com; jiang.liu@linux.intel.com; > eric.auger@linaro.org; linux-kernel@vger.kernel.org; > iommu@lists.linux-foundation.org; kvm@vger.kernel.org > Subject: Re: [v3 23/26] KVM: Update Posted-Interrupts Descriptor when vCPU > is preempted > > On Fri, Dec 12, 2014 at 11:14:57PM +0800, Feng Wu wrote: > > This patch updates the Posted-Interrupts Descriptor when vCPU > > is preempted. > > > > sched out: > > - Set 'SN' to suppress furture non-urgent interrupts posted for > > the vCPU. > > What wakes the vcpu in the case of a non-urgent interrupt, then? Here we set 'SN' when vCPU's state is transmitted from running to runnable (waiting in the runqueue), after the vCPU is chosen to run again, the 'SN' will be clear. So no need to wakeup it explicitly. > > I wonder how is software suppose to configure the urgent/non-urgent > flag. Can you give examples of (hypothetical) urgent and non-urgent > interrupts. Well, urgent and non-urgent flag is supported in hardware, I think the original purpose of urgent interrupts is for real time usage. Then, when such urgent interrupts happen, we can change the behavior of the scheduler and make the related vCPU run immediately. However, from software's point of view, we didn't find a clear picture about which interrupts should be urgent and how to configure it, so we don't support this currently. > > > sched in: > > - Clear 'SN' > > - Change NDST if vCPU is scheduled to a different CPU > > - Set 'NV' to POSTED_INTR_VECTOR > > What about: > > POSTED_INTR_VECTOR interrupt handler: > - Wakeup vcpu. - If the vCPU is still running (not preempted), we don't need to wakeup it. - In POSTED_INTR_VECTOR interrupt handler, it is a little hard to get vCPU related information, even if we get, it is not accurate and may harm the performance. (need search) > - Set 'SN' to suppress future interrupts. We only need to set 'SN' when the vCPU is waiting on the runqueue, So seems set 'SN' in this handler is not a good idea. > > HLT emulation entry: > - Clear 'SN' to receive VT-d interrupt notification. > > > Signed-off-by: Feng Wu > > --- > > arch/x86/kvm/vmx.c | 44 > ++++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 44 insertions(+) > > > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > > index ee3b735..bf2e6cd 100644 > > --- a/arch/x86/kvm/vmx.c > > +++ b/arch/x86/kvm/vmx.c > > @@ -1916,10 +1916,54 @@ static void vmx_vcpu_load(struct kvm_vcpu > *vcpu, int cpu) > > vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */ > > vmx->loaded_vmcs->cpu = cpu; > > } > > + > > + if (irq_remapping_cap(IRQ_POSTING_CAP)) { > > + struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu); > > + struct pi_desc old, new; > > + unsigned int dest; > > + > > + memset(&old, 0, sizeof(old)); > > + memset(&new, 0, sizeof(new)); > > + > > + do { > > + old.control = new.control = pi_desc->control; > > + if (vcpu->cpu != cpu) { > > + dest = cpu_physical_id(cpu); > > + > > + if (x2apic_enabled()) > > + new.ndst = dest; > > + else > > + new.ndst = (dest << 8) & 0xFF00; > > + } > > + > > + pi_clear_sn(&new); > > + > > + /* set 'NV' to 'notification vector' */ > > + new.nv = POSTED_INTR_VECTOR; > > + } while (cmpxchg(&pi_desc->control, old.control, > > + new.control) != old.control); > > + } > > } > > > > static void vmx_vcpu_put(struct kvm_vcpu *vcpu) > > { > > + if (irq_remapping_cap(IRQ_POSTING_CAP)) { > > + struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu); > > + struct pi_desc old, new; > > + > > + memset(&old, 0, sizeof(old)); > > + memset(&new, 0, sizeof(new)); > > + > > + /* Set SN when the vCPU is preempted */ > > + if (vcpu->preempted) { > > + do { > > + old.control = new.control = pi_desc->control; > > + pi_set_sn(&new); > > + } while (cmpxchg(&pi_desc->control, old.control, > > + new.control) != old.control); > > + } > > + } > > + > > __vmx_load_host_state(to_vmx(vcpu)); > > if (!vmm_exclusive) { > > __loaded_vmcs_clear(to_vmx(vcpu)->loaded_vmcs); > > -- > > 1.9.1 > > > > -- > > 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