From: Jan Kiszka <[email protected]>

This can provide hints why latencies are not as low as expected, even
without any hypervisor exits.

Signed-off-by: Jan Kiszka <[email protected]>
---
 inmates/demos/x86/apic-demo.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/inmates/demos/x86/apic-demo.c b/inmates/demos/x86/apic-demo.c
index ce03872e..8493ce73 100644
--- a/inmates/demos/x86/apic-demo.c
+++ b/inmates/demos/x86/apic-demo.c
@@ -12,24 +12,32 @@
 
 #include <inmate.h>
 
+#define MSR_MSI_COUNT          0x34
+
 #define POLLUTE_CACHE_SIZE     (512 * 1024)
 
 #define APIC_TIMER_VECTOR      32
 
 static unsigned long expected_time;
 static unsigned long min = -1, max;
+static u32 initial_smis;
 
 static void irq_handler(void)
 {
        unsigned long delta;
+       u32 smis;
 
        delta = tsc_read() - expected_time;
        if (delta < min)
                min = delta;
        if (delta > max)
                max = delta;
-       printk("Timer fired, jitter: %6ld ns, min: %6ld ns, max: %6ld ns\n",
+       printk("Timer fired, jitter: %6ld ns, min: %6ld ns, max: %6ld ns",
               delta, min, max);
+       smis = (u32)read_msr(MSR_MSI_COUNT);
+       if (smis != initial_smis)
+               printk(", SMIs: %d", smis - initial_smis);
+       printk("\n");
 
        expected_time += 100 * NS_PER_MSEC;
        apic_timer_set(expected_time - tsc_read());
@@ -80,6 +88,9 @@ void inmate_main(void)
                printk("Cache pollution enabled\n");
        }
 
+       initial_smis = (u32)read_msr(MSR_MSI_COUNT);
+       printk("Initial number of SMIs: %d\n", initial_smis);
+
        tsc_freq = tsc_init();
        printk("Calibrated TSC frequency: %lu.%03lu kHz\n", tsc_freq / 1000,
               tsc_freq % 1000);
-- 
2.16.4

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to