powerpc/powernv: Don't reprogram SLW image on every KVM guest entry/exit
authorPaul Mackerras <paulus@ozlabs.org>
Tue, 12 Feb 2019 00:58:29 +0000 (11:58 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 21 Feb 2019 13:10:15 +0000 (00:10 +1100)
commit19f8a5b5be2898573a5e1dc1db93e8d40117606a
tree52adebee535e837cf86b0a0cef190f4ed365e5cc
parent8cfaf106918a8c13abb24c641556172afbb9545c
powerpc/powernv: Don't reprogram SLW image on every KVM guest entry/exit

Commit 24be85a23d1f ("powerpc/powernv: Clear PECE1 in LPCR via stop-api
only on Hotplug", 2017-07-21) added two calls to opal_slw_set_reg()
inside pnv_cpu_offline(), with the aim of changing the LPCR value in
the SLW image to disable wakeups from the decrementer while a CPU is
offline.  However, pnv_cpu_offline() gets called each time a secondary
CPU thread is woken up to participate in running a KVM guest, that is,
not just when a CPU is offlined.

Since opal_slw_set_reg() is a very slow operation (with observed
execution times around 20 milliseconds), this means that an offline
secondary CPU can often be busy doing the opal_slw_set_reg() call
when the primary CPU wants to grab all the secondary threads so that
it can run a KVM guest.  This leads to messages like "KVM: couldn't
grab CPU n" being printed and guest execution failing.

There is no need to reprogram the SLW image on every KVM guest entry
and exit.  So that we do it only when a CPU is really transitioning
between online and offline, this moves the calls to
pnv_program_cpu_hotplug_lpcr() into pnv_smp_cpu_kill_self().

Fixes: 24be85a23d1f ("powerpc/powernv: Clear PECE1 in LPCR via stop-api only on Hotplug")
Cc: stable@vger.kernel.org # v4.14+
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/powernv.h
arch/powerpc/platforms/powernv/idle.c
arch/powerpc/platforms/powernv/smp.c