xref: /linux/kernel/Kconfig.preempt (revision 7dadeaa6e851e7d67733f3e24fc53ee107781d0f)
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"
19*7dadeaa6SPeter Zijlstra	default PREEMPT_LAZY if ARCH_HAS_PREEMPT_LAZY
20a8b76910SValentin Schneider	default PREEMPT_NONE
21f8cbd99bSIngo Molnar
22a8b76910SValentin Schneiderconfig PREEMPT_NONE
23f8cbd99bSIngo Molnar	bool "No Forced Preemption (Server)"
2435772d62SPeter Zijlstra	depends on !PREEMPT_RT
25*7dadeaa6SPeter Zijlstra	depends on ARCH_NO_PREEMPT
26a8b76910SValentin Schneider	select PREEMPT_NONE_BUILD if !PREEMPT_DYNAMIC
27cc19ca86SIngo Molnar	help
28f8cbd99bSIngo Molnar	  This is the traditional Linux preemption model, geared towards
29f8cbd99bSIngo Molnar	  throughput. It will still provide good latencies most of the
30f8cbd99bSIngo Molnar	  time, but there are no guarantees and occasional longer delays
31f8cbd99bSIngo Molnar	  are possible.
32f8cbd99bSIngo Molnar
33f8cbd99bSIngo Molnar	  Select this option if you are building a kernel for a server or
34f8cbd99bSIngo Molnar	  scientific/computation system, or if you want to maximize the
35f8cbd99bSIngo Molnar	  raw processing power of the kernel, irrespective of scheduling
36f8cbd99bSIngo Molnar	  latencies.
37f8cbd99bSIngo Molnar
38a8b76910SValentin Schneiderconfig PREEMPT_VOLUNTARY
39f8cbd99bSIngo Molnar	bool "Voluntary Kernel Preemption (Desktop)"
40*7dadeaa6SPeter Zijlstra	depends on !ARCH_HAS_PREEMPT_LAZY
4187a4c375SChristoph Hellwig	depends on !ARCH_NO_PREEMPT
4235772d62SPeter Zijlstra	depends on !PREEMPT_RT
43a8b76910SValentin Schneider	select PREEMPT_VOLUNTARY_BUILD if !PREEMPT_DYNAMIC
44f8cbd99bSIngo Molnar	help
45f8cbd99bSIngo Molnar	  This option reduces the latency of the kernel by adding more
46f8cbd99bSIngo Molnar	  "explicit preemption points" to the kernel code. These new
47f8cbd99bSIngo Molnar	  preemption points have been selected to reduce the maximum
48f8cbd99bSIngo Molnar	  latency of rescheduling, providing faster application reactions,
493dde6ad8SDavid Sterba	  at the cost of slightly lower throughput.
50f8cbd99bSIngo Molnar
51f8cbd99bSIngo Molnar	  This allows reaction to interactive events by allowing a
52f8cbd99bSIngo Molnar	  low priority process to voluntarily preempt itself even if it
53f8cbd99bSIngo Molnar	  is in kernel mode executing a system call. This allows
54f8cbd99bSIngo Molnar	  applications to run more 'smoothly' even when the system is
55cc19ca86SIngo Molnar	  under load.
56cc19ca86SIngo Molnar
57f8cbd99bSIngo Molnar	  Select this if you are building a kernel for a desktop system.
58f8cbd99bSIngo Molnar
59a8b76910SValentin Schneiderconfig PREEMPT
60f8cbd99bSIngo Molnar	bool "Preemptible Kernel (Low-Latency Desktop)"
6187a4c375SChristoph Hellwig	depends on !ARCH_NO_PREEMPT
6235772d62SPeter Zijlstra	select PREEMPT_BUILD if !PREEMPT_DYNAMIC
63f8cbd99bSIngo Molnar	help
64f8cbd99bSIngo Molnar	  This option reduces the latency of the kernel by making
65f8cbd99bSIngo Molnar	  all kernel code (that is not executing in a critical section)
66f8cbd99bSIngo Molnar	  preemptible.  This allows reaction to interactive events by
67f8cbd99bSIngo Molnar	  permitting a low priority process to be preempted involuntarily
68f8cbd99bSIngo Molnar	  even if it is in kernel mode executing a system call and would
69f8cbd99bSIngo Molnar	  otherwise not be about to reach a natural preemption point.
70f8cbd99bSIngo Molnar	  This allows applications to run more 'smoothly' even when the
713dde6ad8SDavid Sterba	  system is under load, at the cost of slightly lower throughput
72f8cbd99bSIngo Molnar	  and a slight runtime overhead to kernel code.
73f8cbd99bSIngo Molnar
74f8cbd99bSIngo Molnar	  Select this if you are building a kernel for a desktop or
75f8cbd99bSIngo Molnar	  embedded system with latency requirements in the milliseconds
76f8cbd99bSIngo Molnar	  range.
77f8cbd99bSIngo Molnar
787c70cb94SPeter Zijlstraconfig PREEMPT_LAZY
797c70cb94SPeter Zijlstra	bool "Scheduler controlled preemption model"
807c70cb94SPeter Zijlstra	depends on !ARCH_NO_PREEMPT
817c70cb94SPeter Zijlstra	depends on ARCH_HAS_PREEMPT_LAZY
8235772d62SPeter Zijlstra	select PREEMPT_BUILD if !PREEMPT_DYNAMIC
837c70cb94SPeter Zijlstra	help
847c70cb94SPeter Zijlstra	  This option provides a scheduler driven preemption model that
857c70cb94SPeter Zijlstra	  is fundamentally similar to full preemption, but is less
867c70cb94SPeter Zijlstra	  eager to preempt SCHED_NORMAL tasks in an attempt to
877c70cb94SPeter Zijlstra	  reduce lock holder preemption and recover some of the performance
887c70cb94SPeter Zijlstra	  gains seen from using Voluntary preemption.
897c70cb94SPeter Zijlstra
9035772d62SPeter Zijlstraendchoice
9135772d62SPeter Zijlstra
92a50a3f4bSThomas Gleixnerconfig PREEMPT_RT
93a50a3f4bSThomas Gleixner	bool "Fully Preemptible Kernel (Real-Time)"
94fe9beaaaSPeter Zijlstra	depends on EXPERT && ARCH_SUPPORTS_RT && !COMPILE_TEST
95b8d33498SThomas Gleixner	select PREEMPTION
96a50a3f4bSThomas Gleixner	help
97a50a3f4bSThomas Gleixner	  This option turns the kernel into a real-time kernel by replacing
98a50a3f4bSThomas Gleixner	  various locking primitives (spinlocks, rwlocks, etc.) with
99a50a3f4bSThomas Gleixner	  preemptible priority-inheritance aware variants, enforcing
100a50a3f4bSThomas Gleixner	  interrupt threading and introducing mechanisms to break up long
101a50a3f4bSThomas Gleixner	  non-preemptible sections. This makes the kernel, except for very
102d61ca3c2SSrivatsa S. Bhat (VMware)	  low level and critical code paths (entry code, scheduler, low
103a50a3f4bSThomas Gleixner	  level interrupt handling) fully preemptible and brings most
104a50a3f4bSThomas Gleixner	  execution contexts under scheduler control.
105a50a3f4bSThomas Gleixner
106a50a3f4bSThomas Gleixner	  Select this if you are building a kernel for systems which
107a50a3f4bSThomas Gleixner	  require real-time guarantees.
108a50a3f4bSThomas Gleixner
1093253cb49SSebastian Andrzej Siewiorconfig PREEMPT_RT_NEEDS_BH_LOCK
1103253cb49SSebastian Andrzej Siewior	bool "Enforce softirq synchronisation on PREEMPT_RT"
1113253cb49SSebastian Andrzej Siewior	depends on PREEMPT_RT
1123253cb49SSebastian Andrzej Siewior	help
1133253cb49SSebastian Andrzej Siewior	  Enforce synchronisation across the softirqs context. On PREEMPT_RT
1143253cb49SSebastian Andrzej Siewior	  the softirq is preemptible. This enforces the same per-CPU BLK
1153253cb49SSebastian Andrzej Siewior	  semantic non-PREEMPT_RT builds have. This should not be needed
1163253cb49SSebastian Andrzej Siewior	  because per-CPU locks were added to avoid the per-CPU BKL.
1173253cb49SSebastian Andrzej Siewior
1183253cb49SSebastian Andrzej Siewior	  This switch provides the old behaviour for testing reasons. Select
1193253cb49SSebastian Andrzej Siewior	  this if you suspect an error with preemptible softirq and want test
1203253cb49SSebastian Andrzej Siewior	  the old synchronized behaviour.
1213253cb49SSebastian Andrzej Siewior
122bdd4e85dSFrederic Weisbeckerconfig PREEMPT_COUNT
123bdd4e85dSFrederic Weisbecker       bool
124a50a3f4bSThomas Gleixner
125b8d33498SThomas Gleixnerconfig PREEMPTION
126a50a3f4bSThomas Gleixner       bool
127a50a3f4bSThomas Gleixner       select PREEMPT_COUNT
1286ef869e0SMichal Hocko
1296ef869e0SMichal Hockoconfig PREEMPT_DYNAMIC
130c597bfddSFrederic Weisbecker	bool "Preemption behaviour defined on boot"
13135772d62SPeter Zijlstra	depends on HAVE_PREEMPT_DYNAMIC
13299cf983cSMark Rutland	select JUMP_LABEL if HAVE_PREEMPT_DYNAMIC_KEY
133a8b76910SValentin Schneider	select PREEMPT_BUILD
13499cf983cSMark Rutland	default y if HAVE_PREEMPT_DYNAMIC_CALL
1356ef869e0SMichal Hocko	help
1366ef869e0SMichal Hocko	  This option allows to define the preemption model on the kernel
1376ef869e0SMichal Hocko	  command line parameter and thus override the default preemption
1386ef869e0SMichal Hocko	  model defined during compile time.
1396ef869e0SMichal Hocko
1406ef869e0SMichal Hocko	  The feature is primarily interesting for Linux distributions which
1416ef869e0SMichal Hocko	  provide a pre-built kernel binary to reduce the number of kernel
1426ef869e0SMichal Hocko	  flavors they offer while still offering different usecases.
1436ef869e0SMichal Hocko
1446ef869e0SMichal Hocko	  The runtime overhead is negligible with HAVE_STATIC_CALL_INLINE enabled
1456ef869e0SMichal Hocko	  but if runtime patching is not available for the specific architecture
1466ef869e0SMichal Hocko	  then the potential overhead should be considered.
1476ef869e0SMichal Hocko
1486ef869e0SMichal Hocko	  Interesting if you want the same pre-built kernel should be used for
1496ef869e0SMichal Hocko	  both Server and Desktop workloads.
1509edeaea1SPeter Zijlstra
1519edeaea1SPeter Zijlstraconfig SCHED_CORE
1529edeaea1SPeter Zijlstra	bool "Core Scheduling for SMT"
1539edeaea1SPeter Zijlstra	depends on SCHED_SMT
1547b419f47SPeter Zijlstra	help
1557b419f47SPeter Zijlstra	  This option permits Core Scheduling, a means of coordinated task
1567b419f47SPeter Zijlstra	  selection across SMT siblings. When enabled -- see
1577b419f47SPeter Zijlstra	  prctl(PR_SCHED_CORE) -- task selection ensures that all SMT siblings
1587b419f47SPeter Zijlstra	  will execute a task from the same 'core group', forcing idle when no
1597b419f47SPeter Zijlstra	  matching task is found.
1607b419f47SPeter Zijlstra
1617b419f47SPeter Zijlstra	  Use of this feature includes:
1627b419f47SPeter Zijlstra	   - mitigation of some (not all) SMT side channels;
1637b419f47SPeter Zijlstra	   - limiting SMT interference to improve determinism and/or performance.
1647b419f47SPeter Zijlstra
165d2343cb8SIngo Molnar	  SCHED_CORE is default disabled. When it is enabled and unused,
166d2343cb8SIngo Molnar	  which is the likely usage by Linux distributions, there should
167d2343cb8SIngo Molnar	  be no measurable impact on performance.
1687b419f47SPeter Zijlstra
169f0e1a064STejun Heoconfig SCHED_CLASS_EXT
170f0e1a064STejun Heo	bool "Extensible Scheduling Class"
171b5ba2e1aSAndrea Righi	depends on BPF_SYSCALL && BPF_JIT && DEBUG_INFO_BTF
172a2f4b16eSTejun Heo	select STACKTRACE if STACKTRACE_SUPPORT
173f0e1a064STejun Heo	help
174f0e1a064STejun Heo	  This option enables a new scheduler class sched_ext (SCX), which
175f0e1a064STejun Heo	  allows scheduling policies to be implemented as BPF programs to
176f0e1a064STejun Heo	  achieve the following:
1779edeaea1SPeter Zijlstra
178f0e1a064STejun Heo	  - Ease of experimentation and exploration: Enabling rapid
179f0e1a064STejun Heo	    iteration of new scheduling policies.
180f0e1a064STejun Heo	  - Customization: Building application-specific schedulers which
181f0e1a064STejun Heo	    implement policies that are not applicable to general-purpose
182f0e1a064STejun Heo	    schedulers.
183f0e1a064STejun Heo	  - Rapid scheduler deployments: Non-disruptive swap outs of
184f0e1a064STejun Heo	    scheduling policies in production environments.
185f0e1a064STejun Heo
186f0e1a064STejun Heo	  sched_ext leverages BPF struct_ops feature to define a structure
187f0e1a064STejun Heo	  which exports function callbacks and flags to BPF programs that
188f0e1a064STejun Heo	  wish to implement scheduling policies. The struct_ops structure
189f0e1a064STejun Heo	  exported by sched_ext is struct sched_ext_ops, and is conceptually
190f0e1a064STejun Heo	  similar to struct sched_class.
191f0e1a064STejun Heo
192f0e1a064STejun Heo	  For more information:
193fa48e8d2STejun Heo	    Documentation/scheduler/sched-ext.rst
194f0e1a064STejun Heo	    https://github.com/sched-ext/scx
195