Skip to content

Commit

Permalink
KVM: Reduce atomic operations on vcpu->requests
Browse files Browse the repository at this point in the history
Usually the vcpu->requests bitmap is sparse, so a test_and_clear_bit() for
each request generates a large number of unneeded atomics if a bit is set.

Replace with a separate test/clear sequence.  This is safe since there is
no clear_bit() outside the vcpu thread.

Signed-off-by: Avi Kivity <avi@redhat.com>
  • Loading branch information
Avi Kivity committed Aug 1, 2010
1 parent a8eeb04 commit 0719837
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion include/linux/kvm_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,12 @@ static inline bool kvm_make_check_request(int req, struct kvm_vcpu *vcpu)

static inline bool kvm_check_request(int req, struct kvm_vcpu *vcpu)
{
return test_and_clear_bit(req, &vcpu->requests);
if (test_bit(req, &vcpu->requests)) {
clear_bit(req, &vcpu->requests);
return true;
} else {
return false;
}
}

#endif
Expand Down

0 comments on commit 0719837

Please sign in to comment.