All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: "Wu, Feng" <feng.wu@intel.com>, f@amt.cnet
Cc: "hpa@zytor.com" <hpa@zytor.com>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"x86@kernel.org" <x86@kernel.org>,
	"gleb@kernel.org" <gleb@kernel.org>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	"dwmw2@infradead.org" <dwmw2@infradead.org>,
	"joro@8bytes.org" <joro@8bytes.org>,
	"alex.williamson@redhat.com" <alex.williamson@redhat.com>,
	"jiang.liu@linux.intel.com" <jiang.liu@linux.intel.com>,
	"eric.auger@linaro.org" <eric.auger@linaro.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"iommu@lists.linux-foundation.org"
	<iommu@lists.linux-foundation.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: Re: [v3 24/26] KVM: Update Posted-Interrupts Descriptor when vCPU is blocked
Date: Mon, 30 Mar 2015 20:55:33 -0300	[thread overview]
Message-ID: <20150330235533.GA15792@amt.cnet> (raw)
In-Reply-To: <E959C4978C3B6342920538CF579893F002479E58@SHSMSX104.ccr.corp.intel.com>

On Mon, Mar 30, 2015 at 04:46:55AM +0000, Wu, Feng wrote:
> 
> 
> > -----Original Message-----
> > From: Marcelo Tosatti [mailto:mtosatti@redhat.com]
> > Sent: Saturday, March 28, 2015 3:30 AM
> > To: Wu, Feng
> > Cc: hpa@zytor.com; tglx@linutronix.de; mingo@redhat.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 24/26] KVM: Update Posted-Interrupts Descriptor when vCPU
> > is blocked
> > 
> > On Fri, Mar 27, 2015 at 06:34:14AM +0000, Wu, Feng wrote:
> > > > > Currently, the following code is executed before local_irq_disable() is
> > called,
> > > > > so do you mean 1)moving local_irq_disable() to the place before it. 2) after
> > > > interrupt
> > > > > is disabled, set KVM_REQ_EVENT in case the ON bit is set?
> > > >
> > > > 2) after interrupt is disabled, set KVM_REQ_EVENT in case the ON bit
> > > > is set.
> > >
> > > Here is my understanding about your comments here:
> > > - Disable interrupts
> > > - Check 'ON'
> > > - Set KVM_REQ_EVENT if 'ON' is set
> > >
> > > Then we can put the above code inside " if
> > (kvm_check_request(KVM_REQ_EVENT, vcpu) || req_int_win) "
> > > just like it used to be. However, I still have some questions about this
> > comment:
> > >
> > > 1. Where should I set KVM_REQ_EVENT? In function vcpu_enter_guest(), or
> > other places?
> > 
> > See below:
> > 
> > > If in vcpu_enter_guest(), since currently local_irq_disable() is called after
> > 'KVM_REQ_EVENT'
> > > is checked, is it helpful to set KVM_REQ_EVENT after local_irq_disable() is
> > called?
> > 
> >         local_irq_disable();
> > 
> > 	*** add code here ***
> 
> So we need add code like the following here, right?
> 
>           if ('ON' is set)
>               kvm_make_request(KVM_REQ_EVENT, vcpu);

Yes.

> >         if (vcpu->mode == EXITING_GUEST_MODE || vcpu->requests
> > 						^^^^^^^^^^^^^^

Point *1.

> >             || need_resched() || signal_pending(current)) {
> >                 vcpu->mode = OUTSIDE_GUEST_MODE;
> >                 smp_wmb();
> >                 local_irq_enable();
> >                 preempt_enable();
> >                 vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
> >                 r = 1;
> >                 goto cancel_injection;
> >         }
> > 
> > > 2. 'ON' is set by VT-d hardware, it can be set even when interrupt is disabled
> > (the related bit in PIR is also set).
> > 
> > Yes, we are checking if the HW has set an interrupt in PIR while
> > outside VM (which requires PIR->VIRR transfer by software).
> > 
> > If the interrupt it set by hardware after local_irq_disable(),
> > VMX-entry will handle the interrupt and perform the PIR->VIRR
> > transfer and reevaluate interrupts, injecting to guest
> > if necessary, is that correct ?
> > 
> > > So does it make sense to check 'ON' and set KVM_REQ_EVENT accordingly
> > after interrupt is disabled?
> > 
> > To replace the costly
> > 
> > +            */
> > +           if (kvm_x86_ops->hwapic_irr_update)
> > +                   kvm_x86_ops->hwapic_irr_update(vcpu,
> > +                           kvm_lapic_find_highest_irr(vcpu));
> > 
> > Yes, i think so.
> 
> After adding the "checking ON and setting KVM_REQ_EVENT" operations listed in my
> comments above, do you mean we still need to keep the costly code above
> inside "if (kvm_check_request(KVM_REQ_EVENT, vcpu) || req_int_win) {}" in function
> vcpu_enter_guest() as it used to be? If yes, my question is what is the exact purpose
> of "checking ON and setting KVM_REQ_EVENT" operations? Here is the code flow in
> vcpu_enter_guest():
> 
> 1. Check KVM_REQ_EVENT, if it is set, sync pir->virr
> 2. Disable interrupts
> 3. Check ON and set KVM_REQ_EVENT -- Here, we set KVM_REQ_EVENT, but it is
> checked in the step 1, which means, we cannot get any benefits even we set it here,
> since the "pir->virr" sync operation was done in step 1, between step 3 and VM-Entry,
> we don't synchronize the pir to virr. So even we set KVM_REQ_EVENT here, the interrupts
> remaining in PIR cannot be delivered to guest during this VM-Entry, right?

Please check point *1 above. The code will go back to  

"if (kvm_check_request(KVM_REQ_EVENT, vcpu)"

And perform the pir->virr sync.


  reply	other threads:[~2015-03-30 23:56 UTC|newest]

Thread overview: 267+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-12 15:14 [v3 00/26] Add VT-d Posted-Interrupts support Feng Wu
2014-12-12 15:14 ` Feng Wu
2014-12-12 15:14 ` [v3 01/26] genirq: Introduce irq_set_vcpu_affinity() to target an interrupt to a VCPU Feng Wu
2014-12-12 15:14   ` Feng Wu
2014-12-12 15:14 ` [v3 02/26] iommu: Add new member capability to struct irq_remap_ops Feng Wu
2015-01-28 15:22   ` David Woodhouse
2015-01-28 15:22     ` David Woodhouse
2015-01-29  8:34     ` Wu, Feng
2015-01-29  8:34       ` Wu, Feng
2014-12-12 15:14 ` [v3 03/26] iommu, x86: Define new irte structure for VT-d Posted-Interrupts Feng Wu
2014-12-12 15:14   ` Feng Wu
2015-01-28 15:26   ` David Woodhouse
2015-01-28 15:26     ` David Woodhouse
2014-12-12 15:14 ` [v3 04/26] iommu, x86: Implement irq_set_vcpu_affinity for intel_ir_chip Feng Wu
2014-12-12 15:14   ` Feng Wu
2015-01-28 15:26   ` David Woodhouse
2015-01-28 15:26     ` David Woodhouse
2015-01-29  7:55     ` Wu, Feng
2015-01-29  7:55       ` Wu, Feng
2014-12-12 15:14 ` [v3 05/26] x86, irq: Implement irq_set_vcpu_affinity for pci_msi_ir_controller Feng Wu
2014-12-12 15:14   ` Feng Wu
2014-12-12 15:14 ` [v3 06/26] iommu, x86: No need to migrating irq for VT-d Posted-Interrupts Feng Wu
2014-12-12 15:14   ` Feng Wu
2014-12-18 14:26   ` Zhang, Yang Z
2014-12-18 14:26     ` Zhang, Yang Z
2014-12-19  1:40     ` Wu, Feng
2014-12-19  1:40       ` Wu, Feng
2014-12-19  1:46       ` Zhang, Yang Z
2014-12-19  1:46         ` Zhang, Yang Z
2014-12-19 11:59         ` Paolo Bonzini
2014-12-19 11:59           ` Paolo Bonzini
2014-12-23  0:37           ` Zhang, Yang Z
2014-12-23  0:37             ` Zhang, Yang Z
2014-12-23  8:47             ` Paolo Bonzini
2014-12-23  8:47               ` Paolo Bonzini
2014-12-23  9:07               ` Wu, Feng
2014-12-23  9:07                 ` Wu, Feng
2014-12-23  9:34                 ` Paolo Bonzini
2014-12-23  9:34                   ` Paolo Bonzini
2014-12-24  1:38                   ` Zhang, Yang Z
2014-12-24  1:38                     ` Zhang, Yang Z
2014-12-24  2:12                     ` Jiang Liu
2014-12-24  2:12                       ` Jiang Liu
2014-12-24  2:32                       ` Zhang, Yang Z
2014-12-24  2:32                         ` Zhang, Yang Z
2014-12-24  3:08                         ` Wu, Feng
2014-12-24  3:08                           ` Wu, Feng
2014-12-24  4:04                           ` Zhang, Yang Z
2014-12-24  4:04                             ` Zhang, Yang Z
2014-12-24  4:54                         ` Jiang Liu
2014-12-24  4:54                           ` Jiang Liu
2015-01-28 15:29   ` David Woodhouse
2015-01-28 15:29     ` David Woodhouse
2014-12-12 15:14 ` [v3 07/26] iommu, x86: Add cap_pi_support() to detect VT-d PI capability Feng Wu
2015-01-28 15:32   ` David Woodhouse
2015-01-28 15:32     ` David Woodhouse
2014-12-12 15:14 ` [v3 08/26] iommu, x86: Add intel_irq_remapping_capability() for Intel Feng Wu
2015-01-28 15:37   ` David Woodhouse
2015-01-28 15:37     ` David Woodhouse
2015-01-29  8:57     ` Wu, Feng
2015-01-29  8:57       ` Wu, Feng
2014-12-12 15:14 ` [v3 09/26] iommu, x86: define irq_remapping_cap() Feng Wu
2014-12-12 15:14   ` Feng Wu
2014-12-12 15:14 ` [v3 10/26] KVM: change struct pi_desc for VT-d Posted-Interrupts Feng Wu
2014-12-12 15:14   ` Feng Wu
2014-12-12 15:14 ` [v3 11/26] KVM: Add some helper functions for Posted-Interrupts Feng Wu
2014-12-12 15:14   ` Feng Wu
2014-12-12 15:14 ` [v3 12/26] KVM: Initialize VT-d Posted-Interrupts Descriptor Feng Wu
2014-12-12 15:14   ` Feng Wu
2014-12-18 15:19   ` Zhang, Yang Z
2014-12-18 15:19     ` Zhang, Yang Z
2014-12-12 15:14 ` [v3 13/26] KVM: Define a new interface kvm_find_dest_vcpu() for VT-d PI Feng Wu
2014-12-12 15:14   ` Feng Wu
2014-12-18 14:49   ` Zhang, Yang Z
2014-12-18 14:49     ` Zhang, Yang Z
2014-12-18 16:58     ` Paolo Bonzini
2014-12-18 16:58       ` Paolo Bonzini
2014-12-19  1:13       ` Zhang, Yang Z
2014-12-19  1:30         ` Wu, Feng
2014-12-19  1:30           ` Wu, Feng
2014-12-19  1:30       ` Wu, Feng
2014-12-19  1:30         ` Wu, Feng
2014-12-19  1:47         ` Zhang, Yang Z
2014-12-19  1:47           ` Zhang, Yang Z
2014-12-19 11:59         ` Paolo Bonzini
2014-12-19 11:59           ` Paolo Bonzini
2014-12-19 23:48           ` Wu, Feng
2014-12-19 23:48             ` Wu, Feng
2014-12-20 13:16             ` Paolo Bonzini
2014-12-20 13:16               ` Paolo Bonzini
2014-12-22  4:48               ` Wu, Feng
2014-12-22  4:48                 ` Wu, Feng
2014-12-22  9:27                 ` Paolo Bonzini
2014-12-22  9:27                   ` Paolo Bonzini
2014-12-22 11:04                   ` Wu, Feng
2014-12-22 11:04                     ` Wu, Feng
2014-12-22 11:06                     ` Paolo Bonzini
2014-12-22 11:06                       ` Paolo Bonzini
2014-12-22 11:17                       ` Wu, Feng
2014-12-22 11:17                         ` Wu, Feng
2014-12-22 11:23                         ` Paolo Bonzini
2014-12-22 11:23                           ` Paolo Bonzini
2014-12-22 14:13                           ` Yong Wang
2014-12-22 14:13                             ` Yong Wang
2015-01-09 14:54   ` Radim Krčmář
2015-01-09 14:56     ` Paolo Bonzini
2015-01-09 15:12       ` Radim Krčmář
2015-01-09 15:18         ` Paolo Bonzini
2015-01-09 15:47           ` Radim Krčmář
2015-01-13  0:27       ` Wu, Feng
2015-01-13  0:27         ` Wu, Feng
2015-01-13 16:17         ` Radim Kr?má?
2015-01-14  1:27           ` Wu, Feng
2015-01-14  1:27             ` Wu, Feng
2015-01-14 13:02             ` Paolo Bonzini
2015-01-14 13:02               ` Paolo Bonzini
2015-01-14 16:59             ` Radim Kr?má?
2015-01-14 16:59               ` Radim Kr?má?
2015-01-20 21:04               ` Nadav Amit
2015-01-20 21:04                 ` Nadav Amit
2015-01-21 21:16                 ` Radim Kr?má?
2015-01-21 21:16                   ` Radim Kr?má?
2014-12-12 15:14 ` [v3 14/26] KVM: Get Posted-Interrupts descriptor address from struct kvm_vcpu Feng Wu
2014-12-12 15:14 ` [v3 15/26] KVM: add interfaces to control PI outside vmx Feng Wu
2014-12-12 15:14   ` Feng Wu
2014-12-12 15:14 ` [v3 16/26] KVM: Make struct kvm_irq_routing_table accessible Feng Wu
2014-12-12 15:14   ` Feng Wu
2014-12-17 16:17   ` Paolo Bonzini
2014-12-17 16:17     ` Paolo Bonzini
2014-12-19  2:19     ` Wu, Feng
2014-12-19  2:19       ` Wu, Feng
2014-12-19 11:59       ` Paolo Bonzini
2014-12-19 11:59         ` Paolo Bonzini
2014-12-19 23:39         ` Wu, Feng
2014-12-19 23:39           ` Wu, Feng
2014-12-12 15:14 ` [v3 17/26] KVM: make kvm_set_msi_irq() public Feng Wu
2014-12-12 15:14   ` Feng Wu
2014-12-17 17:32   ` Paolo Bonzini
2014-12-17 17:32     ` Paolo Bonzini
2014-12-12 15:14 ` [v3 18/26] KVM: kvm-vfio: User API for VT-d Posted-Interrupts Feng Wu
2014-12-12 15:14   ` Feng Wu
2014-12-12 15:14 ` [v3 19/26] KVM: kvm-vfio: implement the VFIO skeleton " Feng Wu
2014-12-12 15:14   ` Feng Wu
2014-12-12 15:14 ` [v3 20/26] KVM: x86: kvm-vfio: VT-d posted-interrupts setup Feng Wu
2014-12-12 15:14   ` Feng Wu
2014-12-12 15:14 ` [v3 21/26] x86, irq: Define a global vector for VT-d Posted-Interrupts Feng Wu
2014-12-12 15:14   ` Feng Wu
2014-12-18 14:54   ` Zhang, Yang Z
2014-12-18 14:54     ` Zhang, Yang Z
2014-12-19  0:52     ` Wu, Feng
2014-12-19  0:52       ` Wu, Feng
2015-01-30 18:18   ` H. Peter Anvin
2015-01-30 18:18     ` H. Peter Anvin
2015-02-02  1:06     ` Wu, Feng
2015-02-02  1:06       ` Wu, Feng
2015-02-23 22:04   ` Marcelo Tosatti
2015-02-23 22:04     ` Marcelo Tosatti
2014-12-12 15:14 ` [v3 22/26] KVM: Define a wakeup worker thread for vCPU Feng Wu
2014-12-12 15:14   ` Feng Wu
2014-12-12 15:14 ` [v3 23/26] KVM: Update Posted-Interrupts Descriptor when vCPU is preempted Feng Wu
2014-12-12 15:14   ` Feng Wu
2014-12-17 17:11   ` Paolo Bonzini
2014-12-17 17:11     ` Paolo Bonzini
2014-12-18  3:15     ` Wu, Feng
2014-12-18  3:15       ` Wu, Feng
2014-12-18  8:32       ` Paolo Bonzini
2014-12-18  8:32         ` Paolo Bonzini
2014-12-19  2:09         ` Wu, Feng
2014-12-19  2:09           ` Wu, Feng
2014-12-19  2:09           ` Wu, Feng
2015-02-23 22:21   ` Marcelo Tosatti
2015-02-23 22:21     ` Marcelo Tosatti
2015-03-02  9:12     ` Wu, Feng
2015-03-02  9:12       ` Wu, Feng
2014-12-12 15:14 ` [v3 24/26] KVM: Update Posted-Interrupts Descriptor when vCPU is blocked Feng Wu
2014-12-12 15:14   ` Feng Wu
2014-12-17 17:09   ` Paolo Bonzini
2014-12-17 17:09     ` Paolo Bonzini
2014-12-18  3:16     ` Wu, Feng
2014-12-18  3:16       ` Wu, Feng
2014-12-18  8:37       ` Paolo Bonzini
2014-12-18  8:37         ` Paolo Bonzini
2014-12-19  2:51         ` Wu, Feng
2014-12-19  2:51           ` Wu, Feng
2014-12-19  2:51           ` Wu, Feng
2015-02-25 21:50   ` Marcelo Tosatti
2015-02-26  8:08     ` Wu, Feng
2015-02-26 23:41       ` Marcelo Tosatti
2015-02-26 23:41         ` Marcelo Tosatti
2015-02-26 23:40   ` Marcelo Tosatti
2015-02-26 23:40     ` Marcelo Tosatti
2015-03-02 13:36     ` Wu, Feng
2015-03-02 13:36       ` Wu, Feng
2015-03-04 12:06       ` Marcelo Tosatti
2015-03-06  6:51         ` Wu, Feng
2015-03-06  6:51           ` Wu, Feng
2015-03-12  1:15           ` Marcelo Tosatti
2015-03-16 11:42             ` Wu, Feng
2015-03-16 11:42               ` Wu, Feng
2015-03-25 23:17               ` Marcelo Tosatti
2015-03-25 23:17                 ` Marcelo Tosatti
2015-03-27  6:34                 ` Wu, Feng
2015-03-27  6:34                   ` Wu, Feng
2015-03-27 19:30                   ` Marcelo Tosatti
2015-03-30  4:46                     ` Wu, Feng
2015-03-30  4:46                       ` Wu, Feng
2015-03-30 23:55                       ` Marcelo Tosatti [this message]
2015-03-31  1:13                         ` Wu, Feng
2015-04-14  7:37                         ` Wu, Feng
2015-06-05 21:59                           ` Marcelo Tosatti
2015-06-08  1:43                             ` Wu, Feng
2014-12-12 15:14 ` [v3 25/26] KVM: Suppress posted-interrupt when 'SN' is set Feng Wu
2014-12-12 15:14   ` Feng Wu
2014-12-17 17:42   ` Paolo Bonzini
2014-12-17 17:42     ` Paolo Bonzini
2014-12-17 17:42   ` Paolo Bonzini
2014-12-17 17:42     ` Paolo Bonzini
2014-12-18  3:14     ` Wu, Feng
2014-12-18  3:14       ` Wu, Feng
2014-12-18  8:38       ` Paolo Bonzini
2014-12-18  8:38         ` Paolo Bonzini
2014-12-18 15:09         ` Zhang, Yang Z
2014-12-18 15:09           ` Zhang, Yang Z
2014-12-19  2:58           ` Wu, Feng
2014-12-19  2:58             ` Wu, Feng
2014-12-19  2:58             ` Wu, Feng
2014-12-19  3:32             ` Zhang, Yang Z
2014-12-19  3:32               ` Zhang, Yang Z
2014-12-19  3:32               ` Zhang, Yang Z
2014-12-19  4:34               ` Wu, Feng
2014-12-19  4:34                 ` Wu, Feng
2014-12-19  4:34                 ` Wu, Feng
2014-12-19  4:44                 ` Zhang, Yang Z
2014-12-19  4:44                   ` Zhang, Yang Z
2014-12-19  4:44                   ` Zhang, Yang Z
2014-12-19  4:49                   ` Wu, Feng
2014-12-19  4:49                     ` Wu, Feng
2014-12-19  4:49                     ` Wu, Feng
2014-12-19  5:25                     ` Zhang, Yang Z
2014-12-19  5:25                       ` Zhang, Yang Z
2014-12-19  5:25                       ` Zhang, Yang Z
2014-12-19  5:46                       ` Wu, Feng
2014-12-19  5:46                         ` Wu, Feng
2014-12-19  5:46                         ` Wu, Feng
2014-12-19  7:04                         ` Zhang, Yang Z
2014-12-19  7:04                           ` Zhang, Yang Z
2014-12-19 12:00                       ` Paolo Bonzini
2014-12-19 12:00                         ` Paolo Bonzini
2014-12-19 23:34                         ` Wu, Feng
2014-12-19 23:34                           ` Wu, Feng
2014-12-12 15:15 ` [v3 26/26] iommu/vt-d: Add a command line parameter for VT-d posted-interrupts Feng Wu
2014-12-12 15:15   ` Feng Wu
2015-01-28 15:39   ` David Woodhouse
2015-01-28 15:39     ` David Woodhouse
2014-12-16  9:04 ` [v3 00/26] Add VT-d Posted-Interrupts support Wu, Feng
2015-01-06  1:10 ` Wu, Feng
2015-01-06  1:10   ` Wu, Feng
2015-01-09 12:46   ` joro
2015-01-09 13:58     ` Wu, Feng
2015-01-21  2:25 ` Wu, Feng
2015-01-21  2:25   ` Wu, Feng
2015-01-28  3:01   ` Wu, Feng
2015-01-28  3:01     ` Wu, Feng
2015-01-28  3:44     ` Alex Williamson
2015-01-28  3:44       ` Alex Williamson
2015-01-28  4:44       ` Wu, Feng
2015-01-28  4:44         ` Wu, Feng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150330235533.GA15792@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=dwmw2@infradead.org \
    --cc=eric.auger@linaro.org \
    --cc=f@amt.cnet \
    --cc=feng.wu@intel.com \
    --cc=gleb@kernel.org \
    --cc=hpa@zytor.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jiang.liu@linux.intel.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.