2 * Read-Copy Update module-based torture test facility
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 * Copyright (C) IBM Corporation, 2005, 2006
20 * Authors: Paul E. McKenney <paulmck@us.ibm.com>
21 * Josh Triplett <josh@freedesktop.org>
23 * See also: Documentation/RCU/torture.txt
25 #include <linux/types.h>
26 #include <linux/kernel.h>
27 #include <linux/init.h>
28 #include <linux/module.h>
29 #include <linux/kthread.h>
30 #include <linux/err.h>
31 #include <linux/spinlock.h>
32 #include <linux/smp.h>
33 #include <linux/rcupdate.h>
34 #include <linux/interrupt.h>
35 #include <linux/sched.h>
36 #include <linux/atomic.h>
37 #include <linux/bitops.h>
38 #include <linux/completion.h>
39 #include <linux/moduleparam.h>
40 #include <linux/percpu.h>
41 #include <linux/notifier.h>
42 #include <linux/reboot.h>
43 #include <linux/freezer.h>
44 #include <linux/cpu.h>
45 #include <linux/delay.h>
46 #include <linux/stat.h>
47 #include <linux/srcu.h>
48 #include <linux/slab.h>
49 #include <linux/trace_clock.h>
50 #include <asm/byteorder.h>
52 MODULE_LICENSE("GPL");
53 MODULE_AUTHOR("Paul E. McKenney <paulmck@us.ibm.com> and Josh Triplett <josh@freedesktop.org>");
55 static int fqs_duration;
56 module_param(fqs_duration, int, 0444);
57 MODULE_PARM_DESC(fqs_duration, "Duration of fqs bursts (us), 0 to disable");
58 static int fqs_holdoff;
59 module_param(fqs_holdoff, int, 0444);
60 MODULE_PARM_DESC(fqs_holdoff, "Holdoff time within fqs bursts (us)");
61 static int fqs_stutter = 3;
62 module_param(fqs_stutter, int, 0444);
63 MODULE_PARM_DESC(fqs_stutter, "Wait time between fqs bursts (s)");
65 module_param(gp_exp, bool, 0444);
66 MODULE_PARM_DESC(gp_exp, "Use expedited GP wait primitives");
67 static bool gp_normal;
68 module_param(gp_normal, bool, 0444);
69 MODULE_PARM_DESC(gp_normal, "Use normal (non-expedited) GP wait primitives");
70 static int irqreader = 1;
71 module_param(irqreader, int, 0444);
72 MODULE_PARM_DESC(irqreader, "Allow RCU readers from irq handlers");
73 static int n_barrier_cbs;
74 module_param(n_barrier_cbs, int, 0444);
75 MODULE_PARM_DESC(n_barrier_cbs, "# of callbacks/kthreads for barrier testing");
76 static int nfakewriters = 4;
77 module_param(nfakewriters, int, 0444);
78 MODULE_PARM_DESC(nfakewriters, "Number of RCU fake writer threads");
79 static int nreaders = -1;
80 module_param(nreaders, int, 0444);
81 MODULE_PARM_DESC(nreaders, "Number of RCU reader threads");
82 static int object_debug;
83 module_param(object_debug, int, 0444);
84 MODULE_PARM_DESC(object_debug, "Enable debug-object double call_rcu() testing");
85 static int onoff_holdoff;
86 module_param(onoff_holdoff, int, 0444);
87 MODULE_PARM_DESC(onoff_holdoff, "Time after boot before CPU hotplugs (s)");
88 static int onoff_interval;
89 module_param(onoff_interval, int, 0444);
90 MODULE_PARM_DESC(onoff_interval, "Time between CPU hotplugs (s), 0=disable");
91 static int shuffle_interval = 3;
92 module_param(shuffle_interval, int, 0444);
93 MODULE_PARM_DESC(shuffle_interval, "Number of seconds between shuffles");
94 static int shutdown_secs;
95 module_param(shutdown_secs, int, 0444);
96 MODULE_PARM_DESC(shutdown_secs, "Shutdown time (s), <= zero to disable.");
98 module_param(stall_cpu, int, 0444);
99 MODULE_PARM_DESC(stall_cpu, "Stall duration (s), zero to disable.");
100 static int stall_cpu_holdoff = 10;
101 module_param(stall_cpu_holdoff, int, 0444);
102 MODULE_PARM_DESC(stall_cpu_holdoff, "Time to wait before starting stall (s).");
103 static int stat_interval = 60;
104 module_param(stat_interval, int, 0644);
105 MODULE_PARM_DESC(stat_interval, "Number of seconds between stats printk()s");
106 static int stutter = 5;
107 module_param(stutter, int, 0444);
108 MODULE_PARM_DESC(stutter, "Number of seconds to run/halt test");
109 static int test_boost = 1;
110 module_param(test_boost, int, 0444);
111 MODULE_PARM_DESC(test_boost, "Test RCU prio boost: 0=no, 1=maybe, 2=yes.");
112 static int test_boost_duration = 4;
113 module_param(test_boost_duration, int, 0444);
114 MODULE_PARM_DESC(test_boost_duration, "Duration of each boost test, seconds.");
115 static int test_boost_interval = 7;
116 module_param(test_boost_interval, int, 0444);
117 MODULE_PARM_DESC(test_boost_interval, "Interval between boost tests, seconds.");
118 static bool test_no_idle_hz = true;
119 module_param(test_no_idle_hz, bool, 0444);
120 MODULE_PARM_DESC(test_no_idle_hz, "Test support for tickless idle CPUs");
121 static char *torture_type = "rcu";
122 module_param(torture_type, charp, 0444);
123 MODULE_PARM_DESC(torture_type, "Type of RCU to torture (rcu, rcu_bh, ...)");
125 module_param(verbose, bool, 0444);
126 MODULE_PARM_DESC(verbose, "Enable verbose debugging printk()s");
128 #define TORTURE_FLAG "-torture:"
129 #define PRINTK_STRING(s) \
130 do { pr_alert("%s" TORTURE_FLAG s "\n", torture_type); } while (0)
131 #define VERBOSE_PRINTK_STRING(s) \
132 do { if (verbose) pr_alert("%s" TORTURE_FLAG s "\n", torture_type); } while (0)
133 #define VERBOSE_PRINTK_ERRSTRING(s) \
134 do { if (verbose) pr_alert("%s" TORTURE_FLAG "!!! " s "\n", torture_type); } while (0)
136 static char printk_buf[4096];
138 static int nrealreaders;
139 static struct task_struct *writer_task;
140 static struct task_struct **fakewriter_tasks;
141 static struct task_struct **reader_tasks;
142 static struct task_struct *stats_task;
143 static struct task_struct *shuffler_task;
144 static struct task_struct *stutter_task;
145 static struct task_struct *fqs_task;
146 static struct task_struct *boost_tasks[NR_CPUS];
147 static struct task_struct *shutdown_task;
148 #ifdef CONFIG_HOTPLUG_CPU
149 static struct task_struct *onoff_task;
150 #endif /* #ifdef CONFIG_HOTPLUG_CPU */
151 static struct task_struct *stall_task;
152 static struct task_struct **barrier_cbs_tasks;
153 static struct task_struct *barrier_task;
155 #define RCU_TORTURE_PIPE_LEN 10
158 struct rcu_head rtort_rcu;
159 int rtort_pipe_count;
160 struct list_head rtort_free;
164 static LIST_HEAD(rcu_torture_freelist);
165 static struct rcu_torture __rcu *rcu_torture_current;
166 static unsigned long rcu_torture_current_version;
167 static struct rcu_torture rcu_tortures[10 * RCU_TORTURE_PIPE_LEN];
168 static DEFINE_SPINLOCK(rcu_torture_lock);
169 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
171 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
173 static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
174 static atomic_t n_rcu_torture_alloc;
175 static atomic_t n_rcu_torture_alloc_fail;
176 static atomic_t n_rcu_torture_free;
177 static atomic_t n_rcu_torture_mberror;
178 static atomic_t n_rcu_torture_error;
179 static long n_rcu_torture_barrier_error;
180 static long n_rcu_torture_boost_ktrerror;
181 static long n_rcu_torture_boost_rterror;
182 static long n_rcu_torture_boost_failure;
183 static long n_rcu_torture_boosts;
184 static long n_rcu_torture_timers;
185 static long n_offline_attempts;
186 static long n_offline_successes;
187 static unsigned long sum_offline;
188 static int min_offline = -1;
189 static int max_offline;
190 static long n_online_attempts;
191 static long n_online_successes;
192 static unsigned long sum_online;
193 static int min_online = -1;
194 static int max_online;
195 static long n_barrier_attempts;
196 static long n_barrier_successes;
197 static struct list_head rcu_torture_removed;
198 static cpumask_var_t shuffle_tmp_mask;
200 static int stutter_pause_test;
202 #if defined(MODULE) || defined(CONFIG_RCU_TORTURE_TEST_RUNNABLE)
203 #define RCUTORTURE_RUNNABLE_INIT 1
205 #define RCUTORTURE_RUNNABLE_INIT 0
207 int rcutorture_runnable = RCUTORTURE_RUNNABLE_INIT;
208 module_param(rcutorture_runnable, int, 0444);
209 MODULE_PARM_DESC(rcutorture_runnable, "Start rcutorture at boot");
211 #if defined(CONFIG_RCU_BOOST) && !defined(CONFIG_HOTPLUG_CPU)
212 #define rcu_can_boost() 1
213 #else /* #if defined(CONFIG_RCU_BOOST) && !defined(CONFIG_HOTPLUG_CPU) */
214 #define rcu_can_boost() 0
215 #endif /* #else #if defined(CONFIG_RCU_BOOST) && !defined(CONFIG_HOTPLUG_CPU) */
217 #ifdef CONFIG_RCU_TRACE
218 static u64 notrace rcu_trace_clock_local(void)
220 u64 ts = trace_clock_local();
221 unsigned long __maybe_unused ts_rem = do_div(ts, NSEC_PER_USEC);
224 #else /* #ifdef CONFIG_RCU_TRACE */
225 static u64 notrace rcu_trace_clock_local(void)
229 #endif /* #else #ifdef CONFIG_RCU_TRACE */
231 static unsigned long shutdown_time; /* jiffies to system shutdown. */
232 static unsigned long boost_starttime; /* jiffies of next boost test start. */
233 DEFINE_MUTEX(boost_mutex); /* protect setting boost_starttime */
234 /* and boost task create/destroy. */
235 static atomic_t barrier_cbs_count; /* Barrier callbacks registered. */
236 static bool barrier_phase; /* Test phase. */
237 static atomic_t barrier_cbs_invoked; /* Barrier callbacks invoked. */
238 static wait_queue_head_t *barrier_cbs_wq; /* Coordinate barrier testing. */
239 static DECLARE_WAIT_QUEUE_HEAD(barrier_wq);
241 /* Mediate rmmod and system shutdown. Concurrent rmmod & shutdown illegal! */
243 #define FULLSTOP_DONTSTOP 0 /* Normal operation. */
244 #define FULLSTOP_SHUTDOWN 1 /* System shutdown with rcutorture running. */
245 #define FULLSTOP_RMMOD 2 /* Normal rmmod of rcutorture. */
246 static int fullstop = FULLSTOP_RMMOD;
248 * Protect fullstop transitions and spawning of kthreads.
250 static DEFINE_MUTEX(fullstop_mutex);
252 /* Forward reference. */
253 static void rcu_torture_cleanup(void);
256 * Detect and respond to a system shutdown.
259 rcutorture_shutdown_notify(struct notifier_block *unused1,
260 unsigned long unused2, void *unused3)
262 mutex_lock(&fullstop_mutex);
263 if (fullstop == FULLSTOP_DONTSTOP)
264 fullstop = FULLSTOP_SHUTDOWN;
266 pr_warn(/* but going down anyway, so... */
267 "Concurrent 'rmmod rcutorture' and shutdown illegal!\n");
268 mutex_unlock(&fullstop_mutex);
273 * Absorb kthreads into a kernel function that won't return, so that
274 * they won't ever access module text or data again.
276 static void rcutorture_shutdown_absorb(const char *title)
278 if (ACCESS_ONCE(fullstop) == FULLSTOP_SHUTDOWN) {
280 "rcutorture thread %s parking due to system shutdown\n",
282 schedule_timeout_uninterruptible(MAX_SCHEDULE_TIMEOUT);
287 * Allocate an element from the rcu_tortures pool.
289 static struct rcu_torture *
290 rcu_torture_alloc(void)
294 spin_lock_bh(&rcu_torture_lock);
295 if (list_empty(&rcu_torture_freelist)) {
296 atomic_inc(&n_rcu_torture_alloc_fail);
297 spin_unlock_bh(&rcu_torture_lock);
300 atomic_inc(&n_rcu_torture_alloc);
301 p = rcu_torture_freelist.next;
303 spin_unlock_bh(&rcu_torture_lock);
304 return container_of(p, struct rcu_torture, rtort_free);
308 * Free an element to the rcu_tortures pool.
311 rcu_torture_free(struct rcu_torture *p)
313 atomic_inc(&n_rcu_torture_free);
314 spin_lock_bh(&rcu_torture_lock);
315 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
316 spin_unlock_bh(&rcu_torture_lock);
319 struct rcu_random_state {
320 unsigned long rrs_state;
324 #define RCU_RANDOM_MULT 39916801 /* prime */
325 #define RCU_RANDOM_ADD 479001701 /* prime */
326 #define RCU_RANDOM_REFRESH 10000
328 #define DEFINE_RCU_RANDOM(name) struct rcu_random_state name = { 0, 0 }
331 * Crude but fast random-number generator. Uses a linear congruential
332 * generator, with occasional help from cpu_clock().
335 rcu_random(struct rcu_random_state *rrsp)
337 if (--rrsp->rrs_count < 0) {
338 rrsp->rrs_state += (unsigned long)local_clock();
339 rrsp->rrs_count = RCU_RANDOM_REFRESH;
341 rrsp->rrs_state = rrsp->rrs_state * RCU_RANDOM_MULT + RCU_RANDOM_ADD;
342 return swahw32(rrsp->rrs_state);
346 rcu_stutter_wait(const char *title)
348 while (stutter_pause_test || !rcutorture_runnable) {
349 if (rcutorture_runnable)
350 schedule_timeout_interruptible(1);
352 schedule_timeout_interruptible(round_jiffies_relative(HZ));
353 rcutorture_shutdown_absorb(title);
358 * Operations vector for selecting different types of tests.
361 struct rcu_torture_ops {
363 int (*readlock)(void);
364 void (*read_delay)(struct rcu_random_state *rrsp);
365 void (*readunlock)(int idx);
366 int (*completed)(void);
367 void (*deferred_free)(struct rcu_torture *p);
369 void (*exp_sync)(void);
370 void (*call)(struct rcu_head *head, void (*func)(struct rcu_head *rcu));
371 void (*cb_barrier)(void);
373 int (*stats)(char *page);
379 static struct rcu_torture_ops *cur_ops;
382 * Definitions for rcu torture testing.
385 static int rcu_torture_read_lock(void) __acquires(RCU)
391 static void rcu_read_delay(struct rcu_random_state *rrsp)
393 const unsigned long shortdelay_us = 200;
394 const unsigned long longdelay_ms = 50;
396 /* We want a short delay sometimes to make a reader delay the grace
397 * period, and we want a long delay occasionally to trigger
398 * force_quiescent_state. */
400 if (!(rcu_random(rrsp) % (nrealreaders * 2000 * longdelay_ms)))
401 mdelay(longdelay_ms);
402 if (!(rcu_random(rrsp) % (nrealreaders * 2 * shortdelay_us)))
403 udelay(shortdelay_us);
404 #ifdef CONFIG_PREEMPT
405 if (!preempt_count() && !(rcu_random(rrsp) % (nrealreaders * 20000)))
406 preempt_schedule(); /* No QS if preempt_disable() in effect */
410 static void rcu_torture_read_unlock(int idx) __releases(RCU)
415 static int rcu_torture_completed(void)
417 return rcu_batches_completed();
421 rcu_torture_cb(struct rcu_head *p)
424 struct rcu_torture *rp = container_of(p, struct rcu_torture, rtort_rcu);
426 if (fullstop != FULLSTOP_DONTSTOP) {
427 /* Test is ending, just drop callbacks on the floor. */
428 /* The next initialization will pick up the pieces. */
431 i = rp->rtort_pipe_count;
432 if (i > RCU_TORTURE_PIPE_LEN)
433 i = RCU_TORTURE_PIPE_LEN;
434 atomic_inc(&rcu_torture_wcount[i]);
435 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
436 rp->rtort_mbtest = 0;
437 rcu_torture_free(rp);
439 cur_ops->deferred_free(rp);
443 static int rcu_no_completed(void)
448 static void rcu_torture_deferred_free(struct rcu_torture *p)
450 call_rcu(&p->rtort_rcu, rcu_torture_cb);
453 static void rcu_sync_torture_init(void)
455 INIT_LIST_HEAD(&rcu_torture_removed);
458 static struct rcu_torture_ops rcu_ops = {
459 .init = rcu_sync_torture_init,
460 .readlock = rcu_torture_read_lock,
461 .read_delay = rcu_read_delay,
462 .readunlock = rcu_torture_read_unlock,
463 .completed = rcu_torture_completed,
464 .deferred_free = rcu_torture_deferred_free,
465 .sync = synchronize_rcu,
466 .exp_sync = synchronize_rcu_expedited,
468 .cb_barrier = rcu_barrier,
469 .fqs = rcu_force_quiescent_state,
472 .can_boost = rcu_can_boost(),
477 * Definitions for rcu_bh torture testing.
480 static int rcu_bh_torture_read_lock(void) __acquires(RCU_BH)
486 static void rcu_bh_torture_read_unlock(int idx) __releases(RCU_BH)
488 rcu_read_unlock_bh();
491 static int rcu_bh_torture_completed(void)
493 return rcu_batches_completed_bh();
496 static void rcu_bh_torture_deferred_free(struct rcu_torture *p)
498 call_rcu_bh(&p->rtort_rcu, rcu_torture_cb);
501 static struct rcu_torture_ops rcu_bh_ops = {
502 .init = rcu_sync_torture_init,
503 .readlock = rcu_bh_torture_read_lock,
504 .read_delay = rcu_read_delay, /* just reuse rcu's version. */
505 .readunlock = rcu_bh_torture_read_unlock,
506 .completed = rcu_bh_torture_completed,
507 .deferred_free = rcu_bh_torture_deferred_free,
508 .sync = synchronize_rcu_bh,
509 .exp_sync = synchronize_rcu_bh_expedited,
511 .cb_barrier = rcu_barrier_bh,
512 .fqs = rcu_bh_force_quiescent_state,
519 * Definitions for srcu torture testing.
522 DEFINE_STATIC_SRCU(srcu_ctl);
524 static int srcu_torture_read_lock(void) __acquires(&srcu_ctl)
526 return srcu_read_lock(&srcu_ctl);
529 static void srcu_read_delay(struct rcu_random_state *rrsp)
532 const long uspertick = 1000000 / HZ;
533 const long longdelay = 10;
535 /* We want there to be long-running readers, but not all the time. */
537 delay = rcu_random(rrsp) % (nrealreaders * 2 * longdelay * uspertick);
539 schedule_timeout_interruptible(longdelay);
541 rcu_read_delay(rrsp);
544 static void srcu_torture_read_unlock(int idx) __releases(&srcu_ctl)
546 srcu_read_unlock(&srcu_ctl, idx);
549 static int srcu_torture_completed(void)
551 return srcu_batches_completed(&srcu_ctl);
554 static void srcu_torture_deferred_free(struct rcu_torture *rp)
556 call_srcu(&srcu_ctl, &rp->rtort_rcu, rcu_torture_cb);
559 static void srcu_torture_synchronize(void)
561 synchronize_srcu(&srcu_ctl);
564 static void srcu_torture_call(struct rcu_head *head,
565 void (*func)(struct rcu_head *head))
567 call_srcu(&srcu_ctl, head, func);
570 static void srcu_torture_barrier(void)
572 srcu_barrier(&srcu_ctl);
575 static int srcu_torture_stats(char *page)
579 int idx = srcu_ctl.completed & 0x1;
581 cnt += sprintf(&page[cnt], "%s%s per-CPU(idx=%d):",
582 torture_type, TORTURE_FLAG, idx);
583 for_each_possible_cpu(cpu) {
584 cnt += sprintf(&page[cnt], " %d(%lu,%lu)", cpu,
585 per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[!idx],
586 per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[idx]);
588 cnt += sprintf(&page[cnt], "\n");
592 static void srcu_torture_synchronize_expedited(void)
594 synchronize_srcu_expedited(&srcu_ctl);
597 static struct rcu_torture_ops srcu_ops = {
598 .init = rcu_sync_torture_init,
599 .readlock = srcu_torture_read_lock,
600 .read_delay = srcu_read_delay,
601 .readunlock = srcu_torture_read_unlock,
602 .completed = srcu_torture_completed,
603 .deferred_free = srcu_torture_deferred_free,
604 .sync = srcu_torture_synchronize,
605 .exp_sync = srcu_torture_synchronize_expedited,
606 .call = srcu_torture_call,
607 .cb_barrier = srcu_torture_barrier,
608 .stats = srcu_torture_stats,
613 * Definitions for sched torture testing.
616 static int sched_torture_read_lock(void)
622 static void sched_torture_read_unlock(int idx)
627 static void rcu_sched_torture_deferred_free(struct rcu_torture *p)
629 call_rcu_sched(&p->rtort_rcu, rcu_torture_cb);
632 static struct rcu_torture_ops sched_ops = {
633 .init = rcu_sync_torture_init,
634 .readlock = sched_torture_read_lock,
635 .read_delay = rcu_read_delay, /* just reuse rcu's version. */
636 .readunlock = sched_torture_read_unlock,
637 .completed = rcu_no_completed,
638 .deferred_free = rcu_sched_torture_deferred_free,
639 .sync = synchronize_sched,
640 .exp_sync = synchronize_sched_expedited,
641 .call = call_rcu_sched,
642 .cb_barrier = rcu_barrier_sched,
643 .fqs = rcu_sched_force_quiescent_state,
650 * RCU torture priority-boost testing. Runs one real-time thread per
651 * CPU for moderate bursts, repeatedly registering RCU callbacks and
652 * spinning waiting for them to be invoked. If a given callback takes
653 * too long to be invoked, we assume that priority inversion has occurred.
656 struct rcu_boost_inflight {
661 static void rcu_torture_boost_cb(struct rcu_head *head)
663 struct rcu_boost_inflight *rbip =
664 container_of(head, struct rcu_boost_inflight, rcu);
666 smp_mb(); /* Ensure RCU-core accesses precede clearing ->inflight */
670 static int rcu_torture_boost(void *arg)
672 unsigned long call_rcu_time;
673 unsigned long endtime;
674 unsigned long oldstarttime;
675 struct rcu_boost_inflight rbi = { .inflight = 0 };
676 struct sched_param sp;
678 VERBOSE_PRINTK_STRING("rcu_torture_boost started");
680 /* Set real-time priority. */
681 sp.sched_priority = 1;
682 if (sched_setscheduler(current, SCHED_FIFO, &sp) < 0) {
683 VERBOSE_PRINTK_STRING("rcu_torture_boost RT prio failed!");
684 n_rcu_torture_boost_rterror++;
687 init_rcu_head_on_stack(&rbi.rcu);
688 /* Each pass through the following loop does one boost-test cycle. */
690 /* Wait for the next test interval. */
691 oldstarttime = boost_starttime;
692 while (ULONG_CMP_LT(jiffies, oldstarttime)) {
693 schedule_timeout_interruptible(oldstarttime - jiffies);
694 rcu_stutter_wait("rcu_torture_boost");
695 if (kthread_should_stop() ||
696 fullstop != FULLSTOP_DONTSTOP)
700 /* Do one boost-test interval. */
701 endtime = oldstarttime + test_boost_duration * HZ;
702 call_rcu_time = jiffies;
703 while (ULONG_CMP_LT(jiffies, endtime)) {
704 /* If we don't have a callback in flight, post one. */
706 smp_mb(); /* RCU core before ->inflight = 1. */
708 call_rcu(&rbi.rcu, rcu_torture_boost_cb);
709 if (jiffies - call_rcu_time >
710 test_boost_duration * HZ - HZ / 2) {
711 VERBOSE_PRINTK_STRING("rcu_torture_boost boosting failed");
712 n_rcu_torture_boost_failure++;
714 call_rcu_time = jiffies;
717 rcu_stutter_wait("rcu_torture_boost");
718 if (kthread_should_stop() ||
719 fullstop != FULLSTOP_DONTSTOP)
724 * Set the start time of the next test interval.
725 * Yes, this is vulnerable to long delays, but such
726 * delays simply cause a false negative for the next
727 * interval. Besides, we are running at RT priority,
728 * so delays should be relatively rare.
730 while (oldstarttime == boost_starttime &&
731 !kthread_should_stop()) {
732 if (mutex_trylock(&boost_mutex)) {
733 boost_starttime = jiffies +
734 test_boost_interval * HZ;
735 n_rcu_torture_boosts++;
736 mutex_unlock(&boost_mutex);
739 schedule_timeout_uninterruptible(1);
742 /* Go do the stutter. */
743 checkwait: rcu_stutter_wait("rcu_torture_boost");
744 } while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP);
746 /* Clean up and exit. */
747 VERBOSE_PRINTK_STRING("rcu_torture_boost task stopping");
748 rcutorture_shutdown_absorb("rcu_torture_boost");
749 while (!kthread_should_stop() || rbi.inflight)
750 schedule_timeout_uninterruptible(1);
751 smp_mb(); /* order accesses to ->inflight before stack-frame death. */
752 destroy_rcu_head_on_stack(&rbi.rcu);
757 * RCU torture force-quiescent-state kthread. Repeatedly induces
758 * bursts of calls to force_quiescent_state(), increasing the probability
759 * of occurrence of some important types of race conditions.
762 rcu_torture_fqs(void *arg)
764 unsigned long fqs_resume_time;
765 int fqs_burst_remaining;
767 VERBOSE_PRINTK_STRING("rcu_torture_fqs task started");
769 fqs_resume_time = jiffies + fqs_stutter * HZ;
770 while (ULONG_CMP_LT(jiffies, fqs_resume_time) &&
771 !kthread_should_stop()) {
772 schedule_timeout_interruptible(1);
774 fqs_burst_remaining = fqs_duration;
775 while (fqs_burst_remaining > 0 &&
776 !kthread_should_stop()) {
779 fqs_burst_remaining -= fqs_holdoff;
781 rcu_stutter_wait("rcu_torture_fqs");
782 } while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP);
783 VERBOSE_PRINTK_STRING("rcu_torture_fqs task stopping");
784 rcutorture_shutdown_absorb("rcu_torture_fqs");
785 while (!kthread_should_stop())
786 schedule_timeout_uninterruptible(1);
791 * RCU torture writer kthread. Repeatedly substitutes a new structure
792 * for that pointed to by rcu_torture_current, freeing the old structure
793 * after a series of grace periods (the "pipeline").
796 rcu_torture_writer(void *arg)
800 long oldbatch = rcu_batches_completed();
801 struct rcu_torture *rp;
802 struct rcu_torture *rp1;
803 struct rcu_torture *old_rp;
804 static DEFINE_RCU_RANDOM(rand);
806 VERBOSE_PRINTK_STRING("rcu_torture_writer task started");
807 set_user_nice(current, 19);
810 schedule_timeout_uninterruptible(1);
811 rp = rcu_torture_alloc();
814 rp->rtort_pipe_count = 0;
815 udelay(rcu_random(&rand) & 0x3ff);
816 old_rp = rcu_dereference_check(rcu_torture_current,
817 current == writer_task);
818 rp->rtort_mbtest = 1;
819 rcu_assign_pointer(rcu_torture_current, rp);
820 smp_wmb(); /* Mods to old_rp must follow rcu_assign_pointer() */
822 i = old_rp->rtort_pipe_count;
823 if (i > RCU_TORTURE_PIPE_LEN)
824 i = RCU_TORTURE_PIPE_LEN;
825 atomic_inc(&rcu_torture_wcount[i]);
826 old_rp->rtort_pipe_count++;
827 if (gp_normal == gp_exp)
828 exp = !!(rcu_random(&rand) & 0x80);
832 cur_ops->deferred_free(old_rp);
835 list_add(&old_rp->rtort_free,
836 &rcu_torture_removed);
837 list_for_each_entry_safe(rp, rp1,
838 &rcu_torture_removed,
840 i = rp->rtort_pipe_count;
841 if (i > RCU_TORTURE_PIPE_LEN)
842 i = RCU_TORTURE_PIPE_LEN;
843 atomic_inc(&rcu_torture_wcount[i]);
844 if (++rp->rtort_pipe_count >=
845 RCU_TORTURE_PIPE_LEN) {
846 rp->rtort_mbtest = 0;
847 list_del(&rp->rtort_free);
848 rcu_torture_free(rp);
853 rcutorture_record_progress(++rcu_torture_current_version);
854 oldbatch = cur_ops->completed();
855 rcu_stutter_wait("rcu_torture_writer");
856 } while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP);
857 VERBOSE_PRINTK_STRING("rcu_torture_writer task stopping");
858 rcutorture_shutdown_absorb("rcu_torture_writer");
859 while (!kthread_should_stop())
860 schedule_timeout_uninterruptible(1);
865 * RCU torture fake writer kthread. Repeatedly calls sync, with a random
866 * delay between calls.
869 rcu_torture_fakewriter(void *arg)
871 DEFINE_RCU_RANDOM(rand);
873 VERBOSE_PRINTK_STRING("rcu_torture_fakewriter task started");
874 set_user_nice(current, 19);
877 schedule_timeout_uninterruptible(1 + rcu_random(&rand)%10);
878 udelay(rcu_random(&rand) & 0x3ff);
879 if (cur_ops->cb_barrier != NULL &&
880 rcu_random(&rand) % (nfakewriters * 8) == 0) {
881 cur_ops->cb_barrier();
882 } else if (gp_normal == gp_exp) {
883 if (rcu_random(&rand) & 0x80)
887 } else if (gp_normal) {
892 rcu_stutter_wait("rcu_torture_fakewriter");
893 } while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP);
895 VERBOSE_PRINTK_STRING("rcu_torture_fakewriter task stopping");
896 rcutorture_shutdown_absorb("rcu_torture_fakewriter");
897 while (!kthread_should_stop())
898 schedule_timeout_uninterruptible(1);
902 void rcutorture_trace_dump(void)
904 static atomic_t beenhere = ATOMIC_INIT(0);
906 if (atomic_read(&beenhere))
908 if (atomic_xchg(&beenhere, 1) != 0)
910 ftrace_dump(DUMP_ALL);
914 * RCU torture reader from timer handler. Dereferences rcu_torture_current,
915 * incrementing the corresponding element of the pipeline array. The
916 * counter in the element should never be greater than 1, otherwise, the
917 * RCU implementation is broken.
919 static void rcu_torture_timer(unsigned long unused)
924 static DEFINE_RCU_RANDOM(rand);
925 static DEFINE_SPINLOCK(rand_lock);
926 struct rcu_torture *p;
928 unsigned long long ts;
930 idx = cur_ops->readlock();
931 completed = cur_ops->completed();
932 ts = rcu_trace_clock_local();
933 p = rcu_dereference_check(rcu_torture_current,
934 rcu_read_lock_bh_held() ||
935 rcu_read_lock_sched_held() ||
936 srcu_read_lock_held(&srcu_ctl));
938 /* Leave because rcu_torture_writer is not yet underway */
939 cur_ops->readunlock(idx);
942 if (p->rtort_mbtest == 0)
943 atomic_inc(&n_rcu_torture_mberror);
944 spin_lock(&rand_lock);
945 cur_ops->read_delay(&rand);
946 n_rcu_torture_timers++;
947 spin_unlock(&rand_lock);
949 pipe_count = p->rtort_pipe_count;
950 if (pipe_count > RCU_TORTURE_PIPE_LEN) {
951 /* Should not happen, but... */
952 pipe_count = RCU_TORTURE_PIPE_LEN;
954 completed_end = cur_ops->completed();
955 if (pipe_count > 1) {
956 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu, ts,
957 completed, completed_end);
958 rcutorture_trace_dump();
960 __this_cpu_inc(rcu_torture_count[pipe_count]);
961 completed = completed_end - completed;
962 if (completed > RCU_TORTURE_PIPE_LEN) {
963 /* Should not happen, but... */
964 completed = RCU_TORTURE_PIPE_LEN;
966 __this_cpu_inc(rcu_torture_batch[completed]);
968 cur_ops->readunlock(idx);
972 * RCU torture reader kthread. Repeatedly dereferences rcu_torture_current,
973 * incrementing the corresponding element of the pipeline array. The
974 * counter in the element should never be greater than 1, otherwise, the
975 * RCU implementation is broken.
978 rcu_torture_reader(void *arg)
983 DEFINE_RCU_RANDOM(rand);
984 struct rcu_torture *p;
987 unsigned long long ts;
989 VERBOSE_PRINTK_STRING("rcu_torture_reader task started");
990 set_user_nice(current, 19);
991 if (irqreader && cur_ops->irq_capable)
992 setup_timer_on_stack(&t, rcu_torture_timer, 0);
995 if (irqreader && cur_ops->irq_capable) {
996 if (!timer_pending(&t))
997 mod_timer(&t, jiffies + 1);
999 idx = cur_ops->readlock();
1000 completed = cur_ops->completed();
1001 ts = rcu_trace_clock_local();
1002 p = rcu_dereference_check(rcu_torture_current,
1003 rcu_read_lock_bh_held() ||
1004 rcu_read_lock_sched_held() ||
1005 srcu_read_lock_held(&srcu_ctl));
1007 /* Wait for rcu_torture_writer to get underway */
1008 cur_ops->readunlock(idx);
1009 schedule_timeout_interruptible(HZ);
1012 if (p->rtort_mbtest == 0)
1013 atomic_inc(&n_rcu_torture_mberror);
1014 cur_ops->read_delay(&rand);
1016 pipe_count = p->rtort_pipe_count;
1017 if (pipe_count > RCU_TORTURE_PIPE_LEN) {
1018 /* Should not happen, but... */
1019 pipe_count = RCU_TORTURE_PIPE_LEN;
1021 completed_end = cur_ops->completed();
1022 if (pipe_count > 1) {
1023 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu,
1024 ts, completed, completed_end);
1025 rcutorture_trace_dump();
1027 __this_cpu_inc(rcu_torture_count[pipe_count]);
1028 completed = completed_end - completed;
1029 if (completed > RCU_TORTURE_PIPE_LEN) {
1030 /* Should not happen, but... */
1031 completed = RCU_TORTURE_PIPE_LEN;
1033 __this_cpu_inc(rcu_torture_batch[completed]);
1035 cur_ops->readunlock(idx);
1037 rcu_stutter_wait("rcu_torture_reader");
1038 } while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP);
1039 VERBOSE_PRINTK_STRING("rcu_torture_reader task stopping");
1040 rcutorture_shutdown_absorb("rcu_torture_reader");
1041 if (irqreader && cur_ops->irq_capable)
1043 while (!kthread_should_stop())
1044 schedule_timeout_uninterruptible(1);
1049 * Create an RCU-torture statistics message in the specified buffer.
1052 rcu_torture_printk(char *page)
1057 long pipesummary[RCU_TORTURE_PIPE_LEN + 1] = { 0 };
1058 long batchsummary[RCU_TORTURE_PIPE_LEN + 1] = { 0 };
1060 for_each_possible_cpu(cpu) {
1061 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
1062 pipesummary[i] += per_cpu(rcu_torture_count, cpu)[i];
1063 batchsummary[i] += per_cpu(rcu_torture_batch, cpu)[i];
1066 for (i = RCU_TORTURE_PIPE_LEN - 1; i >= 0; i--) {
1067 if (pipesummary[i] != 0)
1070 cnt += sprintf(&page[cnt], "%s%s ", torture_type, TORTURE_FLAG);
1071 cnt += sprintf(&page[cnt],
1072 "rtc: %p ver: %lu tfle: %d rta: %d rtaf: %d rtf: %d ",
1073 rcu_torture_current,
1074 rcu_torture_current_version,
1075 list_empty(&rcu_torture_freelist),
1076 atomic_read(&n_rcu_torture_alloc),
1077 atomic_read(&n_rcu_torture_alloc_fail),
1078 atomic_read(&n_rcu_torture_free));
1079 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
1080 atomic_read(&n_rcu_torture_mberror),
1081 n_rcu_torture_boost_ktrerror,
1082 n_rcu_torture_boost_rterror);
1083 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
1084 n_rcu_torture_boost_failure,
1085 n_rcu_torture_boosts,
1086 n_rcu_torture_timers);
1087 cnt += sprintf(&page[cnt],
1088 "onoff: %ld/%ld:%ld/%ld %d,%d:%d,%d %lu:%lu (HZ=%d) ",
1089 n_online_successes, n_online_attempts,
1090 n_offline_successes, n_offline_attempts,
1091 min_online, max_online,
1092 min_offline, max_offline,
1093 sum_online, sum_offline, HZ);
1094 cnt += sprintf(&page[cnt], "barrier: %ld/%ld:%ld",
1095 n_barrier_successes,
1097 n_rcu_torture_barrier_error);
1098 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
1099 if (atomic_read(&n_rcu_torture_mberror) != 0 ||
1100 n_rcu_torture_barrier_error != 0 ||
1101 n_rcu_torture_boost_ktrerror != 0 ||
1102 n_rcu_torture_boost_rterror != 0 ||
1103 n_rcu_torture_boost_failure != 0 ||
1105 cnt += sprintf(&page[cnt], "!!! ");
1106 atomic_inc(&n_rcu_torture_error);
1109 cnt += sprintf(&page[cnt], "Reader Pipe: ");
1110 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
1111 cnt += sprintf(&page[cnt], " %ld", pipesummary[i]);
1112 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
1113 cnt += sprintf(&page[cnt], "Reader Batch: ");
1114 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
1115 cnt += sprintf(&page[cnt], " %ld", batchsummary[i]);
1116 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
1117 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
1118 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
1119 cnt += sprintf(&page[cnt], " %d",
1120 atomic_read(&rcu_torture_wcount[i]));
1122 cnt += sprintf(&page[cnt], "\n");
1124 cnt += cur_ops->stats(&page[cnt]);
1129 * Print torture statistics. Caller must ensure that there is only
1130 * one call to this function at a given time!!! This is normally
1131 * accomplished by relying on the module system to only have one copy
1132 * of the module loaded, and then by giving the rcu_torture_stats
1133 * kthread full control (or the init/cleanup functions when rcu_torture_stats
1134 * thread is not running).
1137 rcu_torture_stats_print(void)
1141 cnt = rcu_torture_printk(printk_buf);
1142 pr_alert("%s", printk_buf);
1146 * Periodically prints torture statistics, if periodic statistics printing
1147 * was specified via the stat_interval module parameter.
1149 * No need to worry about fullstop here, since this one doesn't reference
1150 * volatile state or register callbacks.
1153 rcu_torture_stats(void *arg)
1155 VERBOSE_PRINTK_STRING("rcu_torture_stats task started");
1157 schedule_timeout_interruptible(stat_interval * HZ);
1158 rcu_torture_stats_print();
1159 rcutorture_shutdown_absorb("rcu_torture_stats");
1160 } while (!kthread_should_stop());
1161 VERBOSE_PRINTK_STRING("rcu_torture_stats task stopping");
1165 static int rcu_idle_cpu; /* Force all torture tasks off this CPU */
1167 /* Shuffle tasks such that we allow @rcu_idle_cpu to become idle. A special case
1168 * is when @rcu_idle_cpu = -1, when we allow the tasks to run on all CPUs.
1170 static void rcu_torture_shuffle_tasks(void)
1174 cpumask_setall(shuffle_tmp_mask);
1177 /* No point in shuffling if there is only one online CPU (ex: UP) */
1178 if (num_online_cpus() == 1) {
1183 if (rcu_idle_cpu != -1)
1184 cpumask_clear_cpu(rcu_idle_cpu, shuffle_tmp_mask);
1186 set_cpus_allowed_ptr(current, shuffle_tmp_mask);
1189 for (i = 0; i < nrealreaders; i++)
1190 if (reader_tasks[i])
1191 set_cpus_allowed_ptr(reader_tasks[i],
1194 if (fakewriter_tasks) {
1195 for (i = 0; i < nfakewriters; i++)
1196 if (fakewriter_tasks[i])
1197 set_cpus_allowed_ptr(fakewriter_tasks[i],
1201 set_cpus_allowed_ptr(writer_task, shuffle_tmp_mask);
1203 set_cpus_allowed_ptr(stats_task, shuffle_tmp_mask);
1205 set_cpus_allowed_ptr(stutter_task, shuffle_tmp_mask);
1207 set_cpus_allowed_ptr(fqs_task, shuffle_tmp_mask);
1209 set_cpus_allowed_ptr(shutdown_task, shuffle_tmp_mask);
1210 #ifdef CONFIG_HOTPLUG_CPU
1212 set_cpus_allowed_ptr(onoff_task, shuffle_tmp_mask);
1213 #endif /* #ifdef CONFIG_HOTPLUG_CPU */
1215 set_cpus_allowed_ptr(stall_task, shuffle_tmp_mask);
1216 if (barrier_cbs_tasks)
1217 for (i = 0; i < n_barrier_cbs; i++)
1218 if (barrier_cbs_tasks[i])
1219 set_cpus_allowed_ptr(barrier_cbs_tasks[i],
1222 set_cpus_allowed_ptr(barrier_task, shuffle_tmp_mask);
1224 if (rcu_idle_cpu == -1)
1225 rcu_idle_cpu = num_online_cpus() - 1;
1232 /* Shuffle tasks across CPUs, with the intent of allowing each CPU in the
1233 * system to become idle at a time and cut off its timer ticks. This is meant
1234 * to test the support for such tickless idle CPU in RCU.
1237 rcu_torture_shuffle(void *arg)
1239 VERBOSE_PRINTK_STRING("rcu_torture_shuffle task started");
1241 schedule_timeout_interruptible(shuffle_interval * HZ);
1242 rcu_torture_shuffle_tasks();
1243 rcutorture_shutdown_absorb("rcu_torture_shuffle");
1244 } while (!kthread_should_stop());
1245 VERBOSE_PRINTK_STRING("rcu_torture_shuffle task stopping");
1249 /* Cause the rcutorture test to "stutter", starting and stopping all
1250 * threads periodically.
1253 rcu_torture_stutter(void *arg)
1255 VERBOSE_PRINTK_STRING("rcu_torture_stutter task started");
1257 schedule_timeout_interruptible(stutter * HZ);
1258 stutter_pause_test = 1;
1259 if (!kthread_should_stop())
1260 schedule_timeout_interruptible(stutter * HZ);
1261 stutter_pause_test = 0;
1262 rcutorture_shutdown_absorb("rcu_torture_stutter");
1263 } while (!kthread_should_stop());
1264 VERBOSE_PRINTK_STRING("rcu_torture_stutter task stopping");
1269 rcu_torture_print_module_parms(struct rcu_torture_ops *cur_ops, const char *tag)
1271 pr_alert("%s" TORTURE_FLAG
1272 "--- %s: nreaders=%d nfakewriters=%d "
1273 "stat_interval=%d verbose=%d test_no_idle_hz=%d "
1274 "shuffle_interval=%d stutter=%d irqreader=%d "
1275 "fqs_duration=%d fqs_holdoff=%d fqs_stutter=%d "
1276 "test_boost=%d/%d test_boost_interval=%d "
1277 "test_boost_duration=%d shutdown_secs=%d "
1278 "stall_cpu=%d stall_cpu_holdoff=%d "
1280 "onoff_interval=%d onoff_holdoff=%d\n",
1281 torture_type, tag, nrealreaders, nfakewriters,
1282 stat_interval, verbose, test_no_idle_hz, shuffle_interval,
1283 stutter, irqreader, fqs_duration, fqs_holdoff, fqs_stutter,
1284 test_boost, cur_ops->can_boost,
1285 test_boost_interval, test_boost_duration, shutdown_secs,
1286 stall_cpu, stall_cpu_holdoff,
1288 onoff_interval, onoff_holdoff);
1291 static struct notifier_block rcutorture_shutdown_nb = {
1292 .notifier_call = rcutorture_shutdown_notify,
1295 static void rcutorture_booster_cleanup(int cpu)
1297 struct task_struct *t;
1299 if (boost_tasks[cpu] == NULL)
1301 mutex_lock(&boost_mutex);
1302 VERBOSE_PRINTK_STRING("Stopping rcu_torture_boost task");
1303 t = boost_tasks[cpu];
1304 boost_tasks[cpu] = NULL;
1305 mutex_unlock(&boost_mutex);
1307 /* This must be outside of the mutex, otherwise deadlock! */
1309 boost_tasks[cpu] = NULL;
1312 static int rcutorture_booster_init(int cpu)
1316 if (boost_tasks[cpu] != NULL)
1317 return 0; /* Already created, nothing more to do. */
1319 /* Don't allow time recalculation while creating a new task. */
1320 mutex_lock(&boost_mutex);
1321 VERBOSE_PRINTK_STRING("Creating rcu_torture_boost task");
1322 boost_tasks[cpu] = kthread_create_on_node(rcu_torture_boost, NULL,
1324 "rcu_torture_boost");
1325 if (IS_ERR(boost_tasks[cpu])) {
1326 retval = PTR_ERR(boost_tasks[cpu]);
1327 VERBOSE_PRINTK_STRING("rcu_torture_boost task create failed");
1328 n_rcu_torture_boost_ktrerror++;
1329 boost_tasks[cpu] = NULL;
1330 mutex_unlock(&boost_mutex);
1333 kthread_bind(boost_tasks[cpu], cpu);
1334 wake_up_process(boost_tasks[cpu]);
1335 mutex_unlock(&boost_mutex);
1340 * Cause the rcutorture test to shutdown the system after the test has
1341 * run for the time specified by the shutdown_secs module parameter.
1344 rcu_torture_shutdown(void *arg)
1347 unsigned long jiffies_snap;
1349 VERBOSE_PRINTK_STRING("rcu_torture_shutdown task started");
1350 jiffies_snap = ACCESS_ONCE(jiffies);
1351 while (ULONG_CMP_LT(jiffies_snap, shutdown_time) &&
1352 !kthread_should_stop()) {
1353 delta = shutdown_time - jiffies_snap;
1355 pr_alert("%s" TORTURE_FLAG
1356 "rcu_torture_shutdown task: %lu jiffies remaining\n",
1357 torture_type, delta);
1358 schedule_timeout_interruptible(delta);
1359 jiffies_snap = ACCESS_ONCE(jiffies);
1361 if (kthread_should_stop()) {
1362 VERBOSE_PRINTK_STRING("rcu_torture_shutdown task stopping");
1366 /* OK, shut down the system. */
1368 VERBOSE_PRINTK_STRING("rcu_torture_shutdown task shutting down system");
1369 shutdown_task = NULL; /* Avoid self-kill deadlock. */
1370 rcu_torture_cleanup(); /* Get the success/failure message. */
1371 kernel_power_off(); /* Shut down the system. */
1375 #ifdef CONFIG_HOTPLUG_CPU
1378 * Execute random CPU-hotplug operations at the interval specified
1379 * by the onoff_interval.
1382 rcu_torture_onoff(void *arg)
1385 unsigned long delta;
1387 DEFINE_RCU_RANDOM(rand);
1389 unsigned long starttime;
1391 VERBOSE_PRINTK_STRING("rcu_torture_onoff task started");
1392 for_each_online_cpu(cpu)
1394 WARN_ON(maxcpu < 0);
1395 if (onoff_holdoff > 0) {
1396 VERBOSE_PRINTK_STRING("rcu_torture_onoff begin holdoff");
1397 schedule_timeout_interruptible(onoff_holdoff * HZ);
1398 VERBOSE_PRINTK_STRING("rcu_torture_onoff end holdoff");
1400 while (!kthread_should_stop()) {
1401 cpu = (rcu_random(&rand) >> 4) % (maxcpu + 1);
1402 if (cpu_online(cpu) && cpu_is_hotpluggable(cpu)) {
1404 pr_alert("%s" TORTURE_FLAG
1405 "rcu_torture_onoff task: offlining %d\n",
1407 starttime = jiffies;
1408 n_offline_attempts++;
1409 ret = cpu_down(cpu);
1412 pr_alert("%s" TORTURE_FLAG
1413 "rcu_torture_onoff task: offline %d failed: errno %d\n",
1414 torture_type, cpu, ret);
1417 pr_alert("%s" TORTURE_FLAG
1418 "rcu_torture_onoff task: offlined %d\n",
1420 n_offline_successes++;
1421 delta = jiffies - starttime;
1422 sum_offline += delta;
1423 if (min_offline < 0) {
1424 min_offline = delta;
1425 max_offline = delta;
1427 if (min_offline > delta)
1428 min_offline = delta;
1429 if (max_offline < delta)
1430 max_offline = delta;
1432 } else if (cpu_is_hotpluggable(cpu)) {
1434 pr_alert("%s" TORTURE_FLAG
1435 "rcu_torture_onoff task: onlining %d\n",
1437 starttime = jiffies;
1438 n_online_attempts++;
1439 if (cpu_up(cpu) == 0) {
1441 pr_alert("%s" TORTURE_FLAG
1442 "rcu_torture_onoff task: onlined %d\n",
1444 n_online_successes++;
1445 delta = jiffies - starttime;
1446 sum_online += delta;
1447 if (min_online < 0) {
1451 if (min_online > delta)
1453 if (max_online < delta)
1457 schedule_timeout_interruptible(onoff_interval * HZ);
1459 VERBOSE_PRINTK_STRING("rcu_torture_onoff task stopping");
1464 rcu_torture_onoff_init(void)
1468 if (onoff_interval <= 0)
1470 onoff_task = kthread_run(rcu_torture_onoff, NULL, "rcu_torture_onoff");
1471 if (IS_ERR(onoff_task)) {
1472 ret = PTR_ERR(onoff_task);
1479 static void rcu_torture_onoff_cleanup(void)
1481 if (onoff_task == NULL)
1483 VERBOSE_PRINTK_STRING("Stopping rcu_torture_onoff task");
1484 kthread_stop(onoff_task);
1488 #else /* #ifdef CONFIG_HOTPLUG_CPU */
1491 rcu_torture_onoff_init(void)
1496 static void rcu_torture_onoff_cleanup(void)
1500 #endif /* #else #ifdef CONFIG_HOTPLUG_CPU */
1503 * CPU-stall kthread. It waits as specified by stall_cpu_holdoff, then
1504 * induces a CPU stall for the time specified by stall_cpu.
1506 static int rcu_torture_stall(void *args)
1508 unsigned long stop_at;
1510 VERBOSE_PRINTK_STRING("rcu_torture_stall task started");
1511 if (stall_cpu_holdoff > 0) {
1512 VERBOSE_PRINTK_STRING("rcu_torture_stall begin holdoff");
1513 schedule_timeout_interruptible(stall_cpu_holdoff * HZ);
1514 VERBOSE_PRINTK_STRING("rcu_torture_stall end holdoff");
1516 if (!kthread_should_stop()) {
1517 stop_at = get_seconds() + stall_cpu;
1518 /* RCU CPU stall is expected behavior in following code. */
1519 pr_alert("rcu_torture_stall start.\n");
1522 while (ULONG_CMP_LT(get_seconds(), stop_at))
1523 continue; /* Induce RCU CPU stall warning. */
1526 pr_alert("rcu_torture_stall end.\n");
1528 rcutorture_shutdown_absorb("rcu_torture_stall");
1529 while (!kthread_should_stop())
1530 schedule_timeout_interruptible(10 * HZ);
1534 /* Spawn CPU-stall kthread, if stall_cpu specified. */
1535 static int __init rcu_torture_stall_init(void)
1541 stall_task = kthread_run(rcu_torture_stall, NULL, "rcu_torture_stall");
1542 if (IS_ERR(stall_task)) {
1543 ret = PTR_ERR(stall_task);
1550 /* Clean up after the CPU-stall kthread, if one was spawned. */
1551 static void rcu_torture_stall_cleanup(void)
1553 if (stall_task == NULL)
1555 VERBOSE_PRINTK_STRING("Stopping rcu_torture_stall_task.");
1556 kthread_stop(stall_task);
1560 /* Callback function for RCU barrier testing. */
1561 void rcu_torture_barrier_cbf(struct rcu_head *rcu)
1563 atomic_inc(&barrier_cbs_invoked);
1566 /* kthread function to register callbacks used to test RCU barriers. */
1567 static int rcu_torture_barrier_cbs(void *arg)
1569 long myid = (long)arg;
1571 struct rcu_head rcu;
1573 init_rcu_head_on_stack(&rcu);
1574 VERBOSE_PRINTK_STRING("rcu_torture_barrier_cbs task started");
1575 set_user_nice(current, 19);
1577 wait_event(barrier_cbs_wq[myid],
1578 barrier_phase != lastphase ||
1579 kthread_should_stop() ||
1580 fullstop != FULLSTOP_DONTSTOP);
1581 lastphase = barrier_phase;
1582 smp_mb(); /* ensure barrier_phase load before ->call(). */
1583 if (kthread_should_stop() || fullstop != FULLSTOP_DONTSTOP)
1585 cur_ops->call(&rcu, rcu_torture_barrier_cbf);
1586 if (atomic_dec_and_test(&barrier_cbs_count))
1587 wake_up(&barrier_wq);
1588 } while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP);
1589 VERBOSE_PRINTK_STRING("rcu_torture_barrier_cbs task stopping");
1590 rcutorture_shutdown_absorb("rcu_torture_barrier_cbs");
1591 while (!kthread_should_stop())
1592 schedule_timeout_interruptible(1);
1593 cur_ops->cb_barrier();
1594 destroy_rcu_head_on_stack(&rcu);
1598 /* kthread function to drive and coordinate RCU barrier testing. */
1599 static int rcu_torture_barrier(void *arg)
1603 VERBOSE_PRINTK_STRING("rcu_torture_barrier task starting");
1605 atomic_set(&barrier_cbs_invoked, 0);
1606 atomic_set(&barrier_cbs_count, n_barrier_cbs);
1607 smp_mb(); /* Ensure barrier_phase after prior assignments. */
1608 barrier_phase = !barrier_phase;
1609 for (i = 0; i < n_barrier_cbs; i++)
1610 wake_up(&barrier_cbs_wq[i]);
1611 wait_event(barrier_wq,
1612 atomic_read(&barrier_cbs_count) == 0 ||
1613 kthread_should_stop() ||
1614 fullstop != FULLSTOP_DONTSTOP);
1615 if (kthread_should_stop() || fullstop != FULLSTOP_DONTSTOP)
1617 n_barrier_attempts++;
1618 cur_ops->cb_barrier();
1619 if (atomic_read(&barrier_cbs_invoked) != n_barrier_cbs) {
1620 n_rcu_torture_barrier_error++;
1623 n_barrier_successes++;
1624 schedule_timeout_interruptible(HZ / 10);
1625 } while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP);
1626 VERBOSE_PRINTK_STRING("rcu_torture_barrier task stopping");
1627 rcutorture_shutdown_absorb("rcu_torture_barrier");
1628 while (!kthread_should_stop())
1629 schedule_timeout_interruptible(1);
1633 /* Initialize RCU barrier testing. */
1634 static int rcu_torture_barrier_init(void)
1639 if (n_barrier_cbs == 0)
1641 if (cur_ops->call == NULL || cur_ops->cb_barrier == NULL) {
1642 pr_alert("%s" TORTURE_FLAG
1643 " Call or barrier ops missing for %s,\n",
1644 torture_type, cur_ops->name);
1645 pr_alert("%s" TORTURE_FLAG
1646 " RCU barrier testing omitted from run.\n",
1650 atomic_set(&barrier_cbs_count, 0);
1651 atomic_set(&barrier_cbs_invoked, 0);
1653 kzalloc(n_barrier_cbs * sizeof(barrier_cbs_tasks[0]),
1656 kzalloc(n_barrier_cbs * sizeof(barrier_cbs_wq[0]),
1658 if (barrier_cbs_tasks == NULL || !barrier_cbs_wq)
1660 for (i = 0; i < n_barrier_cbs; i++) {
1661 init_waitqueue_head(&barrier_cbs_wq[i]);
1662 barrier_cbs_tasks[i] = kthread_run(rcu_torture_barrier_cbs,
1664 "rcu_torture_barrier_cbs");
1665 if (IS_ERR(barrier_cbs_tasks[i])) {
1666 ret = PTR_ERR(barrier_cbs_tasks[i]);
1667 VERBOSE_PRINTK_ERRSTRING("Failed to create rcu_torture_barrier_cbs");
1668 barrier_cbs_tasks[i] = NULL;
1672 barrier_task = kthread_run(rcu_torture_barrier, NULL,
1673 "rcu_torture_barrier");
1674 if (IS_ERR(barrier_task)) {
1675 ret = PTR_ERR(barrier_task);
1676 VERBOSE_PRINTK_ERRSTRING("Failed to create rcu_torture_barrier");
1677 barrier_task = NULL;
1682 /* Clean up after RCU barrier testing. */
1683 static void rcu_torture_barrier_cleanup(void)
1687 if (barrier_task != NULL) {
1688 VERBOSE_PRINTK_STRING("Stopping rcu_torture_barrier task");
1689 kthread_stop(barrier_task);
1690 barrier_task = NULL;
1692 if (barrier_cbs_tasks != NULL) {
1693 for (i = 0; i < n_barrier_cbs; i++) {
1694 if (barrier_cbs_tasks[i] != NULL) {
1695 VERBOSE_PRINTK_STRING("Stopping rcu_torture_barrier_cbs task");
1696 kthread_stop(barrier_cbs_tasks[i]);
1697 barrier_cbs_tasks[i] = NULL;
1700 kfree(barrier_cbs_tasks);
1701 barrier_cbs_tasks = NULL;
1703 if (barrier_cbs_wq != NULL) {
1704 kfree(barrier_cbs_wq);
1705 barrier_cbs_wq = NULL;
1709 static int rcutorture_cpu_notify(struct notifier_block *self,
1710 unsigned long action, void *hcpu)
1712 long cpu = (long)hcpu;
1716 case CPU_DOWN_FAILED:
1717 (void)rcutorture_booster_init(cpu);
1719 case CPU_DOWN_PREPARE:
1720 rcutorture_booster_cleanup(cpu);
1728 static struct notifier_block rcutorture_cpu_nb = {
1729 .notifier_call = rcutorture_cpu_notify,
1733 rcu_torture_cleanup(void)
1737 mutex_lock(&fullstop_mutex);
1738 rcutorture_record_test_transition();
1739 if (fullstop == FULLSTOP_SHUTDOWN) {
1740 pr_warn(/* but going down anyway, so... */
1741 "Concurrent 'rmmod rcutorture' and shutdown illegal!\n");
1742 mutex_unlock(&fullstop_mutex);
1743 schedule_timeout_uninterruptible(10);
1744 if (cur_ops->cb_barrier != NULL)
1745 cur_ops->cb_barrier();
1748 fullstop = FULLSTOP_RMMOD;
1749 mutex_unlock(&fullstop_mutex);
1750 unregister_reboot_notifier(&rcutorture_shutdown_nb);
1751 rcu_torture_barrier_cleanup();
1752 rcu_torture_stall_cleanup();
1754 VERBOSE_PRINTK_STRING("Stopping rcu_torture_stutter task");
1755 kthread_stop(stutter_task);
1757 stutter_task = NULL;
1758 if (shuffler_task) {
1759 VERBOSE_PRINTK_STRING("Stopping rcu_torture_shuffle task");
1760 kthread_stop(shuffler_task);
1761 free_cpumask_var(shuffle_tmp_mask);
1763 shuffler_task = NULL;
1766 VERBOSE_PRINTK_STRING("Stopping rcu_torture_writer task");
1767 kthread_stop(writer_task);
1772 for (i = 0; i < nrealreaders; i++) {
1773 if (reader_tasks[i]) {
1774 VERBOSE_PRINTK_STRING(
1775 "Stopping rcu_torture_reader task");
1776 kthread_stop(reader_tasks[i]);
1778 reader_tasks[i] = NULL;
1780 kfree(reader_tasks);
1781 reader_tasks = NULL;
1783 rcu_torture_current = NULL;
1785 if (fakewriter_tasks) {
1786 for (i = 0; i < nfakewriters; i++) {
1787 if (fakewriter_tasks[i]) {
1788 VERBOSE_PRINTK_STRING(
1789 "Stopping rcu_torture_fakewriter task");
1790 kthread_stop(fakewriter_tasks[i]);
1792 fakewriter_tasks[i] = NULL;
1794 kfree(fakewriter_tasks);
1795 fakewriter_tasks = NULL;
1799 VERBOSE_PRINTK_STRING("Stopping rcu_torture_stats task");
1800 kthread_stop(stats_task);
1805 VERBOSE_PRINTK_STRING("Stopping rcu_torture_fqs task");
1806 kthread_stop(fqs_task);
1809 if ((test_boost == 1 && cur_ops->can_boost) ||
1811 unregister_cpu_notifier(&rcutorture_cpu_nb);
1812 for_each_possible_cpu(i)
1813 rcutorture_booster_cleanup(i);
1815 if (shutdown_task != NULL) {
1816 VERBOSE_PRINTK_STRING("Stopping rcu_torture_shutdown task");
1817 kthread_stop(shutdown_task);
1819 shutdown_task = NULL;
1820 rcu_torture_onoff_cleanup();
1822 /* Wait for all RCU callbacks to fire. */
1824 if (cur_ops->cb_barrier != NULL)
1825 cur_ops->cb_barrier();
1827 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
1829 if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
1830 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
1831 else if (n_online_successes != n_online_attempts ||
1832 n_offline_successes != n_offline_attempts)
1833 rcu_torture_print_module_parms(cur_ops,
1834 "End of test: RCU_HOTPLUG");
1836 rcu_torture_print_module_parms(cur_ops, "End of test: SUCCESS");
1839 #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD
1840 static void rcu_torture_leak_cb(struct rcu_head *rhp)
1844 static void rcu_torture_err_cb(struct rcu_head *rhp)
1847 * This -might- happen due to race conditions, but is unlikely.
1848 * The scenario that leads to this happening is that the
1849 * first of the pair of duplicate callbacks is queued,
1850 * someone else starts a grace period that includes that
1851 * callback, then the second of the pair must wait for the
1852 * next grace period. Unlikely, but can happen. If it
1853 * does happen, the debug-objects subsystem won't have splatted.
1855 pr_alert("rcutorture: duplicated callback was invoked.\n");
1857 #endif /* #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */
1860 * Verify that double-free causes debug-objects to complain, but only
1861 * if CONFIG_DEBUG_OBJECTS_RCU_HEAD=y. Otherwise, say that the test
1862 * cannot be carried out.
1864 static void rcu_test_debug_objects(void)
1866 #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD
1867 struct rcu_head rh1;
1868 struct rcu_head rh2;
1870 init_rcu_head_on_stack(&rh1);
1871 init_rcu_head_on_stack(&rh2);
1872 pr_alert("rcutorture: WARN: Duplicate call_rcu() test starting.\n");
1874 /* Try to queue the rh2 pair of callbacks for the same grace period. */
1875 preempt_disable(); /* Prevent preemption from interrupting test. */
1876 rcu_read_lock(); /* Make it impossible to finish a grace period. */
1877 call_rcu(&rh1, rcu_torture_leak_cb); /* Start grace period. */
1878 local_irq_disable(); /* Make it harder to start a new grace period. */
1879 call_rcu(&rh2, rcu_torture_leak_cb);
1880 call_rcu(&rh2, rcu_torture_err_cb); /* Duplicate callback. */
1885 /* Wait for them all to get done so we can safely return. */
1887 pr_alert("rcutorture: WARN: Duplicate call_rcu() test complete.\n");
1888 destroy_rcu_head_on_stack(&rh1);
1889 destroy_rcu_head_on_stack(&rh2);
1890 #else /* #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */
1891 pr_alert("rcutorture: !CONFIG_DEBUG_OBJECTS_RCU_HEAD, not testing duplicate call_rcu()\n");
1892 #endif /* #else #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */
1896 rcu_torture_init(void)
1902 static struct rcu_torture_ops *torture_ops[] = {
1903 &rcu_ops, &rcu_bh_ops, &srcu_ops, &sched_ops,
1906 mutex_lock(&fullstop_mutex);
1908 /* Process args and tell the world that the torturer is on the job. */
1909 for (i = 0; i < ARRAY_SIZE(torture_ops); i++) {
1910 cur_ops = torture_ops[i];
1911 if (strcmp(torture_type, cur_ops->name) == 0)
1914 if (i == ARRAY_SIZE(torture_ops)) {
1915 pr_alert("rcu-torture: invalid torture type: \"%s\"\n",
1917 pr_alert("rcu-torture types:");
1918 for (i = 0; i < ARRAY_SIZE(torture_ops); i++)
1919 pr_alert(" %s", torture_ops[i]->name);
1921 mutex_unlock(&fullstop_mutex);
1924 if (cur_ops->fqs == NULL && fqs_duration != 0) {
1925 pr_alert("rcu-torture: ->fqs NULL and non-zero fqs_duration, fqs disabled.\n");
1929 cur_ops->init(); /* no "goto unwind" prior to this point!!! */
1932 nrealreaders = nreaders;
1934 nrealreaders = 2 * num_online_cpus();
1935 rcu_torture_print_module_parms(cur_ops, "Start of test");
1936 fullstop = FULLSTOP_DONTSTOP;
1938 /* Set up the freelist. */
1940 INIT_LIST_HEAD(&rcu_torture_freelist);
1941 for (i = 0; i < ARRAY_SIZE(rcu_tortures); i++) {
1942 rcu_tortures[i].rtort_mbtest = 0;
1943 list_add_tail(&rcu_tortures[i].rtort_free,
1944 &rcu_torture_freelist);
1947 /* Initialize the statistics so that each run gets its own numbers. */
1949 rcu_torture_current = NULL;
1950 rcu_torture_current_version = 0;
1951 atomic_set(&n_rcu_torture_alloc, 0);
1952 atomic_set(&n_rcu_torture_alloc_fail, 0);
1953 atomic_set(&n_rcu_torture_free, 0);
1954 atomic_set(&n_rcu_torture_mberror, 0);
1955 atomic_set(&n_rcu_torture_error, 0);
1956 n_rcu_torture_barrier_error = 0;
1957 n_rcu_torture_boost_ktrerror = 0;
1958 n_rcu_torture_boost_rterror = 0;
1959 n_rcu_torture_boost_failure = 0;
1960 n_rcu_torture_boosts = 0;
1961 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
1962 atomic_set(&rcu_torture_wcount[i], 0);
1963 for_each_possible_cpu(cpu) {
1964 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
1965 per_cpu(rcu_torture_count, cpu)[i] = 0;
1966 per_cpu(rcu_torture_batch, cpu)[i] = 0;
1970 /* Start up the kthreads. */
1972 VERBOSE_PRINTK_STRING("Creating rcu_torture_writer task");
1973 writer_task = kthread_create(rcu_torture_writer, NULL,
1974 "rcu_torture_writer");
1975 if (IS_ERR(writer_task)) {
1976 firsterr = PTR_ERR(writer_task);
1977 VERBOSE_PRINTK_ERRSTRING("Failed to create writer");
1981 wake_up_process(writer_task);
1982 fakewriter_tasks = kzalloc(nfakewriters * sizeof(fakewriter_tasks[0]),
1984 if (fakewriter_tasks == NULL) {
1985 VERBOSE_PRINTK_ERRSTRING("out of memory");
1989 for (i = 0; i < nfakewriters; i++) {
1990 VERBOSE_PRINTK_STRING("Creating rcu_torture_fakewriter task");
1991 fakewriter_tasks[i] = kthread_run(rcu_torture_fakewriter, NULL,
1992 "rcu_torture_fakewriter");
1993 if (IS_ERR(fakewriter_tasks[i])) {
1994 firsterr = PTR_ERR(fakewriter_tasks[i]);
1995 VERBOSE_PRINTK_ERRSTRING("Failed to create fakewriter");
1996 fakewriter_tasks[i] = NULL;
2000 reader_tasks = kzalloc(nrealreaders * sizeof(reader_tasks[0]),
2002 if (reader_tasks == NULL) {
2003 VERBOSE_PRINTK_ERRSTRING("out of memory");
2007 for (i = 0; i < nrealreaders; i++) {
2008 VERBOSE_PRINTK_STRING("Creating rcu_torture_reader task");
2009 reader_tasks[i] = kthread_run(rcu_torture_reader, NULL,
2010 "rcu_torture_reader");
2011 if (IS_ERR(reader_tasks[i])) {
2012 firsterr = PTR_ERR(reader_tasks[i]);
2013 VERBOSE_PRINTK_ERRSTRING("Failed to create reader");
2014 reader_tasks[i] = NULL;
2018 if (stat_interval > 0) {
2019 VERBOSE_PRINTK_STRING("Creating rcu_torture_stats task");
2020 stats_task = kthread_run(rcu_torture_stats, NULL,
2021 "rcu_torture_stats");
2022 if (IS_ERR(stats_task)) {
2023 firsterr = PTR_ERR(stats_task);
2024 VERBOSE_PRINTK_ERRSTRING("Failed to create stats");
2029 if (test_no_idle_hz) {
2030 rcu_idle_cpu = num_online_cpus() - 1;
2032 if (!alloc_cpumask_var(&shuffle_tmp_mask, GFP_KERNEL)) {
2034 VERBOSE_PRINTK_ERRSTRING("Failed to alloc mask");
2038 /* Create the shuffler thread */
2039 shuffler_task = kthread_run(rcu_torture_shuffle, NULL,
2040 "rcu_torture_shuffle");
2041 if (IS_ERR(shuffler_task)) {
2042 free_cpumask_var(shuffle_tmp_mask);
2043 firsterr = PTR_ERR(shuffler_task);
2044 VERBOSE_PRINTK_ERRSTRING("Failed to create shuffler");
2045 shuffler_task = NULL;
2052 /* Create the stutter thread */
2053 stutter_task = kthread_run(rcu_torture_stutter, NULL,
2054 "rcu_torture_stutter");
2055 if (IS_ERR(stutter_task)) {
2056 firsterr = PTR_ERR(stutter_task);
2057 VERBOSE_PRINTK_ERRSTRING("Failed to create stutter");
2058 stutter_task = NULL;
2062 if (fqs_duration < 0)
2065 /* Create the stutter thread */
2066 fqs_task = kthread_run(rcu_torture_fqs, NULL,
2068 if (IS_ERR(fqs_task)) {
2069 firsterr = PTR_ERR(fqs_task);
2070 VERBOSE_PRINTK_ERRSTRING("Failed to create fqs");
2075 if (test_boost_interval < 1)
2076 test_boost_interval = 1;
2077 if (test_boost_duration < 2)
2078 test_boost_duration = 2;
2079 if ((test_boost == 1 && cur_ops->can_boost) ||
2082 boost_starttime = jiffies + test_boost_interval * HZ;
2083 register_cpu_notifier(&rcutorture_cpu_nb);
2084 for_each_possible_cpu(i) {
2085 if (cpu_is_offline(i))
2086 continue; /* Heuristic: CPU can go offline. */
2087 retval = rcutorture_booster_init(i);
2094 if (shutdown_secs > 0) {
2095 shutdown_time = jiffies + shutdown_secs * HZ;
2096 shutdown_task = kthread_create(rcu_torture_shutdown, NULL,
2097 "rcu_torture_shutdown");
2098 if (IS_ERR(shutdown_task)) {
2099 firsterr = PTR_ERR(shutdown_task);
2100 VERBOSE_PRINTK_ERRSTRING("Failed to create shutdown");
2101 shutdown_task = NULL;
2104 wake_up_process(shutdown_task);
2106 i = rcu_torture_onoff_init();
2111 register_reboot_notifier(&rcutorture_shutdown_nb);
2112 i = rcu_torture_stall_init();
2117 retval = rcu_torture_barrier_init();
2123 rcu_test_debug_objects();
2124 rcutorture_record_test_transition();
2125 mutex_unlock(&fullstop_mutex);
2129 mutex_unlock(&fullstop_mutex);
2130 rcu_torture_cleanup();
2134 module_init(rcu_torture_init);
2135 module_exit(rcu_torture_cleanup);