From: Jerone Young Date: Mon, 31 Mar 2008 12:57:54 +0000 Subject: [kvm-ppc-devel] [PATCH 2 of 2] Add PowerPC KVM guest wait handling Message-Id: <529f5a653d1e86b81270.1206968274@thinkpadL> List-Id: References: <21179d0ab8a62ecc24d1.1206740047@thinkpadL> In-Reply-To: <21179d0ab8a62ecc24d1.1206740047@thinkpadL> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: kvm-ppc@vger.kernel.org # HG changeset patch # User Jerone Young # Date 1206968186 18000 # Node ID 529f5a653d1e86b81270eeb7598dafcdba9abc1d # Parent 15675e59e019c4800a834ae79090d92b07f1d0ce 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 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 @@ -214,6 +214,10 @@ static void kvmppc_deliver_interrupt(str vcpu->arch.tsr |= TSR_DIS; break; } + + /* clear guest wait state */ + if (vcpu->arch.msr & MSR_WE) + vcpu->arch.msr &= ~MSR_WE; vcpu->arch.srr0 = vcpu->arch.pc; vcpu->arch.srr1 = vcpu->arch.msr; @@ -452,6 +456,20 @@ int kvmppc_handle_exit(struct kvm_run *r local_irq_disable(); kvmppc_check_and_deliver_interrupts(vcpu); + + /* handle guest vcpu that is in wait state */ + if (vcpu->arch.msr & MSR_WE) { + DECLARE_WAITQUEUE(wait, current); + add_wait_queue(&vcpu->wq, &wait); + + while (!signal_pending(current)) { + set_current_state(TASK_INTERRUPTIBLE); + schedule(); + } + + set_current_state(TASK_RUNNING); + remove_wait_queue(&vcpu->wq, &wait); + } /* Do some exit accounting. */ vcpu->stat.exits++; ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace _______________________________________________ kvm-ppc-devel mailing list kvm-ppc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel