@@ -1207,4 +1207,11 @@ static inline bool vcpu_valid_wakeup(struct kvm_vcpu *vcpu)
}
#endif /* CONFIG_HAVE_KVM_INVALID_WAKEUPS */
+#ifdef CONFIG_KVM_ASYNC_PF
+static inline bool kvm_async_pf_has_ready(struct kvm_vcpu *vcpu)
+{
+ return !list_empty_careful(&vcpu->async_pf.done);
+}
+#endif
+
#endif
@@ -8182,7 +8182,7 @@ void kvm_arch_flush_shadow_memslot(struct kvm *kvm,
static inline bool kvm_vcpu_has_events(struct kvm_vcpu *vcpu)
{
- if (!list_empty_careful(&vcpu->async_pf.done))
+ if (kvm_async_pf_has_ready(vcpu))
return true;
if (kvm_apic_has_events(vcpu))
@@ -159,7 +159,7 @@ void kvm_check_async_pf_completion(struct kvm_vcpu *vcpu)
{
struct kvm_async_pf *work;
- while (!list_empty_careful(&vcpu->async_pf.done) &&
+ while (kvm_async_pf_has_ready(vcpu) &&
kvm_arch_can_inject_async_page_present(vcpu)) {
spin_lock(&vcpu->async_pf.lock);
work = list_first_entry(&vcpu->async_pf.done, typeof(*work),
@@ -227,7 +227,7 @@ int kvm_async_pf_wakeup_all(struct kvm_vcpu *vcpu)
{
struct kvm_async_pf *work;
- if (!list_empty_careful(&vcpu->async_pf.done))
+ if (kvm_async_pf_has_ready(vcpu))
return 0;
work = kmem_cache_zalloc(async_pf_cache, GFP_ATOMIC);
Add helper inline function to test if there are async_pf's ready on a given vCPU. There are already 3 callsites for it and I'm about to add more. Signed-off-by: Roman Kagan <rkagan@virtuozzo.com> --- include/linux/kvm_host.h | 7 +++++++ arch/x86/kvm/x86.c | 2 +- virt/kvm/async_pf.c | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-)