Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

powerpc: Add preempt lazy support

Define preempt lazy bit for Powerpc. Use bit 9 which is free and within
16 bit range of NEED_RESCHED, so compiler can issue single andi.

Since Powerpc doesn't use the generic entry/exit, add lazy check at exit
to user. CONFIG_PREEMPTION is defined for lazy/full/rt so use it for
return to kernel.

Ran a few benchmarks and db workload on Power10. Performance is close to
preempt=none/voluntary.

Since Powerpc systems can have large core count and large memory,
preempt lazy is going to be helpful in avoiding soft lockup issues.

Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Reviewed-by: Ankur Arora <ankur.a.arora@oracle.com>
Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20241116192306.88217-2-sshegde@linux.ibm.com

authored by

Shrikanth Hegde and committed by
Madhavan Srinivasan
00199ed6 d629d7a8

+9 -5
+1
arch/powerpc/Kconfig
··· 145 145 select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE 146 146 select ARCH_HAS_PHYS_TO_DMA 147 147 select ARCH_HAS_PMEM_API 148 + select ARCH_HAS_PREEMPT_LAZY 148 149 select ARCH_HAS_PTE_DEVMAP if PPC_BOOK3S_64 149 150 select ARCH_HAS_PTE_SPECIAL 150 151 select ARCH_HAS_SCALED_CPUTIME if VIRT_CPU_ACCOUNTING_NATIVE && PPC_BOOK3S_64
+6 -3
arch/powerpc/include/asm/thread_info.h
··· 103 103 #define TIF_PATCH_PENDING 6 /* pending live patching update */ 104 104 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */ 105 105 #define TIF_SINGLESTEP 8 /* singlestepping active */ 106 + #define TIF_NEED_RESCHED_LAZY 9 /* Scheduler driven lazy preemption */ 106 107 #define TIF_SECCOMP 10 /* secure computing */ 107 108 #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */ 108 109 #define TIF_NOERROR 12 /* Force successful syscall return */ ··· 123 122 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 124 123 #define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 125 124 #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 125 + #define _TIF_NEED_RESCHED_LAZY (1<<TIF_NEED_RESCHED_LAZY) 126 126 #define _TIF_NOTIFY_SIGNAL (1<<TIF_NOTIFY_SIGNAL) 127 127 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 128 128 #define _TIF_32BIT (1<<TIF_32BIT) ··· 144 142 _TIF_SYSCALL_EMU) 145 143 146 144 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \ 147 - _TIF_NOTIFY_RESUME | _TIF_UPROBE | \ 148 - _TIF_RESTORE_TM | _TIF_PATCH_PENDING | \ 149 - _TIF_NOTIFY_SIGNAL) 145 + _TIF_NEED_RESCHED_LAZY | _TIF_NOTIFY_RESUME | \ 146 + _TIF_UPROBE | _TIF_RESTORE_TM | \ 147 + _TIF_PATCH_PENDING | _TIF_NOTIFY_SIGNAL) 148 + 150 149 #define _TIF_PERSYSCALL_MASK (_TIF_RESTOREALL|_TIF_NOERROR) 151 150 152 151 /* Bits in local_flags */
+2 -2
arch/powerpc/kernel/interrupt.c
··· 185 185 ti_flags = read_thread_flags(); 186 186 while (unlikely(ti_flags & (_TIF_USER_WORK_MASK & ~_TIF_RESTORE_TM))) { 187 187 local_irq_enable(); 188 - if (ti_flags & _TIF_NEED_RESCHED) { 188 + if (ti_flags & (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY)) { 189 189 schedule(); 190 190 } else { 191 191 /* ··· 396 396 /* Returning to a kernel context with local irqs enabled. */ 397 397 WARN_ON_ONCE(!(regs->msr & MSR_EE)); 398 398 again: 399 - if (IS_ENABLED(CONFIG_PREEMPT)) { 399 + if (IS_ENABLED(CONFIG_PREEMPTION)) { 400 400 /* Return to preemptible kernel context */ 401 401 if (unlikely(read_thread_flags() & _TIF_NEED_RESCHED)) { 402 402 if (preempt_count() == 0)