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