Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0719837c authored by Avi Kivity's avatar Avi Kivity
Browse files

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: default avatarAvi Kivity <avi@redhat.com>
parent a8eeb04a
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -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