public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: No disable_irq for MSI/MSI-X interrupt on device assignment
@ 2009-04-30  2:58 Sheng Yang
  2009-05-04  8:25 ` Avi Kivity
  2009-05-31  9:48 ` Avi Kivity
  0 siblings, 2 replies; 6+ messages in thread
From: Sheng Yang @ 2009-04-30  2:58 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: kvm, Sheng Yang

Disable interrupt at interrupt handler and enable it when guest ack is for
the level triggered interrupt, to prevent reinjected interrupt. MSI/MSI-X don't
need it.

One possible problem is multiply same vector interrupt injected between irq
handler and scheduled work handler would be merged as one for MSI/MSI-X.
But AFAIK, the drivers handle it well.

The patch fixed the oplin card performance issue(MSI-X performance is half of
MSI/INTx).

Signed-off-by: Sheng Yang <sheng@linux.intel.com>
---
 virt/kvm/kvm_main.c |   22 ++++++++--------------
 1 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index eebc5ed..de8f205 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -120,7 +120,7 @@ static void kvm_assigned_dev_interrupt_work_handler(struct work_struct *work)
 {
 	struct kvm_assigned_dev_kernel *assigned_dev;
 	struct kvm *kvm;
-	int irq, i;
+	int i;
 
 	assigned_dev = container_of(work, struct kvm_assigned_dev_kernel,
 				    interrupt_work);
@@ -143,20 +143,10 @@ static void kvm_assigned_dev_interrupt_work_handler(struct work_struct *work)
 			kvm_set_irq(assigned_dev->kvm,
 				    assigned_dev->irq_source_id,
 				    guest_entries[i].vector, 1);
-			irq = assigned_dev->host_msix_entries[i].vector;
-			if (irq != 0)
-				enable_irq(irq);
-			assigned_dev->host_irq_disabled = false;
 		}
-	} else {
+	} else
 		kvm_set_irq(assigned_dev->kvm, assigned_dev->irq_source_id,
 			    assigned_dev->guest_irq, 1);
-		if (assigned_dev->irq_requested_type &
-				KVM_DEV_IRQ_GUEST_MSI) {
-			enable_irq(assigned_dev->host_irq);
-			assigned_dev->host_irq_disabled = false;
-		}
-	}
 
 	spin_unlock_irq(&assigned_dev->assigned_dev_lock);
 	mutex_unlock(&assigned_dev->kvm->lock);
@@ -179,8 +169,10 @@ static irqreturn_t kvm_assigned_dev_intr(int irq, void *dev_id)
 
 	schedule_work(&assigned_dev->interrupt_work);
 
-	disable_irq_nosync(irq);
-	assigned_dev->host_irq_disabled = true;
+	if (assigned_dev->irq_requested_type & KVM_DEV_IRQ_GUEST_INTX) {
+		disable_irq_nosync(irq);
+		assigned_dev->host_irq_disabled = true;
+	}
 
 out:
 	spin_unlock_irqrestore(&assigned_dev->assigned_dev_lock, flags);
@@ -417,6 +409,7 @@ static int assigned_device_enable_guest_msi(struct kvm *kvm,
 {
 	dev->guest_irq = irq->guest_irq;
 	dev->ack_notifier.gsi = -1;
+	dev->host_irq_disabled = false;
 	return 0;
 }
 #endif
@@ -427,6 +420,7 @@ static int assigned_device_enable_guest_msix(struct kvm *kvm,
 {
 	dev->guest_irq = irq->guest_irq;
 	dev->ack_notifier.gsi = -1;
+	dev->host_irq_disabled = false;
 	return 0;
 }
 #endif
-- 
1.5.4.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: No disable_irq for MSI/MSI-X interrupt on device assignment
  2009-04-30  2:58 [PATCH] KVM: No disable_irq for MSI/MSI-X interrupt on device assignment Sheng Yang
@ 2009-05-04  8:25 ` Avi Kivity
  2009-05-04  8:30   ` Sheng Yang
  2009-05-31  9:48 ` Avi Kivity
  1 sibling, 1 reply; 6+ messages in thread
From: Avi Kivity @ 2009-05-04  8:25 UTC (permalink / raw)
  To: Sheng Yang; +Cc: Marcelo Tosatti, kvm

Sheng Yang wrote:
> Disable interrupt at interrupt handler and enable it when guest ack is for
> the level triggered interrupt, to prevent reinjected interrupt. MSI/MSI-X don't
> need it.
>
> One possible problem is multiply same vector interrupt injected between irq
> handler and scheduled work handler would be merged as one for MSI/MSI-X.
> But AFAIK, the drivers handle it well.
>
> The patch fixed the oplin card performance issue(MSI-X performance is half of
> MSI/INTx).
>
>  
>  	schedule_work(&assigned_dev->interrupt_work);
>  
> -	disable_irq_nosync(irq);
> -	assigned_dev->host_irq_disabled = true;
> +	if (assigned_dev->irq_requested_type & KVM_DEV_IRQ_GUEST_INTX) {
> +		disable_irq_nosync(irq);
> +		assigned_dev->host_irq_disabled = true;
> +	}
>  
>  out:
>  	spin_unlock_irqrestore(&assigned_dev->assigned_dev_lock, flags);
>   

I don't have the spin_lock_irqrestore() here.  The patch applies, but 
with fuzz.  Am I missing a patch?

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to panic.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: No disable_irq for MSI/MSI-X interrupt on device assignment
  2009-05-04  8:25 ` Avi Kivity
@ 2009-05-04  8:30   ` Sheng Yang
  2009-05-04  8:34     ` Avi Kivity
  0 siblings, 1 reply; 6+ messages in thread
From: Sheng Yang @ 2009-05-04  8:30 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Marcelo Tosatti, kvm

On Monday 04 May 2009 16:25:55 Avi Kivity wrote:
> Sheng Yang wrote:
> > Disable interrupt at interrupt handler and enable it when guest ack is
> > for the level triggered interrupt, to prevent reinjected interrupt.
> > MSI/MSI-X don't need it.
> >
> > One possible problem is multiply same vector interrupt injected between
> > irq handler and scheduled work handler would be merged as one for
> > MSI/MSI-X. But AFAIK, the drivers handle it well.
> >
> > The patch fixed the oplin card performance issue(MSI-X performance is
> > half of MSI/INTx).
> >
> >
> >  	schedule_work(&assigned_dev->interrupt_work);
> >
> > -	disable_irq_nosync(irq);
> > -	assigned_dev->host_irq_disabled = true;
> > +	if (assigned_dev->irq_requested_type & KVM_DEV_IRQ_GUEST_INTX) {
> > +		disable_irq_nosync(irq);
> > +		assigned_dev->host_irq_disabled = true;
> > +	}
> >
> >  out:
> >  	spin_unlock_irqrestore(&assigned_dev->assigned_dev_lock, flags);
>
> I don't have the spin_lock_irqrestore() here.  The patch applies, but
> with fuzz.  Am I missing a patch?

Oh, it's Marcelo's patchset...

[patch 0/4] use smp_send_reschedule in vcpu_kick / assigned dev host intx race 
fix

-- 
regards
Yang, Sheng

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: No disable_irq for MSI/MSI-X interrupt on device assignment
  2009-05-04  8:30   ` Sheng Yang
@ 2009-05-04  8:34     ` Avi Kivity
  2009-05-04  8:37       ` Sheng Yang
  0 siblings, 1 reply; 6+ messages in thread
From: Avi Kivity @ 2009-05-04  8:34 UTC (permalink / raw)
  To: Sheng Yang; +Cc: Marcelo Tosatti, kvm

Sheng Yang wrote:
> On Monday 04 May 2009 16:25:55 Avi Kivity wrote:
>   
>> Sheng Yang wrote:
>>     
>>> Disable interrupt at interrupt handler and enable it when guest ack is
>>> for the level triggered interrupt, to prevent reinjected interrupt.
>>> MSI/MSI-X don't need it.
>>>
>>> One possible problem is multiply same vector interrupt injected between
>>> irq handler and scheduled work handler would be merged as one for
>>> MSI/MSI-X. But AFAIK, the drivers handle it well.
>>>
>>> The patch fixed the oplin card performance issue(MSI-X performance is
>>> half of MSI/INTx).
>>>
>>>
>>>  	schedule_work(&assigned_dev->interrupt_work);
>>>
>>> -	disable_irq_nosync(irq);
>>> -	assigned_dev->host_irq_disabled = true;
>>> +	if (assigned_dev->irq_requested_type & KVM_DEV_IRQ_GUEST_INTX) {
>>> +		disable_irq_nosync(irq);
>>> +		assigned_dev->host_irq_disabled = true;
>>> +	}
>>>
>>>  out:
>>>  	spin_unlock_irqrestore(&assigned_dev->assigned_dev_lock, flags);
>>>       
>> I don't have the spin_lock_irqrestore() here.  The patch applies, but
>> with fuzz.  Am I missing a patch?
>>     
>
> Oh, it's Marcelo's patchset...
>
> [patch 0/4] use smp_send_reschedule in vcpu_kick / assigned dev host intx race 
> fix
>   

Okay, I am working my queue in reverse order :)

But please note dependencies on other patches for me.

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to panic.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: No disable_irq for MSI/MSI-X interrupt on device assignment
  2009-05-04  8:34     ` Avi Kivity
@ 2009-05-04  8:37       ` Sheng Yang
  0 siblings, 0 replies; 6+ messages in thread
From: Sheng Yang @ 2009-05-04  8:37 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Marcelo Tosatti, kvm

On Monday 04 May 2009 16:34:00 Avi Kivity wrote:
> Sheng Yang wrote:
> > On Monday 04 May 2009 16:25:55 Avi Kivity wrote:
> >> Sheng Yang wrote:
> >>> Disable interrupt at interrupt handler and enable it when guest ack is
> >>> for the level triggered interrupt, to prevent reinjected interrupt.
> >>> MSI/MSI-X don't need it.
> >>>
> >>> One possible problem is multiply same vector interrupt injected between
> >>> irq handler and scheduled work handler would be merged as one for
> >>> MSI/MSI-X. But AFAIK, the drivers handle it well.
> >>>
> >>> The patch fixed the oplin card performance issue(MSI-X performance is
> >>> half of MSI/INTx).
> >>>
> >>>
> >>>  	schedule_work(&assigned_dev->interrupt_work);
> >>>
> >>> -	disable_irq_nosync(irq);
> >>> -	assigned_dev->host_irq_disabled = true;
> >>> +	if (assigned_dev->irq_requested_type & KVM_DEV_IRQ_GUEST_INTX) {
> >>> +		disable_irq_nosync(irq);
> >>> +		assigned_dev->host_irq_disabled = true;
> >>> +	}
> >>>
> >>>  out:
> >>>  	spin_unlock_irqrestore(&assigned_dev->assigned_dev_lock, flags);
> >>
> >> I don't have the spin_lock_irqrestore() here.  The patch applies, but
> >> with fuzz.  Am I missing a patch?
> >
> > Oh, it's Marcelo's patchset...
> >
> > [patch 0/4] use smp_send_reschedule in vcpu_kick / assigned dev host intx
> > race fix
>
> Okay, I am working my queue in reverse order :)
>
> But please note dependencies on other patches for me.

Yes, sorry for totally forgot (mine based on his patchset)... :(

-- 
regards
Yang, Sheng


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: No disable_irq for MSI/MSI-X interrupt on device assignment
  2009-04-30  2:58 [PATCH] KVM: No disable_irq for MSI/MSI-X interrupt on device assignment Sheng Yang
  2009-05-04  8:25 ` Avi Kivity
@ 2009-05-31  9:48 ` Avi Kivity
  1 sibling, 0 replies; 6+ messages in thread
From: Avi Kivity @ 2009-05-31  9:48 UTC (permalink / raw)
  To: Sheng Yang; +Cc: Marcelo Tosatti, kvm

Sheng Yang wrote:
> Disable interrupt at interrupt handler and enable it when guest ack is for
> the level triggered interrupt, to prevent reinjected interrupt. MSI/MSI-X don't
> need it.
>
> One possible problem is multiply same vector interrupt injected between irq
> handler and scheduled work handler would be merged as one for MSI/MSI-X.
> But AFAIK, the drivers handle it well.
>
> The patch fixed the oplin card performance issue(MSI-X performance is half of
> MSI/INTx).
>   

Applied, thanks.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-05-31  9:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-30  2:58 [PATCH] KVM: No disable_irq for MSI/MSI-X interrupt on device assignment Sheng Yang
2009-05-04  8:25 ` Avi Kivity
2009-05-04  8:30   ` Sheng Yang
2009-05-04  8:34     ` Avi Kivity
2009-05-04  8:37       ` Sheng Yang
2009-05-31  9:48 ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox