xref: /linux/kernel/Kconfig.preempt (revision 35772d627b55cc7fb4f33bae57c564a25b3121a9)
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)"
23*35772d62SPeter 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
39*35772d62SPeter 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
59*35772d62SPeter 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
79*35772d62SPeter 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
87*35772d62SPeter Zijlstraendchoice
88*35772d62SPeter Zijlstra
89a50a3f4bSThomas Gleixnerconfig PREEMPT_RT
90a50a3f4bSThomas Gleixner	bool "Fully Preemptible Kernel (Real-Time)"
91a8b76910SValentin Schneider	depends on EXPERT && ARCH_SUPPORTS_RT
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
106bdd4e85dSFrederic Weisbeckerconfig PREEMPT_COUNT
107bdd4e85dSFrederic Weisbecker       bool
108a50a3f4bSThomas Gleixner
109b8d33498SThomas Gleixnerconfig PREEMPTION
110a50a3f4bSThomas Gleixner       bool
111a50a3f4bSThomas Gleixner       select PREEMPT_COUNT
1126ef869e0SMichal Hocko
1136ef869e0SMichal Hockoconfig PREEMPT_DYNAMIC
114c597bfddSFrederic Weisbecker	bool "Preemption behaviour defined on boot"
115*35772d62SPeter Zijlstra	depends on HAVE_PREEMPT_DYNAMIC
11699cf983cSMark Rutland	select JUMP_LABEL if HAVE_PREEMPT_DYNAMIC_KEY
117a8b76910SValentin Schneider	select PREEMPT_BUILD
11899cf983cSMark Rutland	default y if HAVE_PREEMPT_DYNAMIC_CALL
1196ef869e0SMichal Hocko	help
1206ef869e0SMichal Hocko	  This option allows to define the preemption model on the kernel
1216ef869e0SMichal Hocko	  command line parameter and thus override the default preemption
1226ef869e0SMichal Hocko	  model defined during compile time.
1236ef869e0SMichal Hocko
1246ef869e0SMichal Hocko	  The feature is primarily interesting for Linux distributions which
1256ef869e0SMichal Hocko	  provide a pre-built kernel binary to reduce the number of kernel
1266ef869e0SMichal Hocko	  flavors they offer while still offering different usecases.
1276ef869e0SMichal Hocko
1286ef869e0SMichal Hocko	  The runtime overhead is negligible with HAVE_STATIC_CALL_INLINE enabled
1296ef869e0SMichal Hocko	  but if runtime patching is not available for the specific architecture
1306ef869e0SMichal Hocko	  then the potential overhead should be considered.
1316ef869e0SMichal Hocko
1326ef869e0SMichal Hocko	  Interesting if you want the same pre-built kernel should be used for
1336ef869e0SMichal Hocko	  both Server and Desktop workloads.
1349edeaea1SPeter Zijlstra
1359edeaea1SPeter Zijlstraconfig SCHED_CORE
1369edeaea1SPeter Zijlstra	bool "Core Scheduling for SMT"
1379edeaea1SPeter Zijlstra	depends on SCHED_SMT
1387b419f47SPeter Zijlstra	help
1397b419f47SPeter Zijlstra	  This option permits Core Scheduling, a means of coordinated task
1407b419f47SPeter Zijlstra	  selection across SMT siblings. When enabled -- see
1417b419f47SPeter Zijlstra	  prctl(PR_SCHED_CORE) -- task selection ensures that all SMT siblings
1427b419f47SPeter Zijlstra	  will execute a task from the same 'core group', forcing idle when no
1437b419f47SPeter Zijlstra	  matching task is found.
1447b419f47SPeter Zijlstra
1457b419f47SPeter Zijlstra	  Use of this feature includes:
1467b419f47SPeter Zijlstra	   - mitigation of some (not all) SMT side channels;
1477b419f47SPeter Zijlstra	   - limiting SMT interference to improve determinism and/or performance.
1487b419f47SPeter Zijlstra
149d2343cb8SIngo Molnar	  SCHED_CORE is default disabled. When it is enabled and unused,
150d2343cb8SIngo Molnar	  which is the likely usage by Linux distributions, there should
151d2343cb8SIngo Molnar	  be no measurable impact on performance.
1527b419f47SPeter Zijlstra
153f0e1a064STejun Heoconfig SCHED_CLASS_EXT
154f0e1a064STejun Heo	bool "Extensible Scheduling Class"
155b5ba2e1aSAndrea Righi	depends on BPF_SYSCALL && BPF_JIT && DEBUG_INFO_BTF
156a2f4b16eSTejun Heo	select STACKTRACE if STACKTRACE_SUPPORT
157f0e1a064STejun Heo	help
158f0e1a064STejun Heo	  This option enables a new scheduler class sched_ext (SCX), which
159f0e1a064STejun Heo	  allows scheduling policies to be implemented as BPF programs to
160f0e1a064STejun Heo	  achieve the following:
1619edeaea1SPeter Zijlstra
162f0e1a064STejun Heo	  - Ease of experimentation and exploration: Enabling rapid
163f0e1a064STejun Heo	    iteration of new scheduling policies.
164f0e1a064STejun Heo	  - Customization: Building application-specific schedulers which
165f0e1a064STejun Heo	    implement policies that are not applicable to general-purpose
166f0e1a064STejun Heo	    schedulers.
167f0e1a064STejun Heo	  - Rapid scheduler deployments: Non-disruptive swap outs of
168f0e1a064STejun Heo	    scheduling policies in production environments.
169f0e1a064STejun Heo
170f0e1a064STejun Heo	  sched_ext leverages BPF struct_ops feature to define a structure
171f0e1a064STejun Heo	  which exports function callbacks and flags to BPF programs that
172f0e1a064STejun Heo	  wish to implement scheduling policies. The struct_ops structure
173f0e1a064STejun Heo	  exported by sched_ext is struct sched_ext_ops, and is conceptually
174f0e1a064STejun Heo	  similar to struct sched_class.
175f0e1a064STejun Heo
176f0e1a064STejun Heo	  For more information:
177fa48e8d2STejun Heo	    Documentation/scheduler/sched-ext.rst
178f0e1a064STejun Heo	    https://github.com/sched-ext/scx
179