KVM: Fix unbounded preemption latency
authorAvi Kivity <avi@qumranet.com>
Tue, 15 Jan 2008 16:27:32 +0000 (18:27 +0200)
committerAvi Kivity <avi@qumranet.com>
Wed, 30 Jan 2008 16:01:22 +0000 (18:01 +0200)
When preparing to enter the guest, if an interrupt comes in while
preemption is disabled but interrupts are still enabled, we miss a
preemption point.  Fix by explicitly checking whether we need to
reschedule.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Avi Kivity <avi@qumranet.com>
arch/x86/kvm/x86.c

index 77d57ff3d74ebf6d88501cfda6cea522b396b250..f0493e7dcf0cd6de76d932b9f5fb7fe28d9a13a7 100644 (file)
@@ -2535,6 +2535,13 @@ again:
 
        local_irq_disable();
 
+       if (need_resched()) {
+               local_irq_enable();
+               preempt_enable();
+               r = 1;
+               goto out;
+       }
+
        if (signal_pending(current)) {
                local_irq_enable();
                preempt_enable();