Skip to contentSkip to conversation

ppc: Avoid decrementer related kvm exits

PATCH Applied David Gibson 2 participants 3 messages Oct 17, 2011 – Oct 21, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ppc: Avoid decrementer related kvm exits

In __cpu_ppc_store_decr(), we set up a regular timer used to trigger decrementer interrupts. This is necessary to implement the decrementer properly under TCG, but is unnecessary under KVM (true for both Book3S-PR and Book3S-HV KVM variants), because the kernel handles generating and delivering decrementer exceptions.

Under kvm, in fact, the timer causes expensive and unnecessary exits from kvm to qemu. This patch, therefore, disables setting the timer when kvm is in use.

---
 hw/ppc.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
hw/ppc.c +6 -0
index 25b59dd..d29af0b 100644
@@ -662,6 +662,12 @@ static void __cpu_ppc_store_decr (CPUState *env, uint64_t *nextp,
 
     LOG_TB("%s: %08" PRIx32 " => %08" PRIx32 "\n", __func__,
                 decr, value);
+
+    if (kvm_enabled()) {
+        /* KVM handles decrementer exceptions, we don't need our own timer */
+        return;
+    }
+
     now = qemu_get_clock_ns(vm_clock);
     next = now + muldiv64(value, get_ticks_per_sec(), tb_env->decr_freq);
     if (is_excp) {
Signature · 1 line
1.7.6.3
#1 lore raw
Quoted 6 lines · David Gibson

In __cpu_ppc_store_decr(), we set up a regular timer used to trigger decrementer interrupts. This is necessary to implement the decrementer properly under TCG, but is unnecessary under KVM (true for both Book3S-PR and Book3S-HV KVM variants), because the kernel handles generating and delivering decrementer exceptions.

Quoted 6 lines

Under kvm, in fact, the timer causes expensive and unnecessary exits from kvm to qemu. This patch, therefore, disables setting the timer when kvm is in use.

Thanks, applied to ppc-next.

Alex

#2 lore raw
Quoted 9 lines · Alexander Graf
Quoted 6 lines · David Gibson

In __cpu_ppc_store_decr(), we set up a regular timer used to trigger decrementer interrupts. This is necessary to implement the decrementer properly under TCG, but is unnecessary under KVM (true for both Book3S-PR and Book3S-HV KVM variants), because the kernel handles generating and delivering decrementer exceptions.

Quoted 8 lines
Quoted 6 lines

Under kvm, in fact, the timer causes expensive and unnecessary exits from kvm to qemu. This patch, therefore, disables setting the timer when kvm is in use.

Thanks, applied to ppc-next.

I think you've forgotten to push out the new ppc-next again..

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson