From 04c5d0d8b5c842e3a13f7f5f6a764e121269d135 Mon Sep 17 00:00:00 2001 From: Marcelo Tosatti Date: Thu, 8 May 2008 19:47:01 -0300 Subject: [PATCH] --- yaml --- r: 96921 b: refs/heads/master c: e5c239cfd5b0ec22751c099dbf4d91f3c504a64f h: refs/heads/master i: 96919: 3ec9341d4c43b1fd8032f7e0180a10c401bc89e5 v: v3 --- [refs] | 2 +- trunk/virt/kvm/kvm_main.c | 29 +++++++++++++++-------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/[refs] b/[refs] index 636f7c146786..36364675c9f6 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: bd25ed033af52c8c054d43a9cce9c5976266ae74 +refs/heads/master: e5c239cfd5b0ec22751c099dbf4d91f3c504a64f diff --git a/trunk/virt/kvm/kvm_main.c b/trunk/virt/kvm/kvm_main.c index f7ba099049ea..2d29e260da3d 100644 --- a/trunk/virt/kvm/kvm_main.c +++ b/trunk/virt/kvm/kvm_main.c @@ -758,25 +758,26 @@ void mark_page_dirty(struct kvm *kvm, gfn_t gfn) */ void kvm_vcpu_block(struct kvm_vcpu *vcpu) { - DECLARE_WAITQUEUE(wait, current); - - add_wait_queue(&vcpu->wq, &wait); - - /* - * We will block until either an interrupt or a signal wakes us up - */ - while (!kvm_cpu_has_interrupt(vcpu) - && !kvm_cpu_has_pending_timer(vcpu) - && !signal_pending(current) - && !kvm_arch_vcpu_runnable(vcpu)) { - set_current_state(TASK_INTERRUPTIBLE); + DEFINE_WAIT(wait); + + for (;;) { + prepare_to_wait(&vcpu->wq, &wait, TASK_INTERRUPTIBLE); + + if (kvm_cpu_has_interrupt(vcpu)) + break; + if (kvm_cpu_has_pending_timer(vcpu)) + break; + if (kvm_arch_vcpu_runnable(vcpu)) + break; + if (signal_pending(current)) + break; + vcpu_put(vcpu); schedule(); vcpu_load(vcpu); } - __set_current_state(TASK_RUNNING); - remove_wait_queue(&vcpu->wq, &wait); + finish_wait(&vcpu->wq, &wait); } void kvm_resched(struct kvm_vcpu *vcpu)