[RFC 0/3] powerpc64: Preempt count optimizations
flat view
From: Shrikanth Hegde <sshegde@linux.ibm.com>
Date: 2026-10-02 16:47:08
Also in:
lkml
This is an RFC and initial implementation of the idea which was discussed in few threads. [1][2][3] It is lightly tested, but given changes are involving the core api, it definitely needs more testing. Also I need to investigate the patches in more detail and likely changelogs needs update too. Please go ahead and try to see if works/breaks for you. Ideas in brief: 1. Move preempt count to PACA. preempt count in PACA is better as it make it direct access from r13 instead of obtaining from thread info. 2. Fold need_resched into preempt count. Also it was noted that adopting similar style of folding need_resched into preempt count as ARM64 is better as it helps load-store archs and helps to avoid accessing thread info in fast paths. 3. Enable HAS_SEPARATE_PREEMPT_RESCHED_BITS. While there enable the HAS_SEPARATE_PREEMPT_RESCHED_BITS which is a recent trick to fold the NMI bits into preempt count(29-32bits) instead of using separate per_cpu count. [1] https://lore.kernel.org/all/e8efdade-161e-4efe-8bd3-abb12ad45dee@linux.ibm.com/ (local) [2] https://lore.kernel.org/all/1eab63fc-b70d-41ef-b720-8ae77d8e56d8@linux.ibm.com/#t (local) [3] https://lore.kernel.org/all/20260805094219.GM687043@noisy.programming.kicks-ass.net/ (local) Below are hackbench results. Test Baseline Patched Gain ============================================================= Hackbench process 10 groups 1.000x 0.991x +0.88% Hackbench process 20 groups 1.000x 0.972x +2.81% Hackbench process 30 groups 1.000x 0.976x +2.37% Hackbench process 40 groups 1.000x 0.979x +2.11% Hackbench process 50 groups 1.000x 0.980x +2.05% Hackbench process 60 groups 1.000x 0.982x +1.79% Hackbench thread 10 groups 1.000x 0.978x +2.23% Hackbench thread 20 groups 1.000x 0.971x +2.93% Hackbench process pipe 10 groups 1.000x 0.957x +4.35% Hackbench process pipe 20 groups 1.000x 0.977x +2.32% Hackbench process pipe 30 groups 1.000x 0.981x +1.95% Hackbench process pipe 40 groups 1.000x 0.981x +1.93% Hackbench process pipe 50 groups 1.000x 0.975x +2.54% Hackbench process pipe 60 groups 1.000x 1.024x -2.37% Hackbench thread pipe 10 groups 1.000x 0.970x +3.04% Hackbench thread pipe 20 groups 1.000x 0.981x +1.89% Things tested(no warnings/crash): - Build and boot. - hackbench run. - daytrader run. - kexec. Shrikanth Hegde (3): powerpc64: move preempt count to paca powerpc64/preempt: Add need_resched bit inside preempt_count powerpc64/Kconfig: Enable HAS_SEPARATE_PREEMPT_RESCHED_BITS arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/paca.h | 12 +++ arch/powerpc/include/asm/preempt.h | 113 +++++++++++++++++++++++++ arch/powerpc/include/asm/thread_info.h | 14 ++- arch/powerpc/kernel/paca.c | 1 + arch/powerpc/kexec/core_64.c | 2 +- 6 files changed, 139 insertions(+), 4 deletions(-) create mode 100644 arch/powerpc/include/asm/preempt.h -- 2.52.0