]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
KVM: Reduce atomic operations on vcpu->requests
authorAvi Kivity <avi@redhat.com>
Mon, 10 May 2010 10:08:26 +0000 (13:08 +0300)
committerAvi Kivity <avi@redhat.com>
Sun, 1 Aug 2010 07:47:06 +0000 (10:47 +0300)
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>
include/linux/kvm_host.h

index c8a9d628898e43323a7140e29156bd40ca546940..e820eb5791083b3f7cc77bac258bda326e0278f4 100644 (file)
@@ -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