linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] ppc:Set runlatch bits correctly for offline threads and vcpus
@ 2014-04-11 10:31 Preeti U Murthy
  2014-04-11 10:31 ` [PATCH 1/3] ppc/powernv: Set the runlatch bits correctly for offline cpus Preeti U Murthy
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Preeti U Murthy @ 2014-04-11 10:31 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: paulus, linux-kernel, srivatsa.bhat

The runlatch bits with their value indicated by CTRL_RUNLATCH are set and
cleared in the SPRN_CTRL registers to indicate a busy and idle cpu
respectively. This is currently being done in the cpuidle path of the host.
But needs to be taken care of in hotplug and kvm scenarios. This patchset
is aimed at ensuring that the runlatch bits are consisten with the
utilization of a CPU under all circumstances.
---

Preeti U Murthy (3):
      ppc/powernv: Set the runlatch bits correctly for offline cpus
      ppc/kvm: Set the runlatch bit of a CPU just before starting guest
      ppc/kvm: Clear the runlatch bit of a vcpu before napping


 arch/powerpc/kvm/book3s_hv_rmhandlers.S |   18 +++++++++++++++++-
 arch/powerpc/platforms/powernv/smp.c    |    3 +++
 2 files changed, 20 insertions(+), 1 deletion(-)

-- 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] ppc/powernv: Set the runlatch bits correctly for offline cpus
  2014-04-11 10:31 [PATCH 0/3] ppc:Set runlatch bits correctly for offline threads and vcpus Preeti U Murthy
@ 2014-04-11 10:31 ` Preeti U Murthy
  2014-04-11 10:31 ` [PATCH 2/3] ppc/kvm: Set the runlatch bit of a CPU just before starting guest Preeti U Murthy
  2014-04-11 10:32 ` [PATCH 3/3] ppc/kvm: Clear the runlatch bit of a vcpu before napping Preeti U Murthy
  2 siblings, 0 replies; 4+ messages in thread
From: Preeti U Murthy @ 2014-04-11 10:31 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: paulus, linux-kernel, srivatsa.bhat

Up until now we have been setting the runlatch bits for a busy CPU and
clearing it when a CPU enters idle state. The runlatch bit has thus
been consistent with the utilization of a CPU as long as the CPU is online.

However when a CPU is hotplugged out the runlatch bit is not cleared. It
needs to be cleared to indicate an unused CPU. Hence this patch has the
runlatch bit cleared for an offline CPU just before entering an idle state
and sets it immediately after it exits the idle state.

Signed-off-by: Preeti U Murthy <preeti@linux.vnet.ibm.com>
Acked-by: Paul Mackerras <paulus@samba.org>
Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
---

 arch/powerpc/platforms/powernv/smp.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/powerpc/platforms/powernv/smp.c b/arch/powerpc/platforms/powernv/smp.c
index 908672b..bf5fcd4 100644
--- a/arch/powerpc/platforms/powernv/smp.c
+++ b/arch/powerpc/platforms/powernv/smp.c
@@ -30,6 +30,7 @@
 #include <asm/cputhreads.h>
 #include <asm/xics.h>
 #include <asm/opal.h>
+#include <asm/runlatch.h>
 
 #include "powernv.h"
 
@@ -156,7 +157,9 @@ static void pnv_smp_cpu_kill_self(void)
 	 */
 	mtspr(SPRN_LPCR, mfspr(SPRN_LPCR) & ~(u64)LPCR_PECE1);
 	while (!generic_check_cpu_restart(cpu)) {
+		ppc64_runlatch_off();
 		power7_nap();
+		ppc64_runlatch_on();
 		if (!generic_check_cpu_restart(cpu)) {
 			DBG("CPU%d Unexpected exit while offline !\n", cpu);
 			/* We may be getting an IPI, so we re-enable

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] ppc/kvm: Set the runlatch bit of a CPU just before starting guest
  2014-04-11 10:31 [PATCH 0/3] ppc:Set runlatch bits correctly for offline threads and vcpus Preeti U Murthy
  2014-04-11 10:31 ` [PATCH 1/3] ppc/powernv: Set the runlatch bits correctly for offline cpus Preeti U Murthy
@ 2014-04-11 10:31 ` Preeti U Murthy
  2014-04-11 10:32 ` [PATCH 3/3] ppc/kvm: Clear the runlatch bit of a vcpu before napping Preeti U Murthy
  2 siblings, 0 replies; 4+ messages in thread
From: Preeti U Murthy @ 2014-04-11 10:31 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: paulus, linux-kernel, srivatsa.bhat

The secondary threads in the core are kept offline before launching guests
in kvm on powerpc: "371fefd6f2dc4666:KVM: PPC: Allow book3s_hv guests to use
SMT processor modes."

Hence their runlatch bits are cleared. When the secondary threads are called
in to start a guest, their runlatch bits need to be set to indicate that they
are busy. The primary thread has its runlatch bit set though, but there is no
harm in setting this bit once again. Hence set the runlatch bit for all
threads before they start guest.

Signed-off-by: Preeti U Murthy <preeti@linux.vnet.ibm.com>
Acked-by: Paul Mackerras <paulus@samba.org>
Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
---

 arch/powerpc/kvm/book3s_hv_rmhandlers.S |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
index ffbb871..b254075 100644
--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -242,6 +242,12 @@ kvm_novcpu_exit:
  */
 	.globl	kvm_start_guest
 kvm_start_guest:
+
+	/* Set runlatch bit the minute you wake up from nap */
+	mfspr	r1, SPRN_CTRLF
+	ori 	r1, r1, 1
+	mtspr	SPRN_CTRLT, r1
+
 	ld	r2,PACATOC(r13)
 
 	li	r0,KVM_HWTHREAD_IN_KVM

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] ppc/kvm: Clear the runlatch bit of a vcpu before napping
  2014-04-11 10:31 [PATCH 0/3] ppc:Set runlatch bits correctly for offline threads and vcpus Preeti U Murthy
  2014-04-11 10:31 ` [PATCH 1/3] ppc/powernv: Set the runlatch bits correctly for offline cpus Preeti U Murthy
  2014-04-11 10:31 ` [PATCH 2/3] ppc/kvm: Set the runlatch bit of a CPU just before starting guest Preeti U Murthy
@ 2014-04-11 10:32 ` Preeti U Murthy
  2 siblings, 0 replies; 4+ messages in thread
From: Preeti U Murthy @ 2014-04-11 10:32 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: paulus, linux-kernel, srivatsa.bhat

When the guest cedes the vcpu or the vcpu has no guest to
run it naps. Clear the runlatch bit of the vcpu before
napping to indicate an idle cpu.

Signed-off-by: Preeti U Murthy <preeti@linux.vnet.ibm.com>
Acked-by: Paul Mackerras <paulus@samba.org>
Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
---

 arch/powerpc/kvm/book3s_hv_rmhandlers.S |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
index b254075..b031f93 100644
--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -315,6 +315,11 @@ kvm_no_guest:
 	li	r0, KVM_HWTHREAD_IN_NAP
 	stb	r0, HSTATE_HWTHREAD_STATE(r13)
 kvm_do_nap:
+	/* Clear the runlatch bit before napping */
+	mfspr	r2, SPRN_CTRLF
+	clrrdi	r2, r2, 1
+	mtspr	SPRN_CTRLT, r2
+
 	li	r3, LPCR_PECE0
 	mfspr	r4, SPRN_LPCR
 	rlwimi	r4, r3, 0, LPCR_PECE0 | LPCR_PECE1
@@ -2005,8 +2010,13 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_206)
 
 	/*
 	 * Take a nap until a decrementer or external or doobell interrupt
-	 * occurs, with PECE1, PECE0 and PECEDP set in LPCR
+	 * occurs, with PECE1, PECE0 and PECEDP set in LPCR. Also clear the
+	 * runlatch bit before napping.
 	 */
+	mfspr	r2, SPRN_CTRLF
+	clrrdi	r2, r2, 1
+	mtspr	SPRN_CTRLT, r2
+
 	li	r0,1
 	stb	r0,HSTATE_HWTHREAD_REQ(r13)
 	mfspr	r5,SPRN_LPCR

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-04-11 10:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-11 10:31 [PATCH 0/3] ppc:Set runlatch bits correctly for offline threads and vcpus Preeti U Murthy
2014-04-11 10:31 ` [PATCH 1/3] ppc/powernv: Set the runlatch bits correctly for offline cpus Preeti U Murthy
2014-04-11 10:31 ` [PATCH 2/3] ppc/kvm: Set the runlatch bit of a CPU just before starting guest Preeti U Murthy
2014-04-11 10:32 ` [PATCH 3/3] ppc/kvm: Clear the runlatch bit of a vcpu before napping Preeti U Murthy

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).