rcu-tasks: Provide boot parameter to delay IPIs until late in grace period
[linux-2.6-block.git] / kernel / rcu / tasks.h
CommitLineData
eacd6f04
PM
1/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * Task-based RCU implementations.
4 *
5 * Copyright (C) 2020 Paul E. McKenney
6 */
7
8fd8ca38 8#ifdef CONFIG_TASKS_RCU_GENERIC
5873b8a9
PM
9
10////////////////////////////////////////////////////////////////////////
11//
12// Generic data structures.
13
14struct rcu_tasks;
15typedef void (*rcu_tasks_gp_func_t)(struct rcu_tasks *rtp);
e4fe5dd6
PM
16typedef void (*pregp_func_t)(void);
17typedef void (*pertask_func_t)(struct task_struct *t, struct list_head *hop);
18typedef void (*postscan_func_t)(void);
19typedef void (*holdouts_func_t)(struct list_head *hop, bool ndrpt, bool *frptp);
af051ca4 20typedef void (*postgp_func_t)(struct rcu_tasks *rtp);
eacd6f04 21
07e10515
PM
22/**
23 * Definition for a Tasks-RCU-like mechanism.
24 * @cbs_head: Head of callback list.
25 * @cbs_tail: Tail pointer for callback list.
26 * @cbs_wq: Wait queue allowning new callback to get kthread's attention.
27 * @cbs_lock: Lock protecting callback list.
28 * @kthread_ptr: This flavor's grace-period/callback-invocation kthread.
5873b8a9 29 * @gp_func: This flavor's grace-period-wait function.
af051ca4
PM
30 * @gp_state: Grace period's most recent state transition (debugging).
31 * @gp_jiffies: Time of last @gp_state transition.
32 * @gp_start: Most recent grace-period start in jiffies.
e4fe5dd6
PM
33 * @pregp_func: This flavor's pre-grace-period function (optional).
34 * @pertask_func: This flavor's per-task scan function (optional).
35 * @postscan_func: This flavor's post-task scan function (optional).
36 * @holdout_func: This flavor's holdout-list scan function (optional).
37 * @postgp_func: This flavor's post-grace-period function (optional).
5873b8a9 38 * @call_func: This flavor's call_rcu()-equivalent function.
c97d12a6
PM
39 * @name: This flavor's textual name.
40 * @kname: This flavor's kthread name.
07e10515
PM
41 */
42struct rcu_tasks {
43 struct rcu_head *cbs_head;
44 struct rcu_head **cbs_tail;
45 struct wait_queue_head cbs_wq;
46 raw_spinlock_t cbs_lock;
af051ca4
PM
47 int gp_state;
48 unsigned long gp_jiffies;
88092d0c 49 unsigned long gp_start;
07e10515 50 struct task_struct *kthread_ptr;
5873b8a9 51 rcu_tasks_gp_func_t gp_func;
e4fe5dd6
PM
52 pregp_func_t pregp_func;
53 pertask_func_t pertask_func;
54 postscan_func_t postscan_func;
55 holdouts_func_t holdouts_func;
56 postgp_func_t postgp_func;
5873b8a9 57 call_rcu_func_t call_func;
c97d12a6
PM
58 char *name;
59 char *kname;
07e10515
PM
60};
61
c97d12a6
PM
62#define DEFINE_RCU_TASKS(rt_name, gp, call, n) \
63static struct rcu_tasks rt_name = \
07e10515 64{ \
c97d12a6
PM
65 .cbs_tail = &rt_name.cbs_head, \
66 .cbs_wq = __WAIT_QUEUE_HEAD_INITIALIZER(rt_name.cbs_wq), \
67 .cbs_lock = __RAW_SPIN_LOCK_UNLOCKED(rt_name.cbs_lock), \
5873b8a9
PM
68 .gp_func = gp, \
69 .call_func = call, \
c97d12a6
PM
70 .name = n, \
71 .kname = #rt_name, \
07e10515
PM
72}
73
eacd6f04
PM
74/* Track exiting tasks in order to allow them to be waited for. */
75DEFINE_STATIC_SRCU(tasks_rcu_exit_srcu);
76
b0afa0f0
PM
77/* Avoid IPIing CPUs early in the grace period. */
78#define RCU_TASK_IPI_DELAY (HZ / 2)
79static int rcu_task_ipi_delay __read_mostly = RCU_TASK_IPI_DELAY;
80module_param(rcu_task_ipi_delay, int, 0644);
81
eacd6f04
PM
82/* Control stall timeouts. Disable with <= 0, otherwise jiffies till stall. */
83#define RCU_TASK_STALL_TIMEOUT (HZ * 60 * 10)
84static int rcu_task_stall_timeout __read_mostly = RCU_TASK_STALL_TIMEOUT;
85module_param(rcu_task_stall_timeout, int, 0644);
86
af051ca4
PM
87/* RCU tasks grace-period state for debugging. */
88#define RTGS_INIT 0
89#define RTGS_WAIT_WAIT_CBS 1
90#define RTGS_WAIT_GP 2
91#define RTGS_PRE_WAIT_GP 3
92#define RTGS_SCAN_TASKLIST 4
93#define RTGS_POST_SCAN_TASKLIST 5
94#define RTGS_WAIT_SCAN_HOLDOUTS 6
95#define RTGS_SCAN_HOLDOUTS 7
96#define RTGS_POST_GP 8
97#define RTGS_WAIT_READERS 9
98#define RTGS_INVOKE_CBS 10
99#define RTGS_WAIT_CBS 11
100static const char * const rcu_tasks_gp_state_names[] = {
101 "RTGS_INIT",
102 "RTGS_WAIT_WAIT_CBS",
103 "RTGS_WAIT_GP",
104 "RTGS_PRE_WAIT_GP",
105 "RTGS_SCAN_TASKLIST",
106 "RTGS_POST_SCAN_TASKLIST",
107 "RTGS_WAIT_SCAN_HOLDOUTS",
108 "RTGS_SCAN_HOLDOUTS",
109 "RTGS_POST_GP",
110 "RTGS_WAIT_READERS",
111 "RTGS_INVOKE_CBS",
112 "RTGS_WAIT_CBS",
113};
114
5873b8a9
PM
115////////////////////////////////////////////////////////////////////////
116//
117// Generic code.
118
af051ca4
PM
119/* Record grace-period phase and time. */
120static void set_tasks_gp_state(struct rcu_tasks *rtp, int newstate)
121{
122 rtp->gp_state = newstate;
123 rtp->gp_jiffies = jiffies;
124}
125
126/* Return state name. */
127static const char *tasks_gp_state_getname(struct rcu_tasks *rtp)
128{
129 int i = data_race(rtp->gp_state); // Let KCSAN detect update races
130 int j = READ_ONCE(i); // Prevent the compiler from reading twice
131
132 if (j >= ARRAY_SIZE(rcu_tasks_gp_state_names))
133 return "???";
134 return rcu_tasks_gp_state_names[j];
135}
136
5873b8a9
PM
137// Enqueue a callback for the specified flavor of Tasks RCU.
138static void call_rcu_tasks_generic(struct rcu_head *rhp, rcu_callback_t func,
139 struct rcu_tasks *rtp)
eacd6f04
PM
140{
141 unsigned long flags;
142 bool needwake;
143
144 rhp->next = NULL;
145 rhp->func = func;
07e10515
PM
146 raw_spin_lock_irqsave(&rtp->cbs_lock, flags);
147 needwake = !rtp->cbs_head;
148 WRITE_ONCE(*rtp->cbs_tail, rhp);
149 rtp->cbs_tail = &rhp->next;
150 raw_spin_unlock_irqrestore(&rtp->cbs_lock, flags);
eacd6f04 151 /* We can't create the thread unless interrupts are enabled. */
07e10515
PM
152 if (needwake && READ_ONCE(rtp->kthread_ptr))
153 wake_up(&rtp->cbs_wq);
eacd6f04 154}
eacd6f04 155
5873b8a9
PM
156// Wait for a grace period for the specified flavor of Tasks RCU.
157static void synchronize_rcu_tasks_generic(struct rcu_tasks *rtp)
eacd6f04
PM
158{
159 /* Complain if the scheduler has not started. */
160 RCU_LOCKDEP_WARN(rcu_scheduler_active == RCU_SCHEDULER_INACTIVE,
161 "synchronize_rcu_tasks called too soon");
162
163 /* Wait for the grace period. */
5873b8a9 164 wait_rcu_gp(rtp->call_func);
eacd6f04
PM
165}
166
167/* RCU-tasks kthread that detects grace periods and invokes callbacks. */
168static int __noreturn rcu_tasks_kthread(void *arg)
169{
170 unsigned long flags;
eacd6f04
PM
171 struct rcu_head *list;
172 struct rcu_head *next;
07e10515 173 struct rcu_tasks *rtp = arg;
eacd6f04
PM
174
175 /* Run on housekeeping CPUs by default. Sysadm can move if desired. */
176 housekeeping_affine(current, HK_FLAG_RCU);
07e10515 177 WRITE_ONCE(rtp->kthread_ptr, current); // Let GPs start!
eacd6f04
PM
178
179 /*
180 * Each pass through the following loop makes one check for
181 * newly arrived callbacks, and, if there are some, waits for
182 * one RCU-tasks grace period and then invokes the callbacks.
183 * This loop is terminated by the system going down. ;-)
184 */
185 for (;;) {
186
187 /* Pick up any new callbacks. */
07e10515 188 raw_spin_lock_irqsave(&rtp->cbs_lock, flags);
43766c3e 189 smp_mb__after_spinlock(); // Order updates vs. GP.
07e10515
PM
190 list = rtp->cbs_head;
191 rtp->cbs_head = NULL;
192 rtp->cbs_tail = &rtp->cbs_head;
193 raw_spin_unlock_irqrestore(&rtp->cbs_lock, flags);
eacd6f04
PM
194
195 /* If there were none, wait a bit and start over. */
196 if (!list) {
07e10515
PM
197 wait_event_interruptible(rtp->cbs_wq,
198 READ_ONCE(rtp->cbs_head));
199 if (!rtp->cbs_head) {
eacd6f04 200 WARN_ON(signal_pending(current));
af051ca4 201 set_tasks_gp_state(rtp, RTGS_WAIT_WAIT_CBS);
eacd6f04
PM
202 schedule_timeout_interruptible(HZ/10);
203 }
204 continue;
205 }
206
5873b8a9 207 // Wait for one grace period.
af051ca4 208 set_tasks_gp_state(rtp, RTGS_WAIT_GP);
88092d0c 209 rtp->gp_start = jiffies;
5873b8a9 210 rtp->gp_func(rtp);
eacd6f04
PM
211
212 /* Invoke the callbacks. */
af051ca4 213 set_tasks_gp_state(rtp, RTGS_INVOKE_CBS);
eacd6f04
PM
214 while (list) {
215 next = list->next;
216 local_bh_disable();
217 list->func(list);
218 local_bh_enable();
219 list = next;
220 cond_resched();
221 }
222 /* Paranoid sleep to keep this from entering a tight loop */
223 schedule_timeout_uninterruptible(HZ/10);
af051ca4
PM
224
225 set_tasks_gp_state(rtp, RTGS_WAIT_CBS);
eacd6f04
PM
226 }
227}
228
5873b8a9
PM
229/* Spawn RCU-tasks grace-period kthread, e.g., at core_initcall() time. */
230static void __init rcu_spawn_tasks_kthread_generic(struct rcu_tasks *rtp)
eacd6f04
PM
231{
232 struct task_struct *t;
233
c97d12a6
PM
234 t = kthread_run(rcu_tasks_kthread, rtp, "%s_kthread", rtp->kname);
235 if (WARN_ONCE(IS_ERR(t), "%s: Could not start %s grace-period kthread, OOM is now expected behavior\n", __func__, rtp->name))
5873b8a9 236 return;
eacd6f04 237 smp_mb(); /* Ensure others see full kthread. */
eacd6f04 238}
eacd6f04
PM
239
240/* Do the srcu_read_lock() for the above synchronize_srcu(). */
241void exit_tasks_rcu_start(void) __acquires(&tasks_rcu_exit_srcu)
242{
243 preempt_disable();
244 current->rcu_tasks_idx = __srcu_read_lock(&tasks_rcu_exit_srcu);
245 preempt_enable();
246}
247
d5f177d3
PM
248static void exit_tasks_rcu_finish_trace(struct task_struct *t);
249
eacd6f04
PM
250/* Do the srcu_read_unlock() for the above synchronize_srcu(). */
251void exit_tasks_rcu_finish(void) __releases(&tasks_rcu_exit_srcu)
252{
d5f177d3
PM
253 struct task_struct *t = current;
254
eacd6f04 255 preempt_disable();
d5f177d3 256 __srcu_read_unlock(&tasks_rcu_exit_srcu, t->rcu_tasks_idx);
eacd6f04 257 preempt_enable();
d5f177d3 258 exit_tasks_rcu_finish_trace(t);
eacd6f04
PM
259}
260
eacd6f04
PM
261#ifndef CONFIG_TINY_RCU
262
263/*
264 * Print any non-default Tasks RCU settings.
265 */
266static void __init rcu_tasks_bootup_oddness(void)
267{
d5f177d3 268#if defined(CONFIG_TASKS_RCU) || defined(CONFIG_TASKS_TRACE_RCU)
eacd6f04
PM
269 if (rcu_task_stall_timeout != RCU_TASK_STALL_TIMEOUT)
270 pr_info("\tTasks-RCU CPU stall warnings timeout set to %d (rcu_task_stall_timeout).\n", rcu_task_stall_timeout);
d5f177d3
PM
271#endif /* #ifdef CONFIG_TASKS_RCU */
272#ifdef CONFIG_TASKS_RCU
273 pr_info("\tTrampoline variant of Tasks RCU enabled.\n");
eacd6f04 274#endif /* #ifdef CONFIG_TASKS_RCU */
c84aad76
PM
275#ifdef CONFIG_TASKS_RUDE_RCU
276 pr_info("\tRude variant of Tasks RCU enabled.\n");
277#endif /* #ifdef CONFIG_TASKS_RUDE_RCU */
d5f177d3
PM
278#ifdef CONFIG_TASKS_TRACE_RCU
279 pr_info("\tTracing variant of Tasks RCU enabled.\n");
280#endif /* #ifdef CONFIG_TASKS_TRACE_RCU */
eacd6f04
PM
281}
282
283#endif /* #ifndef CONFIG_TINY_RCU */
5873b8a9 284
e21408ce
PM
285/* Dump out rcutorture-relevant state common to all RCU-tasks flavors. */
286static void show_rcu_tasks_generic_gp_kthread(struct rcu_tasks *rtp, char *s)
287{
af051ca4 288 pr_info("%s: %s(%d) since %lu %c%c %s\n",
e21408ce 289 rtp->kname,
af051ca4
PM
290 tasks_gp_state_getname(rtp),
291 data_race(rtp->gp_state),
292 jiffies - data_race(rtp->gp_jiffies),
e21408ce
PM
293 ".k"[!!data_race(rtp->kthread_ptr)],
294 ".C"[!!data_race(rtp->cbs_head)],
295 s);
296}
297
5873b8a9
PM
298#ifdef CONFIG_TASKS_RCU
299
d01aa263
PM
300////////////////////////////////////////////////////////////////////////
301//
302// Shared code between task-list-scanning variants of Tasks RCU.
303
304/* Wait for one RCU-tasks grace period. */
305static void rcu_tasks_wait_gp(struct rcu_tasks *rtp)
306{
307 struct task_struct *g, *t;
308 unsigned long lastreport;
309 LIST_HEAD(holdouts);
310 int fract;
311
af051ca4 312 set_tasks_gp_state(rtp, RTGS_PRE_WAIT_GP);
d01aa263
PM
313 rtp->pregp_func();
314
315 /*
316 * There were callbacks, so we need to wait for an RCU-tasks
317 * grace period. Start off by scanning the task list for tasks
318 * that are not already voluntarily blocked. Mark these tasks
319 * and make a list of them in holdouts.
320 */
af051ca4 321 set_tasks_gp_state(rtp, RTGS_SCAN_TASKLIST);
d01aa263
PM
322 rcu_read_lock();
323 for_each_process_thread(g, t)
324 rtp->pertask_func(t, &holdouts);
325 rcu_read_unlock();
326
af051ca4 327 set_tasks_gp_state(rtp, RTGS_POST_SCAN_TASKLIST);
d01aa263
PM
328 rtp->postscan_func();
329
330 /*
331 * Each pass through the following loop scans the list of holdout
332 * tasks, removing any that are no longer holdouts. When the list
333 * is empty, we are done.
334 */
335 lastreport = jiffies;
336
337 /* Start off with HZ/10 wait and slowly back off to 1 HZ wait. */
338 fract = 10;
339
340 for (;;) {
341 bool firstreport;
342 bool needreport;
343 int rtst;
344
345 if (list_empty(&holdouts))
346 break;
347
348 /* Slowly back off waiting for holdouts */
af051ca4 349 set_tasks_gp_state(rtp, RTGS_WAIT_SCAN_HOLDOUTS);
d01aa263
PM
350 schedule_timeout_interruptible(HZ/fract);
351
352 if (fract > 1)
353 fract--;
354
355 rtst = READ_ONCE(rcu_task_stall_timeout);
356 needreport = rtst > 0 && time_after(jiffies, lastreport + rtst);
357 if (needreport)
358 lastreport = jiffies;
359 firstreport = true;
360 WARN_ON(signal_pending(current));
af051ca4 361 set_tasks_gp_state(rtp, RTGS_SCAN_HOLDOUTS);
d01aa263
PM
362 rtp->holdouts_func(&holdouts, needreport, &firstreport);
363 }
364
af051ca4
PM
365 set_tasks_gp_state(rtp, RTGS_POST_GP);
366 rtp->postgp_func(rtp);
d01aa263
PM
367}
368
5873b8a9
PM
369////////////////////////////////////////////////////////////////////////
370//
371// Simple variant of RCU whose quiescent states are voluntary context
372// switch, cond_resched_rcu_qs(), user-space execution, and idle.
373// As such, grace periods can take one good long time. There are no
374// read-side primitives similar to rcu_read_lock() and rcu_read_unlock()
375// because this implementation is intended to get the system into a safe
376// state for some of the manipulations involved in tracing and the like.
377// Finally, this implementation does not support high call_rcu_tasks()
378// rates from multiple CPUs. If this is required, per-CPU callback lists
379// will be needed.
380
e4fe5dd6
PM
381/* Pre-grace-period preparation. */
382static void rcu_tasks_pregp_step(void)
383{
384 /*
385 * Wait for all pre-existing t->on_rq and t->nvcsw transitions
386 * to complete. Invoking synchronize_rcu() suffices because all
387 * these transitions occur with interrupts disabled. Without this
388 * synchronize_rcu(), a read-side critical section that started
389 * before the grace period might be incorrectly seen as having
390 * started after the grace period.
391 *
392 * This synchronize_rcu() also dispenses with the need for a
393 * memory barrier on the first store to t->rcu_tasks_holdout,
394 * as it forces the store to happen after the beginning of the
395 * grace period.
396 */
397 synchronize_rcu();
398}
399
400/* Per-task initial processing. */
401static void rcu_tasks_pertask(struct task_struct *t, struct list_head *hop)
402{
403 if (t != current && READ_ONCE(t->on_rq) && !is_idle_task(t)) {
404 get_task_struct(t);
405 t->rcu_tasks_nvcsw = READ_ONCE(t->nvcsw);
406 WRITE_ONCE(t->rcu_tasks_holdout, true);
407 list_add(&t->rcu_tasks_holdout_list, hop);
408 }
409}
410
411/* Processing between scanning taskslist and draining the holdout list. */
412void rcu_tasks_postscan(void)
413{
414 /*
415 * Wait for tasks that are in the process of exiting. This
416 * does only part of the job, ensuring that all tasks that were
417 * previously exiting reach the point where they have disabled
418 * preemption, allowing the later synchronize_rcu() to finish
419 * the job.
420 */
421 synchronize_srcu(&tasks_rcu_exit_srcu);
422}
423
5873b8a9
PM
424/* See if tasks are still holding out, complain if so. */
425static void check_holdout_task(struct task_struct *t,
426 bool needreport, bool *firstreport)
427{
428 int cpu;
429
430 if (!READ_ONCE(t->rcu_tasks_holdout) ||
431 t->rcu_tasks_nvcsw != READ_ONCE(t->nvcsw) ||
432 !READ_ONCE(t->on_rq) ||
433 (IS_ENABLED(CONFIG_NO_HZ_FULL) &&
434 !is_idle_task(t) && t->rcu_tasks_idle_cpu >= 0)) {
435 WRITE_ONCE(t->rcu_tasks_holdout, false);
436 list_del_init(&t->rcu_tasks_holdout_list);
437 put_task_struct(t);
438 return;
439 }
440 rcu_request_urgent_qs_task(t);
441 if (!needreport)
442 return;
443 if (*firstreport) {
444 pr_err("INFO: rcu_tasks detected stalls on tasks:\n");
445 *firstreport = false;
446 }
447 cpu = task_cpu(t);
448 pr_alert("%p: %c%c nvcsw: %lu/%lu holdout: %d idle_cpu: %d/%d\n",
449 t, ".I"[is_idle_task(t)],
450 "N."[cpu < 0 || !tick_nohz_full_cpu(cpu)],
451 t->rcu_tasks_nvcsw, t->nvcsw, t->rcu_tasks_holdout,
452 t->rcu_tasks_idle_cpu, cpu);
453 sched_show_task(t);
454}
455
e4fe5dd6
PM
456/* Scan the holdout lists for tasks no longer holding out. */
457static void check_all_holdout_tasks(struct list_head *hop,
458 bool needreport, bool *firstreport)
459{
460 struct task_struct *t, *t1;
461
462 list_for_each_entry_safe(t, t1, hop, rcu_tasks_holdout_list) {
463 check_holdout_task(t, needreport, firstreport);
464 cond_resched();
465 }
466}
467
468/* Finish off the Tasks-RCU grace period. */
af051ca4 469static void rcu_tasks_postgp(struct rcu_tasks *rtp)
e4fe5dd6
PM
470{
471 /*
472 * Because ->on_rq and ->nvcsw are not guaranteed to have a full
473 * memory barriers prior to them in the schedule() path, memory
474 * reordering on other CPUs could cause their RCU-tasks read-side
475 * critical sections to extend past the end of the grace period.
476 * However, because these ->nvcsw updates are carried out with
477 * interrupts disabled, we can use synchronize_rcu() to force the
478 * needed ordering on all such CPUs.
479 *
480 * This synchronize_rcu() also confines all ->rcu_tasks_holdout
481 * accesses to be within the grace period, avoiding the need for
482 * memory barriers for ->rcu_tasks_holdout accesses.
483 *
484 * In addition, this synchronize_rcu() waits for exiting tasks
485 * to complete their final preempt_disable() region of execution,
486 * cleaning up after the synchronize_srcu() above.
487 */
488 synchronize_rcu();
489}
490
5873b8a9 491void call_rcu_tasks(struct rcu_head *rhp, rcu_callback_t func);
c97d12a6 492DEFINE_RCU_TASKS(rcu_tasks, rcu_tasks_wait_gp, call_rcu_tasks, "RCU Tasks");
5873b8a9
PM
493
494/**
495 * call_rcu_tasks() - Queue an RCU for invocation task-based grace period
496 * @rhp: structure to be used for queueing the RCU updates.
497 * @func: actual callback function to be invoked after the grace period
498 *
499 * The callback function will be invoked some time after a full grace
500 * period elapses, in other words after all currently executing RCU
501 * read-side critical sections have completed. call_rcu_tasks() assumes
502 * that the read-side critical sections end at a voluntary context
503 * switch (not a preemption!), cond_resched_rcu_qs(), entry into idle,
504 * or transition to usermode execution. As such, there are no read-side
505 * primitives analogous to rcu_read_lock() and rcu_read_unlock() because
506 * this primitive is intended to determine that all tasks have passed
507 * through a safe state, not so much for data-strcuture synchronization.
508 *
509 * See the description of call_rcu() for more detailed information on
510 * memory ordering guarantees.
511 */
512void call_rcu_tasks(struct rcu_head *rhp, rcu_callback_t func)
513{
514 call_rcu_tasks_generic(rhp, func, &rcu_tasks);
515}
516EXPORT_SYMBOL_GPL(call_rcu_tasks);
517
518/**
519 * synchronize_rcu_tasks - wait until an rcu-tasks grace period has elapsed.
520 *
521 * Control will return to the caller some time after a full rcu-tasks
522 * grace period has elapsed, in other words after all currently
523 * executing rcu-tasks read-side critical sections have elapsed. These
524 * read-side critical sections are delimited by calls to schedule(),
525 * cond_resched_tasks_rcu_qs(), idle execution, userspace execution, calls
526 * to synchronize_rcu_tasks(), and (in theory, anyway) cond_resched().
527 *
528 * This is a very specialized primitive, intended only for a few uses in
529 * tracing and other situations requiring manipulation of function
530 * preambles and profiling hooks. The synchronize_rcu_tasks() function
531 * is not (yet) intended for heavy use from multiple CPUs.
532 *
533 * See the description of synchronize_rcu() for more detailed information
534 * on memory ordering guarantees.
535 */
536void synchronize_rcu_tasks(void)
537{
538 synchronize_rcu_tasks_generic(&rcu_tasks);
539}
540EXPORT_SYMBOL_GPL(synchronize_rcu_tasks);
541
542/**
543 * rcu_barrier_tasks - Wait for in-flight call_rcu_tasks() callbacks.
544 *
545 * Although the current implementation is guaranteed to wait, it is not
546 * obligated to, for example, if there are no pending callbacks.
547 */
548void rcu_barrier_tasks(void)
549{
550 /* There is only one callback queue, so this is easy. ;-) */
551 synchronize_rcu_tasks();
552}
553EXPORT_SYMBOL_GPL(rcu_barrier_tasks);
554
555static int __init rcu_spawn_tasks_kthread(void)
556{
e4fe5dd6
PM
557 rcu_tasks.pregp_func = rcu_tasks_pregp_step;
558 rcu_tasks.pertask_func = rcu_tasks_pertask;
559 rcu_tasks.postscan_func = rcu_tasks_postscan;
560 rcu_tasks.holdouts_func = check_all_holdout_tasks;
561 rcu_tasks.postgp_func = rcu_tasks_postgp;
5873b8a9
PM
562 rcu_spawn_tasks_kthread_generic(&rcu_tasks);
563 return 0;
564}
565core_initcall(rcu_spawn_tasks_kthread);
566
e21408ce
PM
567static void show_rcu_tasks_classic_gp_kthread(void)
568{
569 show_rcu_tasks_generic_gp_kthread(&rcu_tasks, "");
570}
571
572#else /* #ifdef CONFIG_TASKS_RCU */
573static void show_rcu_tasks_classic_gp_kthread(void) { }
574#endif /* #else #ifdef CONFIG_TASKS_RCU */
c84aad76
PM
575
576#ifdef CONFIG_TASKS_RUDE_RCU
577
578////////////////////////////////////////////////////////////////////////
579//
580// "Rude" variant of Tasks RCU, inspired by Steve Rostedt's trick of
581// passing an empty function to schedule_on_each_cpu(). This approach
582// provides an asynchronous call_rcu_tasks_rude() API and batching
583// of concurrent calls to the synchronous synchronize_rcu_rude() API.
584// This sends IPIs far and wide and induces otherwise unnecessary context
585// switches on all online CPUs, whether idle or not.
586
587// Empty function to allow workqueues to force a context switch.
588static void rcu_tasks_be_rude(struct work_struct *work)
589{
590}
591
592// Wait for one rude RCU-tasks grace period.
593static void rcu_tasks_rude_wait_gp(struct rcu_tasks *rtp)
594{
595 schedule_on_each_cpu(rcu_tasks_be_rude);
596}
597
598void call_rcu_tasks_rude(struct rcu_head *rhp, rcu_callback_t func);
c97d12a6
PM
599DEFINE_RCU_TASKS(rcu_tasks_rude, rcu_tasks_rude_wait_gp, call_rcu_tasks_rude,
600 "RCU Tasks Rude");
c84aad76
PM
601
602/**
603 * call_rcu_tasks_rude() - Queue a callback rude task-based grace period
604 * @rhp: structure to be used for queueing the RCU updates.
605 * @func: actual callback function to be invoked after the grace period
606 *
607 * The callback function will be invoked some time after a full grace
608 * period elapses, in other words after all currently executing RCU
609 * read-side critical sections have completed. call_rcu_tasks_rude()
610 * assumes that the read-side critical sections end at context switch,
611 * cond_resched_rcu_qs(), or transition to usermode execution. As such,
612 * there are no read-side primitives analogous to rcu_read_lock() and
613 * rcu_read_unlock() because this primitive is intended to determine
614 * that all tasks have passed through a safe state, not so much for
615 * data-strcuture synchronization.
616 *
617 * See the description of call_rcu() for more detailed information on
618 * memory ordering guarantees.
619 */
620void call_rcu_tasks_rude(struct rcu_head *rhp, rcu_callback_t func)
621{
622 call_rcu_tasks_generic(rhp, func, &rcu_tasks_rude);
623}
624EXPORT_SYMBOL_GPL(call_rcu_tasks_rude);
625
626/**
627 * synchronize_rcu_tasks_rude - wait for a rude rcu-tasks grace period
628 *
629 * Control will return to the caller some time after a rude rcu-tasks
630 * grace period has elapsed, in other words after all currently
631 * executing rcu-tasks read-side critical sections have elapsed. These
632 * read-side critical sections are delimited by calls to schedule(),
633 * cond_resched_tasks_rcu_qs(), userspace execution, and (in theory,
634 * anyway) cond_resched().
635 *
636 * This is a very specialized primitive, intended only for a few uses in
637 * tracing and other situations requiring manipulation of function preambles
638 * and profiling hooks. The synchronize_rcu_tasks_rude() function is not
639 * (yet) intended for heavy use from multiple CPUs.
640 *
641 * See the description of synchronize_rcu() for more detailed information
642 * on memory ordering guarantees.
643 */
644void synchronize_rcu_tasks_rude(void)
645{
646 synchronize_rcu_tasks_generic(&rcu_tasks_rude);
647}
648EXPORT_SYMBOL_GPL(synchronize_rcu_tasks_rude);
649
650/**
651 * rcu_barrier_tasks_rude - Wait for in-flight call_rcu_tasks_rude() callbacks.
652 *
653 * Although the current implementation is guaranteed to wait, it is not
654 * obligated to, for example, if there are no pending callbacks.
655 */
656void rcu_barrier_tasks_rude(void)
657{
658 /* There is only one callback queue, so this is easy. ;-) */
659 synchronize_rcu_tasks_rude();
660}
661EXPORT_SYMBOL_GPL(rcu_barrier_tasks_rude);
662
663static int __init rcu_spawn_tasks_rude_kthread(void)
664{
665 rcu_spawn_tasks_kthread_generic(&rcu_tasks_rude);
666 return 0;
667}
668core_initcall(rcu_spawn_tasks_rude_kthread);
669
e21408ce
PM
670static void show_rcu_tasks_rude_gp_kthread(void)
671{
672 show_rcu_tasks_generic_gp_kthread(&rcu_tasks_rude, "");
673}
674
675#else /* #ifdef CONFIG_TASKS_RUDE_RCU */
676static void show_rcu_tasks_rude_gp_kthread(void) {}
677#endif /* #else #ifdef CONFIG_TASKS_RUDE_RCU */
d5f177d3
PM
678
679////////////////////////////////////////////////////////////////////////
680//
681// Tracing variant of Tasks RCU. This variant is designed to be used
682// to protect tracing hooks, including those of BPF. This variant
683// therefore:
684//
685// 1. Has explicit read-side markers to allow finite grace periods
686// in the face of in-kernel loops for PREEMPT=n builds.
687//
688// 2. Protects code in the idle loop, exception entry/exit, and
689// CPU-hotplug code paths, similar to the capabilities of SRCU.
690//
691// 3. Avoids expensive read-side instruction, having overhead similar
692// to that of Preemptible RCU.
693//
694// There are of course downsides. The grace-period code can send IPIs to
695// CPUs, even when those CPUs are in the idle loop or in nohz_full userspace.
696// It is necessary to scan the full tasklist, much as for Tasks RCU. There
697// is a single callback queue guarded by a single lock, again, much as for
698// Tasks RCU. If needed, these downsides can be at least partially remedied.
699//
700// Perhaps most important, this variant of RCU does not affect the vanilla
701// flavors, rcu_preempt and rcu_sched. The fact that RCU Tasks Trace
702// readers can operate from idle, offline, and exception entry/exit in no
703// way allows rcu_preempt and rcu_sched readers to also do so.
704
705// The lockdep state must be outside of #ifdef to be useful.
706#ifdef CONFIG_DEBUG_LOCK_ALLOC
707static struct lock_class_key rcu_lock_trace_key;
708struct lockdep_map rcu_trace_lock_map =
709 STATIC_LOCKDEP_MAP_INIT("rcu_read_lock_trace", &rcu_lock_trace_key);
710EXPORT_SYMBOL_GPL(rcu_trace_lock_map);
711#endif /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
712
713#ifdef CONFIG_TASKS_TRACE_RCU
714
715atomic_t trc_n_readers_need_end; // Number of waited-for readers.
716DECLARE_WAIT_QUEUE_HEAD(trc_wait); // List of holdout tasks.
717
718// Record outstanding IPIs to each CPU. No point in sending two...
719static DEFINE_PER_CPU(bool, trc_ipi_to_cpu);
720
b0afa0f0
PM
721void call_rcu_tasks_trace(struct rcu_head *rhp, rcu_callback_t func);
722DEFINE_RCU_TASKS(rcu_tasks_trace, rcu_tasks_wait_gp, call_rcu_tasks_trace,
723 "RCU Tasks Trace");
724
d5f177d3
PM
725/* If we are the last reader, wake up the grace-period kthread. */
726void rcu_read_unlock_trace_special(struct task_struct *t)
727{
728 WRITE_ONCE(t->trc_reader_need_end, false);
729 if (atomic_dec_and_test(&trc_n_readers_need_end))
730 wake_up(&trc_wait);
731}
732EXPORT_SYMBOL_GPL(rcu_read_unlock_trace_special);
733
734/* Add a task to the holdout list, if it is not already on the list. */
735static void trc_add_holdout(struct task_struct *t, struct list_head *bhp)
736{
737 if (list_empty(&t->trc_holdout_list)) {
738 get_task_struct(t);
739 list_add(&t->trc_holdout_list, bhp);
740 }
741}
742
743/* Remove a task from the holdout list, if it is in fact present. */
744static void trc_del_holdout(struct task_struct *t)
745{
746 if (!list_empty(&t->trc_holdout_list)) {
747 list_del_init(&t->trc_holdout_list);
748 put_task_struct(t);
749 }
750}
751
752/* IPI handler to check task state. */
753static void trc_read_check_handler(void *t_in)
754{
755 struct task_struct *t = current;
756 struct task_struct *texp = t_in;
757
758 // If the task is no longer running on this CPU, leave.
759 if (unlikely(texp != t)) {
760 if (WARN_ON_ONCE(atomic_dec_and_test(&trc_n_readers_need_end)))
761 wake_up(&trc_wait);
762 goto reset_ipi; // Already on holdout list, so will check later.
763 }
764
765 // If the task is not in a read-side critical section, and
766 // if this is the last reader, awaken the grace-period kthread.
767 if (likely(!t->trc_reader_nesting)) {
768 if (WARN_ON_ONCE(atomic_dec_and_test(&trc_n_readers_need_end)))
769 wake_up(&trc_wait);
770 // Mark as checked after decrement to avoid false
771 // positives on the above WARN_ON_ONCE().
772 WRITE_ONCE(t->trc_reader_checked, true);
773 goto reset_ipi;
774 }
775 WRITE_ONCE(t->trc_reader_checked, true);
776
777 // Get here if the task is in a read-side critical section. Set
778 // its state so that it will awaken the grace-period kthread upon
779 // exit from that critical section.
780 WARN_ON_ONCE(t->trc_reader_need_end);
781 WRITE_ONCE(t->trc_reader_need_end, true);
782
783reset_ipi:
784 // Allow future IPIs to be sent on CPU and for task.
785 // Also order this IPI handler against any later manipulations of
786 // the intended task.
787 smp_store_release(&per_cpu(trc_ipi_to_cpu, smp_processor_id()), false); // ^^^
788 smp_store_release(&texp->trc_ipi_to_cpu, -1); // ^^^
789}
790
791/* Callback function for scheduler to check locked-down task. */
792static bool trc_inspect_reader(struct task_struct *t, void *arg)
793{
794 if (task_curr(t))
795 return false; // It is running, so decline to inspect it.
796
797 // Mark as checked. Because this is called from the grace-period
798 // kthread, also remove the task from the holdout list.
799 t->trc_reader_checked = true;
800 trc_del_holdout(t);
801
802 // If the task is in a read-side critical section, set up its
803 // its state so that it will awaken the grace-period kthread upon
804 // exit from that critical section.
805 if (unlikely(t->trc_reader_nesting)) {
806 atomic_inc(&trc_n_readers_need_end); // One more to wait on.
807 WARN_ON_ONCE(t->trc_reader_need_end);
808 WRITE_ONCE(t->trc_reader_need_end, true);
809 }
810 return true;
811}
812
813/* Attempt to extract the state for the specified task. */
814static void trc_wait_for_one_reader(struct task_struct *t,
815 struct list_head *bhp)
816{
817 int cpu;
818
819 // If a previous IPI is still in flight, let it complete.
820 if (smp_load_acquire(&t->trc_ipi_to_cpu) != -1) // Order IPI
821 return;
822
823 // The current task had better be in a quiescent state.
824 if (t == current) {
825 t->trc_reader_checked = true;
826 trc_del_holdout(t);
827 WARN_ON_ONCE(t->trc_reader_nesting);
828 return;
829 }
830
831 // Attempt to nail down the task for inspection.
832 get_task_struct(t);
833 if (try_invoke_on_locked_down_task(t, trc_inspect_reader, NULL)) {
834 put_task_struct(t);
835 return;
836 }
837 put_task_struct(t);
838
839 // If currently running, send an IPI, either way, add to list.
840 trc_add_holdout(t, bhp);
841 if (task_curr(t) && time_after(jiffies, rcu_tasks_trace.gp_start + rcu_task_ipi_delay)) {
842 // The task is currently running, so try IPIing it.
843 cpu = task_cpu(t);
844
845 // If there is already an IPI outstanding, let it happen.
846 if (per_cpu(trc_ipi_to_cpu, cpu) || t->trc_ipi_to_cpu >= 0)
847 return;
848
849 atomic_inc(&trc_n_readers_need_end);
850 per_cpu(trc_ipi_to_cpu, cpu) = true;
851 t->trc_ipi_to_cpu = cpu;
852 if (smp_call_function_single(cpu,
853 trc_read_check_handler, t, 0)) {
854 // Just in case there is some other reason for
855 // failure than the target CPU being offline.
856 per_cpu(trc_ipi_to_cpu, cpu) = false;
857 t->trc_ipi_to_cpu = cpu;
858 if (atomic_dec_and_test(&trc_n_readers_need_end)) {
859 WARN_ON_ONCE(1);
860 wake_up(&trc_wait);
861 }
862 }
863 }
864}
865
866/* Initialize for a new RCU-tasks-trace grace period. */
867static void rcu_tasks_trace_pregp_step(void)
868{
869 int cpu;
870
871 // Wait for CPU-hotplug paths to complete.
872 cpus_read_lock();
873 cpus_read_unlock();
874
875 // Allow for fast-acting IPIs.
876 atomic_set(&trc_n_readers_need_end, 1);
877
878 // There shouldn't be any old IPIs, but...
879 for_each_possible_cpu(cpu)
880 WARN_ON_ONCE(per_cpu(trc_ipi_to_cpu, cpu));
881}
882
883/* Do first-round processing for the specified task. */
884static void rcu_tasks_trace_pertask(struct task_struct *t,
885 struct list_head *hop)
886{
887 WRITE_ONCE(t->trc_reader_need_end, false);
43766c3e 888 WRITE_ONCE(t->trc_reader_checked, false);
d5f177d3
PM
889 t->trc_ipi_to_cpu = -1;
890 trc_wait_for_one_reader(t, hop);
891}
892
893/* Do intermediate processing between task and holdout scans. */
894static void rcu_tasks_trace_postscan(void)
895{
896 // Wait for late-stage exiting tasks to finish exiting.
897 // These might have passed the call to exit_tasks_rcu_finish().
898 synchronize_rcu();
899 // Any tasks that exit after this point will set ->trc_reader_checked.
900}
901
4593e772
PM
902/* Show the state of a task stalling the current RCU tasks trace GP. */
903static void show_stalled_task_trace(struct task_struct *t, bool *firstreport)
904{
905 int cpu;
906
907 if (*firstreport) {
908 pr_err("INFO: rcu_tasks_trace detected stalls on tasks:\n");
909 *firstreport = false;
910 }
911 // FIXME: This should attempt to use try_invoke_on_nonrunning_task().
912 cpu = task_cpu(t);
913 pr_alert("P%d: %c%c%c nesting: %d%c cpu: %d\n",
914 t->pid,
915 ".I"[READ_ONCE(t->trc_ipi_to_cpu) > 0],
916 ".i"[is_idle_task(t)],
917 ".N"[cpu > 0 && tick_nohz_full_cpu(cpu)],
918 t->trc_reader_nesting,
919 " N"[!!t->trc_reader_need_end],
920 cpu);
921 sched_show_task(t);
922}
923
924/* List stalled IPIs for RCU tasks trace. */
925static void show_stalled_ipi_trace(void)
926{
927 int cpu;
928
929 for_each_possible_cpu(cpu)
930 if (per_cpu(trc_ipi_to_cpu, cpu))
931 pr_alert("\tIPI outstanding to CPU %d\n", cpu);
932}
933
d5f177d3
PM
934/* Do one scan of the holdout list. */
935static void check_all_holdout_tasks_trace(struct list_head *hop,
4593e772 936 bool needreport, bool *firstreport)
d5f177d3
PM
937{
938 struct task_struct *g, *t;
939
940 list_for_each_entry_safe(t, g, hop, trc_holdout_list) {
941 // If safe and needed, try to check the current task.
942 if (READ_ONCE(t->trc_ipi_to_cpu) == -1 &&
943 !READ_ONCE(t->trc_reader_checked))
944 trc_wait_for_one_reader(t, hop);
945
946 // If check succeeded, remove this task from the list.
947 if (READ_ONCE(t->trc_reader_checked))
948 trc_del_holdout(t);
4593e772
PM
949 else if (needreport)
950 show_stalled_task_trace(t, firstreport);
951 }
952 if (needreport) {
953 if (firstreport)
954 pr_err("INFO: rcu_tasks_trace detected stalls? (Late IPI?)\n");
955 show_stalled_ipi_trace();
d5f177d3
PM
956 }
957}
958
959/* Wait for grace period to complete and provide ordering. */
af051ca4 960static void rcu_tasks_trace_postgp(struct rcu_tasks *rtp)
d5f177d3 961{
4593e772
PM
962 bool firstreport;
963 struct task_struct *g, *t;
964 LIST_HEAD(holdouts);
965 long ret;
966
d5f177d3
PM
967 // Remove the safety count.
968 smp_mb__before_atomic(); // Order vs. earlier atomics
969 atomic_dec(&trc_n_readers_need_end);
970 smp_mb__after_atomic(); // Order vs. later atomics
971
972 // Wait for readers.
af051ca4 973 set_tasks_gp_state(rtp, RTGS_WAIT_READERS);
4593e772
PM
974 for (;;) {
975 ret = wait_event_idle_exclusive_timeout(
976 trc_wait,
977 atomic_read(&trc_n_readers_need_end) == 0,
978 READ_ONCE(rcu_task_stall_timeout));
979 if (ret)
980 break; // Count reached zero.
af051ca4 981 // Stall warning time, so make a list of the offenders.
4593e772
PM
982 for_each_process_thread(g, t)
983 if (READ_ONCE(t->trc_reader_need_end))
984 trc_add_holdout(t, &holdouts);
985 firstreport = true;
986 list_for_each_entry_safe(t, g, &holdouts, trc_holdout_list)
987 if (READ_ONCE(t->trc_reader_need_end)) {
988 show_stalled_task_trace(t, &firstreport);
989 trc_del_holdout(t);
990 }
991 if (firstreport)
992 pr_err("INFO: rcu_tasks_trace detected stalls? (Counter/taskslist mismatch?)\n");
993 show_stalled_ipi_trace();
994 pr_err("\t%d holdouts\n", atomic_read(&trc_n_readers_need_end));
995 }
d5f177d3 996 smp_mb(); // Caller's code must be ordered after wakeup.
43766c3e 997 // Pairs with pretty much every ordering primitive.
d5f177d3
PM
998}
999
1000/* Report any needed quiescent state for this exiting task. */
1001void exit_tasks_rcu_finish_trace(struct task_struct *t)
1002{
1003 WRITE_ONCE(t->trc_reader_checked, true);
1004 WARN_ON_ONCE(t->trc_reader_nesting);
1005 WRITE_ONCE(t->trc_reader_nesting, 0);
1006 if (WARN_ON_ONCE(READ_ONCE(t->trc_reader_need_end)))
1007 rcu_read_unlock_trace_special(t);
1008}
1009
d5f177d3
PM
1010/**
1011 * call_rcu_tasks_trace() - Queue a callback trace task-based grace period
1012 * @rhp: structure to be used for queueing the RCU updates.
1013 * @func: actual callback function to be invoked after the grace period
1014 *
1015 * The callback function will be invoked some time after a full grace
1016 * period elapses, in other words after all currently executing RCU
1017 * read-side critical sections have completed. call_rcu_tasks_trace()
1018 * assumes that the read-side critical sections end at context switch,
1019 * cond_resched_rcu_qs(), or transition to usermode execution. As such,
1020 * there are no read-side primitives analogous to rcu_read_lock() and
1021 * rcu_read_unlock() because this primitive is intended to determine
1022 * that all tasks have passed through a safe state, not so much for
1023 * data-strcuture synchronization.
1024 *
1025 * See the description of call_rcu() for more detailed information on
1026 * memory ordering guarantees.
1027 */
1028void call_rcu_tasks_trace(struct rcu_head *rhp, rcu_callback_t func)
1029{
1030 call_rcu_tasks_generic(rhp, func, &rcu_tasks_trace);
1031}
1032EXPORT_SYMBOL_GPL(call_rcu_tasks_trace);
1033
1034/**
1035 * synchronize_rcu_tasks_trace - wait for a trace rcu-tasks grace period
1036 *
1037 * Control will return to the caller some time after a trace rcu-tasks
1038 * grace period has elapsed, in other words after all currently
1039 * executing rcu-tasks read-side critical sections have elapsed. These
1040 * read-side critical sections are delimited by calls to schedule(),
1041 * cond_resched_tasks_rcu_qs(), userspace execution, and (in theory,
1042 * anyway) cond_resched().
1043 *
1044 * This is a very specialized primitive, intended only for a few uses in
1045 * tracing and other situations requiring manipulation of function preambles
1046 * and profiling hooks. The synchronize_rcu_tasks_trace() function is not
1047 * (yet) intended for heavy use from multiple CPUs.
1048 *
1049 * See the description of synchronize_rcu() for more detailed information
1050 * on memory ordering guarantees.
1051 */
1052void synchronize_rcu_tasks_trace(void)
1053{
1054 RCU_LOCKDEP_WARN(lock_is_held(&rcu_trace_lock_map), "Illegal synchronize_rcu_tasks_trace() in RCU Tasks Trace read-side critical section");
1055 synchronize_rcu_tasks_generic(&rcu_tasks_trace);
1056}
1057EXPORT_SYMBOL_GPL(synchronize_rcu_tasks_trace);
1058
1059/**
1060 * rcu_barrier_tasks_trace - Wait for in-flight call_rcu_tasks_trace() callbacks.
1061 *
1062 * Although the current implementation is guaranteed to wait, it is not
1063 * obligated to, for example, if there are no pending callbacks.
1064 */
1065void rcu_barrier_tasks_trace(void)
1066{
1067 /* There is only one callback queue, so this is easy. ;-) */
1068 synchronize_rcu_tasks_trace();
1069}
1070EXPORT_SYMBOL_GPL(rcu_barrier_tasks_trace);
1071
1072static int __init rcu_spawn_tasks_trace_kthread(void)
1073{
1074 rcu_tasks_trace.pregp_func = rcu_tasks_trace_pregp_step;
1075 rcu_tasks_trace.pertask_func = rcu_tasks_trace_pertask;
1076 rcu_tasks_trace.postscan_func = rcu_tasks_trace_postscan;
1077 rcu_tasks_trace.holdouts_func = check_all_holdout_tasks_trace;
1078 rcu_tasks_trace.postgp_func = rcu_tasks_trace_postgp;
1079 rcu_spawn_tasks_kthread_generic(&rcu_tasks_trace);
1080 return 0;
1081}
1082core_initcall(rcu_spawn_tasks_trace_kthread);
1083
e21408ce
PM
1084static void show_rcu_tasks_trace_gp_kthread(void)
1085{
1086 char buf[32];
1087
1088 sprintf(buf, "N%d", atomic_read(&trc_n_readers_need_end));
1089 show_rcu_tasks_generic_gp_kthread(&rcu_tasks_trace, buf);
1090}
1091
d5f177d3
PM
1092#else /* #ifdef CONFIG_TASKS_TRACE_RCU */
1093void exit_tasks_rcu_finish_trace(struct task_struct *t) { }
e21408ce 1094static inline void show_rcu_tasks_trace_gp_kthread(void) {}
d5f177d3 1095#endif /* #else #ifdef CONFIG_TASKS_TRACE_RCU */
8fd8ca38 1096
e21408ce
PM
1097void show_rcu_tasks_gp_kthreads(void)
1098{
1099 show_rcu_tasks_classic_gp_kthread();
1100 show_rcu_tasks_rude_gp_kthread();
1101 show_rcu_tasks_trace_gp_kthread();
1102}
1103
8fd8ca38
PM
1104#else /* #ifdef CONFIG_TASKS_RCU_GENERIC */
1105static inline void rcu_tasks_bootup_oddness(void) {}
e21408ce 1106void show_rcu_tasks_gp_kthreads(void) {}
8fd8ca38 1107#endif /* #else #ifdef CONFIG_TASKS_RCU_GENERIC */