xref: /linux/kernel/Kconfig.preempt (revision 3b2074c77d25f453247163300d5638adfab4e4fa)
1# SPDX-License-Identifier: GPL-2.0-only
2
3config PREEMPT_NONE_BUILD
4	bool
5
6config PREEMPT_VOLUNTARY_BUILD
7	bool
8
9config PREEMPT_BUILD
10	bool
11	select PREEMPTION
12	select UNINLINE_SPIN_UNLOCK if !ARCH_INLINE_SPIN_UNLOCK
13
14config ARCH_HAS_PREEMPT_LAZY
15	bool
16
17choice
18	prompt "Preemption Model"
19	default PREEMPT_NONE
20
21config PREEMPT_NONE
22	bool "No Forced Preemption (Server)"
23	depends on !PREEMPT_RT
24	select PREEMPT_NONE_BUILD if !PREEMPT_DYNAMIC
25	help
26	  This is the traditional Linux preemption model, geared towards
27	  throughput. It will still provide good latencies most of the
28	  time, but there are no guarantees and occasional longer delays
29	  are possible.
30
31	  Select this option if you are building a kernel for a server or
32	  scientific/computation system, or if you want to maximize the
33	  raw processing power of the kernel, irrespective of scheduling
34	  latencies.
35
36config PREEMPT_VOLUNTARY
37	bool "Voluntary Kernel Preemption (Desktop)"
38	depends on !ARCH_NO_PREEMPT
39	depends on !PREEMPT_RT
40	select PREEMPT_VOLUNTARY_BUILD if !PREEMPT_DYNAMIC
41	help
42	  This option reduces the latency of the kernel by adding more
43	  "explicit preemption points" to the kernel code. These new
44	  preemption points have been selected to reduce the maximum
45	  latency of rescheduling, providing faster application reactions,
46	  at the cost of slightly lower throughput.
47
48	  This allows reaction to interactive events by allowing a
49	  low priority process to voluntarily preempt itself even if it
50	  is in kernel mode executing a system call. This allows
51	  applications to run more 'smoothly' even when the system is
52	  under load.
53
54	  Select this if you are building a kernel for a desktop system.
55
56config PREEMPT
57	bool "Preemptible Kernel (Low-Latency Desktop)"
58	depends on !ARCH_NO_PREEMPT
59	select PREEMPT_BUILD if !PREEMPT_DYNAMIC
60	help
61	  This option reduces the latency of the kernel by making
62	  all kernel code (that is not executing in a critical section)
63	  preemptible.  This allows reaction to interactive events by
64	  permitting a low priority process to be preempted involuntarily
65	  even if it is in kernel mode executing a system call and would
66	  otherwise not be about to reach a natural preemption point.
67	  This allows applications to run more 'smoothly' even when the
68	  system is under load, at the cost of slightly lower throughput
69	  and a slight runtime overhead to kernel code.
70
71	  Select this if you are building a kernel for a desktop or
72	  embedded system with latency requirements in the milliseconds
73	  range.
74
75config PREEMPT_LAZY
76	bool "Scheduler controlled preemption model"
77	depends on !ARCH_NO_PREEMPT
78	depends on ARCH_HAS_PREEMPT_LAZY
79	select PREEMPT_BUILD if !PREEMPT_DYNAMIC
80	help
81	  This option provides a scheduler driven preemption model that
82	  is fundamentally similar to full preemption, but is less
83	  eager to preempt SCHED_NORMAL tasks in an attempt to
84	  reduce lock holder preemption and recover some of the performance
85	  gains seen from using Voluntary preemption.
86
87endchoice
88
89config PREEMPT_RT
90	bool "Fully Preemptible Kernel (Real-Time)"
91	depends on EXPERT && ARCH_SUPPORTS_RT && !COMPILE_TEST
92	select PREEMPTION
93	help
94	  This option turns the kernel into a real-time kernel by replacing
95	  various locking primitives (spinlocks, rwlocks, etc.) with
96	  preemptible priority-inheritance aware variants, enforcing
97	  interrupt threading and introducing mechanisms to break up long
98	  non-preemptible sections. This makes the kernel, except for very
99	  low level and critical code paths (entry code, scheduler, low
100	  level interrupt handling) fully preemptible and brings most
101	  execution contexts under scheduler control.
102
103	  Select this if you are building a kernel for systems which
104	  require real-time guarantees.
105
106config PREEMPT_RT_NEEDS_BH_LOCK
107	bool "Enforce softirq synchronisation on PREEMPT_RT"
108	depends on PREEMPT_RT
109	help
110	  Enforce synchronisation across the softirqs context. On PREEMPT_RT
111	  the softirq is preemptible. This enforces the same per-CPU BLK
112	  semantic non-PREEMPT_RT builds have. This should not be needed
113	  because per-CPU locks were added to avoid the per-CPU BKL.
114
115	  This switch provides the old behaviour for testing reasons. Select
116	  this if you suspect an error with preemptible softirq and want test
117	  the old synchronized behaviour.
118
119config PREEMPT_COUNT
120       bool
121
122config PREEMPTION
123       bool
124       select PREEMPT_COUNT
125
126config PREEMPT_DYNAMIC
127	bool "Preemption behaviour defined on boot"
128	depends on HAVE_PREEMPT_DYNAMIC
129	select JUMP_LABEL if HAVE_PREEMPT_DYNAMIC_KEY
130	select PREEMPT_BUILD
131	default y if HAVE_PREEMPT_DYNAMIC_CALL
132	help
133	  This option allows to define the preemption model on the kernel
134	  command line parameter and thus override the default preemption
135	  model defined during compile time.
136
137	  The feature is primarily interesting for Linux distributions which
138	  provide a pre-built kernel binary to reduce the number of kernel
139	  flavors they offer while still offering different usecases.
140
141	  The runtime overhead is negligible with HAVE_STATIC_CALL_INLINE enabled
142	  but if runtime patching is not available for the specific architecture
143	  then the potential overhead should be considered.
144
145	  Interesting if you want the same pre-built kernel should be used for
146	  both Server and Desktop workloads.
147
148config SCHED_CORE
149	bool "Core Scheduling for SMT"
150	depends on SCHED_SMT
151	help
152	  This option permits Core Scheduling, a means of coordinated task
153	  selection across SMT siblings. When enabled -- see
154	  prctl(PR_SCHED_CORE) -- task selection ensures that all SMT siblings
155	  will execute a task from the same 'core group', forcing idle when no
156	  matching task is found.
157
158	  Use of this feature includes:
159	   - mitigation of some (not all) SMT side channels;
160	   - limiting SMT interference to improve determinism and/or performance.
161
162	  SCHED_CORE is default disabled. When it is enabled and unused,
163	  which is the likely usage by Linux distributions, there should
164	  be no measurable impact on performance.
165
166config SCHED_CLASS_EXT
167	bool "Extensible Scheduling Class"
168	depends on BPF_SYSCALL && BPF_JIT && DEBUG_INFO_BTF
169	select STACKTRACE if STACKTRACE_SUPPORT
170	help
171	  This option enables a new scheduler class sched_ext (SCX), which
172	  allows scheduling policies to be implemented as BPF programs to
173	  achieve the following:
174
175	  - Ease of experimentation and exploration: Enabling rapid
176	    iteration of new scheduling policies.
177	  - Customization: Building application-specific schedulers which
178	    implement policies that are not applicable to general-purpose
179	    schedulers.
180	  - Rapid scheduler deployments: Non-disruptive swap outs of
181	    scheduling policies in production environments.
182
183	  sched_ext leverages BPF struct_ops feature to define a structure
184	  which exports function callbacks and flags to BPF programs that
185	  wish to implement scheduling policies. The struct_ops structure
186	  exported by sched_ext is struct sched_ext_ops, and is conceptually
187	  similar to struct sched_class.
188
189	  For more information:
190	    Documentation/scheduler/sched-ext.rst
191	    https://github.com/sched-ext/scx
192