Skip to content

Commit

Permalink
kvm: Serialize wq active checks in kvm_vcpu_wake_up()
Browse files Browse the repository at this point in the history
This is a generic call and can be suceptible to races
in reading the wq task_list while another task is adding
itself to the list. Add a full barrier by using the
swq_has_sleeper() helper.

Signed-off-by: Davidlohr Bueso <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
Davidlohr Bueso authored and bonzini committed Sep 15, 2017
1 parent a0cff57 commit 5e0018b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion virt/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2187,7 +2187,7 @@ bool kvm_vcpu_wake_up(struct kvm_vcpu *vcpu)
struct swait_queue_head *wqp;

wqp = kvm_arch_vcpu_wq(vcpu);
if (swait_active(wqp)) {
if (swq_has_sleeper(wqp)) {
swake_up(wqp);
++vcpu->stat.halt_wakeup;
return true;
Expand Down

0 comments on commit 5e0018b

Please sign in to comment.