powerpc/64s: Reimplement book3s idle code in C
Reimplement Book3S idle code in C, moving POWER7/8/9 implementation speific HV idle code to the powernv platform code. Book3S assembly stubs are kept in common code and used only to save the stack frame and non-volatile GPRs before executing architected idle instructions, and restoring the stack and reloading GPRs then returning to C after waking from idle. The complex logic dealing with threads and subcores, locking, SPRs, HMIs, timebase resync, etc., is all done in C which makes it more maintainable. This is not a strict translation to C code, there are some significant differences: - Idle wakeup no longer uses the ->cpu_restore call to reinit SPRs, but saves and restores them itself. - The optimisation where EC=ESL=0 idle modes did not have to save GPRs or change MSR is restored, because it's now simple to do. ESL=1 sleeps that do not lose GPRs can use this optimization too. - KVM secondary entry and cede is now more of a call/return style rather than branchy. nap_state_lost is not required because KVM always returns via NVGPR restoring path. - KVM secondary wakeup from offline sequence is moved entirely into the offline wakeup, which avoids a hwsync in the normal idle wakeup path. Performance measured with context switch ping-pong on different threads or cores, is possibly improved a small amount, 1-3% depending on stop state and core vs thread test for shallow states. Deep states it's in the noise compared with other latencies. KVM improvements: - Idle sleepers now always return to caller rather than branch out to KVM first. - This allows optimisations like very fast return to caller when no state has been lost. - KVM no longer requires nap_state_lost because it controls NVGPR save/restore itself on the way in and out. - The heavy idle wakeup KVM request check can be moved out of the normal host idle code and into the not-performance-critical offline code. - KVM nap code now returns from where it is called, which makes the flow a bit easier to follow. Reviewed-by:Gautham R. Shenoy <ego@linux.vnet.ibm.com> Signed-off-by:
Nicholas Piggin <npiggin@gmail.com> [mpe: Squash the KVM changes in] Signed-off-by:
Michael Ellerman <mpe@ellerman.id.au>
Showing
- arch/powerpc/include/asm/cpuidle.h 3 additions, 16 deletionsarch/powerpc/include/asm/cpuidle.h
- arch/powerpc/include/asm/paca.h 22 additions, 18 deletionsarch/powerpc/include/asm/paca.h
- arch/powerpc/include/asm/processor.h 6 additions, 3 deletionsarch/powerpc/include/asm/processor.h
- arch/powerpc/include/asm/reg.h 4 additions, 4 deletionsarch/powerpc/include/asm/reg.h
- arch/powerpc/kernel/asm-offsets.c 0 additions, 18 deletionsarch/powerpc/kernel/asm-offsets.c
- arch/powerpc/kernel/exceptions-64s.S 14 additions, 9 deletionsarch/powerpc/kernel/exceptions-64s.S
- arch/powerpc/kernel/idle_book3s.S 146 additions, 914 deletionsarch/powerpc/kernel/idle_book3s.S
- arch/powerpc/kernel/setup-common.c 2 additions, 2 deletionsarch/powerpc/kernel/setup-common.c
- arch/powerpc/kvm/book3s_hv_rmhandlers.S 72 additions, 46 deletionsarch/powerpc/kvm/book3s_hv_rmhandlers.S
- arch/powerpc/platforms/powernv/idle.c 689 additions, 173 deletionsarch/powerpc/platforms/powernv/idle.c
- arch/powerpc/platforms/powernv/subcore.c 1 addition, 1 deletionarch/powerpc/platforms/powernv/subcore.c
- arch/powerpc/xmon/xmon.c 10 additions, 14 deletionsarch/powerpc/xmon/xmon.c
Loading
Please register or sign in to comment