1# SPDX-License-Identifier: GPL-2.0-only
2#
3# RCU-related configuration options
4#
5
6menu "RCU Subsystem"
7
8config TREE_RCU
9	bool
10	default y if SMP
11	# Dynticks-idle tracking
12	select CONTEXT_TRACKING_IDLE
13	help
14	  This option selects the RCU implementation that is
15	  designed for very large SMP system with hundreds or
16	  thousands of CPUs.  It also scales down nicely to
17	  smaller systems.
18
19config PREEMPT_RCU
20	bool
21	default y if (PREEMPT || PREEMPT_RT || PREEMPT_DYNAMIC)
22	select TREE_RCU
23	help
24	  This option selects the RCU implementation that is
25	  designed for very large SMP systems with hundreds or
26	  thousands of CPUs, but for which real-time response
27	  is also required.  It also scales down nicely to
28	  smaller systems.
29
30	  Select this option if you are unsure.
31
32config TINY_RCU
33	bool
34	default y if !PREEMPT_RCU && !SMP
35	help
36	  This option selects the RCU implementation that is
37	  designed for UP systems from which real-time response
38	  is not required.  This option greatly reduces the
39	  memory footprint of RCU.
40
41config RCU_EXPERT
42	bool "Make expert-level adjustments to RCU configuration"
43	default n
44	help
45	  This option needs to be enabled if you wish to make
46	  expert-level adjustments to RCU configuration.  By default,
47	  no such adjustments can be made, which has the often-beneficial
48	  side-effect of preventing "make oldconfig" from asking you all
49	  sorts of detailed questions about how you would like numerous
50	  obscure RCU options to be set up.
51
52	  Say Y if you need to make expert-level adjustments to RCU.
53
54	  Say N if you are unsure.
55
56config TINY_SRCU
57	bool
58	default y if TINY_RCU
59	help
60	  This option selects the single-CPU non-preemptible version of SRCU.
61
62config TREE_SRCU
63	bool
64	default y if !TINY_RCU
65	help
66	  This option selects the full-fledged version of SRCU.
67
68config FORCE_NEED_SRCU_NMI_SAFE
69	bool "Force selection of NEED_SRCU_NMI_SAFE"
70	depends on !TINY_SRCU
71	depends on RCU_EXPERT
72	depends on ARCH_HAS_NMI_SAFE_THIS_CPU_OPS
73	select NEED_SRCU_NMI_SAFE
74	default n
75	help
76	  This option forces selection of the NEED_SRCU_NMI_SAFE
77	  Kconfig option, allowing testing of srcu_read_lock_nmisafe()
78	  and srcu_read_unlock_nmisafe() on architectures (like x86)
79	  that select the ARCH_HAS_NMI_SAFE_THIS_CPU_OPS Kconfig option.
80
81config NEED_SRCU_NMI_SAFE
82	def_bool HAVE_NMI && !ARCH_HAS_NMI_SAFE_THIS_CPU_OPS && !TINY_SRCU
83
84config TASKS_RCU_GENERIC
85	def_bool TASKS_RCU || TASKS_RUDE_RCU || TASKS_TRACE_RCU
86	help
87	  This option enables generic infrastructure code supporting
88	  task-based RCU implementations.  Not for manual selection.
89
90config FORCE_TASKS_RCU
91	bool "Force selection of TASKS_RCU"
92	depends on RCU_EXPERT
93	select TASKS_RCU
94	default n
95	help
96	  This option force-enables a task-based RCU implementation
97	  that uses only voluntary context switch (not preemption!),
98	  idle, and user-mode execution as quiescent states.  Not for
99	  manual selection in most cases.
100
101config NEED_TASKS_RCU
102	bool
103	default n
104
105config TASKS_RCU
106	bool
107	default NEED_TASKS_RCU && PREEMPTION
108	select IRQ_WORK
109
110config FORCE_TASKS_RUDE_RCU
111	bool "Force selection of Tasks Rude RCU"
112	depends on RCU_EXPERT
113	select TASKS_RUDE_RCU
114	default n
115	help
116	  This option force-enables a task-based RCU implementation
117	  that uses only context switch (including preemption) and
118	  user-mode execution as quiescent states.  It forces IPIs and
119	  context switches on all online CPUs, including idle ones,
120	  so use with caution.	Not for manual selection in most cases.
121
122config TASKS_RUDE_RCU
123	bool
124	default n
125	select IRQ_WORK
126
127config FORCE_TASKS_TRACE_RCU
128	bool "Force selection of Tasks Trace RCU"
129	depends on RCU_EXPERT
130	select TASKS_TRACE_RCU
131	default n
132	help
133	  This option enables a task-based RCU implementation that uses
134	  explicit rcu_read_lock_trace() read-side markers, and allows
135	  these readers to appear in the idle loop as well as on the
136	  CPU hotplug code paths.  It can force IPIs on online CPUs,
137	  including idle ones, so use with caution.  Not for manual
138	  selection in most cases.
139
140config TASKS_TRACE_RCU
141	bool
142	default n
143	select IRQ_WORK
144
145config RCU_STALL_COMMON
146	def_bool TREE_RCU
147	help
148	  This option enables RCU CPU stall code that is common between
149	  the TINY and TREE variants of RCU.  The purpose is to allow
150	  the tiny variants to disable RCU CPU stall warnings, while
151	  making these warnings mandatory for the tree variants.
152
153config RCU_NEED_SEGCBLIST
154	def_bool ( TREE_RCU || TREE_SRCU || TASKS_RCU_GENERIC )
155
156config RCU_FANOUT
157	int "Tree-based hierarchical RCU fanout value"
158	range 2 64 if 64BIT
159	range 2 32 if !64BIT
160	depends on TREE_RCU && RCU_EXPERT
161	default 64 if 64BIT
162	default 32 if !64BIT
163	help
164	  This option controls the fanout of hierarchical implementations
165	  of RCU, allowing RCU to work efficiently on machines with
166	  large numbers of CPUs.  This value must be at least the fourth
167	  root of NR_CPUS, which allows NR_CPUS to be insanely large.
168	  The default value of RCU_FANOUT should be used for production
169	  systems, but if you are stress-testing the RCU implementation
170	  itself, small RCU_FANOUT values allow you to test large-system
171	  code paths on small(er) systems.
172
173	  Select a specific number if testing RCU itself.
174	  Take the default if unsure.
175
176config RCU_FANOUT_LEAF
177	int "Tree-based hierarchical RCU leaf-level fanout value"
178	range 2 64 if 64BIT && !RCU_STRICT_GRACE_PERIOD
179	range 2 32 if !64BIT && !RCU_STRICT_GRACE_PERIOD
180	range 2 3 if RCU_STRICT_GRACE_PERIOD
181	depends on TREE_RCU && RCU_EXPERT
182	default 16 if !RCU_STRICT_GRACE_PERIOD
183	default 2 if RCU_STRICT_GRACE_PERIOD
184	help
185	  This option controls the leaf-level fanout of hierarchical
186	  implementations of RCU, and allows trading off cache misses
187	  against lock contention.  Systems that synchronize their
188	  scheduling-clock interrupts for energy-efficiency reasons will
189	  want the default because the smaller leaf-level fanout keeps
190	  lock contention levels acceptably low.  Very large systems
191	  (hundreds or thousands of CPUs) will instead want to set this
192	  value to the maximum value possible in order to reduce the
193	  number of cache misses incurred during RCU's grace-period
194	  initialization.  These systems tend to run CPU-bound, and thus
195	  are not helped by synchronized interrupts, and thus tend to
196	  skew them, which reduces lock contention enough that large
197	  leaf-level fanouts work well.  That said, setting leaf-level
198	  fanout to a large number will likely cause problematic
199	  lock contention on the leaf-level rcu_node structures unless
200	  you boot with the skew_tick kernel parameter.
201
202	  Select a specific number if testing RCU itself.
203
204	  Select the maximum permissible value for large systems, but
205	  please understand that you may also need to set the skew_tick
206	  kernel boot parameter to avoid contention on the rcu_node
207	  structure's locks.
208
209	  Take the default if unsure.
210
211config RCU_BOOST
212	bool "Enable RCU priority boosting"
213	depends on (RT_MUTEXES && PREEMPT_RCU && RCU_EXPERT) || PREEMPT_RT
214	default y if PREEMPT_RT
215	help
216	  This option boosts the priority of preempted RCU readers that
217	  block the current preemptible RCU grace period for too long.
218	  This option also prevents heavy loads from blocking RCU
219	  callback invocation.
220
221	  Say Y here if you are working with real-time apps or heavy loads
222	  Say N here if you are unsure.
223
224config RCU_BOOST_DELAY
225	int "Milliseconds to delay boosting after RCU grace-period start"
226	range 0 3000
227	depends on RCU_BOOST
228	default 500
229	help
230	  This option specifies the time to wait after the beginning of
231	  a given grace period before priority-boosting preempted RCU
232	  readers blocking that grace period.  Note that any RCU reader
233	  blocking an expedited RCU grace period is boosted immediately.
234
235	  Accept the default if unsure.
236
237config RCU_EXP_KTHREAD
238	bool "Perform RCU expedited work in a real-time kthread"
239	depends on RCU_BOOST && RCU_EXPERT
240	default !PREEMPT_RT && NR_CPUS <= 32
241	help
242	  Use this option to further reduce the latencies of expedited
243	  grace periods at the expense of being more disruptive.
244
245	  This option is disabled by default on PREEMPT_RT=y kernels which
246	  disable expedited grace periods after boot by unconditionally
247	  setting rcupdate.rcu_normal_after_boot=1.
248
249	  Accept the default if unsure.
250
251config RCU_NOCB_CPU
252	bool "Offload RCU callback processing from boot-selected CPUs"
253	depends on TREE_RCU
254	depends on RCU_EXPERT || NO_HZ_FULL
255	default n
256	help
257	  Use this option to reduce OS jitter for aggressive HPC or
258	  real-time workloads.	It can also be used to offload RCU
259	  callback invocation to energy-efficient CPUs in battery-powered
260	  asymmetric multiprocessors.  The price of this reduced jitter
261	  is that the overhead of call_rcu() increases and that some
262	  workloads will incur significant increases in context-switch
263	  rates.
264
265	  This option offloads callback invocation from the set of
266	  CPUs specified at boot time by the rcu_nocbs parameter.
267	  For each such CPU, a kthread ("rcuox/N") will be created to
268	  invoke callbacks, where the "N" is the CPU being offloaded,
269	  and where the "x" is "p" for RCU-preempt (PREEMPTION kernels)
270	  and "s" for RCU-sched (!PREEMPTION kernels).	This option
271	  also creates another kthread for each sqrt(nr_cpu_ids) CPUs
272	  ("rcuog/N", where N is the first CPU in that group to come
273	  online), which handles grace periods for its group.  Nothing
274	  prevents these kthreads from running on the specified CPUs,
275	  but (1) the kthreads may be preempted between each callback,
276	  and (2) affinity or cgroups can be used to force the kthreads
277	  to run on whatever set of CPUs is desired.
278
279	  The sqrt(nr_cpu_ids) grouping may be overridden using the
280	  rcutree.rcu_nocb_gp_stride kernel boot parameter.  This can
281	  be especially helpful for smaller numbers of CPUs, where
282	  sqrt(nr_cpu_ids) can be a bit of a blunt instrument.
283
284	  Say Y here if you need reduced OS jitter, despite added overhead.
285	  Say N here if you are unsure.
286
287config RCU_NOCB_CPU_DEFAULT_ALL
288	bool "Offload RCU callback processing from all CPUs by default"
289	depends on RCU_NOCB_CPU
290	default n
291	help
292	  Use this option to offload callback processing from all CPUs
293	  by default, in the absence of the rcu_nocbs or nohz_full boot
294	  parameter. This also avoids the need to use any boot parameters
295	  to achieve the effect of offloading all CPUs on boot.
296
297	  Say Y here if you want offload all CPUs by default on boot.
298	  Say N here if you are unsure.
299
300config RCU_NOCB_CPU_CB_BOOST
301	bool "Offload RCU callback from real-time kthread"
302	depends on RCU_NOCB_CPU && RCU_BOOST
303	default y if PREEMPT_RT
304	help
305	  Use this option to invoke offloaded callbacks as SCHED_FIFO
306	  to avoid starvation by heavy SCHED_OTHER background load.
307	  Of course, running as SCHED_FIFO during callback floods will
308	  cause the rcuo[ps] kthreads to monopolize the CPU for hundreds
309	  of milliseconds or more.  Therefore, when enabling this option,
310	  it is your responsibility to ensure that latency-sensitive
311	  tasks either run with higher priority or run on some other CPU.
312
313	  Say Y here if you want to set RT priority for offloading kthreads.
314	  Say N here if you are building a !PREEMPT_RT kernel and are unsure.
315
316config TASKS_TRACE_RCU_READ_MB
317	bool "Tasks Trace RCU readers use memory barriers in user and idle"
318	depends on RCU_EXPERT && TASKS_TRACE_RCU
319	default PREEMPT_RT || NR_CPUS < 8
320	help
321	  Use this option to further reduce the number of IPIs sent
322	  to CPUs executing in userspace or idle during tasks trace
323	  RCU grace periods.  Given that a reasonable setting of
324	  the rcupdate.rcu_task_ipi_delay kernel boot parameter
325	  eliminates such IPIs for many workloads, proper setting
326	  of this Kconfig option is important mostly for aggressive
327	  real-time installations and for battery-powered devices,
328	  hence the default chosen above.
329
330	  Say Y here if you hate IPIs.
331	  Say N here if you hate read-side memory barriers.
332	  Take the default if you are unsure.
333
334config RCU_LAZY
335	bool "RCU callback lazy invocation functionality"
336	depends on RCU_NOCB_CPU
337	default n
338	help
339	  To save power, batch RCU callbacks and delay starting the
340	  corresponding grace  period for multiple seconds.  The grace
341	  period will be started after this delay, in case of memory
342	  pressure, or if the corresponding CPU's callback list grows
343	  too large.
344
345	  These delays happen only on rcu_nocbs CPUs, that is, CPUs
346	  whose callbacks have been offloaded.
347
348	  Use the rcutree.enable_rcu_lazy=0 kernel-boot parameter to
349	  globally disable these delays.
350
351config RCU_LAZY_DEFAULT_OFF
352	bool "Turn RCU lazy invocation off by default"
353	depends on RCU_LAZY
354	default n
355	help
356	  Build the kernel with CONFIG_RCU_LAZY=y, but cause the kernel
357	  to boot with these energy-efficiency delays disabled.  Use the
358	  rcutree.enable_rcu_lazy=0 kernel-boot parameter to override
359	  the this option at boot time, thus re-enabling these delays.
360
361config RCU_DOUBLE_CHECK_CB_TIME
362	bool "RCU callback-batch backup time check"
363	depends on RCU_EXPERT
364	default n
365	help
366	  Use this option to provide more precise enforcement of the
367	  rcutree.rcu_resched_ns module parameter in situations where
368	  a single RCU callback might run for hundreds of microseconds,
369	  thus defeating the 32-callback batching used to amortize the
370	  cost of the fine-grained but expensive local_clock() function.
371
372	  This option rounds rcutree.rcu_resched_ns up to the next
373	  jiffy, and overrides the 32-callback batching if this limit
374	  is exceeded.
375
376	  Say Y here if you need tighter callback-limit enforcement.
377	  Say N here if you are unsure.
378
379endmenu # "RCU Subsystem"
380