From: Avi Kivity Date: Mon, 10 May 2010 10:08:26 +0000 (+0300) Subject: KVM: Reduce atomic operations on vcpu->requests X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0719837c0832a7b305e42327caa7d330462360ea;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git KVM: Reduce atomic operations on vcpu->requests 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 --- diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index c8a9d628898e..e820eb579108 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -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