* [PATCH] KVM: PPC: Book3s PR: Disable AIL mode with OPAL
@ 2014-06-10 17:23 Alexander Graf
2014-06-12 3:56 ` Paul Mackerras
0 siblings, 1 reply; 3+ messages in thread
From: Alexander Graf @ 2014-06-10 17:23 UTC (permalink / raw)
To: kvm-ppc; +Cc: kvm
When we're using PR KVM we must not allow the CPU to take interrupts
in virtual mode, as the SLB does not contain host kernel mappings
when running inside the guest context.
To make sure we get good performance for non-KVM tasks but still
properly functioning PR KVM, let's just disable AIL whenever a vcpu
is scheduled in.
This patch fixes running PR KVM on POWER8 bare metal for me.
Signed-off-by: Alexander Graf <agraf@suse.de>
---
arch/powerpc/kvm/book3s_pr.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
index 03fc884..cdc0eef 100644
--- a/arch/powerpc/kvm/book3s_pr.c
+++ b/arch/powerpc/kvm/book3s_pr.c
@@ -71,6 +71,12 @@ static void kvmppc_core_vcpu_load_pr(struct kvm_vcpu *vcpu, int cpu)
svcpu->in_use = 0;
svcpu_put(svcpu);
#endif
+
+ /* Disable AIL if supported */
+ if (cpu_has_feature(CPU_FTR_HVMODE) &&
+ cpu_has_feature(CPU_FTR_ARCH_207S))
+ mtspr(SPRN_LPCR, mfspr(SPRN_LPCR) & ~LPCR_AIL);
+
vcpu->cpu = smp_processor_id();
#ifdef CONFIG_PPC_BOOK3S_32
current->thread.kvm_shadow_vcpu = vcpu->arch.shadow_vcpu;
@@ -91,6 +97,12 @@ static void kvmppc_core_vcpu_put_pr(struct kvm_vcpu *vcpu)
kvmppc_giveup_ext(vcpu, MSR_FP | MSR_VEC | MSR_VSX);
kvmppc_giveup_fac(vcpu, FSCR_TAR_LG);
+
+ /* Enable AIL if supported */
+ if (cpu_has_feature(CPU_FTR_HVMODE) &&
+ cpu_has_feature(CPU_FTR_ARCH_207S))
+ mtspr(SPRN_LPCR, mfspr(SPRN_LPCR) | LPCR_AIL_3);
+
vcpu->cpu = -1;
}
--
1.8.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: PPC: Book3s PR: Disable AIL mode with OPAL
2014-06-10 17:23 [PATCH] KVM: PPC: Book3s PR: Disable AIL mode with OPAL Alexander Graf
@ 2014-06-12 3:56 ` Paul Mackerras
2014-06-17 9:18 ` Alexander Graf
0 siblings, 1 reply; 3+ messages in thread
From: Paul Mackerras @ 2014-06-12 3:56 UTC (permalink / raw)
To: Alexander Graf; +Cc: kvm-ppc, kvm
On Tue, Jun 10, 2014 at 07:23:00PM +0200, Alexander Graf wrote:
> When we're using PR KVM we must not allow the CPU to take interrupts
> in virtual mode, as the SLB does not contain host kernel mappings
> when running inside the guest context.
>
> To make sure we get good performance for non-KVM tasks but still
> properly functioning PR KVM, let's just disable AIL whenever a vcpu
> is scheduled in.
>
> This patch fixes running PR KVM on POWER8 bare metal for me.
We already handle this for the situation where we're running under a
hypervisor with the calls to pSeries_disable_reloc_on_exc() and
pSeries_enable_reloc_on_exc() in kvmppc_core_init_vm_pr() and
kvmppc_core_destroy_vm_pr() respectively.
The obvious approach to fixing this problem would be to generalize
those calls, perhaps via a ppc_md callback, to work on the powernv
platform too. If you don't want to do that, for instance because
those calls are defined to operate across the whole machine rather
than a single CPU thread, and you prefer to affect just the one thread
we're running on, then I think you need to explain that in the commit
message.
Regards,
Paul.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: PPC: Book3s PR: Disable AIL mode with OPAL
2014-06-12 3:56 ` Paul Mackerras
@ 2014-06-17 9:18 ` Alexander Graf
0 siblings, 0 replies; 3+ messages in thread
From: Alexander Graf @ 2014-06-17 9:18 UTC (permalink / raw)
To: Paul Mackerras; +Cc: kvm-ppc, kvm
On 12.06.14 05:56, Paul Mackerras wrote:
> On Tue, Jun 10, 2014 at 07:23:00PM +0200, Alexander Graf wrote:
>> When we're using PR KVM we must not allow the CPU to take interrupts
>> in virtual mode, as the SLB does not contain host kernel mappings
>> when running inside the guest context.
>>
>> To make sure we get good performance for non-KVM tasks but still
>> properly functioning PR KVM, let's just disable AIL whenever a vcpu
>> is scheduled in.
>>
>> This patch fixes running PR KVM on POWER8 bare metal for me.
> We already handle this for the situation where we're running under a
> hypervisor with the calls to pSeries_disable_reloc_on_exc() and
> pSeries_enable_reloc_on_exc() in kvmppc_core_init_vm_pr() and
> kvmppc_core_destroy_vm_pr() respectively.
>
> The obvious approach to fixing this problem would be to generalize
> those calls, perhaps via a ppc_md callback, to work on the powernv
> platform too. If you don't want to do that, for instance because
> those calls are defined to operate across the whole machine rather
> than a single CPU thread, and you prefer to affect just the one thread
> we're running on, then I think you need to explain that in the commit
> message.
It's what I've done at first, yes. Unfortunately the pSeries call is
system global, while we need to do the AIL switching per cpu on bare metal.
Once you start considering CPU hotplug and how that affects the
secondary bringup paths you start wondering whether it's worth the
hassle :). This way you can have a single guest running which only slows
down (disables AIL) on its own vcpu, while all the others still enjoy
the benefits of AIL.
Alex
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-06-17 9:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-10 17:23 [PATCH] KVM: PPC: Book3s PR: Disable AIL mode with OPAL Alexander Graf
2014-06-12 3:56 ` Paul Mackerras
2014-06-17 9:18 ` Alexander Graf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox