1ec8f24b7SThomas Gleixner# SPDX-License-Identifier: GPL-2.0-only 2cc19ca86SIngo Molnar 3a8b76910SValentin Schneiderconfig PREEMPT_NONE_BUILD 4a8b76910SValentin Schneider bool 5a8b76910SValentin Schneider 6a8b76910SValentin Schneiderconfig PREEMPT_VOLUNTARY_BUILD 7a8b76910SValentin Schneider bool 8a8b76910SValentin Schneider 9a8b76910SValentin Schneiderconfig PREEMPT_BUILD 10a8b76910SValentin Schneider bool 11a8b76910SValentin Schneider select PREEMPTION 12a8b76910SValentin Schneider select UNINLINE_SPIN_UNLOCK if !ARCH_INLINE_SPIN_UNLOCK 13a8b76910SValentin Schneider 147c70cb94SPeter Zijlstraconfig ARCH_HAS_PREEMPT_LAZY 157c70cb94SPeter Zijlstra bool 167c70cb94SPeter Zijlstra 17f8cbd99bSIngo Molnarchoice 18f8cbd99bSIngo Molnar prompt "Preemption Model" 19a8b76910SValentin Schneider default PREEMPT_NONE 20f8cbd99bSIngo Molnar 21a8b76910SValentin Schneiderconfig PREEMPT_NONE 22f8cbd99bSIngo Molnar bool "No Forced Preemption (Server)" 2335772d62SPeter Zijlstra depends on !PREEMPT_RT 24a8b76910SValentin Schneider select PREEMPT_NONE_BUILD if !PREEMPT_DYNAMIC 25cc19ca86SIngo Molnar help 26f8cbd99bSIngo Molnar This is the traditional Linux preemption model, geared towards 27f8cbd99bSIngo Molnar throughput. It will still provide good latencies most of the 28f8cbd99bSIngo Molnar time, but there are no guarantees and occasional longer delays 29f8cbd99bSIngo Molnar are possible. 30f8cbd99bSIngo Molnar 31f8cbd99bSIngo Molnar Select this option if you are building a kernel for a server or 32f8cbd99bSIngo Molnar scientific/computation system, or if you want to maximize the 33f8cbd99bSIngo Molnar raw processing power of the kernel, irrespective of scheduling 34f8cbd99bSIngo Molnar latencies. 35f8cbd99bSIngo Molnar 36a8b76910SValentin Schneiderconfig PREEMPT_VOLUNTARY 37f8cbd99bSIngo Molnar bool "Voluntary Kernel Preemption (Desktop)" 3887a4c375SChristoph Hellwig depends on !ARCH_NO_PREEMPT 3935772d62SPeter Zijlstra depends on !PREEMPT_RT 40a8b76910SValentin Schneider select PREEMPT_VOLUNTARY_BUILD if !PREEMPT_DYNAMIC 41f8cbd99bSIngo Molnar help 42f8cbd99bSIngo Molnar This option reduces the latency of the kernel by adding more 43f8cbd99bSIngo Molnar "explicit preemption points" to the kernel code. These new 44f8cbd99bSIngo Molnar preemption points have been selected to reduce the maximum 45f8cbd99bSIngo Molnar latency of rescheduling, providing faster application reactions, 463dde6ad8SDavid Sterba at the cost of slightly lower throughput. 47f8cbd99bSIngo Molnar 48f8cbd99bSIngo Molnar This allows reaction to interactive events by allowing a 49f8cbd99bSIngo Molnar low priority process to voluntarily preempt itself even if it 50f8cbd99bSIngo Molnar is in kernel mode executing a system call. This allows 51f8cbd99bSIngo Molnar applications to run more 'smoothly' even when the system is 52cc19ca86SIngo Molnar under load. 53cc19ca86SIngo Molnar 54f8cbd99bSIngo Molnar Select this if you are building a kernel for a desktop system. 55f8cbd99bSIngo Molnar 56a8b76910SValentin Schneiderconfig PREEMPT 57f8cbd99bSIngo Molnar bool "Preemptible Kernel (Low-Latency Desktop)" 5887a4c375SChristoph Hellwig depends on !ARCH_NO_PREEMPT 5935772d62SPeter Zijlstra select PREEMPT_BUILD if !PREEMPT_DYNAMIC 60f8cbd99bSIngo Molnar help 61f8cbd99bSIngo Molnar This option reduces the latency of the kernel by making 62f8cbd99bSIngo Molnar all kernel code (that is not executing in a critical section) 63f8cbd99bSIngo Molnar preemptible. This allows reaction to interactive events by 64f8cbd99bSIngo Molnar permitting a low priority process to be preempted involuntarily 65f8cbd99bSIngo Molnar even if it is in kernel mode executing a system call and would 66f8cbd99bSIngo Molnar otherwise not be about to reach a natural preemption point. 67f8cbd99bSIngo Molnar This allows applications to run more 'smoothly' even when the 683dde6ad8SDavid Sterba system is under load, at the cost of slightly lower throughput 69f8cbd99bSIngo Molnar and a slight runtime overhead to kernel code. 70f8cbd99bSIngo Molnar 71f8cbd99bSIngo Molnar Select this if you are building a kernel for a desktop or 72f8cbd99bSIngo Molnar embedded system with latency requirements in the milliseconds 73f8cbd99bSIngo Molnar range. 74f8cbd99bSIngo Molnar 757c70cb94SPeter Zijlstraconfig PREEMPT_LAZY 767c70cb94SPeter Zijlstra bool "Scheduler controlled preemption model" 777c70cb94SPeter Zijlstra depends on !ARCH_NO_PREEMPT 787c70cb94SPeter Zijlstra depends on ARCH_HAS_PREEMPT_LAZY 7935772d62SPeter Zijlstra select PREEMPT_BUILD if !PREEMPT_DYNAMIC 807c70cb94SPeter Zijlstra help 817c70cb94SPeter Zijlstra This option provides a scheduler driven preemption model that 827c70cb94SPeter Zijlstra is fundamentally similar to full preemption, but is less 837c70cb94SPeter Zijlstra eager to preempt SCHED_NORMAL tasks in an attempt to 847c70cb94SPeter Zijlstra reduce lock holder preemption and recover some of the performance 857c70cb94SPeter Zijlstra gains seen from using Voluntary preemption. 867c70cb94SPeter Zijlstra 8735772d62SPeter Zijlstraendchoice 8835772d62SPeter Zijlstra 89a50a3f4bSThomas Gleixnerconfig PREEMPT_RT 90a50a3f4bSThomas Gleixner bool "Fully Preemptible Kernel (Real-Time)" 91fe9beaaaSPeter Zijlstra depends on EXPERT && ARCH_SUPPORTS_RT && !COMPILE_TEST 92b8d33498SThomas Gleixner select PREEMPTION 93a50a3f4bSThomas Gleixner help 94a50a3f4bSThomas Gleixner This option turns the kernel into a real-time kernel by replacing 95a50a3f4bSThomas Gleixner various locking primitives (spinlocks, rwlocks, etc.) with 96a50a3f4bSThomas Gleixner preemptible priority-inheritance aware variants, enforcing 97a50a3f4bSThomas Gleixner interrupt threading and introducing mechanisms to break up long 98a50a3f4bSThomas Gleixner non-preemptible sections. This makes the kernel, except for very 99d61ca3c2SSrivatsa S. Bhat (VMware) low level and critical code paths (entry code, scheduler, low 100a50a3f4bSThomas Gleixner level interrupt handling) fully preemptible and brings most 101a50a3f4bSThomas Gleixner execution contexts under scheduler control. 102a50a3f4bSThomas Gleixner 103a50a3f4bSThomas Gleixner Select this if you are building a kernel for systems which 104a50a3f4bSThomas Gleixner require real-time guarantees. 105a50a3f4bSThomas Gleixner 106*3253cb49SSebastian Andrzej Siewiorconfig PREEMPT_RT_NEEDS_BH_LOCK 107*3253cb49SSebastian Andrzej Siewior bool "Enforce softirq synchronisation on PREEMPT_RT" 108*3253cb49SSebastian Andrzej Siewior depends on PREEMPT_RT 109*3253cb49SSebastian Andrzej Siewior help 110*3253cb49SSebastian Andrzej Siewior Enforce synchronisation across the softirqs context. On PREEMPT_RT 111*3253cb49SSebastian Andrzej Siewior the softirq is preemptible. This enforces the same per-CPU BLK 112*3253cb49SSebastian Andrzej Siewior semantic non-PREEMPT_RT builds have. This should not be needed 113*3253cb49SSebastian Andrzej Siewior because per-CPU locks were added to avoid the per-CPU BKL. 114*3253cb49SSebastian Andrzej Siewior 115*3253cb49SSebastian Andrzej Siewior This switch provides the old behaviour for testing reasons. Select 116*3253cb49SSebastian Andrzej Siewior this if you suspect an error with preemptible softirq and want test 117*3253cb49SSebastian Andrzej Siewior the old synchronized behaviour. 118*3253cb49SSebastian Andrzej Siewior 119bdd4e85dSFrederic Weisbeckerconfig PREEMPT_COUNT 120bdd4e85dSFrederic Weisbecker bool 121a50a3f4bSThomas Gleixner 122b8d33498SThomas Gleixnerconfig PREEMPTION 123a50a3f4bSThomas Gleixner bool 124a50a3f4bSThomas Gleixner select PREEMPT_COUNT 1256ef869e0SMichal Hocko 1266ef869e0SMichal Hockoconfig PREEMPT_DYNAMIC 127c597bfddSFrederic Weisbecker bool "Preemption behaviour defined on boot" 12835772d62SPeter Zijlstra depends on HAVE_PREEMPT_DYNAMIC 12999cf983cSMark Rutland select JUMP_LABEL if HAVE_PREEMPT_DYNAMIC_KEY 130a8b76910SValentin Schneider select PREEMPT_BUILD 13199cf983cSMark Rutland default y if HAVE_PREEMPT_DYNAMIC_CALL 1326ef869e0SMichal Hocko help 1336ef869e0SMichal Hocko This option allows to define the preemption model on the kernel 1346ef869e0SMichal Hocko command line parameter and thus override the default preemption 1356ef869e0SMichal Hocko model defined during compile time. 1366ef869e0SMichal Hocko 1376ef869e0SMichal Hocko The feature is primarily interesting for Linux distributions which 1386ef869e0SMichal Hocko provide a pre-built kernel binary to reduce the number of kernel 1396ef869e0SMichal Hocko flavors they offer while still offering different usecases. 1406ef869e0SMichal Hocko 1416ef869e0SMichal Hocko The runtime overhead is negligible with HAVE_STATIC_CALL_INLINE enabled 1426ef869e0SMichal Hocko but if runtime patching is not available for the specific architecture 1436ef869e0SMichal Hocko then the potential overhead should be considered. 1446ef869e0SMichal Hocko 1456ef869e0SMichal Hocko Interesting if you want the same pre-built kernel should be used for 1466ef869e0SMichal Hocko both Server and Desktop workloads. 1479edeaea1SPeter Zijlstra 1489edeaea1SPeter Zijlstraconfig SCHED_CORE 1499edeaea1SPeter Zijlstra bool "Core Scheduling for SMT" 1509edeaea1SPeter Zijlstra depends on SCHED_SMT 1517b419f47SPeter Zijlstra help 1527b419f47SPeter Zijlstra This option permits Core Scheduling, a means of coordinated task 1537b419f47SPeter Zijlstra selection across SMT siblings. When enabled -- see 1547b419f47SPeter Zijlstra prctl(PR_SCHED_CORE) -- task selection ensures that all SMT siblings 1557b419f47SPeter Zijlstra will execute a task from the same 'core group', forcing idle when no 1567b419f47SPeter Zijlstra matching task is found. 1577b419f47SPeter Zijlstra 1587b419f47SPeter Zijlstra Use of this feature includes: 1597b419f47SPeter Zijlstra - mitigation of some (not all) SMT side channels; 1607b419f47SPeter Zijlstra - limiting SMT interference to improve determinism and/or performance. 1617b419f47SPeter Zijlstra 162d2343cb8SIngo Molnar SCHED_CORE is default disabled. When it is enabled and unused, 163d2343cb8SIngo Molnar which is the likely usage by Linux distributions, there should 164d2343cb8SIngo Molnar be no measurable impact on performance. 1657b419f47SPeter Zijlstra 166f0e1a064STejun Heoconfig SCHED_CLASS_EXT 167f0e1a064STejun Heo bool "Extensible Scheduling Class" 168b5ba2e1aSAndrea Righi depends on BPF_SYSCALL && BPF_JIT && DEBUG_INFO_BTF 169a2f4b16eSTejun Heo select STACKTRACE if STACKTRACE_SUPPORT 170f0e1a064STejun Heo help 171f0e1a064STejun Heo This option enables a new scheduler class sched_ext (SCX), which 172f0e1a064STejun Heo allows scheduling policies to be implemented as BPF programs to 173f0e1a064STejun Heo achieve the following: 1749edeaea1SPeter Zijlstra 175f0e1a064STejun Heo - Ease of experimentation and exploration: Enabling rapid 176f0e1a064STejun Heo iteration of new scheduling policies. 177f0e1a064STejun Heo - Customization: Building application-specific schedulers which 178f0e1a064STejun Heo implement policies that are not applicable to general-purpose 179f0e1a064STejun Heo schedulers. 180f0e1a064STejun Heo - Rapid scheduler deployments: Non-disruptive swap outs of 181f0e1a064STejun Heo scheduling policies in production environments. 182f0e1a064STejun Heo 183f0e1a064STejun Heo sched_ext leverages BPF struct_ops feature to define a structure 184f0e1a064STejun Heo which exports function callbacks and flags to BPF programs that 185f0e1a064STejun Heo wish to implement scheduling policies. The struct_ops structure 186f0e1a064STejun Heo exported by sched_ext is struct sched_ext_ops, and is conceptually 187f0e1a064STejun Heo similar to struct sched_class. 188f0e1a064STejun Heo 189f0e1a064STejun Heo For more information: 190fa48e8d2STejun Heo Documentation/scheduler/sched-ext.rst 191f0e1a064STejun Heo https://github.com/sched-ext/scx 192