From: "Radim Krčmář" <rkrcmar@redhat.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: Christoffer Dall <cdall@linaro.org>,
Andrew Jones <drjones@redhat.com>,
Marc Zyngier <marc.zyngier@arm.com>,
Paolo Bonzini <pbonzini@redhat.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>
Subject: [PATCH v2 8/9] KVM: return if kvm_vcpu_wake_up() did wake up the VCPU
Date: Wed, 26 Apr 2017 22:32:26 +0200 [thread overview]
Message-ID: <20170426203227.12321-9-rkrcmar@redhat.com> (raw)
In-Reply-To: <20170426203227.12321-1-rkrcmar@redhat.com>
No need to kick a VCPU that we have just woken up.
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
---
include/linux/kvm_host.h | 2 +-
virt/kvm/kvm_main.c | 12 ++++++++----
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 955debd82cf2..38cfe372918c 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -698,7 +698,7 @@ void kvm_vcpu_mark_page_dirty(struct kvm_vcpu *vcpu, gfn_t gfn);
void kvm_vcpu_block(struct kvm_vcpu *vcpu);
void kvm_arch_vcpu_blocking(struct kvm_vcpu *vcpu);
void kvm_arch_vcpu_unblocking(struct kvm_vcpu *vcpu);
-void kvm_vcpu_wake_up(struct kvm_vcpu *vcpu);
+bool kvm_vcpu_wake_up(struct kvm_vcpu *vcpu);
void kvm_vcpu_kick(struct kvm_vcpu *vcpu);
int kvm_vcpu_yield_to(struct kvm_vcpu *target);
void kvm_vcpu_on_spin(struct kvm_vcpu *vcpu);
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 1efb07643035..632f7b3e198c 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -183,8 +183,8 @@ bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req)
kvm_make_request(req, vcpu);
cpu = vcpu->cpu;
- if (!(req & KVM_REQUEST_NO_WAKEUP))
- kvm_vcpu_wake_up(vcpu);
+ if (!(req & KVM_REQUEST_NO_WAKEUP) && kvm_vcpu_wake_up(vcpu))
+ continue;
if (cpus != NULL && cpu != -1 && cpu != me &&
kvm_vcpu_exiting_guest_mode(vcpu) != OUTSIDE_GUEST_MODE)
@@ -2195,7 +2195,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
}
EXPORT_SYMBOL_GPL(kvm_vcpu_block);
-void kvm_vcpu_wake_up(struct kvm_vcpu *vcpu)
+bool kvm_vcpu_wake_up(struct kvm_vcpu *vcpu)
{
struct swait_queue_head *wqp;
@@ -2203,8 +2203,10 @@ void kvm_vcpu_wake_up(struct kvm_vcpu *vcpu)
if (swait_active(wqp)) {
swake_up(wqp);
++vcpu->stat.halt_wakeup;
+ return true;
}
+ return false;
}
EXPORT_SYMBOL_GPL(kvm_vcpu_wake_up);
@@ -2216,7 +2218,9 @@ void kvm_vcpu_kick(struct kvm_vcpu *vcpu)
int me;
int cpu = vcpu->cpu;
- kvm_vcpu_wake_up(vcpu);
+ if (kvm_vcpu_wake_up(vcpu))
+ return;
+
me = get_cpu();
if (cpu != me && (unsigned)cpu < nr_cpu_ids && cpu_online(cpu))
if (kvm_arch_vcpu_should_kick(vcpu))
--
2.12.2
next prev parent reply other threads:[~2017-04-26 20:33 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-26 20:32 [PATCH v2 0/9] KVM: towards maintainable kvm_make_all_cpus_request() Radim Krčmář
2017-04-26 20:32 ` [PATCH v2 1/9] KVM: add kvm_{test,clear}_request to replace {test,clear}_bit Radim Krčmář
2017-04-27 11:33 ` Andrew Jones
2017-04-27 11:38 ` Cornelia Huck
2017-04-26 20:32 ` [PATCH v2 2/9] KVM: x86: always use kvm_make_request instead of set_bit Radim Krčmář
2017-04-27 11:33 ` Andrew Jones
2017-04-26 20:32 ` [PATCH v2 3/9] KVM: remove #ifndef CONFIG_S390 around kvm_vcpu_wake_up Radim Krčmář
2017-04-27 11:45 ` Cornelia Huck
2017-05-03 16:05 ` Radim Krčmář
2017-05-03 16:16 ` [PATCH v3] " Radim Krčmář
2017-05-03 17:04 ` Cornelia Huck
2017-04-26 20:32 ` [PATCH v2 4/9] KVM: mark requests that do not need a wakeup Radim Krčmář
2017-04-27 11:35 ` Andrew Jones
2017-04-27 12:00 ` Cornelia Huck
2017-04-26 20:32 ` [PATCH v2 5/9] KVM: perform a wake_up in kvm_make_all_cpus_request Radim Krčmář
2017-04-27 11:36 ` Andrew Jones
2017-04-27 12:06 ` Cornelia Huck
2017-04-27 12:15 ` Paolo Bonzini
2017-04-26 20:32 ` [PATCH v2 6/9] KVM: add explicit barrier to kvm_vcpu_kick Radim Krčmář
2017-04-26 20:32 ` [PATCH v2 7/9] KVM: improve arch vcpu request defining Radim Krčmář
2017-04-27 12:11 ` Cornelia Huck
2017-04-26 20:32 ` Radim Krčmář [this message]
2017-04-27 11:41 ` [PATCH v2 8/9] KVM: return if kvm_vcpu_wake_up() did wake up the VCPU Andrew Jones
2017-04-26 20:32 ` [PATCH v2 9/9] KVM: mark requests that need synchronization Radim Krčmář
2017-04-27 11:55 ` Andrew Jones
2017-04-27 12:36 ` Paolo Bonzini
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=20170426203227.12321-9-rkrcmar@redhat.com \
--to=rkrcmar@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cdall@linaro.org \
--cc=cornelia.huck@de.ibm.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;
as well as URLs for NNTP newsgroup(s).