Commit 214bd3a6 authored by Marc Zyngier's avatar Marc Zyngier Committed by Paolo Bonzini

KVM: Convert kvm_for_each_vcpu() to using xa_for_each_range()

Now that the vcpu array is backed by an xarray, use the optimised
iterator that matches the underlying data structure.
Suggested-by: default avatarSean Christopherson <seanjc@google.com>
Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
Message-Id: <20211116160403.4074052-8-maz@kernel.org>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 46808a4c
...@@ -705,11 +705,9 @@ static inline struct kvm_vcpu *kvm_get_vcpu(struct kvm *kvm, int i) ...@@ -705,11 +705,9 @@ static inline struct kvm_vcpu *kvm_get_vcpu(struct kvm *kvm, int i)
return xa_load(&kvm->vcpu_array, i); return xa_load(&kvm->vcpu_array, i);
} }
#define kvm_for_each_vcpu(idx, vcpup, kvm) \ #define kvm_for_each_vcpu(idx, vcpup, kvm) \
for (idx = 0; \ xa_for_each_range(&kvm->vcpu_array, idx, vcpup, 0, \
idx < atomic_read(&kvm->online_vcpus) && \ (atomic_read(&kvm->online_vcpus) - 1))
(vcpup = kvm_get_vcpu(kvm, idx)) != NULL; \
idx++)
static inline struct kvm_vcpu *kvm_get_vcpu_by_id(struct kvm *kvm, int id) static inline struct kvm_vcpu *kvm_get_vcpu_by_id(struct kvm *kvm, int id)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment