All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Mackerras <paulus@samba.org>
To: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org
Cc: Alexander Graf <agraf@suse.de>
Subject: [PATCH 07/12] KVM: PPC: Book3S HV: Don't wake thread with no vcpu on guest IPI
Date: Fri, 27 Mar 2015 14:29:51 +1100	[thread overview]
Message-ID: <1427426996-17651-8-git-send-email-paulus@samba.org> (raw)
In-Reply-To: <1427426996-17651-1-git-send-email-paulus@samba.org>

When running a multi-threaded guest and vcpu 0 in a virtual core
is not running in the guest (i.e. it is busy elsewhere in the host),
thread 0 of the physical core will switch the MMU to the guest and
then go to nap mode in the code at kvm_do_nap.  If the guest sends
an IPI to thread 0 using the msgsndp instruction, that will wake
up thread 0 and cause all the threads in the guest to exit to the
host unnecessarily.  To avoid the unnecessary exit, this arranges
for the PECEDP bit to be cleared in this situation.  When napping
due to a H_CEDE from the guest, we still set PECEDP so that the
thread will wake up on an IPI sent using msgsndp.

Signed-off-by: Paul Mackerras <paulus@samba.org>
---
 arch/powerpc/kvm/book3s_hv_rmhandlers.S | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
index 0a35b8d..35b1847 100644
--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -191,6 +191,7 @@ kvmppc_primary_no_guest:
 	li	r3, NAPPING_NOVCPU
 	stb	r3, HSTATE_NAPPING(r13)
 
+	li	r3, 0		/* Don't wake on privileged (OS) doorbell */
 	b	kvm_do_nap
 
 kvm_novcpu_wakeup:
@@ -2128,10 +2129,13 @@ _GLOBAL(kvmppc_h_cede)		/* r3 = vcpu pointer, r11 = msr, r13 = paca */
 	bl	kvmhv_accumulate_time
 #endif
 
+	lis	r3, LPCR_PECEDP@h	/* Do wake on privileged doorbell */
+
 	/*
 	 * Take a nap until a decrementer or external or doobell interrupt
-	 * occurs, with PECE1, PECE0 and PECEDP set in LPCR. Also clear the
-	 * runlatch bit before napping.
+	 * occurs, with PECE1 and PECE0 set in LPCR.
+	 * On POWER8, if we are ceding, also set PECEDP.
+	 * Also clear the runlatch bit before napping.
 	 */
 kvm_do_nap:
 	mfspr	r0, SPRN_CTRLF
@@ -2143,7 +2147,7 @@ kvm_do_nap:
 	mfspr	r5,SPRN_LPCR
 	ori	r5,r5,LPCR_PECE0 | LPCR_PECE1
 BEGIN_FTR_SECTION
-	oris	r5,r5,LPCR_PECEDP@h
+	rlwimi	r5, r3, 0, LPCR_PECEDP
 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
 	mtspr	SPRN_LPCR,r5
 	isync
-- 
2.1.4


WARNING: multiple messages have this Message-ID (diff)
From: Paul Mackerras <paulus@samba.org>
To: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org
Cc: Alexander Graf <agraf@suse.de>
Subject: [PATCH 07/12] KVM: PPC: Book3S HV: Don't wake thread with no vcpu on guest IPI
Date: Fri, 27 Mar 2015 03:29:51 +0000	[thread overview]
Message-ID: <1427426996-17651-8-git-send-email-paulus@samba.org> (raw)
In-Reply-To: <1427426996-17651-1-git-send-email-paulus@samba.org>

When running a multi-threaded guest and vcpu 0 in a virtual core
is not running in the guest (i.e. it is busy elsewhere in the host),
thread 0 of the physical core will switch the MMU to the guest and
then go to nap mode in the code at kvm_do_nap.  If the guest sends
an IPI to thread 0 using the msgsndp instruction, that will wake
up thread 0 and cause all the threads in the guest to exit to the
host unnecessarily.  To avoid the unnecessary exit, this arranges
for the PECEDP bit to be cleared in this situation.  When napping
due to a H_CEDE from the guest, we still set PECEDP so that the
thread will wake up on an IPI sent using msgsndp.

Signed-off-by: Paul Mackerras <paulus@samba.org>
---
 arch/powerpc/kvm/book3s_hv_rmhandlers.S | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
index 0a35b8d..35b1847 100644
--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -191,6 +191,7 @@ kvmppc_primary_no_guest:
 	li	r3, NAPPING_NOVCPU
 	stb	r3, HSTATE_NAPPING(r13)
 
+	li	r3, 0		/* Don't wake on privileged (OS) doorbell */
 	b	kvm_do_nap
 
 kvm_novcpu_wakeup:
@@ -2128,10 +2129,13 @@ _GLOBAL(kvmppc_h_cede)		/* r3 = vcpu pointer, r11 = msr, r13 = paca */
 	bl	kvmhv_accumulate_time
 #endif
 
+	lis	r3, LPCR_PECEDP@h	/* Do wake on privileged doorbell */
+
 	/*
 	 * Take a nap until a decrementer or external or doobell interrupt
-	 * occurs, with PECE1, PECE0 and PECEDP set in LPCR. Also clear the
-	 * runlatch bit before napping.
+	 * occurs, with PECE1 and PECE0 set in LPCR.
+	 * On POWER8, if we are ceding, also set PECEDP.
+	 * Also clear the runlatch bit before napping.
 	 */
 kvm_do_nap:
 	mfspr	r0, SPRN_CTRLF
@@ -2143,7 +2147,7 @@ kvm_do_nap:
 	mfspr	r5,SPRN_LPCR
 	ori	r5,r5,LPCR_PECE0 | LPCR_PECE1
 BEGIN_FTR_SECTION
-	oris	r5,r5,LPCR_PECEDP@h
+	rlwimi	r5, r3, 0, LPCR_PECEDP
 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
 	mtspr	SPRN_LPCR,r5
 	isync
-- 
2.1.4


  parent reply	other threads:[~2015-03-27  3:30 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-27  3:29 [PATCH 00/12] Remaining improvements for HV KVM Paul Mackerras
2015-03-27  3:29 ` Paul Mackerras
2015-03-27  3:29 ` [PATCH 01/12] KVM: PPC: Book3S HV: Create debugfs file for each guest's HPT Paul Mackerras
2015-03-27  3:29   ` Paul Mackerras
2015-03-27  3:29 ` [PATCH 02/12] KVM: PPC: Book3S HV: Accumulate timing information for real-mode code Paul Mackerras
2015-03-27  3:29   ` Paul Mackerras
2015-03-27 11:47   ` Paul Mackerras
2015-03-27 11:47     ` Paul Mackerras
2015-03-27  3:29 ` [PATCH 03/12] KVM: PPC: Book3S HV: Simplify handling of VCPUs that need a VPA update Paul Mackerras
2015-03-27  3:29   ` Paul Mackerras
2015-03-27  3:29 ` [PATCH 04/12] KVM: PPC: Book3S HV: Minor cleanups Paul Mackerras
2015-03-27  3:29   ` Paul Mackerras
2015-03-27  3:29 ` [PATCH 05/12] KVM: PPC: Book3S HV: Move vcore preemption point up into kvmppc_run_vcpu Paul Mackerras
2015-03-27  3:29   ` Paul Mackerras
2015-03-27  3:29 ` [PATCH 06/12] KVM: PPC: Book3S HV: Get rid of vcore nap_count and n_woken Paul Mackerras
2015-03-27  3:29   ` Paul Mackerras
2015-03-27  3:29 ` Paul Mackerras [this message]
2015-03-27  3:29   ` [PATCH 07/12] KVM: PPC: Book3S HV: Don't wake thread with no vcpu on guest IPI Paul Mackerras
2015-03-27  3:29 ` [PATCH 08/12] KVM: PPC: Book3S HV: Use decrementer to wake napping threads Paul Mackerras
2015-03-27  3:29   ` Paul Mackerras
2015-03-27  3:29 ` [PATCH 09/12] KVM: PPC: Book3S HV: Use bitmap of active threads rather than count Paul Mackerras
2015-03-27  3:29   ` Paul Mackerras
2015-03-27  3:29 ` [PATCH 10/12] KVM: PPC: Book3S HV: Streamline guest entry and exit Paul Mackerras
2015-03-27  3:29   ` Paul Mackerras
2015-03-27  3:29 ` [PATCH 11/12] KVM: PPC: Book3S HV: Translate kvmhv_commence_exit to C Paul Mackerras
2015-03-27  3:29   ` Paul Mackerras
2015-03-27  3:29 ` [PATCH 12/12] KVM: PPC: Book3S HV: Use msgsnd for signalling threads on POWER8 Paul Mackerras
2015-03-27  3:29   ` Paul Mackerras
2015-03-28  3:21 [PATCH v2 00/12] Remaining improvements for HV KVM Paul Mackerras
2015-03-28  3:21 ` [PATCH 07/12] KVM: PPC: Book3S HV: Don't wake thread with no vcpu on guest IPI Paul Mackerras
2015-03-28  3:21   ` Paul Mackerras

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=1427426996-17651-8-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 \
    /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 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.