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 <asm/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 <asm/byteorder.h>
51 MODULE_LICENSE("GPL");
52 MODULE_AUTHOR("Paul E. McKenney <paulmck@us.ibm.com> and "
53 "Josh Triplett <josh@freedesktop.org>");
55 static int nreaders
= -1; /* # reader threads, defaults to 2*ncpus */
56 static int nfakewriters
= 4; /* # fake writer threads */
57 static int stat_interval
; /* Interval between stats, in seconds. */
58 /* Defaults to "only at end of test". */
59 static int verbose
; /* Print more debug info. */
60 static int test_no_idle_hz
; /* Test RCU's support for tickless idle CPUs. */
61 static int shuffle_interval
= 3; /* Interval between shuffles (in sec)*/
62 static int stutter
= 5; /* Start/stop testing interval (in sec) */
63 static int irqreader
= 1; /* RCU readers from irq (timers). */
64 static int fqs_duration
= 0; /* Duration of bursts (us), 0 to disable. */
65 static int fqs_holdoff
= 0; /* Hold time within burst (us). */
66 static int fqs_stutter
= 3; /* Wait time between bursts (s). */
67 static char *torture_type
= "rcu"; /* What RCU implementation to torture. */
69 module_param(nreaders
, int, 0444);
70 MODULE_PARM_DESC(nreaders
, "Number of RCU reader threads");
71 module_param(nfakewriters
, int, 0444);
72 MODULE_PARM_DESC(nfakewriters
, "Number of RCU fake writer threads");
73 module_param(stat_interval
, int, 0444);
74 MODULE_PARM_DESC(stat_interval
, "Number of seconds between stats printk()s");
75 module_param(verbose
, bool, 0444);
76 MODULE_PARM_DESC(verbose
, "Enable verbose debugging printk()s");
77 module_param(test_no_idle_hz
, bool, 0444);
78 MODULE_PARM_DESC(test_no_idle_hz
, "Test support for tickless idle CPUs");
79 module_param(shuffle_interval
, int, 0444);
80 MODULE_PARM_DESC(shuffle_interval
, "Number of seconds between shuffles");
81 module_param(stutter
, int, 0444);
82 MODULE_PARM_DESC(stutter
, "Number of seconds to run/halt test");
83 module_param(irqreader
, int, 0444);
84 MODULE_PARM_DESC(irqreader
, "Allow RCU readers from irq handlers");
85 module_param(fqs_duration
, int, 0444);
86 MODULE_PARM_DESC(fqs_duration
, "Duration of fqs bursts (us)");
87 module_param(fqs_holdoff
, int, 0444);
88 MODULE_PARM_DESC(fqs_holdoff
, "Holdoff time within fqs bursts (us)");
89 module_param(fqs_stutter
, int, 0444);
90 MODULE_PARM_DESC(fqs_stutter
, "Wait time between fqs bursts (s)");
91 module_param(torture_type
, charp
, 0444);
92 MODULE_PARM_DESC(torture_type
, "Type of RCU to torture (rcu, rcu_bh, srcu)");
94 #define TORTURE_FLAG "-torture:"
95 #define PRINTK_STRING(s) \
96 do { printk(KERN_ALERT "%s" TORTURE_FLAG s "\n", torture_type); } while (0)
97 #define VERBOSE_PRINTK_STRING(s) \
98 do { if (verbose) printk(KERN_ALERT "%s" TORTURE_FLAG s "\n", torture_type); } while (0)
99 #define VERBOSE_PRINTK_ERRSTRING(s) \
100 do { if (verbose) printk(KERN_ALERT "%s" TORTURE_FLAG "!!! " s "\n", torture_type); } while (0)
102 static char printk_buf
[4096];
104 static int nrealreaders
;
105 static struct task_struct
*writer_task
;
106 static struct task_struct
**fakewriter_tasks
;
107 static struct task_struct
**reader_tasks
;
108 static struct task_struct
*stats_task
;
109 static struct task_struct
*shuffler_task
;
110 static struct task_struct
*stutter_task
;
111 static struct task_struct
*fqs_task
;
113 #define RCU_TORTURE_PIPE_LEN 10
116 struct rcu_head rtort_rcu
;
117 int rtort_pipe_count
;
118 struct list_head rtort_free
;
122 static LIST_HEAD(rcu_torture_freelist
);
123 static struct rcu_torture
*rcu_torture_current
;
124 static long rcu_torture_current_version
;
125 static struct rcu_torture rcu_tortures
[10 * RCU_TORTURE_PIPE_LEN
];
126 static DEFINE_SPINLOCK(rcu_torture_lock
);
127 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN
+ 1], rcu_torture_count
) =
129 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN
+ 1], rcu_torture_batch
) =
131 static atomic_t rcu_torture_wcount
[RCU_TORTURE_PIPE_LEN
+ 1];
132 static atomic_t n_rcu_torture_alloc
;
133 static atomic_t n_rcu_torture_alloc_fail
;
134 static atomic_t n_rcu_torture_free
;
135 static atomic_t n_rcu_torture_mberror
;
136 static atomic_t n_rcu_torture_error
;
137 static long n_rcu_torture_timers
;
138 static struct list_head rcu_torture_removed
;
139 static cpumask_var_t shuffle_tmp_mask
;
141 static int stutter_pause_test
;
143 #if defined(MODULE) || defined(CONFIG_RCU_TORTURE_TEST_RUNNABLE)
144 #define RCUTORTURE_RUNNABLE_INIT 1
146 #define RCUTORTURE_RUNNABLE_INIT 0
148 int rcutorture_runnable
= RCUTORTURE_RUNNABLE_INIT
;
150 /* Mediate rmmod and system shutdown. Concurrent rmmod & shutdown illegal! */
152 #define FULLSTOP_DONTSTOP 0 /* Normal operation. */
153 #define FULLSTOP_SHUTDOWN 1 /* System shutdown with rcutorture running. */
154 #define FULLSTOP_RMMOD 2 /* Normal rmmod of rcutorture. */
155 static int fullstop
= FULLSTOP_RMMOD
;
156 DEFINE_MUTEX(fullstop_mutex
); /* Protect fullstop transitions and spawning */
160 * Detect and respond to a system shutdown.
163 rcutorture_shutdown_notify(struct notifier_block
*unused1
,
164 unsigned long unused2
, void *unused3
)
166 mutex_lock(&fullstop_mutex
);
167 if (fullstop
== FULLSTOP_DONTSTOP
)
168 fullstop
= FULLSTOP_SHUTDOWN
;
170 printk(KERN_WARNING
/* but going down anyway, so... */
171 "Concurrent 'rmmod rcutorture' and shutdown illegal!\n");
172 mutex_unlock(&fullstop_mutex
);
177 * Absorb kthreads into a kernel function that won't return, so that
178 * they won't ever access module text or data again.
180 static void rcutorture_shutdown_absorb(char *title
)
182 if (ACCESS_ONCE(fullstop
) == FULLSTOP_SHUTDOWN
) {
184 "rcutorture thread %s parking due to system shutdown\n",
186 schedule_timeout_uninterruptible(MAX_SCHEDULE_TIMEOUT
);
191 * Allocate an element from the rcu_tortures pool.
193 static struct rcu_torture
*
194 rcu_torture_alloc(void)
198 spin_lock_bh(&rcu_torture_lock
);
199 if (list_empty(&rcu_torture_freelist
)) {
200 atomic_inc(&n_rcu_torture_alloc_fail
);
201 spin_unlock_bh(&rcu_torture_lock
);
204 atomic_inc(&n_rcu_torture_alloc
);
205 p
= rcu_torture_freelist
.next
;
207 spin_unlock_bh(&rcu_torture_lock
);
208 return container_of(p
, struct rcu_torture
, rtort_free
);
212 * Free an element to the rcu_tortures pool.
215 rcu_torture_free(struct rcu_torture
*p
)
217 atomic_inc(&n_rcu_torture_free
);
218 spin_lock_bh(&rcu_torture_lock
);
219 list_add_tail(&p
->rtort_free
, &rcu_torture_freelist
);
220 spin_unlock_bh(&rcu_torture_lock
);
223 struct rcu_random_state
{
224 unsigned long rrs_state
;
228 #define RCU_RANDOM_MULT 39916801 /* prime */
229 #define RCU_RANDOM_ADD 479001701 /* prime */
230 #define RCU_RANDOM_REFRESH 10000
232 #define DEFINE_RCU_RANDOM(name) struct rcu_random_state name = { 0, 0 }
235 * Crude but fast random-number generator. Uses a linear congruential
236 * generator, with occasional help from cpu_clock().
239 rcu_random(struct rcu_random_state
*rrsp
)
241 if (--rrsp
->rrs_count
< 0) {
242 rrsp
->rrs_state
+= (unsigned long)local_clock();
243 rrsp
->rrs_count
= RCU_RANDOM_REFRESH
;
245 rrsp
->rrs_state
= rrsp
->rrs_state
* RCU_RANDOM_MULT
+ RCU_RANDOM_ADD
;
246 return swahw32(rrsp
->rrs_state
);
250 rcu_stutter_wait(char *title
)
252 while (stutter_pause_test
|| !rcutorture_runnable
) {
253 if (rcutorture_runnable
)
254 schedule_timeout_interruptible(1);
256 schedule_timeout_interruptible(round_jiffies_relative(HZ
));
257 rcutorture_shutdown_absorb(title
);
262 * Operations vector for selecting different types of tests.
265 struct rcu_torture_ops
{
267 void (*cleanup
)(void);
268 int (*readlock
)(void);
269 void (*read_delay
)(struct rcu_random_state
*rrsp
);
270 void (*readunlock
)(int idx
);
271 int (*completed
)(void);
272 void (*deferred_free
)(struct rcu_torture
*p
);
274 void (*cb_barrier
)(void);
276 int (*stats
)(char *page
);
281 static struct rcu_torture_ops
*cur_ops
;
284 * Definitions for rcu torture testing.
287 static int rcu_torture_read_lock(void) __acquires(RCU
)
293 static void rcu_read_delay(struct rcu_random_state
*rrsp
)
295 const unsigned long shortdelay_us
= 200;
296 const unsigned long longdelay_ms
= 50;
298 /* We want a short delay sometimes to make a reader delay the grace
299 * period, and we want a long delay occasionally to trigger
300 * force_quiescent_state. */
302 if (!(rcu_random(rrsp
) % (nrealreaders
* 2000 * longdelay_ms
)))
303 mdelay(longdelay_ms
);
304 if (!(rcu_random(rrsp
) % (nrealreaders
* 2 * shortdelay_us
)))
305 udelay(shortdelay_us
);
306 #ifdef CONFIG_PREEMPT
307 if (!preempt_count() && !(rcu_random(rrsp
) % (nrealreaders
* 20000)))
308 preempt_schedule(); /* No QS if preempt_disable() in effect */
312 static void rcu_torture_read_unlock(int idx
) __releases(RCU
)
317 static int rcu_torture_completed(void)
319 return rcu_batches_completed();
323 rcu_torture_cb(struct rcu_head
*p
)
326 struct rcu_torture
*rp
= container_of(p
, struct rcu_torture
, rtort_rcu
);
328 if (fullstop
!= FULLSTOP_DONTSTOP
) {
329 /* Test is ending, just drop callbacks on the floor. */
330 /* The next initialization will pick up the pieces. */
333 i
= rp
->rtort_pipe_count
;
334 if (i
> RCU_TORTURE_PIPE_LEN
)
335 i
= RCU_TORTURE_PIPE_LEN
;
336 atomic_inc(&rcu_torture_wcount
[i
]);
337 if (++rp
->rtort_pipe_count
>= RCU_TORTURE_PIPE_LEN
) {
338 rp
->rtort_mbtest
= 0;
339 rcu_torture_free(rp
);
341 cur_ops
->deferred_free(rp
);
344 static int rcu_no_completed(void)
349 static void rcu_torture_deferred_free(struct rcu_torture
*p
)
351 call_rcu(&p
->rtort_rcu
, rcu_torture_cb
);
354 static struct rcu_torture_ops rcu_ops
= {
357 .readlock
= rcu_torture_read_lock
,
358 .read_delay
= rcu_read_delay
,
359 .readunlock
= rcu_torture_read_unlock
,
360 .completed
= rcu_torture_completed
,
361 .deferred_free
= rcu_torture_deferred_free
,
362 .sync
= synchronize_rcu
,
363 .cb_barrier
= rcu_barrier
,
364 .fqs
= rcu_force_quiescent_state
,
370 static void rcu_sync_torture_deferred_free(struct rcu_torture
*p
)
373 struct rcu_torture
*rp
;
374 struct rcu_torture
*rp1
;
377 list_add(&p
->rtort_free
, &rcu_torture_removed
);
378 list_for_each_entry_safe(rp
, rp1
, &rcu_torture_removed
, rtort_free
) {
379 i
= rp
->rtort_pipe_count
;
380 if (i
> RCU_TORTURE_PIPE_LEN
)
381 i
= RCU_TORTURE_PIPE_LEN
;
382 atomic_inc(&rcu_torture_wcount
[i
]);
383 if (++rp
->rtort_pipe_count
>= RCU_TORTURE_PIPE_LEN
) {
384 rp
->rtort_mbtest
= 0;
385 list_del(&rp
->rtort_free
);
386 rcu_torture_free(rp
);
391 static void rcu_sync_torture_init(void)
393 INIT_LIST_HEAD(&rcu_torture_removed
);
396 static struct rcu_torture_ops rcu_sync_ops
= {
397 .init
= rcu_sync_torture_init
,
399 .readlock
= rcu_torture_read_lock
,
400 .read_delay
= rcu_read_delay
,
401 .readunlock
= rcu_torture_read_unlock
,
402 .completed
= rcu_torture_completed
,
403 .deferred_free
= rcu_sync_torture_deferred_free
,
404 .sync
= synchronize_rcu
,
406 .fqs
= rcu_force_quiescent_state
,
412 static struct rcu_torture_ops rcu_expedited_ops
= {
413 .init
= rcu_sync_torture_init
,
415 .readlock
= rcu_torture_read_lock
,
416 .read_delay
= rcu_read_delay
, /* just reuse rcu's version. */
417 .readunlock
= rcu_torture_read_unlock
,
418 .completed
= rcu_no_completed
,
419 .deferred_free
= rcu_sync_torture_deferred_free
,
420 .sync
= synchronize_rcu_expedited
,
422 .fqs
= rcu_force_quiescent_state
,
425 .name
= "rcu_expedited"
429 * Definitions for rcu_bh torture testing.
432 static int rcu_bh_torture_read_lock(void) __acquires(RCU_BH
)
438 static void rcu_bh_torture_read_unlock(int idx
) __releases(RCU_BH
)
440 rcu_read_unlock_bh();
443 static int rcu_bh_torture_completed(void)
445 return rcu_batches_completed_bh();
448 static void rcu_bh_torture_deferred_free(struct rcu_torture
*p
)
450 call_rcu_bh(&p
->rtort_rcu
, rcu_torture_cb
);
453 struct rcu_bh_torture_synchronize
{
454 struct rcu_head head
;
455 struct completion completion
;
458 static void rcu_bh_torture_wakeme_after_cb(struct rcu_head
*head
)
460 struct rcu_bh_torture_synchronize
*rcu
;
462 rcu
= container_of(head
, struct rcu_bh_torture_synchronize
, head
);
463 complete(&rcu
->completion
);
466 static void rcu_bh_torture_synchronize(void)
468 struct rcu_bh_torture_synchronize rcu
;
470 init_rcu_head_on_stack(&rcu
.head
);
471 init_completion(&rcu
.completion
);
472 call_rcu_bh(&rcu
.head
, rcu_bh_torture_wakeme_after_cb
);
473 wait_for_completion(&rcu
.completion
);
474 destroy_rcu_head_on_stack(&rcu
.head
);
477 static struct rcu_torture_ops rcu_bh_ops
= {
480 .readlock
= rcu_bh_torture_read_lock
,
481 .read_delay
= rcu_read_delay
, /* just reuse rcu's version. */
482 .readunlock
= rcu_bh_torture_read_unlock
,
483 .completed
= rcu_bh_torture_completed
,
484 .deferred_free
= rcu_bh_torture_deferred_free
,
485 .sync
= rcu_bh_torture_synchronize
,
486 .cb_barrier
= rcu_barrier_bh
,
487 .fqs
= rcu_bh_force_quiescent_state
,
493 static struct rcu_torture_ops rcu_bh_sync_ops
= {
494 .init
= rcu_sync_torture_init
,
496 .readlock
= rcu_bh_torture_read_lock
,
497 .read_delay
= rcu_read_delay
, /* just reuse rcu's version. */
498 .readunlock
= rcu_bh_torture_read_unlock
,
499 .completed
= rcu_bh_torture_completed
,
500 .deferred_free
= rcu_sync_torture_deferred_free
,
501 .sync
= rcu_bh_torture_synchronize
,
503 .fqs
= rcu_bh_force_quiescent_state
,
506 .name
= "rcu_bh_sync"
510 * Definitions for srcu torture testing.
513 static struct srcu_struct srcu_ctl
;
515 static void srcu_torture_init(void)
517 init_srcu_struct(&srcu_ctl
);
518 rcu_sync_torture_init();
521 static void srcu_torture_cleanup(void)
523 synchronize_srcu(&srcu_ctl
);
524 cleanup_srcu_struct(&srcu_ctl
);
527 static int srcu_torture_read_lock(void) __acquires(&srcu_ctl
)
529 return srcu_read_lock(&srcu_ctl
);
532 static void srcu_read_delay(struct rcu_random_state
*rrsp
)
535 const long uspertick
= 1000000 / HZ
;
536 const long longdelay
= 10;
538 /* We want there to be long-running readers, but not all the time. */
540 delay
= rcu_random(rrsp
) % (nrealreaders
* 2 * longdelay
* uspertick
);
542 schedule_timeout_interruptible(longdelay
);
544 rcu_read_delay(rrsp
);
547 static void srcu_torture_read_unlock(int idx
) __releases(&srcu_ctl
)
549 srcu_read_unlock(&srcu_ctl
, idx
);
552 static int srcu_torture_completed(void)
554 return srcu_batches_completed(&srcu_ctl
);
557 static void srcu_torture_synchronize(void)
559 synchronize_srcu(&srcu_ctl
);
562 static int srcu_torture_stats(char *page
)
566 int idx
= srcu_ctl
.completed
& 0x1;
568 cnt
+= sprintf(&page
[cnt
], "%s%s per-CPU(idx=%d):",
569 torture_type
, TORTURE_FLAG
, idx
);
570 for_each_possible_cpu(cpu
) {
571 cnt
+= sprintf(&page
[cnt
], " %d(%d,%d)", cpu
,
572 per_cpu_ptr(srcu_ctl
.per_cpu_ref
, cpu
)->c
[!idx
],
573 per_cpu_ptr(srcu_ctl
.per_cpu_ref
, cpu
)->c
[idx
]);
575 cnt
+= sprintf(&page
[cnt
], "\n");
579 static struct rcu_torture_ops srcu_ops
= {
580 .init
= srcu_torture_init
,
581 .cleanup
= srcu_torture_cleanup
,
582 .readlock
= srcu_torture_read_lock
,
583 .read_delay
= srcu_read_delay
,
584 .readunlock
= srcu_torture_read_unlock
,
585 .completed
= srcu_torture_completed
,
586 .deferred_free
= rcu_sync_torture_deferred_free
,
587 .sync
= srcu_torture_synchronize
,
589 .stats
= srcu_torture_stats
,
593 static void srcu_torture_synchronize_expedited(void)
595 synchronize_srcu_expedited(&srcu_ctl
);
598 static struct rcu_torture_ops srcu_expedited_ops
= {
599 .init
= srcu_torture_init
,
600 .cleanup
= srcu_torture_cleanup
,
601 .readlock
= srcu_torture_read_lock
,
602 .read_delay
= srcu_read_delay
,
603 .readunlock
= srcu_torture_read_unlock
,
604 .completed
= srcu_torture_completed
,
605 .deferred_free
= rcu_sync_torture_deferred_free
,
606 .sync
= srcu_torture_synchronize_expedited
,
608 .stats
= srcu_torture_stats
,
609 .name
= "srcu_expedited"
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 void sched_torture_synchronize(void)
637 static struct rcu_torture_ops sched_ops
= {
638 .init
= rcu_sync_torture_init
,
640 .readlock
= sched_torture_read_lock
,
641 .read_delay
= rcu_read_delay
, /* just reuse rcu's version. */
642 .readunlock
= sched_torture_read_unlock
,
643 .completed
= rcu_no_completed
,
644 .deferred_free
= rcu_sched_torture_deferred_free
,
645 .sync
= sched_torture_synchronize
,
646 .cb_barrier
= rcu_barrier_sched
,
647 .fqs
= rcu_sched_force_quiescent_state
,
653 static struct rcu_torture_ops sched_sync_ops
= {
654 .init
= rcu_sync_torture_init
,
656 .readlock
= sched_torture_read_lock
,
657 .read_delay
= rcu_read_delay
, /* just reuse rcu's version. */
658 .readunlock
= sched_torture_read_unlock
,
659 .completed
= rcu_no_completed
,
660 .deferred_free
= rcu_sync_torture_deferred_free
,
661 .sync
= sched_torture_synchronize
,
663 .fqs
= rcu_sched_force_quiescent_state
,
668 static struct rcu_torture_ops sched_expedited_ops
= {
669 .init
= rcu_sync_torture_init
,
671 .readlock
= sched_torture_read_lock
,
672 .read_delay
= rcu_read_delay
, /* just reuse rcu's version. */
673 .readunlock
= sched_torture_read_unlock
,
674 .completed
= rcu_no_completed
,
675 .deferred_free
= rcu_sync_torture_deferred_free
,
676 .sync
= synchronize_sched_expedited
,
678 .fqs
= rcu_sched_force_quiescent_state
,
681 .name
= "sched_expedited"
685 * RCU torture force-quiescent-state kthread. Repeatedly induces
686 * bursts of calls to force_quiescent_state(), increasing the probability
687 * of occurrence of some important types of race conditions.
690 rcu_torture_fqs(void *arg
)
692 unsigned long fqs_resume_time
;
693 int fqs_burst_remaining
;
695 VERBOSE_PRINTK_STRING("rcu_torture_fqs task started");
697 fqs_resume_time
= jiffies
+ fqs_stutter
* HZ
;
698 while (jiffies
- fqs_resume_time
> LONG_MAX
) {
699 schedule_timeout_interruptible(1);
701 fqs_burst_remaining
= fqs_duration
;
702 while (fqs_burst_remaining
> 0) {
705 fqs_burst_remaining
-= fqs_holdoff
;
707 rcu_stutter_wait("rcu_torture_fqs");
708 } while (!kthread_should_stop() && fullstop
== FULLSTOP_DONTSTOP
);
709 VERBOSE_PRINTK_STRING("rcu_torture_fqs task stopping");
710 rcutorture_shutdown_absorb("rcu_torture_fqs");
711 while (!kthread_should_stop())
712 schedule_timeout_uninterruptible(1);
717 * RCU torture writer kthread. Repeatedly substitutes a new structure
718 * for that pointed to by rcu_torture_current, freeing the old structure
719 * after a series of grace periods (the "pipeline").
722 rcu_torture_writer(void *arg
)
725 long oldbatch
= rcu_batches_completed();
726 struct rcu_torture
*rp
;
727 struct rcu_torture
*old_rp
;
728 static DEFINE_RCU_RANDOM(rand
);
730 VERBOSE_PRINTK_STRING("rcu_torture_writer task started");
731 set_user_nice(current
, 19);
734 schedule_timeout_uninterruptible(1);
735 rp
= rcu_torture_alloc();
738 rp
->rtort_pipe_count
= 0;
739 udelay(rcu_random(&rand
) & 0x3ff);
740 old_rp
= rcu_torture_current
;
741 rp
->rtort_mbtest
= 1;
742 rcu_assign_pointer(rcu_torture_current
, rp
);
743 smp_wmb(); /* Mods to old_rp must follow rcu_assign_pointer() */
745 i
= old_rp
->rtort_pipe_count
;
746 if (i
> RCU_TORTURE_PIPE_LEN
)
747 i
= RCU_TORTURE_PIPE_LEN
;
748 atomic_inc(&rcu_torture_wcount
[i
]);
749 old_rp
->rtort_pipe_count
++;
750 cur_ops
->deferred_free(old_rp
);
752 rcu_torture_current_version
++;
753 oldbatch
= cur_ops
->completed();
754 rcu_stutter_wait("rcu_torture_writer");
755 } while (!kthread_should_stop() && fullstop
== FULLSTOP_DONTSTOP
);
756 VERBOSE_PRINTK_STRING("rcu_torture_writer task stopping");
757 rcutorture_shutdown_absorb("rcu_torture_writer");
758 while (!kthread_should_stop())
759 schedule_timeout_uninterruptible(1);
764 * RCU torture fake writer kthread. Repeatedly calls sync, with a random
765 * delay between calls.
768 rcu_torture_fakewriter(void *arg
)
770 DEFINE_RCU_RANDOM(rand
);
772 VERBOSE_PRINTK_STRING("rcu_torture_fakewriter task started");
773 set_user_nice(current
, 19);
776 schedule_timeout_uninterruptible(1 + rcu_random(&rand
)%10);
777 udelay(rcu_random(&rand
) & 0x3ff);
779 rcu_stutter_wait("rcu_torture_fakewriter");
780 } while (!kthread_should_stop() && fullstop
== FULLSTOP_DONTSTOP
);
782 VERBOSE_PRINTK_STRING("rcu_torture_fakewriter task stopping");
783 rcutorture_shutdown_absorb("rcu_torture_fakewriter");
784 while (!kthread_should_stop())
785 schedule_timeout_uninterruptible(1);
790 * RCU torture reader from timer handler. Dereferences rcu_torture_current,
791 * incrementing the corresponding element of the pipeline array. The
792 * counter in the element should never be greater than 1, otherwise, the
793 * RCU implementation is broken.
795 static void rcu_torture_timer(unsigned long unused
)
799 static DEFINE_RCU_RANDOM(rand
);
800 static DEFINE_SPINLOCK(rand_lock
);
801 struct rcu_torture
*p
;
804 idx
= cur_ops
->readlock();
805 completed
= cur_ops
->completed();
806 p
= rcu_dereference_check(rcu_torture_current
,
807 rcu_read_lock_held() ||
808 rcu_read_lock_bh_held() ||
809 rcu_read_lock_sched_held() ||
810 srcu_read_lock_held(&srcu_ctl
));
812 /* Leave because rcu_torture_writer is not yet underway */
813 cur_ops
->readunlock(idx
);
816 if (p
->rtort_mbtest
== 0)
817 atomic_inc(&n_rcu_torture_mberror
);
818 spin_lock(&rand_lock
);
819 cur_ops
->read_delay(&rand
);
820 n_rcu_torture_timers
++;
821 spin_unlock(&rand_lock
);
823 pipe_count
= p
->rtort_pipe_count
;
824 if (pipe_count
> RCU_TORTURE_PIPE_LEN
) {
825 /* Should not happen, but... */
826 pipe_count
= RCU_TORTURE_PIPE_LEN
;
828 __this_cpu_inc(rcu_torture_count
[pipe_count
]);
829 completed
= cur_ops
->completed() - completed
;
830 if (completed
> RCU_TORTURE_PIPE_LEN
) {
831 /* Should not happen, but... */
832 completed
= RCU_TORTURE_PIPE_LEN
;
834 __this_cpu_inc(rcu_torture_batch
[completed
]);
836 cur_ops
->readunlock(idx
);
840 * RCU torture reader kthread. Repeatedly dereferences rcu_torture_current,
841 * incrementing the corresponding element of the pipeline array. The
842 * counter in the element should never be greater than 1, otherwise, the
843 * RCU implementation is broken.
846 rcu_torture_reader(void *arg
)
850 DEFINE_RCU_RANDOM(rand
);
851 struct rcu_torture
*p
;
855 VERBOSE_PRINTK_STRING("rcu_torture_reader task started");
856 set_user_nice(current
, 19);
857 if (irqreader
&& cur_ops
->irq_capable
)
858 setup_timer_on_stack(&t
, rcu_torture_timer
, 0);
861 if (irqreader
&& cur_ops
->irq_capable
) {
862 if (!timer_pending(&t
))
863 mod_timer(&t
, jiffies
+ 1);
865 idx
= cur_ops
->readlock();
866 completed
= cur_ops
->completed();
867 p
= rcu_dereference_check(rcu_torture_current
,
868 rcu_read_lock_held() ||
869 rcu_read_lock_bh_held() ||
870 rcu_read_lock_sched_held() ||
871 srcu_read_lock_held(&srcu_ctl
));
873 /* Wait for rcu_torture_writer to get underway */
874 cur_ops
->readunlock(idx
);
875 schedule_timeout_interruptible(HZ
);
878 if (p
->rtort_mbtest
== 0)
879 atomic_inc(&n_rcu_torture_mberror
);
880 cur_ops
->read_delay(&rand
);
882 pipe_count
= p
->rtort_pipe_count
;
883 if (pipe_count
> RCU_TORTURE_PIPE_LEN
) {
884 /* Should not happen, but... */
885 pipe_count
= RCU_TORTURE_PIPE_LEN
;
887 __this_cpu_inc(rcu_torture_count
[pipe_count
]);
888 completed
= cur_ops
->completed() - completed
;
889 if (completed
> RCU_TORTURE_PIPE_LEN
) {
890 /* Should not happen, but... */
891 completed
= RCU_TORTURE_PIPE_LEN
;
893 __this_cpu_inc(rcu_torture_batch
[completed
]);
895 cur_ops
->readunlock(idx
);
897 rcu_stutter_wait("rcu_torture_reader");
898 } while (!kthread_should_stop() && fullstop
== FULLSTOP_DONTSTOP
);
899 VERBOSE_PRINTK_STRING("rcu_torture_reader task stopping");
900 rcutorture_shutdown_absorb("rcu_torture_reader");
901 if (irqreader
&& cur_ops
->irq_capable
)
903 while (!kthread_should_stop())
904 schedule_timeout_uninterruptible(1);
909 * Create an RCU-torture statistics message in the specified buffer.
912 rcu_torture_printk(char *page
)
917 long pipesummary
[RCU_TORTURE_PIPE_LEN
+ 1] = { 0 };
918 long batchsummary
[RCU_TORTURE_PIPE_LEN
+ 1] = { 0 };
920 for_each_possible_cpu(cpu
) {
921 for (i
= 0; i
< RCU_TORTURE_PIPE_LEN
+ 1; i
++) {
922 pipesummary
[i
] += per_cpu(rcu_torture_count
, cpu
)[i
];
923 batchsummary
[i
] += per_cpu(rcu_torture_batch
, cpu
)[i
];
926 for (i
= RCU_TORTURE_PIPE_LEN
- 1; i
>= 0; i
--) {
927 if (pipesummary
[i
] != 0)
930 cnt
+= sprintf(&page
[cnt
], "%s%s ", torture_type
, TORTURE_FLAG
);
931 cnt
+= sprintf(&page
[cnt
],
932 "rtc: %p ver: %ld tfle: %d rta: %d rtaf: %d rtf: %d "
935 rcu_torture_current_version
,
936 list_empty(&rcu_torture_freelist
),
937 atomic_read(&n_rcu_torture_alloc
),
938 atomic_read(&n_rcu_torture_alloc_fail
),
939 atomic_read(&n_rcu_torture_free
),
940 atomic_read(&n_rcu_torture_mberror
),
941 n_rcu_torture_timers
);
942 if (atomic_read(&n_rcu_torture_mberror
) != 0)
943 cnt
+= sprintf(&page
[cnt
], " !!!");
944 cnt
+= sprintf(&page
[cnt
], "\n%s%s ", torture_type
, TORTURE_FLAG
);
946 cnt
+= sprintf(&page
[cnt
], "!!! ");
947 atomic_inc(&n_rcu_torture_error
);
950 cnt
+= sprintf(&page
[cnt
], "Reader Pipe: ");
951 for (i
= 0; i
< RCU_TORTURE_PIPE_LEN
+ 1; i
++)
952 cnt
+= sprintf(&page
[cnt
], " %ld", pipesummary
[i
]);
953 cnt
+= sprintf(&page
[cnt
], "\n%s%s ", torture_type
, TORTURE_FLAG
);
954 cnt
+= sprintf(&page
[cnt
], "Reader Batch: ");
955 for (i
= 0; i
< RCU_TORTURE_PIPE_LEN
+ 1; i
++)
956 cnt
+= sprintf(&page
[cnt
], " %ld", batchsummary
[i
]);
957 cnt
+= sprintf(&page
[cnt
], "\n%s%s ", torture_type
, TORTURE_FLAG
);
958 cnt
+= sprintf(&page
[cnt
], "Free-Block Circulation: ");
959 for (i
= 0; i
< RCU_TORTURE_PIPE_LEN
+ 1; i
++) {
960 cnt
+= sprintf(&page
[cnt
], " %d",
961 atomic_read(&rcu_torture_wcount
[i
]));
963 cnt
+= sprintf(&page
[cnt
], "\n");
965 cnt
+= cur_ops
->stats(&page
[cnt
]);
970 * Print torture statistics. Caller must ensure that there is only
971 * one call to this function at a given time!!! This is normally
972 * accomplished by relying on the module system to only have one copy
973 * of the module loaded, and then by giving the rcu_torture_stats
974 * kthread full control (or the init/cleanup functions when rcu_torture_stats
975 * thread is not running).
978 rcu_torture_stats_print(void)
982 cnt
= rcu_torture_printk(printk_buf
);
983 printk(KERN_ALERT
"%s", printk_buf
);
987 * Periodically prints torture statistics, if periodic statistics printing
988 * was specified via the stat_interval module parameter.
990 * No need to worry about fullstop here, since this one doesn't reference
991 * volatile state or register callbacks.
994 rcu_torture_stats(void *arg
)
996 VERBOSE_PRINTK_STRING("rcu_torture_stats task started");
998 schedule_timeout_interruptible(stat_interval
* HZ
);
999 rcu_torture_stats_print();
1000 rcutorture_shutdown_absorb("rcu_torture_stats");
1001 } while (!kthread_should_stop());
1002 VERBOSE_PRINTK_STRING("rcu_torture_stats task stopping");
1006 static int rcu_idle_cpu
; /* Force all torture tasks off this CPU */
1008 /* Shuffle tasks such that we allow @rcu_idle_cpu to become idle. A special case
1009 * is when @rcu_idle_cpu = -1, when we allow the tasks to run on all CPUs.
1011 static void rcu_torture_shuffle_tasks(void)
1015 cpumask_setall(shuffle_tmp_mask
);
1018 /* No point in shuffling if there is only one online CPU (ex: UP) */
1019 if (num_online_cpus() == 1) {
1024 if (rcu_idle_cpu
!= -1)
1025 cpumask_clear_cpu(rcu_idle_cpu
, shuffle_tmp_mask
);
1027 set_cpus_allowed_ptr(current
, shuffle_tmp_mask
);
1030 for (i
= 0; i
< nrealreaders
; i
++)
1031 if (reader_tasks
[i
])
1032 set_cpus_allowed_ptr(reader_tasks
[i
],
1036 if (fakewriter_tasks
) {
1037 for (i
= 0; i
< nfakewriters
; i
++)
1038 if (fakewriter_tasks
[i
])
1039 set_cpus_allowed_ptr(fakewriter_tasks
[i
],
1044 set_cpus_allowed_ptr(writer_task
, shuffle_tmp_mask
);
1047 set_cpus_allowed_ptr(stats_task
, shuffle_tmp_mask
);
1049 if (rcu_idle_cpu
== -1)
1050 rcu_idle_cpu
= num_online_cpus() - 1;
1057 /* Shuffle tasks across CPUs, with the intent of allowing each CPU in the
1058 * system to become idle at a time and cut off its timer ticks. This is meant
1059 * to test the support for such tickless idle CPU in RCU.
1062 rcu_torture_shuffle(void *arg
)
1064 VERBOSE_PRINTK_STRING("rcu_torture_shuffle task started");
1066 schedule_timeout_interruptible(shuffle_interval
* HZ
);
1067 rcu_torture_shuffle_tasks();
1068 rcutorture_shutdown_absorb("rcu_torture_shuffle");
1069 } while (!kthread_should_stop());
1070 VERBOSE_PRINTK_STRING("rcu_torture_shuffle task stopping");
1074 /* Cause the rcutorture test to "stutter", starting and stopping all
1075 * threads periodically.
1078 rcu_torture_stutter(void *arg
)
1080 VERBOSE_PRINTK_STRING("rcu_torture_stutter task started");
1082 schedule_timeout_interruptible(stutter
* HZ
);
1083 stutter_pause_test
= 1;
1084 if (!kthread_should_stop())
1085 schedule_timeout_interruptible(stutter
* HZ
);
1086 stutter_pause_test
= 0;
1087 rcutorture_shutdown_absorb("rcu_torture_stutter");
1088 } while (!kthread_should_stop());
1089 VERBOSE_PRINTK_STRING("rcu_torture_stutter task stopping");
1094 rcu_torture_print_module_parms(char *tag
)
1096 printk(KERN_ALERT
"%s" TORTURE_FLAG
1097 "--- %s: nreaders=%d nfakewriters=%d "
1098 "stat_interval=%d verbose=%d test_no_idle_hz=%d "
1099 "shuffle_interval=%d stutter=%d irqreader=%d "
1100 "fqs_duration=%d fqs_holdoff=%d fqs_stutter=%d\n",
1101 torture_type
, tag
, nrealreaders
, nfakewriters
,
1102 stat_interval
, verbose
, test_no_idle_hz
, shuffle_interval
,
1103 stutter
, irqreader
, fqs_duration
, fqs_holdoff
, fqs_stutter
);
1106 static struct notifier_block rcutorture_nb
= {
1107 .notifier_call
= rcutorture_shutdown_notify
,
1111 rcu_torture_cleanup(void)
1115 mutex_lock(&fullstop_mutex
);
1116 if (fullstop
== FULLSTOP_SHUTDOWN
) {
1117 printk(KERN_WARNING
/* but going down anyway, so... */
1118 "Concurrent 'rmmod rcutorture' and shutdown illegal!\n");
1119 mutex_unlock(&fullstop_mutex
);
1120 schedule_timeout_uninterruptible(10);
1121 if (cur_ops
->cb_barrier
!= NULL
)
1122 cur_ops
->cb_barrier();
1125 fullstop
= FULLSTOP_RMMOD
;
1126 mutex_unlock(&fullstop_mutex
);
1127 unregister_reboot_notifier(&rcutorture_nb
);
1129 VERBOSE_PRINTK_STRING("Stopping rcu_torture_stutter task");
1130 kthread_stop(stutter_task
);
1132 stutter_task
= NULL
;
1133 if (shuffler_task
) {
1134 VERBOSE_PRINTK_STRING("Stopping rcu_torture_shuffle task");
1135 kthread_stop(shuffler_task
);
1136 free_cpumask_var(shuffle_tmp_mask
);
1138 shuffler_task
= NULL
;
1141 VERBOSE_PRINTK_STRING("Stopping rcu_torture_writer task");
1142 kthread_stop(writer_task
);
1147 for (i
= 0; i
< nrealreaders
; i
++) {
1148 if (reader_tasks
[i
]) {
1149 VERBOSE_PRINTK_STRING(
1150 "Stopping rcu_torture_reader task");
1151 kthread_stop(reader_tasks
[i
]);
1153 reader_tasks
[i
] = NULL
;
1155 kfree(reader_tasks
);
1156 reader_tasks
= NULL
;
1158 rcu_torture_current
= NULL
;
1160 if (fakewriter_tasks
) {
1161 for (i
= 0; i
< nfakewriters
; i
++) {
1162 if (fakewriter_tasks
[i
]) {
1163 VERBOSE_PRINTK_STRING(
1164 "Stopping rcu_torture_fakewriter task");
1165 kthread_stop(fakewriter_tasks
[i
]);
1167 fakewriter_tasks
[i
] = NULL
;
1169 kfree(fakewriter_tasks
);
1170 fakewriter_tasks
= NULL
;
1174 VERBOSE_PRINTK_STRING("Stopping rcu_torture_stats task");
1175 kthread_stop(stats_task
);
1180 VERBOSE_PRINTK_STRING("Stopping rcu_torture_fqs task");
1181 kthread_stop(fqs_task
);
1185 /* Wait for all RCU callbacks to fire. */
1187 if (cur_ops
->cb_barrier
!= NULL
)
1188 cur_ops
->cb_barrier();
1190 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
1192 if (cur_ops
->cleanup
)
1194 if (atomic_read(&n_rcu_torture_error
))
1195 rcu_torture_print_module_parms("End of test: FAILURE");
1197 rcu_torture_print_module_parms("End of test: SUCCESS");
1201 rcu_torture_init(void)
1206 static struct rcu_torture_ops
*torture_ops
[] =
1207 { &rcu_ops
, &rcu_sync_ops
, &rcu_expedited_ops
,
1208 &rcu_bh_ops
, &rcu_bh_sync_ops
,
1209 &srcu_ops
, &srcu_expedited_ops
,
1210 &sched_ops
, &sched_sync_ops
, &sched_expedited_ops
, };
1212 mutex_lock(&fullstop_mutex
);
1214 /* Process args and tell the world that the torturer is on the job. */
1215 for (i
= 0; i
< ARRAY_SIZE(torture_ops
); i
++) {
1216 cur_ops
= torture_ops
[i
];
1217 if (strcmp(torture_type
, cur_ops
->name
) == 0)
1220 if (i
== ARRAY_SIZE(torture_ops
)) {
1221 printk(KERN_ALERT
"rcu-torture: invalid torture type: \"%s\"\n",
1223 printk(KERN_ALERT
"rcu-torture types:");
1224 for (i
= 0; i
< ARRAY_SIZE(torture_ops
); i
++)
1225 printk(KERN_ALERT
" %s", torture_ops
[i
]->name
);
1226 printk(KERN_ALERT
"\n");
1227 mutex_unlock(&fullstop_mutex
);
1230 if (cur_ops
->fqs
== NULL
&& fqs_duration
!= 0) {
1231 printk(KERN_ALERT
"rcu-torture: ->fqs NULL and non-zero "
1232 "fqs_duration, fqs disabled.\n");
1236 cur_ops
->init(); /* no "goto unwind" prior to this point!!! */
1239 nrealreaders
= nreaders
;
1241 nrealreaders
= 2 * num_online_cpus();
1242 rcu_torture_print_module_parms("Start of test");
1243 fullstop
= FULLSTOP_DONTSTOP
;
1245 /* Set up the freelist. */
1247 INIT_LIST_HEAD(&rcu_torture_freelist
);
1248 for (i
= 0; i
< ARRAY_SIZE(rcu_tortures
); i
++) {
1249 rcu_tortures
[i
].rtort_mbtest
= 0;
1250 list_add_tail(&rcu_tortures
[i
].rtort_free
,
1251 &rcu_torture_freelist
);
1254 /* Initialize the statistics so that each run gets its own numbers. */
1256 rcu_torture_current
= NULL
;
1257 rcu_torture_current_version
= 0;
1258 atomic_set(&n_rcu_torture_alloc
, 0);
1259 atomic_set(&n_rcu_torture_alloc_fail
, 0);
1260 atomic_set(&n_rcu_torture_free
, 0);
1261 atomic_set(&n_rcu_torture_mberror
, 0);
1262 atomic_set(&n_rcu_torture_error
, 0);
1263 for (i
= 0; i
< RCU_TORTURE_PIPE_LEN
+ 1; i
++)
1264 atomic_set(&rcu_torture_wcount
[i
], 0);
1265 for_each_possible_cpu(cpu
) {
1266 for (i
= 0; i
< RCU_TORTURE_PIPE_LEN
+ 1; i
++) {
1267 per_cpu(rcu_torture_count
, cpu
)[i
] = 0;
1268 per_cpu(rcu_torture_batch
, cpu
)[i
] = 0;
1272 /* Start up the kthreads. */
1274 VERBOSE_PRINTK_STRING("Creating rcu_torture_writer task");
1275 writer_task
= kthread_run(rcu_torture_writer
, NULL
,
1276 "rcu_torture_writer");
1277 if (IS_ERR(writer_task
)) {
1278 firsterr
= PTR_ERR(writer_task
);
1279 VERBOSE_PRINTK_ERRSTRING("Failed to create writer");
1283 fakewriter_tasks
= kzalloc(nfakewriters
* sizeof(fakewriter_tasks
[0]),
1285 if (fakewriter_tasks
== NULL
) {
1286 VERBOSE_PRINTK_ERRSTRING("out of memory");
1290 for (i
= 0; i
< nfakewriters
; i
++) {
1291 VERBOSE_PRINTK_STRING("Creating rcu_torture_fakewriter task");
1292 fakewriter_tasks
[i
] = kthread_run(rcu_torture_fakewriter
, NULL
,
1293 "rcu_torture_fakewriter");
1294 if (IS_ERR(fakewriter_tasks
[i
])) {
1295 firsterr
= PTR_ERR(fakewriter_tasks
[i
]);
1296 VERBOSE_PRINTK_ERRSTRING("Failed to create fakewriter");
1297 fakewriter_tasks
[i
] = NULL
;
1301 reader_tasks
= kzalloc(nrealreaders
* sizeof(reader_tasks
[0]),
1303 if (reader_tasks
== NULL
) {
1304 VERBOSE_PRINTK_ERRSTRING("out of memory");
1308 for (i
= 0; i
< nrealreaders
; i
++) {
1309 VERBOSE_PRINTK_STRING("Creating rcu_torture_reader task");
1310 reader_tasks
[i
] = kthread_run(rcu_torture_reader
, NULL
,
1311 "rcu_torture_reader");
1312 if (IS_ERR(reader_tasks
[i
])) {
1313 firsterr
= PTR_ERR(reader_tasks
[i
]);
1314 VERBOSE_PRINTK_ERRSTRING("Failed to create reader");
1315 reader_tasks
[i
] = NULL
;
1319 if (stat_interval
> 0) {
1320 VERBOSE_PRINTK_STRING("Creating rcu_torture_stats task");
1321 stats_task
= kthread_run(rcu_torture_stats
, NULL
,
1322 "rcu_torture_stats");
1323 if (IS_ERR(stats_task
)) {
1324 firsterr
= PTR_ERR(stats_task
);
1325 VERBOSE_PRINTK_ERRSTRING("Failed to create stats");
1330 if (test_no_idle_hz
) {
1331 rcu_idle_cpu
= num_online_cpus() - 1;
1333 if (!alloc_cpumask_var(&shuffle_tmp_mask
, GFP_KERNEL
)) {
1335 VERBOSE_PRINTK_ERRSTRING("Failed to alloc mask");
1339 /* Create the shuffler thread */
1340 shuffler_task
= kthread_run(rcu_torture_shuffle
, NULL
,
1341 "rcu_torture_shuffle");
1342 if (IS_ERR(shuffler_task
)) {
1343 free_cpumask_var(shuffle_tmp_mask
);
1344 firsterr
= PTR_ERR(shuffler_task
);
1345 VERBOSE_PRINTK_ERRSTRING("Failed to create shuffler");
1346 shuffler_task
= NULL
;
1353 /* Create the stutter thread */
1354 stutter_task
= kthread_run(rcu_torture_stutter
, NULL
,
1355 "rcu_torture_stutter");
1356 if (IS_ERR(stutter_task
)) {
1357 firsterr
= PTR_ERR(stutter_task
);
1358 VERBOSE_PRINTK_ERRSTRING("Failed to create stutter");
1359 stutter_task
= NULL
;
1363 if (fqs_duration
< 0)
1366 /* Create the stutter thread */
1367 fqs_task
= kthread_run(rcu_torture_fqs
, NULL
,
1369 if (IS_ERR(fqs_task
)) {
1370 firsterr
= PTR_ERR(fqs_task
);
1371 VERBOSE_PRINTK_ERRSTRING("Failed to create fqs");
1376 register_reboot_notifier(&rcutorture_nb
);
1377 mutex_unlock(&fullstop_mutex
);
1381 mutex_unlock(&fullstop_mutex
);
1382 rcu_torture_cleanup();
1386 module_init(rcu_torture_init
);
1387 module_exit(rcu_torture_cleanup
);