* [Qemu-devel] [PATCH] [PPC] [KVM] Make iothread work
@ 2010-04-18 21:10 Alexander Graf
2010-05-18 18:22 ` Aurelien Jarno
0 siblings, 1 reply; 2+ messages in thread
From: Alexander Graf @ 2010-04-18 21:10 UTC (permalink / raw)
To: qemu-devel Developers; +Cc: Aurelien Jarno
When running with --enable-io-thread the timer we have doesn't help,
because it doesn't wake up the CPU thread. So instead we need to
actually kick it.
While at it I refined the logic a bit to not dumbly trigger a timer
every 500ms, but rather do it more often after an interrupt got injected.
If there's no level based interrupt to be expected, we don't need the
timer anyways.
This makes qemu-system-ppc with --enable-io-thread work when using KVM.
Signed-off-by: Alexander Graf <agraf@suse.de>
---
target-ppc/kvm.c | 30 +++++++++++++++---------------
1 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index aa3d432..6e7a023 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -37,20 +37,20 @@
do { } while (0)
#endif
-/* XXX For some odd reason we sometimes hang inside KVM forever. I'd guess it's
- * a race condition where we actually have a level triggered interrupt, but
- * the infrastructure can't expose that yet, so the guest ACKs it, goes to
- * sleep and never gets notified that there's still an interrupt pending.
+/* XXX We have a race condition where we actually have a level triggered
+ * interrupt, but the infrastructure can't expose that yet, so the guest
+ * takes but ignores it, goes to sleep and never gets notified that there's
+ * still an interrupt pending.
*
- * As a quick workaround, let's just wake up every 500 ms. That way we can
- * assure that we're always reinjecting interrupts in time.
+ * As a quick workaround, let's just wake up again 20 ms after we injected
+ * an interrupt. That way we can assure that we're always reinjecting
+ * interrupts in case the guest swallowed them.
*/
static QEMUTimer *idle_timer;
-static void do_nothing(void *opaque)
+static void kvm_kick_env(void *env)
{
- qemu_mod_timer(idle_timer, qemu_get_clock(vm_clock) +
- (get_ticks_per_sec() / 2));
+ qemu_cpu_kick(env);
}
int kvm_arch_init(KVMState *s, int smp_cpus)
@@ -66,6 +66,8 @@ int kvm_arch_init_vcpu(CPUState *cenv)
sregs.pvr = cenv->spr[SPR_PVR];
ret = kvm_vcpu_ioctl(cenv, KVM_SET_SREGS, &sregs);
+ idle_timer = qemu_new_timer(vm_clock, kvm_kick_env, cenv);
+
return ret;
}
@@ -189,12 +191,6 @@ int kvm_arch_pre_run(CPUState *env, struct kvm_run *run)
int r;
unsigned irq;
- if (!idle_timer) {
- idle_timer = qemu_new_timer(vm_clock, do_nothing, NULL);
- qemu_mod_timer(idle_timer, qemu_get_clock(vm_clock) +
- (get_ticks_per_sec() / 2));
- }
-
/* PowerPC Qemu tracks the various core input pins (interrupt, critical
* interrupt, reset, etc) in PPC-specific env->irq_input_state. */
if (run->ready_for_interrupt_injection &&
@@ -211,6 +207,10 @@ int kvm_arch_pre_run(CPUState *env, struct kvm_run *run)
r = kvm_vcpu_ioctl(env, KVM_INTERRUPT, &irq);
if (r < 0)
printf("cpu %d fail inject %x\n", env->cpu_index, irq);
+
+ /* Always wake up soon in case the interrupt was level based */
+ qemu_mod_timer(idle_timer, qemu_get_clock(vm_clock) +
+ (get_ticks_per_sec() / 50));
}
/* We don't know if there are more interrupts pending after this. However,
--
1.6.0.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] [PPC] [KVM] Make iothread work
2010-04-18 21:10 [Qemu-devel] [PATCH] [PPC] [KVM] Make iothread work Alexander Graf
@ 2010-05-18 18:22 ` Aurelien Jarno
0 siblings, 0 replies; 2+ messages in thread
From: Aurelien Jarno @ 2010-05-18 18:22 UTC (permalink / raw)
To: Alexander Graf; +Cc: qemu-devel Developers
On Sun, Apr 18, 2010 at 11:10:17PM +0200, Alexander Graf wrote:
> When running with --enable-io-thread the timer we have doesn't help,
> because it doesn't wake up the CPU thread. So instead we need to
> actually kick it.
>
> While at it I refined the logic a bit to not dumbly trigger a timer
> every 500ms, but rather do it more often after an interrupt got injected.
> If there's no level based interrupt to be expected, we don't need the
> timer anyways.
>
> This makes qemu-system-ppc with --enable-io-thread work when using KVM.
>
> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
> target-ppc/kvm.c | 30 +++++++++++++++---------------
> 1 files changed, 15 insertions(+), 15 deletions(-)
Thanks, applied.
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-05-18 18:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-18 21:10 [Qemu-devel] [PATCH] [PPC] [KVM] Make iothread work Alexander Graf
2010-05-18 18:22 ` Aurelien Jarno
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).