From: Hollis B. <ho...@us...> - 2008-04-15 15:30:00
|
On Thursday 03 April 2008 14:35:59 Jerone Young wrote: > # HG changeset patch > # User Jerone Young <jy...@us...> > # Date 1207250241 18000 > # Node ID 3e781009d2f28c4691ccbb999bf679716f66f349 > # Parent b7794c1fa50b531c9b84382c3f3d9a5466d86c0d > Add PowerPC KVM guest wait handling support > > This patch handles a guest that is in a wait state. This ensures that the > guest is not allways eating up 100% cpu when it is idle. > > Signed-off-by: Jerone Young <jy...@us...> > > diff --git a/arch/powerpc/kvm/emulate.c b/arch/powerpc/kvm/emulate.c > --- a/arch/powerpc/kvm/emulate.c > +++ b/arch/powerpc/kvm/emulate.c > @@ -269,6 +269,25 @@ int kvmppc_emulate_instruction(struct kv > case 146: /* mtmsr */ > rs = get_rs(inst); > kvmppc_set_msr(vcpu, vcpu->arch.gpr[rs]); > + > + /* handle guest vcpu that is in wait state */ > + if (vcpu->arch.msr & MSR_WE) { > + /* XXX eventually replace with kvm_vcpu_block() */ > + DECLARE_WAITQUEUE(wait, current); > + > + add_wait_queue(&vcpu->wq, &wait); > + > + while (!kvm_cpu_has_interrupt(vcpu) > + && !signal_pending(current) > + && !kvm_arch_vcpu_runnable(vcpu)) { > + set_current_state(TASK_INTERRUPTIBLE); > + schedule(); > + } > + > + __set_current_state(TASK_RUNNING); > + remove_wait_queue(&vcpu->wq, &wait); > + } > + > break; > > case 163: /* wrteei */ > diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c > --- a/arch/powerpc/kvm/powerpc.c > +++ b/arch/powerpc/kvm/powerpc.c > @@ -164,13 +164,12 @@ void kvmppc_dump_vcpu(struct kvm_vcpu *v > > int kvm_cpu_has_interrupt(struct kvm_vcpu *v) > { > - /* XXX implement me */ > - return 0; > + return !!(v->arch.pending_exceptions); > } > > int kvm_arch_vcpu_runnable(struct kvm_vcpu *v) > { > - return 1; > + return !(v->arch.msr & MSR_WE); > } > > /* Check if we are ready to deliver the interrupt */ Hmm, did you ever revise this patch? I don't see the corrected version. -- Hollis Blanchard IBM Linux Technology Center |