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 14*7c70cb94SPeter Zijlstraconfig ARCH_HAS_PREEMPT_LAZY 15*7c70cb94SPeter Zijlstra bool 16*7c70cb94SPeter 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)" 23a8b76910SValentin Schneider select PREEMPT_NONE_BUILD if !PREEMPT_DYNAMIC 24cc19ca86SIngo Molnar help 25f8cbd99bSIngo Molnar This is the traditional Linux preemption model, geared towards 26f8cbd99bSIngo Molnar throughput. It will still provide good latencies most of the 27f8cbd99bSIngo Molnar time, but there are no guarantees and occasional longer delays 28f8cbd99bSIngo Molnar are possible. 29f8cbd99bSIngo Molnar 30f8cbd99bSIngo Molnar Select this option if you are building a kernel for a server or 31f8cbd99bSIngo Molnar scientific/computation system, or if you want to maximize the 32f8cbd99bSIngo Molnar raw processing power of the kernel, irrespective of scheduling 33f8cbd99bSIngo Molnar latencies. 34f8cbd99bSIngo Molnar 35a8b76910SValentin Schneiderconfig PREEMPT_VOLUNTARY 36f8cbd99bSIngo Molnar bool "Voluntary Kernel Preemption (Desktop)" 3787a4c375SChristoph Hellwig depends on !ARCH_NO_PREEMPT 38a8b76910SValentin Schneider select PREEMPT_VOLUNTARY_BUILD if !PREEMPT_DYNAMIC 39f8cbd99bSIngo Molnar help 40f8cbd99bSIngo Molnar This option reduces the latency of the kernel by adding more 41f8cbd99bSIngo Molnar "explicit preemption points" to the kernel code. These new 42f8cbd99bSIngo Molnar preemption points have been selected to reduce the maximum 43f8cbd99bSIngo Molnar latency of rescheduling, providing faster application reactions, 443dde6ad8SDavid Sterba at the cost of slightly lower throughput. 45f8cbd99bSIngo Molnar 46f8cbd99bSIngo Molnar This allows reaction to interactive events by allowing a 47f8cbd99bSIngo Molnar low priority process to voluntarily preempt itself even if it 48f8cbd99bSIngo Molnar is in kernel mode executing a system call. This allows 49f8cbd99bSIngo Molnar applications to run more 'smoothly' even when the system is 50cc19ca86SIngo Molnar under load. 51cc19ca86SIngo Molnar 52f8cbd99bSIngo Molnar Select this if you are building a kernel for a desktop system. 53f8cbd99bSIngo Molnar 54a8b76910SValentin Schneiderconfig PREEMPT 55f8cbd99bSIngo Molnar bool "Preemptible Kernel (Low-Latency Desktop)" 5687a4c375SChristoph Hellwig depends on !ARCH_NO_PREEMPT 57a8b76910SValentin Schneider select PREEMPT_BUILD 58f8cbd99bSIngo Molnar help 59f8cbd99bSIngo Molnar This option reduces the latency of the kernel by making 60f8cbd99bSIngo Molnar all kernel code (that is not executing in a critical section) 61f8cbd99bSIngo Molnar preemptible. This allows reaction to interactive events by 62f8cbd99bSIngo Molnar permitting a low priority process to be preempted involuntarily 63f8cbd99bSIngo Molnar even if it is in kernel mode executing a system call and would 64f8cbd99bSIngo Molnar otherwise not be about to reach a natural preemption point. 65f8cbd99bSIngo Molnar This allows applications to run more 'smoothly' even when the 663dde6ad8SDavid Sterba system is under load, at the cost of slightly lower throughput 67f8cbd99bSIngo Molnar and a slight runtime overhead to kernel code. 68f8cbd99bSIngo Molnar 69f8cbd99bSIngo Molnar Select this if you are building a kernel for a desktop or 70f8cbd99bSIngo Molnar embedded system with latency requirements in the milliseconds 71f8cbd99bSIngo Molnar range. 72f8cbd99bSIngo Molnar 73*7c70cb94SPeter Zijlstraconfig PREEMPT_LAZY 74*7c70cb94SPeter Zijlstra bool "Scheduler controlled preemption model" 75*7c70cb94SPeter Zijlstra depends on !ARCH_NO_PREEMPT 76*7c70cb94SPeter Zijlstra depends on ARCH_HAS_PREEMPT_LAZY 77*7c70cb94SPeter Zijlstra select PREEMPT_BUILD 78*7c70cb94SPeter Zijlstra help 79*7c70cb94SPeter Zijlstra This option provides a scheduler driven preemption model that 80*7c70cb94SPeter Zijlstra is fundamentally similar to full preemption, but is less 81*7c70cb94SPeter Zijlstra eager to preempt SCHED_NORMAL tasks in an attempt to 82*7c70cb94SPeter Zijlstra reduce lock holder preemption and recover some of the performance 83*7c70cb94SPeter Zijlstra gains seen from using Voluntary preemption. 84*7c70cb94SPeter Zijlstra 85a50a3f4bSThomas Gleixnerconfig PREEMPT_RT 86a50a3f4bSThomas Gleixner bool "Fully Preemptible Kernel (Real-Time)" 87a8b76910SValentin Schneider depends on EXPERT && ARCH_SUPPORTS_RT 88b8d33498SThomas Gleixner select PREEMPTION 89a50a3f4bSThomas Gleixner help 90a50a3f4bSThomas Gleixner This option turns the kernel into a real-time kernel by replacing 91a50a3f4bSThomas Gleixner various locking primitives (spinlocks, rwlocks, etc.) with 92a50a3f4bSThomas Gleixner preemptible priority-inheritance aware variants, enforcing 93a50a3f4bSThomas Gleixner interrupt threading and introducing mechanisms to break up long 94a50a3f4bSThomas Gleixner non-preemptible sections. This makes the kernel, except for very 95d61ca3c2SSrivatsa S. Bhat (VMware) low level and critical code paths (entry code, scheduler, low 96a50a3f4bSThomas Gleixner level interrupt handling) fully preemptible and brings most 97a50a3f4bSThomas Gleixner execution contexts under scheduler control. 98a50a3f4bSThomas Gleixner 99a50a3f4bSThomas Gleixner Select this if you are building a kernel for systems which 100a50a3f4bSThomas Gleixner require real-time guarantees. 101a50a3f4bSThomas Gleixner 102f8cbd99bSIngo Molnarendchoice 103cc19ca86SIngo Molnar 104bdd4e85dSFrederic Weisbeckerconfig PREEMPT_COUNT 105bdd4e85dSFrederic Weisbecker bool 106a50a3f4bSThomas Gleixner 107b8d33498SThomas Gleixnerconfig PREEMPTION 108a50a3f4bSThomas Gleixner bool 109a50a3f4bSThomas Gleixner select PREEMPT_COUNT 1106ef869e0SMichal Hocko 1116ef869e0SMichal Hockoconfig PREEMPT_DYNAMIC 112c597bfddSFrederic Weisbecker bool "Preemption behaviour defined on boot" 113a8b76910SValentin Schneider depends on HAVE_PREEMPT_DYNAMIC && !PREEMPT_RT 11499cf983cSMark Rutland select JUMP_LABEL if HAVE_PREEMPT_DYNAMIC_KEY 115a8b76910SValentin Schneider select PREEMPT_BUILD 11699cf983cSMark Rutland default y if HAVE_PREEMPT_DYNAMIC_CALL 1176ef869e0SMichal Hocko help 1186ef869e0SMichal Hocko This option allows to define the preemption model on the kernel 1196ef869e0SMichal Hocko command line parameter and thus override the default preemption 1206ef869e0SMichal Hocko model defined during compile time. 1216ef869e0SMichal Hocko 1226ef869e0SMichal Hocko The feature is primarily interesting for Linux distributions which 1236ef869e0SMichal Hocko provide a pre-built kernel binary to reduce the number of kernel 1246ef869e0SMichal Hocko flavors they offer while still offering different usecases. 1256ef869e0SMichal Hocko 1266ef869e0SMichal Hocko The runtime overhead is negligible with HAVE_STATIC_CALL_INLINE enabled 1276ef869e0SMichal Hocko but if runtime patching is not available for the specific architecture 1286ef869e0SMichal Hocko then the potential overhead should be considered. 1296ef869e0SMichal Hocko 1306ef869e0SMichal Hocko Interesting if you want the same pre-built kernel should be used for 1316ef869e0SMichal Hocko both Server and Desktop workloads. 1329edeaea1SPeter Zijlstra 1339edeaea1SPeter Zijlstraconfig SCHED_CORE 1349edeaea1SPeter Zijlstra bool "Core Scheduling for SMT" 1359edeaea1SPeter Zijlstra depends on SCHED_SMT 1367b419f47SPeter Zijlstra help 1377b419f47SPeter Zijlstra This option permits Core Scheduling, a means of coordinated task 1387b419f47SPeter Zijlstra selection across SMT siblings. When enabled -- see 1397b419f47SPeter Zijlstra prctl(PR_SCHED_CORE) -- task selection ensures that all SMT siblings 1407b419f47SPeter Zijlstra will execute a task from the same 'core group', forcing idle when no 1417b419f47SPeter Zijlstra matching task is found. 1427b419f47SPeter Zijlstra 1437b419f47SPeter Zijlstra Use of this feature includes: 1447b419f47SPeter Zijlstra - mitigation of some (not all) SMT side channels; 1457b419f47SPeter Zijlstra - limiting SMT interference to improve determinism and/or performance. 1467b419f47SPeter Zijlstra 147d2343cb8SIngo Molnar SCHED_CORE is default disabled. When it is enabled and unused, 148d2343cb8SIngo Molnar which is the likely usage by Linux distributions, there should 149d2343cb8SIngo Molnar be no measurable impact on performance. 1507b419f47SPeter Zijlstra 151f0e1a064STejun Heoconfig SCHED_CLASS_EXT 152f0e1a064STejun Heo bool "Extensible Scheduling Class" 153b5ba2e1aSAndrea Righi depends on BPF_SYSCALL && BPF_JIT && DEBUG_INFO_BTF 154a2f4b16eSTejun Heo select STACKTRACE if STACKTRACE_SUPPORT 155f0e1a064STejun Heo help 156f0e1a064STejun Heo This option enables a new scheduler class sched_ext (SCX), which 157f0e1a064STejun Heo allows scheduling policies to be implemented as BPF programs to 158f0e1a064STejun Heo achieve the following: 1599edeaea1SPeter Zijlstra 160f0e1a064STejun Heo - Ease of experimentation and exploration: Enabling rapid 161f0e1a064STejun Heo iteration of new scheduling policies. 162f0e1a064STejun Heo - Customization: Building application-specific schedulers which 163f0e1a064STejun Heo implement policies that are not applicable to general-purpose 164f0e1a064STejun Heo schedulers. 165f0e1a064STejun Heo - Rapid scheduler deployments: Non-disruptive swap outs of 166f0e1a064STejun Heo scheduling policies in production environments. 167f0e1a064STejun Heo 168f0e1a064STejun Heo sched_ext leverages BPF struct_ops feature to define a structure 169f0e1a064STejun Heo which exports function callbacks and flags to BPF programs that 170f0e1a064STejun Heo wish to implement scheduling policies. The struct_ops structure 171f0e1a064STejun Heo exported by sched_ext is struct sched_ext_ops, and is conceptually 172f0e1a064STejun Heo similar to struct sched_class. 173f0e1a064STejun Heo 174f0e1a064STejun Heo For more information: 175fa48e8d2STejun Heo Documentation/scheduler/sched-ext.rst 176f0e1a064STejun Heo https://github.com/sched-ext/scx 177