From: Roman Kagan <rkagan@virtuozzo.com>
To: "Radim Krčmář" <rkrcmar@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
kvm@vger.kernel.org
Cc: Denis Lunev <den@virtuozzo.com>, Roman Kagan <rkagan@virtuozzo.com>
Subject: [PATCH 2/5] kvm: add helper for testing ready async_pf's
Date: Fri, 2 Dec 2016 11:47:51 +0300 [thread overview]
Message-ID: <20161202084754.22860-3-rkagan@virtuozzo.com> (raw)
In-Reply-To: <20161202084754.22860-1-rkagan@virtuozzo.com>
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(-)
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 01c0b9c..e10516f 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -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
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 14a46e9..638fc5f 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -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))
diff --git a/virt/kvm/async_pf.c b/virt/kvm/async_pf.c
index efeceb0a..9cced14 100644
--- a/virt/kvm/async_pf.c
+++ b/virt/kvm/async_pf.c
@@ -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);
--
2.9.3
next prev parent reply other threads:[~2016-12-02 8:48 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-02 8:47 [PATCH 0/5] kvm: avoid delaying async_pf ready delivery Roman Kagan
2016-12-02 8:47 ` [PATCH 1/5] kvm/x86: fix inversed check for async_pf MSR Roman Kagan
2016-12-02 8:47 ` Roman Kagan [this message]
2016-12-02 8:47 ` [PATCH 3/5] kvm: kick vcpu when async_pf is resolved Roman Kagan
2016-12-02 9:35 ` Christian Borntraeger
2016-12-02 9:40 ` Paolo Bonzini
2016-12-02 10:00 ` Christian Borntraeger
2016-12-02 11:34 ` Roman Kagan
2016-12-05 8:08 ` Christian Borntraeger
2016-12-02 11:28 ` Roman Kagan
2016-12-03 4:02 ` kbuild test robot
2016-12-06 11:05 ` kbuild test robot
2016-12-02 8:47 ` [PATCH 4/5] kvm/vmx: kick L2 guest to L1 by ready async_pf Roman Kagan
2016-12-02 8:47 ` [PATCH 5/5] kvm/svm: " Roman Kagan
2016-12-02 9:35 ` Paolo Bonzini
2016-12-02 12:33 ` Roman Kagan
2016-12-12 12:40 ` Roman Kagan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161202084754.22860-3-rkagan@virtuozzo.com \
--to=rkagan@virtuozzo.com \
--cc=den@virtuozzo.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox