KVM: PPC: Book3S HV: Set RWMR on POWER8 so that PURR/SPURR count correctly
Subsystems (2)
PATCH 2/2 KVM: PPC: Book3S HV: Set RWMR on POWER8 so that PURR/SPURR count correctly
Although Linux doesn't use PURR and SPURR ((Scaled) Processor Utilization of Resources Register), other OSes depend on them. On POWER8 they count at a rate depending on whether the VCPU is idle or running, the activity of the VCPU, and the value in the RWMR (Region-Weighting Mode Register). Hardware expects the hypervisor to update the RWMR when a core is dispatched to reflect the number of online VCPUs in the vcore.
This adds code to maintain a count in the vcore struct indicating how many VCPUs are online. In kvmppc_run_core we use that count to set the RWMR register on POWER8. If the core is split because of a static or dynamic micro-threading mode, we use the value for 8 threads. The RWMR value is not relevant when the host is executing because Linux does not use the PURR or SPURR register, so we don't bother saving and restoring the host value.
For the sake of old userspace which does not set the KVM_REG_PPC_ONLINE register, we set online to 1 if it was 0 at the time of a KVM_RUN ioctl.
--- arch/powerpc/include/asm/kvm_book3s.h | 1 + arch/powerpc/include/asm/reg.h | 1 + arch/powerpc/kvm/book3s_hv.c | 61 ++++++++++++++++++++++++++++++++++- 3 files changed, 62 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/kvm_book3s.h +1 -0
@@ -104,6 +104,7 @@ struct kvmppc_vcore {ulong vtb;/* virtual timebase */ ulong conferring_threads;unsigned int halt_poll_ns; +atomic_t online_count; };struct kvmppc_vcpu_book3s {
arch/powerpc/include/asm/reg.h +1 -0
@@ -365,6 +365,7 @@#define SPRN_PSSCR 0x357/* Processor Stop Status and Control Register (ISA 3.0) */ #define SPRN_PSSCR_PR 0x337/* PSSCR ISA 3.0, privileged mode access */ #define SPRN_PMCR 0x374/* Power Management Control Register */ +#define SPRN_RWMR 0x375/* Region-Weighting Mode Register */ /* HFSCR and FSCR bit numbers are the same */ #define FSCR_SCV_LG 12/* Enable System Call Vectored */
arch/powerpc/kvm/book3s_hv.c +60 -1
85 lines not on this page · raw message
Signature · 1 line
2.7.4
Quoted 66 lines · Paul Mackerras
Although Linux doesn't use PURR and SPURR ((Scaled) Processor Utilization of Resources Register), other OSes depend on them. On POWER8 they count at a rate depending on whether the VCPU is idle or running, the activity of the VCPU, and the value in the RWMR (Region-Weighting Mode Register). Hardware expects the hypervisor to update the RWMR when a core is dispatched to reflect the number of online VCPUs in the vcore.
This adds code to maintain a count in the vcore struct indicating how many VCPUs are online. In
kvmppc_run_corewe use that count to set the RWMR register on POWER8. If the core is split because of a static or dynamic micro-threading mode, we use the value for 8 threads. The RWMR value is not relevant when the host is executing because Linux does not use the PURR or SPURR register, so we don't bother saving and restoring the host value.For the sake of old userspace which does not set the
KVM_REG_PPC_ONLINEregister, we set online to 1 if it was 0 at the time of aKVM_RUNioctl.Signed-off-by Paul Mackerras <[email protected]>--- arch/powerpc/include/asm/kvm_book3s.h | 1 + arch/powerpc/include/asm/reg.h | 1 + arch/powerpc/kvm/book3s_hv.c | 61 ++++++++++++++++++++++++++++++++++- 3 files changed, 62 insertions(+), 1 deletion(-)arch/powerpc/include/asm/kvm_book3s.h +1
-0@@ -104,6 +104,7 @@ struct kvmppc_vcore {ulong vtb;/* virtual timebase */ ulong conferring_threads;unsigned int halt_poll_ns; +atomic_t online_count; };struct kvmppc_vcpu_book3s {arch/powerpc/include/asm/reg.h +1
-0@@ -365,6 +365,7 @@#define SPRN_PSSCR 0x357/* Processor Stop Status and Control Register (ISA 3.0) */ #define SPRN_PSSCR_PR 0x337/* PSSCR ISA 3.0, privileged mode access */ #define SPRN_PMCR 0x374/* Power Management Control Register */ +#define SPRN_RWMR 0x375/* Region-Weighting Mode Register */ /* HFSCR and FSCR bit numbers are the same */ #define FSCR_SCV_LG 12/* Enable System Call Vectored */ arch/powerpc/kvm/book3s_hv.c +7
-0@@ -123,6 +123,32 @@ static bool no_mixing_hpt_and_radix;static void kvmppc_end_cede (struct kvm_vcpu *vcpu);static int kvmppc_hv_setup_htab_rma (struct kvm_vcpu *vcpu); +/* +* RWMR values for POWER8. These control the rate at which PURR +* and SPURR count and should be set according to the number of +* online threads in the vcore being run. +*/ +#define RWMR_RPA_P8_1THREAD 0x164520C62609AECA +#define RWMR_RPA_P8_2THREAD 0x7FFF2908450D8DA9
arch/powerpc/kvm/book3s_hv.c static bool no_mixing_hpt_and_radix; · line 142
Quoted 10 lines
arch/powerpc/kvm/book3s_hv.c +10
-0+#define RWMR_RPA_P8_3THREAD 0x164520C62609AECA +#define RWMR_RPA_P8_4THREAD 0x199A421245058DA9 +#define RWMR_RPA_P8_5THREAD 0x164520C62609AECA +#define RWMR_RPA_P8_6THREAD 0x164520C62609AECA +#define RWMR_RPA_P8_7THREAD 0x164520C62609AECA +#define RWMR_RPA_P8_8THREAD 0x164520C62609AECA + +static unsigned long p8_rwmr_values[MAX_SMT_THREADS +1 ] = { +RWMR_RPA_P8_1THREAD , +RWMR_RPA_P8_1THREAD ,
This has repeated twice here?
Quoted 9 lines
arch/powerpc/kvm/book3s_hv.c +9
-0+RWMR_RPA_P8_2THREAD , +RWMR_RPA_P8_3THREAD , +RWMR_RPA_P8_4THREAD , +RWMR_RPA_P8_5THREAD , +RWMR_RPA_P8_6THREAD , +RWMR_RPA_P8_7THREAD , + RWMR_RPA_P8_8THREAD, +}; +