From: "Radim Krčmář" <rkrcmar@redhat.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Andrew Jones <drjones@redhat.com>,
Marc Zyngier <marc.zyngier@arm.com>,
Christian Borntraeger <borntraeger@de.ibm.com>,
Cornelia Huck <cornelia.huck@de.ibm.com>,
James Hogan <james.hogan@imgtec.com>,
Paul Mackerras <paulus@ozlabs.org>,
Christoffer Dall <christoffer.dall@linaro.org>,
David Hildenbrand <david@redhat.com>
Subject: [PATCH v2 3/5] KVM: add kvm_request_pending
Date: Fri, 24 Feb 2017 20:50:00 +0100 [thread overview]
Message-ID: <20170224195002.28030-4-rkrcmar@redhat.com> (raw)
In-Reply-To: <20170224195002.28030-1-rkrcmar@redhat.com>
Just to complete the encapsulation.
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
---
v2: add READ_ONCE [Drew]
---
arch/mips/kvm/trap_emul.c | 2 +-
arch/powerpc/kvm/booke.c | 2 +-
arch/powerpc/kvm/powerpc.c | 4 ++--
arch/s390/kvm/kvm-s390.c | 2 +-
arch/x86/kvm/x86.c | 4 ++--
include/linux/kvm_host.h | 6 +++++-
6 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/arch/mips/kvm/trap_emul.c b/arch/mips/kvm/trap_emul.c
index 35068823cde6..59e121343170 100644
--- a/arch/mips/kvm/trap_emul.c
+++ b/arch/mips/kvm/trap_emul.c
@@ -1029,7 +1029,7 @@ static void kvm_trap_emul_check_requests(struct kvm_vcpu *vcpu, int cpu,
struct mm_struct *mm;
int i;
- if (likely(!vcpu->requests))
+ if (likely(!kvm_request_pending(vcpu)))
return;
if (kvm_request_test_and_clear(KVM_REQ_TLB_FLUSH, vcpu)) {
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index e9098af0ab2a..54d2d1cca514 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -682,7 +682,7 @@ int kvmppc_core_prepare_to_enter(struct kvm_vcpu *vcpu)
kvmppc_core_check_exceptions(vcpu);
- if (vcpu->requests) {
+ if (kvm_request_pending(vcpu)) {
/* Exception delivery raised request; start over */
return 1;
}
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 2bcc03548c03..8a2ac7a24dd9 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -52,7 +52,7 @@ EXPORT_SYMBOL_GPL(kvmppc_pr_ops);
int kvm_arch_vcpu_runnable(struct kvm_vcpu *v)
{
return !!(v->arch.pending_exceptions) ||
- v->requests;
+ kvm_request_pending(v);
}
int kvm_arch_vcpu_should_kick(struct kvm_vcpu *vcpu)
@@ -104,7 +104,7 @@ int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu)
*/
smp_mb();
- if (vcpu->requests) {
+ if (kvm_request_pending(vcpu)) {
/* Make sure we process requests preemptable */
local_irq_enable();
trace_kvm_check_requests(vcpu);
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index b10acac8facf..089ca2c90d3e 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -2394,7 +2394,7 @@ static int kvm_s390_handle_requests(struct kvm_vcpu *vcpu)
{
retry:
kvm_s390_vcpu_request_handled(vcpu);
- if (!vcpu->requests)
+ if (!kvm_request_pending(vcpu))
return 0;
/*
* We use MMU_RELOAD just to re-arm the ipte notifier for the
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 16493795ab21..16ec68a0e972 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6724,7 +6724,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
bool req_immediate_exit = false;
- if (vcpu->requests) {
+ if (kvm_request_pending(vcpu)) {
if (kvm_request_test_and_clear(KVM_REQ_MMU_RELOAD, vcpu))
kvm_mmu_unload(vcpu);
if (kvm_request_test_and_clear(KVM_REQ_MIGRATE_TIMER, vcpu))
@@ -6888,7 +6888,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
kvm_x86_ops->sync_pir_to_irr(vcpu);
}
- if (vcpu->mode == EXITING_GUEST_MODE || vcpu->requests
+ if (vcpu->mode == EXITING_GUEST_MODE || kvm_request_pending(vcpu)
|| need_resched() || signal_pending(current)) {
vcpu->mode = OUTSIDE_GUEST_MODE;
smp_wmb();
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 6d637dbbb82f..f6c1f2267eb2 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -1098,13 +1098,17 @@ static inline int kvm_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
* 3) remote request with data (= kick + mb)
*
* TODO:
- * - completely encapsulate vcpu->requests
* - do not use __kvm_request* outside request helpers
* - do not use memory barrier in (1) and (2)
* - let architectures define custom vcpu kick
* - add kick when setting remote request
*/
+static inline bool kvm_request_pending(struct kvm_vcpu *vcpu)
+{
+ return READ_ONCE(vcpu->requests);
+}
+
static inline void __kvm_request_set(unsigned req, struct kvm_vcpu *vcpu)
{
set_bit(req, &vcpu->requests);
--
2.11.1
next prev parent reply other threads:[~2017-02-24 19:50 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-24 19:49 [PATCH v2 0/5] KVM: rename and encapsulate vcpu->requests API Radim Krčmář
2017-02-24 19:49 ` [PATCH v2 1/5] KVM: rename API for requests to match bit operations Radim Krčmář
2017-02-27 9:54 ` David Hildenbrand
2017-03-01 16:37 ` Radim Krčmář
2017-02-24 19:49 ` [PATCH v2 2/5] KVM: add KVM request variants without barrier Radim Krčmář
2017-02-27 10:02 ` David Hildenbrand
2017-02-27 10:18 ` David Hildenbrand
2017-03-01 16:58 ` Radim Krčmář
2017-02-28 7:34 ` Peter Xu
2017-02-28 7:40 ` Peter Xu
2017-03-01 17:02 ` Radim Krčmář
2017-03-02 1:15 ` Peter Xu
2017-03-02 2:26 ` Peter Xu
2017-02-24 19:50 ` Radim Krčmář [this message]
2017-02-27 10:02 ` [PATCH v2 3/5] KVM: add kvm_request_pending David Hildenbrand
2017-02-24 19:50 ` [PATCH v2 4/5] KVM: MIPS: remove useless kvm_request_clear Radim Krčmář
2017-02-27 8:45 ` Andrew Jones
2017-02-27 10:03 ` David Hildenbrand
2017-02-28 11:29 ` James Hogan
2017-03-01 17:04 ` Radim Krčmář
2017-02-24 19:50 ` [PATCH v2 5/5] KVM: optimize kvm_make_all_cpus_request Radim Krčmář
2017-02-27 8:47 ` [PATCH v2 0/5] KVM: rename and encapsulate vcpu->requests API Andrew Jones
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=20170224195002.28030-4-rkrcmar@redhat.com \
--to=rkrcmar@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=christoffer.dall@linaro.org \
--cc=cornelia.huck@de.ibm.com \
--cc=david@redhat.com \
--cc=drjones@redhat.com \
--cc=james.hogan@imgtec.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marc.zyngier@arm.com \
--cc=paulus@ozlabs.org \
--cc=pbonzini@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
all inboxes | Powered by JetHome®