@@ -180,7 +180,7 @@ static void apf_task_wake_one(struct kvm_task_sleep_node *n)
hlist_del_init(&n->link);
if (n->halted)
smp_send_reschedule(n->cpu);
- else if (swait_active(&n->wq))
+ else
swake_up(&n->wq);
}
@@ -1325,9 +1325,7 @@ static void apic_timer_expired(struct kvm_lapic *apic)
atomic_inc(&apic->lapic_timer.pending);
kvm_set_pending_timer(vcpu);
-
- if (swait_active(q))
- swake_up(q);
+ swake_up(q);
if (apic_lvtt_tscdeadline(apic))
ktimer->expired_tscdeadline = ktimer->tscdeadline;
@@ -110,8 +110,7 @@ static void async_pf_execute(struct work_struct *work)
* This memory barrier pairs with prepare_to_wait's set_current_state()
*/
smp_mb();
- if (swait_active(&vcpu->wq))
- swake_up(&vcpu->wq);
+ swake_up(&vcpu->wq);
mmput(mm);
kvm_put_kvm(vcpu->kvm);
@@ -2182,11 +2182,7 @@ EXPORT_SYMBOL_GPL(kvm_vcpu_block);
bool kvm_vcpu_wake_up(struct kvm_vcpu *vcpu)
{
- struct swait_queue_head *wqp;
-
- wqp = kvm_arch_vcpu_wq(vcpu);
- if (swait_active(wqp)) {
- swake_up(wqp);
+ if (swake_up(kvm_arch_vcpu_wq(vcpu))) {
++vcpu->stat.halt_wakeup;
return true;
}
Cleanup kvm_vcpu_wake_up() to use the new swake_up() interface, I think kvm_vcpu.stat.halt_wakeup should be more accurate. Meanwhile, touch up some other part of kvm codes to avoid checking swait_active() twice. Signed-off-by: Peter Xu <peterx@redhat.com> --- arch/x86/kernel/kvm.c | 2 +- arch/x86/kvm/lapic.c | 4 +--- virt/kvm/async_pf.c | 3 +-- virt/kvm/kvm_main.c | 6 +----- 4 files changed, 4 insertions(+), 11 deletions(-)