Re: [PATCH v4 00/17] powerpc/64: fast interrupt exits

2021-06-25 Thread Michael Ellerman
On Fri, 18 Jun 2021 01:50:59 +1000, Nicholas Piggin wrote:
> This series attempts to improve the speed of interrupts and system calls
> in three major ways.
> 
> Firstly, the SRR/HSRR registers do not need to be reloaded if they were
> clobbered for the duration of the interrupt and the return NIP and MSR
> did not changed. 64e does not implement this part, but it could quite
> easily.
> 
> [...]

Patches 1-4, and 6-17 applied to powerpc/next.

[01/17] powerpc/interrupt: Fix CONFIG ifdef typo

https://git.kernel.org/powerpc/c/9a3ed7adcabce24a85fbe05f54e762b18756ec22
[02/17] powerpc: remove interrupt exit helpers unused argument

https://git.kernel.org/powerpc/c/bf9155f1970c4dbf9ec6b87d3688433bd494a4e1
[03/17] powerpc/64s: introduce different functions to return from SRR vs HSRR 
interrupts

https://git.kernel.org/powerpc/c/1df7d5e4baeac74d14c1bee18b2dff9302b3efbc
[04/17] powerpc/64s: avoid reloading (H)SRR registers if they are still valid

https://git.kernel.org/powerpc/c/59dc5bfca0cb6a29db1a50847684eb5c19f8f400
[06/17] powerpc/64: move interrupt return asm to interrupt_64.S

https://git.kernel.org/powerpc/c/e754f4d13e3919aafa485657599907aa63b9a40c
[07/17] powerpc/64s: system call avoid setting MSR[RI] until we set MSR[EE]

https://git.kernel.org/powerpc/c/dd152f70bdc1b91445b10c65ac874b90c93fb3b5
[08/17] powerpc/64s: save one more register in the masked interrupt handler

https://git.kernel.org/powerpc/c/63e40806eea984f770c992120bbfd71b589ea580
[09/17] powerpc/64: allow alternate return locations for soft-masked interrupts

https://git.kernel.org/powerpc/c/f23699c93becd746295aaa506537882a46a62219
[10/17] powerpc/64: interrupt soft-enable race fix

https://git.kernel.org/powerpc/c/862fa563524b9f92d7e89fe332732bd3421772db
[11/17] powerpc/64: treat low kernel text as irqs soft-masked

https://git.kernel.org/powerpc/c/9d1988ca87dd90ecf80a0601c7fd13071fbb1a83
[12/17] powerpc/64: use interrupt restart table to speed up return from 
interrupt

https://git.kernel.org/powerpc/c/13799748b957bc5659f97c036224b0f4b42172e2
[13/17] powerpc/interrupt: Rename and lightly change syscall_exit_prepare_main()

https://git.kernel.org/powerpc/c/f84aa284947f325c5697d35b92abd2047224f24b
[14/17] powerpc/interrupt: Refactor interrupt_exit_user_prepare()

https://git.kernel.org/powerpc/c/a214ee8802adb864d175ea6ca4176223bcc11d2b
[15/17] powerpc/interrupt: Interchange prep_irq_for_{kernel_enabled/user}_exit()

https://git.kernel.org/powerpc/c/99f98f849cf13e5fac532979ccdb77dff07665db
[16/17] powerpc/interrupt: Refactor prep_irq_for_{user/kernel_enabled}_exit()

https://git.kernel.org/powerpc/c/61eece2d1707796fd45225ea3d20e9289251311c
[17/17] powerpc/interrupt: Remove prep_irq_for_user_exit()

https://git.kernel.org/powerpc/c/ae58b1c645895c28ca155843db6788d57ea99e11

cheers


[PATCH v4 00/17] powerpc/64: fast interrupt exits

2021-06-17 Thread Nicholas Piggin
This series attempts to improve the speed of interrupts and system calls
in three major ways.

Firstly, the SRR/HSRR registers do not need to be reloaded if they were
clobbered for the duration of the interrupt and the return NIP and MSR
did not changed. 64e does not implement this part, but it could quite
easily.

Secondly, mtmsrd and mtspr are reduced by various means, this is mostly
specific to 64s.

Lastly, an alternate interrupt return location facility is added for
soft-masked asynchronous interrupts, and then that's used to set
everything up for return without having to disable MSR RI or EE.

After this series, the entire system call / interrupt handler fast path
can execute with no mtsprs and one mtmsrd to enable interrupts
initially, and the system call vectored path doesn't even need to do
that. This gives a decent performance benefit. On POWER9 with a
powernv_defconfig without VIRT_CPU_ACCOUNTING_NATIVE, no meltdown
workarounds, gettid sc system call goes from 481 -> 344 cycles, gettid
scv 345->299 cycles, and page fault 1225->1064 cycles.

Since v3:
- Added Christophe's series to the end (with one broken out patch
  at the start and minor tweaks).
- Fix lbz of SOFTE that broke on BE, should be loaded with ld.
- Fix case where fast_interrupt_return was not marking SRRs as
  clobbered correctly, causing random userspace segfaults etc.
- Fix cpu lock inversion problem in the workaround static branch
  switching code.
- Removed the .L local name from some labels for the restart
  handlers, which makes the disassembly easier to read.
- Fixed several nitpicks found by kbuild robot (duplicate include,
  missing prototypes, etc).
- Fix 64e compile bug [from mpe].
- Fix KUAP re-locking in some restart cases.

Christophe Leroy (6):
  powerpc/interrupt: Fix CONFIG ifdef typo
  powerpc/interrupt: Rename and lightly change
syscall_exit_prepare_main()
  powerpc/interrupt: Refactor interrupt_exit_user_prepare()
  powerpc/interrupt: Interchange
prep_irq_for_{kernel_enabled/user}_exit()
  powerpc/interrupt: Refactor prep_irq_for_{user/kernel_enabled}_exit()
  powerpc/interrupt: Remove prep_irq_for_user_exit()

Nicholas Piggin (11):
  powerpc: remove interrupt exit helpers unused argument
  powerpc/64s: introduce different functions to return from SRR vs HSRR
interrupts
  powerpc/64s: avoid reloading (H)SRR registers if they are still valid
  powerpc/64: handle MSR EE and RI in interrupt entry wrapper
  powerpc/64: move interrupt return asm to interrupt_64.S
  powerpc/64s: system call avoid setting MSR[RI] until we set MSR[EE]
  powerpc/64s: save one more register in the masked interrupt handler
  powerpc/64: allow alternate return locations for soft-masked
interrupts
  powerpc/64: interrupt soft-enable race fix
  powerpc/64: treat low kernel text as irqs soft-masked
  powerpc/64: use interrupt restart table to speed up return from
interrupt

 arch/powerpc/Kconfig.debug |   5 +
 arch/powerpc/include/asm/asm-prototypes.h  |   9 +-
 arch/powerpc/include/asm/head-64.h |   2 +-
 arch/powerpc/include/asm/hw_irq.h  |  23 +-
 arch/powerpc/include/asm/interrupt.h   |  60 +-
 arch/powerpc/include/asm/paca.h|   7 +
 arch/powerpc/include/asm/ppc_asm.h |   8 +
 arch/powerpc/include/asm/ptrace.h  |  75 ++-
 arch/powerpc/kernel/asm-offsets.c  |   7 +
 arch/powerpc/kernel/entry_64.S | 516 --
 arch/powerpc/kernel/exceptions-64e.S   |  53 +-
 arch/powerpc/kernel/exceptions-64s.S   | 219 +++---
 arch/powerpc/kernel/fpu.S  |   4 +
 arch/powerpc/kernel/head_64.S  |   5 +-
 arch/powerpc/kernel/interrupt.c| 413 +++-
 arch/powerpc/kernel/interrupt_64.S | 742 +
 arch/powerpc/kernel/irq.c  |  95 +++
 arch/powerpc/kernel/kgdb.c |   2 +-
 arch/powerpc/kernel/kprobes-ftrace.c   |   2 +-
 arch/powerpc/kernel/kprobes.c  |  10 +-
 arch/powerpc/kernel/process.c  |  26 +-
 arch/powerpc/kernel/prom_init.c|   3 +
 arch/powerpc/kernel/rtas.c |  14 +-
 arch/powerpc/kernel/signal.c   |   2 +-
 arch/powerpc/kernel/signal_64.c|   9 +
 arch/powerpc/kernel/syscalls.c |   3 +-
 arch/powerpc/kernel/traps.c|  18 +-
 arch/powerpc/kernel/vector.S   |   8 +-
 arch/powerpc/kernel/vmlinux.lds.S  |  10 +
 arch/powerpc/kvm/book3s_hv.c   |   3 +
 arch/powerpc/kvm/book3s_pr.c   |   2 +
 arch/powerpc/lib/Makefile  |   2 +-
 arch/powerpc/lib/feature-fixups.c  |  52 +-
 arch/powerpc/lib/restart_table.c   |  30 +
 arch/powerpc/lib/sstep.c   |   4 +-
 arch/powerpc/math-emu/math.c   |   2 +-
 arch/powerpc/platforms/powernv/opal-call.c |   4 +
 arch/powerpc/platforms/pseries/hvCall.S|  29 +
 arch/powerpc/sysdev/fsl_pci.c