xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] x86/apicv: enhance posted-interrupt processing
@ 2017-02-27 10:53 Xuquan (Quan Xu)
  2017-02-28 15:08 ` Jan Beulich
  0 siblings, 1 reply; 9+ messages in thread
From: Xuquan (Quan Xu) @ 2017-02-27 10:53 UTC (permalink / raw)
  To: xen-devel@lists.xen.org
  Cc: yang.zhang.wz@gmail.com, Tian, Kevin, quan.xu0@gmail.com,
	Jan Beulich, Andrew Cooper, Jun Nakajima, Gao, Chao

[-- Attachment #1: Type: text/plain, Size: 1950 bytes --]

>From 6b5f702927d832513d270a2bca4634b271f4df47 Mon Sep 17 00:00:00 2001
From: Quan Xu <xuquan8@huawei.com>
Date: Tue, 28 Feb 2017 02:48:29 +0800
Subject: [PATCH v2] x86/apicv: enhance posted-interrupt processing

If guest is already in non-root mode, an posted interrupt will
be directly delivered to guest (leaving softirq being set without
actually incurring a VM-Exit - breaking desired softirq behavior).
Then further posted interrupts will skip the IPI, stay in PIR and
not noted until another VM-Exit happens.

When target vCPU is in non-root mode and running on remote CPU,
posted way is triggered to inject interrupt without VM-Exit.
Otherwise, set VCPU_KICK_SOFTIRQ bit to inject interrupt until
another VM-Entry as a best effort.

Signed-off-by: Quan Xu <xuquan8@huawei.com>
---
 xen/arch/x86/hvm/vmx/vmx.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 61925cf..ecdfbbb 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -1839,17 +1839,14 @@ static void vmx_process_isr(int isr, struct vcpu *v)

 static void __vmx_deliver_posted_interrupt(struct vcpu *v)
 {
-    bool_t running = v->is_running;
+    unsigned int cpu = v->processor;

     vcpu_unblock(v);
-    if ( running && (in_irq() || (v != current)) )
-    {
-        unsigned int cpu = v->processor;
-
-        if ( !test_and_set_bit(VCPU_KICK_SOFTIRQ, &softirq_pending(cpu))
-             && (cpu != smp_processor_id()) )
-            send_IPI_mask(cpumask_of(cpu), posted_intr_vector);
-    }
+    if ( v->is_running && (in_irq() || (v != current)) &&
+         (cpu != smp_processor_id()) )
+        send_IPI_mask(cpumask_of(cpu), posted_intr_vector);
+    else
+        set_bit(VCPU_KICK_SOFTIRQ, &softirq_pending(cpu));
 }

 static void vmx_deliver_posted_intr(struct vcpu *v, u8 vector)
--
1.8.3.1


[-- Attachment #2: 0001-x86-apicv-enhance-posted-interrupt-processing.patch --]
[-- Type: application/octet-stream, Size: 1901 bytes --]

From 6b5f702927d832513d270a2bca4634b271f4df47 Mon Sep 17 00:00:00 2001
From: Quan Xu <xuquan8@huawei.com>
Date: Tue, 28 Feb 2017 02:48:29 +0800
Subject: [PATCH v2] x86/apicv: enhance posted-interrupt processing

If guest is already in non-root mode, an posted interrupt will
be directly delivered to guest (leaving softirq being set without
actually incurring a VM-Exit - breaking desired softirq behavior).
Then further posted interrupts will skip the IPI, stay in PIR and
not noted until another VM-Exit happens.

When target vCPU is in non-root mode and running on remote CPU,
posted way is triggered to inject interrupt without VM-Exit.
Otherwise, set VCPU_KICK_SOFTIRQ bit to inject interrupt until
another VM-Entry as a best effort.

Signed-off-by: Quan Xu <xuquan8@huawei.com>
---
 xen/arch/x86/hvm/vmx/vmx.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 61925cf..ecdfbbb 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -1839,17 +1839,14 @@ static void vmx_process_isr(int isr, struct vcpu *v)
 
 static void __vmx_deliver_posted_interrupt(struct vcpu *v)
 {
-    bool_t running = v->is_running;
+    unsigned int cpu = v->processor;
 
     vcpu_unblock(v);
-    if ( running && (in_irq() || (v != current)) )
-    {
-        unsigned int cpu = v->processor;
-
-        if ( !test_and_set_bit(VCPU_KICK_SOFTIRQ, &softirq_pending(cpu))
-             && (cpu != smp_processor_id()) )
-            send_IPI_mask(cpumask_of(cpu), posted_intr_vector);
-    }
+    if ( v->is_running && (in_irq() || (v != current)) &&
+         (cpu != smp_processor_id()) )
+        send_IPI_mask(cpumask_of(cpu), posted_intr_vector);
+    else
+        set_bit(VCPU_KICK_SOFTIRQ, &softirq_pending(cpu));
 }
 
 static void vmx_deliver_posted_intr(struct vcpu *v, u8 vector)
-- 
1.8.3.1


[-- Attachment #3: Type: text/plain, Size: 127 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

end of thread, other threads:[~2017-03-02  7:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-27 10:53 [PATCH v2] x86/apicv: enhance posted-interrupt processing Xuquan (Quan Xu)
2017-02-28 15:08 ` Jan Beulich
2017-03-01  3:23   ` Xuquan (Quan Xu)
2017-03-01  7:38     ` Jan Beulich
2017-03-01  6:23       ` Chao Gao
2017-03-01 13:36         ` Jan Beulich
2017-03-02  7:02         ` Tian, Kevin
2017-03-02  7:42         ` Xuquan (Quan Xu)
2017-03-02  1:42           ` Chao Gao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).