From: Paul Mackerras <paulus@samba.org> To: Alexander Graf <agraf@suse.de>, kvm-ppc@vger.kernel.org Cc: kvm@vger.kernel.org, "Suresh E. Warrier" <warrier@linux.vnet.ibm.com>, Paul Mackerras <paulus@samba.org> Subject: [PATCH 5/5] KVM: PPC: Book3S HV: Check wait conditions before sleeping in kvmppc_vcore_blocked Date: Mon, 3 Nov 2014 15:52:00 +1100 [thread overview] Message-ID: <1414990320-6378-6-git-send-email-paulus@samba.org> (raw) In-Reply-To: <1414990320-6378-1-git-send-email-paulus@samba.org> From: "Suresh E. Warrier" <warrier@linux.vnet.ibm.com> The kvmppc_vcore_blocked() code does not check for the wait condition after putting the process on the wait queue. This means that it is possible for an external interrupt to become pending, but the vcpu to remain asleep until the next decrementer interrupt. The fix is to make one last check for pending exceptions and ceded state before calling schedule(). Signed-off-by: Suresh Warrier <warrier@linux.vnet.ibm.com> Signed-off-by: Paul Mackerras <paulus@samba.org> --- arch/powerpc/kvm/book3s_hv.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index cd7e030..1a7a281 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -1828,9 +1828,29 @@ static void kvmppc_wait_for_exec(struct kvm_vcpu *vcpu, int wait_state) */ static void kvmppc_vcore_blocked(struct kvmppc_vcore *vc) { + struct kvm_vcpu *vcpu; + int do_sleep = 1; + DEFINE_WAIT(wait); prepare_to_wait(&vc->wq, &wait, TASK_INTERRUPTIBLE); + + /* + * Check one last time for pending exceptions and ceded state after + * we put ourselves on the wait queue + */ + list_for_each_entry(vcpu, &vc->runnable_threads, arch.run_list) { + if (vcpu->arch.pending_exceptions || !vcpu->arch.ceded) { + do_sleep = 0; + break; + } + } + + if (!do_sleep) { + finish_wait(&vc->wq, &wait); + return; + } + vc->vcore_state = VCORE_SLEEPING; spin_unlock(&vc->lock); schedule(); -- 2.1.1
WARNING: multiple messages have this Message-ID (diff)
From: Paul Mackerras <paulus@samba.org> To: Alexander Graf <agraf@suse.de>, kvm-ppc@vger.kernel.org Cc: kvm@vger.kernel.org, "Suresh E. Warrier" <warrier@linux.vnet.ibm.com>, Paul Mackerras <paulus@samba.org> Subject: [PATCH 5/5] KVM: PPC: Book3S HV: Check wait conditions before sleeping in kvmppc_vcore_blocked Date: Mon, 03 Nov 2014 04:52:00 +0000 [thread overview] Message-ID: <1414990320-6378-6-git-send-email-paulus@samba.org> (raw) In-Reply-To: <1414990320-6378-1-git-send-email-paulus@samba.org> From: "Suresh E. Warrier" <warrier@linux.vnet.ibm.com> The kvmppc_vcore_blocked() code does not check for the wait condition after putting the process on the wait queue. This means that it is possible for an external interrupt to become pending, but the vcpu to remain asleep until the next decrementer interrupt. The fix is to make one last check for pending exceptions and ceded state before calling schedule(). Signed-off-by: Suresh Warrier <warrier@linux.vnet.ibm.com> Signed-off-by: Paul Mackerras <paulus@samba.org> --- arch/powerpc/kvm/book3s_hv.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index cd7e030..1a7a281 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -1828,9 +1828,29 @@ static void kvmppc_wait_for_exec(struct kvm_vcpu *vcpu, int wait_state) */ static void kvmppc_vcore_blocked(struct kvmppc_vcore *vc) { + struct kvm_vcpu *vcpu; + int do_sleep = 1; + DEFINE_WAIT(wait); prepare_to_wait(&vc->wq, &wait, TASK_INTERRUPTIBLE); + + /* + * Check one last time for pending exceptions and ceded state after + * we put ourselves on the wait queue + */ + list_for_each_entry(vcpu, &vc->runnable_threads, arch.run_list) { + if (vcpu->arch.pending_exceptions || !vcpu->arch.ceded) { + do_sleep = 0; + break; + } + } + + if (!do_sleep) { + finish_wait(&vc->wq, &wait); + return; + } + vc->vcore_state = VCORE_SLEEPING; spin_unlock(&vc->lock); schedule(); -- 2.1.1
next prev parent reply other threads:[~2014-11-03 4:52 UTC|newest] Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-11-03 4:51 [PATCH 0/5] Some fixes for HV KVM on PPC Paul Mackerras 2014-11-03 4:51 ` Paul Mackerras 2014-11-03 4:51 ` [PATCH 1/5] KVM: PPC: Book3S HV: Fix computation of tlbie operand Paul Mackerras 2014-11-03 4:51 ` Paul Mackerras 2014-11-03 5:59 ` Aneesh Kumar K.V 2014-11-03 6:11 ` Aneesh Kumar K.V 2014-11-03 6:29 ` Aneesh Kumar K.V 2014-11-03 6:41 ` Aneesh Kumar K.V 2014-11-03 4:51 ` [PATCH 2/5] KVM: PPC: Book3S HV: Fix an issue where guest is paused on receiving HMI Paul Mackerras 2014-11-03 4:51 ` Paul Mackerras 2014-11-20 17:32 ` Alexander Graf 2014-11-20 17:32 ` Alexander Graf 2014-11-03 4:51 ` [PATCH 3/5] KVM: PPC: Book3S HV: Fix KSM memory corruption Paul Mackerras 2014-11-03 4:51 ` Paul Mackerras 2014-11-03 4:51 ` [PATCH 4/5] KVM: PPC: Book3S HV: Fix inaccuracies in ICP emulation for H_IPI Paul Mackerras 2014-11-03 4:51 ` Paul Mackerras 2014-11-03 4:52 ` Paul Mackerras [this message] 2014-11-03 4:52 ` [PATCH 5/5] KVM: PPC: Book3S HV: Check wait conditions before sleeping in kvmppc_vcore_blocked Paul Mackerras 2014-11-20 17:36 ` Alexander Graf 2014-11-20 17:36 ` Alexander Graf 2014-11-20 19:31 ` Suresh E. Warrier 2014-11-20 19:31 ` Suresh E. Warrier 2014-11-23 0:41 ` Alexander Graf 2014-11-23 0:41 ` Alexander Graf 2014-11-20 17:36 ` [PATCH 0/5] Some fixes for HV KVM on PPC Alexander Graf 2014-11-20 17:36 ` Alexander Graf
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=1414990320-6378-6-git-send-email-paulus@samba.org \ --to=paulus@samba.org \ --cc=agraf@suse.de \ --cc=kvm-ppc@vger.kernel.org \ --cc=kvm@vger.kernel.org \ --cc=warrier@linux.vnet.ibm.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.