qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] QEMU ARM SMP: IPI delivery delayed until next main loop event // how to improve IPI latency?
@ 2015-06-12 16:38 Alex Züpke
  2015-06-12 18:03 ` Peter Maydell
                   ` (2 more replies)
  0 siblings, 3 replies; 28+ messages in thread
From: Alex Züpke @ 2015-06-12 16:38 UTC (permalink / raw)
  To: qemu-devel

Hi,

I'm benchmarking some IPI (== inter-processor-interrupt) synchronization stuff of my custom kernel on QEMU ARM (qemu-system-arm -M vexpress-a15 -smp 2) and ran into the following problem: pending IPIs are delayed until the QEMU main loop receives an event (for example the timer interrupt expires or I press a key on the console).

The following timing diagram tries to show this:

  CPU #0                       CPU #1
  ======                       ======
  ... other stuff ...          WFI (wait for interrupt, like x86 "HLT")
  send SGI in MPCore
  polls for completeness
                 <time passes ...>
  polls ...
                 <... and passes ...>
  still polls ...
                 <... and passes ...>
  still polls ...
                 <... and passes ...>

  
                 <timer interrupt expires>
                 <now QEMU switches to CPU #1>
                               receives IPI
                               signals completeness
                               WFI
                 <QEMU switches to CPU #0>
  polling done
  process timer interrupt
  ...


My timer is setup to generate an interrupt once a second, so I only get 1 IPI interrupt per second on QEMU. When I run the test on real hardware (i.MX6Q), I get millions of IPIs instead.


I tried to "fix" this by forcing QEMU back into the main loop and added a call to qemu_notify_event() in the IPI-sending path of the ARM interrupt controller:


diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
index c1d2e70..20dba75 100644
--- a/hw/intc/arm_gic.c
+++ b/hw/intc/arm_gic.c
@@ -21,6 +21,7 @@
 #include "hw/sysbus.h"
 #include "gic_internal.h"
 #include "qom/cpu.h"
+#include "qemu/main-loop.h"
 
 //#define DEBUG_GIC
 
@@ -898,6 +899,7 @@ static void gic_dist_writel(void *opaque, hwaddr offset,
             target_cpu = ctz32(mask);
         }
         gic_update(s);
+        qemu_notify_event();
         return;
     }
     gic_dist_writew(opaque, offset, value & 0xffff, attrs);



It works as expects (I get thousands of IPIs per second now), but it does not "feel right", so is there a better way to improve the responsiveness of IPI handling in QEMU?

Best regards
Alex

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

end of thread, other threads:[~2015-06-25 17:13 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-12 16:38 [Qemu-devel] QEMU ARM SMP: IPI delivery delayed until next main loop event // how to improve IPI latency? Alex Züpke
2015-06-12 18:03 ` Peter Maydell
2015-06-15 14:44   ` Alex Züpke
2015-06-15 14:51     ` Peter Maydell
2015-06-15 15:05       ` Alex Züpke
2015-06-15 18:41         ` Peter Maydell
2015-06-15 18:58         ` Peter Maydell
2015-06-15 20:03           ` Alex Zuepke
2015-06-16 10:33             ` Peter Maydell
2015-06-16 10:59               ` Peter Maydell
2015-06-16 11:11                 ` Alex Züpke
2015-06-16 11:53                   ` Peter Maydell
2015-06-16 12:21                     ` Alex Züpke
2015-06-19 15:53                     ` Peter Maydell
2015-06-23  7:31                       ` Frederic Konrad
2015-06-23  8:09                         ` Peter Maydell
2015-06-23  8:33                           ` Frederic Konrad
2015-06-23 18:15                         ` Peter Maydell
2015-06-25 17:13                           ` Peter Maydell
2015-06-15 15:04 ` Peter Maydell
2015-06-15 15:07   ` Alex Züpke
2015-06-15 15:18     ` Peter Maydell
2015-06-15 15:36       ` Alex Züpke
2015-06-15 15:49         ` Peter Maydell
2015-06-15 16:12           ` Alex Züpke
2015-06-15 21:39           ` Peter Crosthwaite
2015-06-19 16:57 ` Paolo Bonzini
2015-06-19 17:25   ` Peter Maydell

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).