]> bbs.cooldavid.org Git - net-next-2.6.git/blame - kernel/rcutorture.c
rtl8187: Fix transmission count sent to mac80211
[net-next-2.6.git] / kernel / rcutorture.c
CommitLineData
a241ec65 1/*
29766f1e 2 * Read-Copy Update module-based torture test facility
a241ec65
PM
3 *
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.
8 *
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.
13 *
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.
17 *
b772e1dd 18 * Copyright (C) IBM Corporation, 2005, 2006
a241ec65
PM
19 *
20 * Authors: Paul E. McKenney <paulmck@us.ibm.com>
b772e1dd 21 * Josh Triplett <josh@freedesktop.org>
a241ec65
PM
22 *
23 * See also: Documentation/RCU/torture.txt
24 */
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>
a241ec65
PM
38#include <linux/completion.h>
39#include <linux/moduleparam.h>
40#include <linux/percpu.h>
41#include <linux/notifier.h>
83144186 42#include <linux/freezer.h>
a241ec65 43#include <linux/cpu.h>
a241ec65 44#include <linux/delay.h>
a241ec65 45#include <linux/stat.h>
b2896d2e 46#include <linux/srcu.h>
1aeb272c 47#include <linux/slab.h>
f07767fd 48#include <asm/byteorder.h>
a241ec65
PM
49
50MODULE_LICENSE("GPL");
b772e1dd
JT
51MODULE_AUTHOR("Paul E. McKenney <paulmck@us.ibm.com> and "
52 "Josh Triplett <josh@freedesktop.org>");
a241ec65 53
4802211c 54static int nreaders = -1; /* # reader threads, defaults to 2*ncpus */
b772e1dd 55static int nfakewriters = 4; /* # fake writer threads */
d84f5203 56static int stat_interval; /* Interval between stats, in seconds. */
a241ec65 57 /* Defaults to "only at end of test". */
d84f5203
SV
58static int verbose; /* Print more debug info. */
59static int test_no_idle_hz; /* Test RCU's support for tickless idle CPUs. */
d120f65f
PM
60static int shuffle_interval = 3; /* Interval between shuffles (in sec)*/
61static int stutter = 5; /* Start/stop testing interval (in sec) */
0729fbf3 62static int irqreader = 1; /* RCU readers from irq (timers). */
20d2e428 63static char *torture_type = "rcu"; /* What RCU implementation to torture. */
a241ec65 64
d6ad6711 65module_param(nreaders, int, 0444);
a241ec65 66MODULE_PARM_DESC(nreaders, "Number of RCU reader threads");
d6ad6711 67module_param(nfakewriters, int, 0444);
b772e1dd 68MODULE_PARM_DESC(nfakewriters, "Number of RCU fake writer threads");
d6ad6711 69module_param(stat_interval, int, 0444);
a241ec65 70MODULE_PARM_DESC(stat_interval, "Number of seconds between stats printk()s");
d6ad6711 71module_param(verbose, bool, 0444);
a241ec65 72MODULE_PARM_DESC(verbose, "Enable verbose debugging printk()s");
d6ad6711 73module_param(test_no_idle_hz, bool, 0444);
d84f5203 74MODULE_PARM_DESC(test_no_idle_hz, "Test support for tickless idle CPUs");
d6ad6711 75module_param(shuffle_interval, int, 0444);
d84f5203 76MODULE_PARM_DESC(shuffle_interval, "Number of seconds between shuffles");
d120f65f
PM
77module_param(stutter, int, 0444);
78MODULE_PARM_DESC(stutter, "Number of seconds to run/halt test");
0729fbf3
PM
79module_param(irqreader, int, 0444);
80MODULE_PARM_DESC(irqreader, "Allow RCU readers from irq handlers");
d6ad6711 81module_param(torture_type, charp, 0444);
b2896d2e 82MODULE_PARM_DESC(torture_type, "Type of RCU to torture (rcu, rcu_bh, srcu)");
72e9bb54
PM
83
84#define TORTURE_FLAG "-torture:"
a241ec65 85#define PRINTK_STRING(s) \
72e9bb54 86 do { printk(KERN_ALERT "%s" TORTURE_FLAG s "\n", torture_type); } while (0)
a241ec65 87#define VERBOSE_PRINTK_STRING(s) \
72e9bb54 88 do { if (verbose) printk(KERN_ALERT "%s" TORTURE_FLAG s "\n", torture_type); } while (0)
a241ec65 89#define VERBOSE_PRINTK_ERRSTRING(s) \
72e9bb54 90 do { if (verbose) printk(KERN_ALERT "%s" TORTURE_FLAG "!!! " s "\n", torture_type); } while (0)
a241ec65
PM
91
92static char printk_buf[4096];
93
94static int nrealreaders;
95static struct task_struct *writer_task;
b772e1dd 96static struct task_struct **fakewriter_tasks;
a241ec65
PM
97static struct task_struct **reader_tasks;
98static struct task_struct *stats_task;
d84f5203 99static struct task_struct *shuffler_task;
d120f65f 100static struct task_struct *stutter_task;
a241ec65
PM
101
102#define RCU_TORTURE_PIPE_LEN 10
103
104struct rcu_torture {
105 struct rcu_head rtort_rcu;
106 int rtort_pipe_count;
107 struct list_head rtort_free;
996417d2 108 int rtort_mbtest;
a241ec65
PM
109};
110
111static int fullstop = 0; /* stop generating callbacks at test end. */
112static LIST_HEAD(rcu_torture_freelist);
113static struct rcu_torture *rcu_torture_current = NULL;
114static long rcu_torture_current_version = 0;
115static struct rcu_torture rcu_tortures[10 * RCU_TORTURE_PIPE_LEN];
116static DEFINE_SPINLOCK(rcu_torture_lock);
117static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
118 { 0 };
119static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
120 { 0 };
121static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
b2896d2e
PM
122static atomic_t n_rcu_torture_alloc;
123static atomic_t n_rcu_torture_alloc_fail;
124static atomic_t n_rcu_torture_free;
125static atomic_t n_rcu_torture_mberror;
126static atomic_t n_rcu_torture_error;
0729fbf3 127static long n_rcu_torture_timers = 0;
e3033736 128static struct list_head rcu_torture_removed;
a241ec65 129
d120f65f
PM
130static int stutter_pause_test = 0;
131
31a72bce
PM
132#if defined(MODULE) || defined(CONFIG_RCU_TORTURE_TEST_RUNNABLE)
133#define RCUTORTURE_RUNNABLE_INIT 1
134#else
135#define RCUTORTURE_RUNNABLE_INIT 0
136#endif
137int rcutorture_runnable = RCUTORTURE_RUNNABLE_INIT;
138
a241ec65
PM
139/*
140 * Allocate an element from the rcu_tortures pool.
141 */
97a41e26 142static struct rcu_torture *
a241ec65
PM
143rcu_torture_alloc(void)
144{
145 struct list_head *p;
146
adac1665 147 spin_lock_bh(&rcu_torture_lock);
a241ec65
PM
148 if (list_empty(&rcu_torture_freelist)) {
149 atomic_inc(&n_rcu_torture_alloc_fail);
adac1665 150 spin_unlock_bh(&rcu_torture_lock);
a241ec65
PM
151 return NULL;
152 }
153 atomic_inc(&n_rcu_torture_alloc);
154 p = rcu_torture_freelist.next;
155 list_del_init(p);
adac1665 156 spin_unlock_bh(&rcu_torture_lock);
a241ec65
PM
157 return container_of(p, struct rcu_torture, rtort_free);
158}
159
160/*
161 * Free an element to the rcu_tortures pool.
162 */
163static void
164rcu_torture_free(struct rcu_torture *p)
165{
166 atomic_inc(&n_rcu_torture_free);
adac1665 167 spin_lock_bh(&rcu_torture_lock);
a241ec65 168 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
adac1665 169 spin_unlock_bh(&rcu_torture_lock);
a241ec65
PM
170}
171
a241ec65
PM
172struct rcu_random_state {
173 unsigned long rrs_state;
75cfef32 174 long rrs_count;
a241ec65
PM
175};
176
177#define RCU_RANDOM_MULT 39916801 /* prime */
178#define RCU_RANDOM_ADD 479001701 /* prime */
179#define RCU_RANDOM_REFRESH 10000
180
181#define DEFINE_RCU_RANDOM(name) struct rcu_random_state name = { 0, 0 }
182
183/*
184 * Crude but fast random-number generator. Uses a linear congruential
c17ac855 185 * generator, with occasional help from cpu_clock().
a241ec65 186 */
75cfef32 187static unsigned long
a241ec65
PM
188rcu_random(struct rcu_random_state *rrsp)
189{
a241ec65 190 if (--rrsp->rrs_count < 0) {
c17ac855
PM
191 rrsp->rrs_state +=
192 (unsigned long)cpu_clock(raw_smp_processor_id());
a241ec65
PM
193 rrsp->rrs_count = RCU_RANDOM_REFRESH;
194 }
195 rrsp->rrs_state = rrsp->rrs_state * RCU_RANDOM_MULT + RCU_RANDOM_ADD;
196 return swahw32(rrsp->rrs_state);
197}
198
d120f65f
PM
199static void
200rcu_stutter_wait(void)
201{
31a72bce 202 while (stutter_pause_test || !rcutorture_runnable)
e3d7be27
PM
203 if (rcutorture_runnable)
204 schedule_timeout_interruptible(1);
205 else
3ccf79f4 206 schedule_timeout_interruptible(round_jiffies_relative(HZ));
d120f65f
PM
207}
208
72e9bb54
PM
209/*
210 * Operations vector for selecting different types of tests.
211 */
212
213struct rcu_torture_ops {
214 void (*init)(void);
215 void (*cleanup)(void);
216 int (*readlock)(void);
b2896d2e 217 void (*readdelay)(struct rcu_random_state *rrsp);
72e9bb54
PM
218 void (*readunlock)(int idx);
219 int (*completed)(void);
220 void (*deferredfree)(struct rcu_torture *p);
b772e1dd 221 void (*sync)(void);
2326974d 222 void (*cb_barrier)(void);
72e9bb54 223 int (*stats)(char *page);
0729fbf3 224 int irqcapable;
72e9bb54
PM
225 char *name;
226};
227static struct rcu_torture_ops *cur_ops = NULL;
228
229/*
230 * Definitions for rcu torture testing.
231 */
232
a49a4af7 233static int rcu_torture_read_lock(void) __acquires(RCU)
72e9bb54
PM
234{
235 rcu_read_lock();
236 return 0;
237}
238
b2896d2e
PM
239static void rcu_read_delay(struct rcu_random_state *rrsp)
240{
241 long delay;
242 const long longdelay = 200;
243
244 /* We want there to be long-running readers, but not all the time. */
245
246 delay = rcu_random(rrsp) % (nrealreaders * 2 * longdelay);
247 if (!delay)
248 udelay(longdelay);
249}
250
a49a4af7 251static void rcu_torture_read_unlock(int idx) __releases(RCU)
72e9bb54
PM
252{
253 rcu_read_unlock();
254}
255
256static int rcu_torture_completed(void)
257{
258 return rcu_batches_completed();
259}
260
261static void
262rcu_torture_cb(struct rcu_head *p)
263{
264 int i;
265 struct rcu_torture *rp = container_of(p, struct rcu_torture, rtort_rcu);
266
267 if (fullstop) {
268 /* Test is ending, just drop callbacks on the floor. */
269 /* The next initialization will pick up the pieces. */
270 return;
271 }
272 i = rp->rtort_pipe_count;
273 if (i > RCU_TORTURE_PIPE_LEN)
274 i = RCU_TORTURE_PIPE_LEN;
275 atomic_inc(&rcu_torture_wcount[i]);
276 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
277 rp->rtort_mbtest = 0;
278 rcu_torture_free(rp);
279 } else
280 cur_ops->deferredfree(rp);
281}
282
283static void rcu_torture_deferred_free(struct rcu_torture *p)
284{
285 call_rcu(&p->rtort_rcu, rcu_torture_cb);
286}
287
288static struct rcu_torture_ops rcu_ops = {
289 .init = NULL,
290 .cleanup = NULL,
291 .readlock = rcu_torture_read_lock,
b2896d2e 292 .readdelay = rcu_read_delay,
72e9bb54
PM
293 .readunlock = rcu_torture_read_unlock,
294 .completed = rcu_torture_completed,
295 .deferredfree = rcu_torture_deferred_free,
b772e1dd 296 .sync = synchronize_rcu,
2326974d 297 .cb_barrier = rcu_barrier,
72e9bb54 298 .stats = NULL,
0729fbf3 299 .irqcapable = 1,
72e9bb54
PM
300 .name = "rcu"
301};
302
e3033736
JT
303static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
304{
305 int i;
306 struct rcu_torture *rp;
307 struct rcu_torture *rp1;
308
309 cur_ops->sync();
310 list_add(&p->rtort_free, &rcu_torture_removed);
311 list_for_each_entry_safe(rp, rp1, &rcu_torture_removed, rtort_free) {
312 i = rp->rtort_pipe_count;
313 if (i > RCU_TORTURE_PIPE_LEN)
314 i = RCU_TORTURE_PIPE_LEN;
315 atomic_inc(&rcu_torture_wcount[i]);
316 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
317 rp->rtort_mbtest = 0;
318 list_del(&rp->rtort_free);
319 rcu_torture_free(rp);
320 }
321 }
322}
323
324static void rcu_sync_torture_init(void)
325{
326 INIT_LIST_HEAD(&rcu_torture_removed);
327}
328
20d2e428
JT
329static struct rcu_torture_ops rcu_sync_ops = {
330 .init = rcu_sync_torture_init,
331 .cleanup = NULL,
332 .readlock = rcu_torture_read_lock,
333 .readdelay = rcu_read_delay,
334 .readunlock = rcu_torture_read_unlock,
335 .completed = rcu_torture_completed,
336 .deferredfree = rcu_sync_torture_deferred_free,
337 .sync = synchronize_rcu,
2326974d 338 .cb_barrier = NULL,
20d2e428 339 .stats = NULL,
0729fbf3 340 .irqcapable = 1,
20d2e428
JT
341 .name = "rcu_sync"
342};
343
c32e0660
PM
344/*
345 * Definitions for rcu_bh torture testing.
346 */
347
a49a4af7 348static int rcu_bh_torture_read_lock(void) __acquires(RCU_BH)
c32e0660
PM
349{
350 rcu_read_lock_bh();
351 return 0;
352}
353
a49a4af7 354static void rcu_bh_torture_read_unlock(int idx) __releases(RCU_BH)
c32e0660
PM
355{
356 rcu_read_unlock_bh();
357}
358
359static int rcu_bh_torture_completed(void)
360{
361 return rcu_batches_completed_bh();
362}
363
364static void rcu_bh_torture_deferred_free(struct rcu_torture *p)
365{
366 call_rcu_bh(&p->rtort_rcu, rcu_torture_cb);
367}
368
b772e1dd
JT
369struct rcu_bh_torture_synchronize {
370 struct rcu_head head;
371 struct completion completion;
372};
373
374static void rcu_bh_torture_wakeme_after_cb(struct rcu_head *head)
375{
376 struct rcu_bh_torture_synchronize *rcu;
377
378 rcu = container_of(head, struct rcu_bh_torture_synchronize, head);
379 complete(&rcu->completion);
380}
381
382static void rcu_bh_torture_synchronize(void)
383{
384 struct rcu_bh_torture_synchronize rcu;
385
386 init_completion(&rcu.completion);
387 call_rcu_bh(&rcu.head, rcu_bh_torture_wakeme_after_cb);
388 wait_for_completion(&rcu.completion);
389}
390
c32e0660
PM
391static struct rcu_torture_ops rcu_bh_ops = {
392 .init = NULL,
393 .cleanup = NULL,
394 .readlock = rcu_bh_torture_read_lock,
b2896d2e 395 .readdelay = rcu_read_delay, /* just reuse rcu's version. */
c32e0660
PM
396 .readunlock = rcu_bh_torture_read_unlock,
397 .completed = rcu_bh_torture_completed,
398 .deferredfree = rcu_bh_torture_deferred_free,
b772e1dd 399 .sync = rcu_bh_torture_synchronize,
2326974d 400 .cb_barrier = rcu_barrier_bh,
c32e0660 401 .stats = NULL,
0729fbf3 402 .irqcapable = 1,
c32e0660
PM
403 .name = "rcu_bh"
404};
405
11a14701
JT
406static struct rcu_torture_ops rcu_bh_sync_ops = {
407 .init = rcu_sync_torture_init,
408 .cleanup = NULL,
409 .readlock = rcu_bh_torture_read_lock,
410 .readdelay = rcu_read_delay, /* just reuse rcu's version. */
411 .readunlock = rcu_bh_torture_read_unlock,
412 .completed = rcu_bh_torture_completed,
413 .deferredfree = rcu_sync_torture_deferred_free,
414 .sync = rcu_bh_torture_synchronize,
2326974d 415 .cb_barrier = NULL,
11a14701 416 .stats = NULL,
0729fbf3 417 .irqcapable = 1,
11a14701
JT
418 .name = "rcu_bh_sync"
419};
420
b2896d2e
PM
421/*
422 * Definitions for srcu torture testing.
423 */
424
425static struct srcu_struct srcu_ctl;
b2896d2e
PM
426
427static void srcu_torture_init(void)
428{
429 init_srcu_struct(&srcu_ctl);
e3033736 430 rcu_sync_torture_init();
b2896d2e
PM
431}
432
433static void srcu_torture_cleanup(void)
434{
435 synchronize_srcu(&srcu_ctl);
436 cleanup_srcu_struct(&srcu_ctl);
437}
438
012d3ca8 439static int srcu_torture_read_lock(void) __acquires(&srcu_ctl)
b2896d2e
PM
440{
441 return srcu_read_lock(&srcu_ctl);
442}
443
444static void srcu_read_delay(struct rcu_random_state *rrsp)
445{
446 long delay;
447 const long uspertick = 1000000 / HZ;
448 const long longdelay = 10;
449
450 /* We want there to be long-running readers, but not all the time. */
451
452 delay = rcu_random(rrsp) % (nrealreaders * 2 * longdelay * uspertick);
453 if (!delay)
454 schedule_timeout_interruptible(longdelay);
455}
456
012d3ca8 457static void srcu_torture_read_unlock(int idx) __releases(&srcu_ctl)
b2896d2e
PM
458{
459 srcu_read_unlock(&srcu_ctl, idx);
460}
461
462static int srcu_torture_completed(void)
463{
464 return srcu_batches_completed(&srcu_ctl);
465}
466
b772e1dd
JT
467static void srcu_torture_synchronize(void)
468{
469 synchronize_srcu(&srcu_ctl);
470}
471
b2896d2e
PM
472static int srcu_torture_stats(char *page)
473{
474 int cnt = 0;
475 int cpu;
476 int idx = srcu_ctl.completed & 0x1;
477
478 cnt += sprintf(&page[cnt], "%s%s per-CPU(idx=%d):",
479 torture_type, TORTURE_FLAG, idx);
480 for_each_possible_cpu(cpu) {
481 cnt += sprintf(&page[cnt], " %d(%d,%d)", cpu,
482 per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[!idx],
483 per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[idx]);
484 }
485 cnt += sprintf(&page[cnt], "\n");
486 return cnt;
487}
488
489static struct rcu_torture_ops srcu_ops = {
490 .init = srcu_torture_init,
491 .cleanup = srcu_torture_cleanup,
492 .readlock = srcu_torture_read_lock,
493 .readdelay = srcu_read_delay,
494 .readunlock = srcu_torture_read_unlock,
495 .completed = srcu_torture_completed,
e3033736 496 .deferredfree = rcu_sync_torture_deferred_free,
b772e1dd 497 .sync = srcu_torture_synchronize,
2326974d 498 .cb_barrier = NULL,
b2896d2e
PM
499 .stats = srcu_torture_stats,
500 .name = "srcu"
501};
502
4b6c2cca
JT
503/*
504 * Definitions for sched torture testing.
505 */
506
507static int sched_torture_read_lock(void)
508{
509 preempt_disable();
510 return 0;
511}
512
513static void sched_torture_read_unlock(int idx)
514{
515 preempt_enable();
516}
517
518static int sched_torture_completed(void)
519{
520 return 0;
521}
522
2326974d
PM
523static void rcu_sched_torture_deferred_free(struct rcu_torture *p)
524{
525 call_rcu_sched(&p->rtort_rcu, rcu_torture_cb);
526}
527
4b6c2cca
JT
528static void sched_torture_synchronize(void)
529{
530 synchronize_sched();
531}
532
533static struct rcu_torture_ops sched_ops = {
534 .init = rcu_sync_torture_init,
535 .cleanup = NULL,
536 .readlock = sched_torture_read_lock,
537 .readdelay = rcu_read_delay, /* just reuse rcu's version. */
538 .readunlock = sched_torture_read_unlock,
539 .completed = sched_torture_completed,
2326974d 540 .deferredfree = rcu_sched_torture_deferred_free,
4b6c2cca 541 .sync = sched_torture_synchronize,
2326974d 542 .cb_barrier = rcu_barrier_sched,
4b6c2cca 543 .stats = NULL,
0729fbf3 544 .irqcapable = 1,
4b6c2cca
JT
545 .name = "sched"
546};
547
2326974d
PM
548static struct rcu_torture_ops sched_ops_sync = {
549 .init = rcu_sync_torture_init,
550 .cleanup = NULL,
551 .readlock = sched_torture_read_lock,
552 .readdelay = rcu_read_delay, /* just reuse rcu's version. */
553 .readunlock = sched_torture_read_unlock,
554 .completed = sched_torture_completed,
555 .deferredfree = rcu_sync_torture_deferred_free,
556 .sync = sched_torture_synchronize,
557 .cb_barrier = NULL,
558 .stats = NULL,
559 .name = "sched_sync"
560};
561
a241ec65
PM
562/*
563 * RCU torture writer kthread. Repeatedly substitutes a new structure
564 * for that pointed to by rcu_torture_current, freeing the old structure
565 * after a series of grace periods (the "pipeline").
566 */
567static int
568rcu_torture_writer(void *arg)
569{
570 int i;
571 long oldbatch = rcu_batches_completed();
572 struct rcu_torture *rp;
573 struct rcu_torture *old_rp;
574 static DEFINE_RCU_RANDOM(rand);
575
576 VERBOSE_PRINTK_STRING("rcu_torture_writer task started");
dbdf65b1
IM
577 set_user_nice(current, 19);
578
a241ec65
PM
579 do {
580 schedule_timeout_uninterruptible(1);
a241ec65
PM
581 if ((rp = rcu_torture_alloc()) == NULL)
582 continue;
583 rp->rtort_pipe_count = 0;
584 udelay(rcu_random(&rand) & 0x3ff);
585 old_rp = rcu_torture_current;
996417d2 586 rp->rtort_mbtest = 1;
a241ec65
PM
587 rcu_assign_pointer(rcu_torture_current, rp);
588 smp_wmb();
c8e5b163 589 if (old_rp) {
a241ec65
PM
590 i = old_rp->rtort_pipe_count;
591 if (i > RCU_TORTURE_PIPE_LEN)
592 i = RCU_TORTURE_PIPE_LEN;
593 atomic_inc(&rcu_torture_wcount[i]);
594 old_rp->rtort_pipe_count++;
72e9bb54 595 cur_ops->deferredfree(old_rp);
a241ec65
PM
596 }
597 rcu_torture_current_version++;
72e9bb54 598 oldbatch = cur_ops->completed();
d120f65f 599 rcu_stutter_wait();
a241ec65
PM
600 } while (!kthread_should_stop() && !fullstop);
601 VERBOSE_PRINTK_STRING("rcu_torture_writer task stopping");
602 while (!kthread_should_stop())
603 schedule_timeout_uninterruptible(1);
604 return 0;
605}
606
b772e1dd
JT
607/*
608 * RCU torture fake writer kthread. Repeatedly calls sync, with a random
609 * delay between calls.
610 */
611static int
612rcu_torture_fakewriter(void *arg)
613{
614 DEFINE_RCU_RANDOM(rand);
615
616 VERBOSE_PRINTK_STRING("rcu_torture_fakewriter task started");
617 set_user_nice(current, 19);
618
619 do {
620 schedule_timeout_uninterruptible(1 + rcu_random(&rand)%10);
621 udelay(rcu_random(&rand) & 0x3ff);
622 cur_ops->sync();
d120f65f 623 rcu_stutter_wait();
b772e1dd
JT
624 } while (!kthread_should_stop() && !fullstop);
625
626 VERBOSE_PRINTK_STRING("rcu_torture_fakewriter task stopping");
627 while (!kthread_should_stop())
628 schedule_timeout_uninterruptible(1);
629 return 0;
630}
631
0729fbf3
PM
632/*
633 * RCU torture reader from timer handler. Dereferences rcu_torture_current,
634 * incrementing the corresponding element of the pipeline array. The
635 * counter in the element should never be greater than 1, otherwise, the
636 * RCU implementation is broken.
637 */
638static void rcu_torture_timer(unsigned long unused)
639{
640 int idx;
641 int completed;
642 static DEFINE_RCU_RANDOM(rand);
643 static DEFINE_SPINLOCK(rand_lock);
644 struct rcu_torture *p;
645 int pipe_count;
646
647 idx = cur_ops->readlock();
648 completed = cur_ops->completed();
649 p = rcu_dereference(rcu_torture_current);
650 if (p == NULL) {
651 /* Leave because rcu_torture_writer is not yet underway */
652 cur_ops->readunlock(idx);
653 return;
654 }
655 if (p->rtort_mbtest == 0)
656 atomic_inc(&n_rcu_torture_mberror);
657 spin_lock(&rand_lock);
658 cur_ops->readdelay(&rand);
659 n_rcu_torture_timers++;
660 spin_unlock(&rand_lock);
661 preempt_disable();
662 pipe_count = p->rtort_pipe_count;
663 if (pipe_count > RCU_TORTURE_PIPE_LEN) {
664 /* Should not happen, but... */
665 pipe_count = RCU_TORTURE_PIPE_LEN;
666 }
667 ++__get_cpu_var(rcu_torture_count)[pipe_count];
668 completed = cur_ops->completed() - completed;
669 if (completed > RCU_TORTURE_PIPE_LEN) {
670 /* Should not happen, but... */
671 completed = RCU_TORTURE_PIPE_LEN;
672 }
673 ++__get_cpu_var(rcu_torture_batch)[completed];
674 preempt_enable();
675 cur_ops->readunlock(idx);
676}
677
a241ec65
PM
678/*
679 * RCU torture reader kthread. Repeatedly dereferences rcu_torture_current,
680 * incrementing the corresponding element of the pipeline array. The
681 * counter in the element should never be greater than 1, otherwise, the
682 * RCU implementation is broken.
683 */
684static int
685rcu_torture_reader(void *arg)
686{
687 int completed;
72e9bb54 688 int idx;
a241ec65
PM
689 DEFINE_RCU_RANDOM(rand);
690 struct rcu_torture *p;
691 int pipe_count;
0729fbf3 692 struct timer_list t;
a241ec65
PM
693
694 VERBOSE_PRINTK_STRING("rcu_torture_reader task started");
dbdf65b1 695 set_user_nice(current, 19);
0729fbf3
PM
696 if (irqreader && cur_ops->irqcapable)
697 setup_timer_on_stack(&t, rcu_torture_timer, 0);
dbdf65b1 698
a241ec65 699 do {
0729fbf3
PM
700 if (irqreader && cur_ops->irqcapable) {
701 if (!timer_pending(&t))
702 mod_timer(&t, 1);
703 }
72e9bb54
PM
704 idx = cur_ops->readlock();
705 completed = cur_ops->completed();
a241ec65
PM
706 p = rcu_dereference(rcu_torture_current);
707 if (p == NULL) {
708 /* Wait for rcu_torture_writer to get underway */
72e9bb54 709 cur_ops->readunlock(idx);
a241ec65
PM
710 schedule_timeout_interruptible(HZ);
711 continue;
712 }
996417d2
PM
713 if (p->rtort_mbtest == 0)
714 atomic_inc(&n_rcu_torture_mberror);
b2896d2e 715 cur_ops->readdelay(&rand);
a241ec65
PM
716 preempt_disable();
717 pipe_count = p->rtort_pipe_count;
718 if (pipe_count > RCU_TORTURE_PIPE_LEN) {
719 /* Should not happen, but... */
720 pipe_count = RCU_TORTURE_PIPE_LEN;
721 }
722 ++__get_cpu_var(rcu_torture_count)[pipe_count];
72e9bb54 723 completed = cur_ops->completed() - completed;
a241ec65
PM
724 if (completed > RCU_TORTURE_PIPE_LEN) {
725 /* Should not happen, but... */
726 completed = RCU_TORTURE_PIPE_LEN;
727 }
728 ++__get_cpu_var(rcu_torture_batch)[completed];
729 preempt_enable();
72e9bb54 730 cur_ops->readunlock(idx);
a241ec65 731 schedule();
d120f65f 732 rcu_stutter_wait();
a241ec65
PM
733 } while (!kthread_should_stop() && !fullstop);
734 VERBOSE_PRINTK_STRING("rcu_torture_reader task stopping");
0729fbf3
PM
735 if (irqreader && cur_ops->irqcapable)
736 del_timer_sync(&t);
a241ec65
PM
737 while (!kthread_should_stop())
738 schedule_timeout_uninterruptible(1);
739 return 0;
740}
741
742/*
743 * Create an RCU-torture statistics message in the specified buffer.
744 */
745static int
746rcu_torture_printk(char *page)
747{
748 int cnt = 0;
749 int cpu;
750 int i;
751 long pipesummary[RCU_TORTURE_PIPE_LEN + 1] = { 0 };
752 long batchsummary[RCU_TORTURE_PIPE_LEN + 1] = { 0 };
753
0a945022 754 for_each_possible_cpu(cpu) {
a241ec65
PM
755 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
756 pipesummary[i] += per_cpu(rcu_torture_count, cpu)[i];
757 batchsummary[i] += per_cpu(rcu_torture_batch, cpu)[i];
758 }
759 }
760 for (i = RCU_TORTURE_PIPE_LEN - 1; i >= 0; i--) {
761 if (pipesummary[i] != 0)
762 break;
763 }
72e9bb54 764 cnt += sprintf(&page[cnt], "%s%s ", torture_type, TORTURE_FLAG);
a241ec65 765 cnt += sprintf(&page[cnt],
996417d2 766 "rtc: %p ver: %ld tfle: %d rta: %d rtaf: %d rtf: %d "
0729fbf3 767 "rtmbe: %d nt: %ld",
a241ec65
PM
768 rcu_torture_current,
769 rcu_torture_current_version,
770 list_empty(&rcu_torture_freelist),
771 atomic_read(&n_rcu_torture_alloc),
772 atomic_read(&n_rcu_torture_alloc_fail),
996417d2 773 atomic_read(&n_rcu_torture_free),
0729fbf3
PM
774 atomic_read(&n_rcu_torture_mberror),
775 n_rcu_torture_timers);
996417d2
PM
776 if (atomic_read(&n_rcu_torture_mberror) != 0)
777 cnt += sprintf(&page[cnt], " !!!");
72e9bb54 778 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
996417d2 779 if (i > 1) {
a241ec65 780 cnt += sprintf(&page[cnt], "!!! ");
996417d2 781 atomic_inc(&n_rcu_torture_error);
5af970a4 782 WARN_ON_ONCE(1);
996417d2 783 }
a241ec65
PM
784 cnt += sprintf(&page[cnt], "Reader Pipe: ");
785 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
786 cnt += sprintf(&page[cnt], " %ld", pipesummary[i]);
72e9bb54 787 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
a241ec65 788 cnt += sprintf(&page[cnt], "Reader Batch: ");
72e9bb54 789 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
a241ec65 790 cnt += sprintf(&page[cnt], " %ld", batchsummary[i]);
72e9bb54 791 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
a241ec65
PM
792 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
793 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
794 cnt += sprintf(&page[cnt], " %d",
795 atomic_read(&rcu_torture_wcount[i]));
796 }
797 cnt += sprintf(&page[cnt], "\n");
c8e5b163 798 if (cur_ops->stats)
72e9bb54 799 cnt += cur_ops->stats(&page[cnt]);
a241ec65
PM
800 return cnt;
801}
802
803/*
804 * Print torture statistics. Caller must ensure that there is only
805 * one call to this function at a given time!!! This is normally
806 * accomplished by relying on the module system to only have one copy
807 * of the module loaded, and then by giving the rcu_torture_stats
808 * kthread full control (or the init/cleanup functions when rcu_torture_stats
809 * thread is not running).
810 */
811static void
812rcu_torture_stats_print(void)
813{
814 int cnt;
815
816 cnt = rcu_torture_printk(printk_buf);
817 printk(KERN_ALERT "%s", printk_buf);
818}
819
820/*
821 * Periodically prints torture statistics, if periodic statistics printing
822 * was specified via the stat_interval module parameter.
823 *
824 * No need to worry about fullstop here, since this one doesn't reference
825 * volatile state or register callbacks.
826 */
827static int
828rcu_torture_stats(void *arg)
829{
830 VERBOSE_PRINTK_STRING("rcu_torture_stats task started");
831 do {
832 schedule_timeout_interruptible(stat_interval * HZ);
833 rcu_torture_stats_print();
834 } while (!kthread_should_stop());
835 VERBOSE_PRINTK_STRING("rcu_torture_stats task stopping");
836 return 0;
837}
838
d84f5203
SV
839static int rcu_idle_cpu; /* Force all torture tasks off this CPU */
840
841/* Shuffle tasks such that we allow @rcu_idle_cpu to become idle. A special case
842 * is when @rcu_idle_cpu = -1, when we allow the tasks to run on all CPUs.
843 */
b2896d2e 844static void rcu_torture_shuffle_tasks(void)
d84f5203 845{
f70316da 846 cpumask_t tmp_mask;
d84f5203
SV
847 int i;
848
f70316da 849 cpus_setall(tmp_mask);
86ef5c9a 850 get_online_cpus();
d84f5203
SV
851
852 /* No point in shuffling if there is only one online CPU (ex: UP) */
853 if (num_online_cpus() == 1) {
86ef5c9a 854 put_online_cpus();
d84f5203
SV
855 return;
856 }
857
858 if (rcu_idle_cpu != -1)
859 cpu_clear(rcu_idle_cpu, tmp_mask);
860
f70316da 861 set_cpus_allowed_ptr(current, &tmp_mask);
d84f5203 862
c8e5b163 863 if (reader_tasks) {
d84f5203
SV
864 for (i = 0; i < nrealreaders; i++)
865 if (reader_tasks[i])
f70316da
MT
866 set_cpus_allowed_ptr(reader_tasks[i],
867 &tmp_mask);
d84f5203
SV
868 }
869
c8e5b163 870 if (fakewriter_tasks) {
b772e1dd
JT
871 for (i = 0; i < nfakewriters; i++)
872 if (fakewriter_tasks[i])
f70316da
MT
873 set_cpus_allowed_ptr(fakewriter_tasks[i],
874 &tmp_mask);
b772e1dd
JT
875 }
876
d84f5203 877 if (writer_task)
f70316da 878 set_cpus_allowed_ptr(writer_task, &tmp_mask);
d84f5203
SV
879
880 if (stats_task)
f70316da 881 set_cpus_allowed_ptr(stats_task, &tmp_mask);
d84f5203
SV
882
883 if (rcu_idle_cpu == -1)
884 rcu_idle_cpu = num_online_cpus() - 1;
885 else
886 rcu_idle_cpu--;
887
86ef5c9a 888 put_online_cpus();
d84f5203
SV
889}
890
891/* Shuffle tasks across CPUs, with the intent of allowing each CPU in the
892 * system to become idle at a time and cut off its timer ticks. This is meant
893 * to test the support for such tickless idle CPU in RCU.
894 */
895static int
896rcu_torture_shuffle(void *arg)
897{
898 VERBOSE_PRINTK_STRING("rcu_torture_shuffle task started");
899 do {
900 schedule_timeout_interruptible(shuffle_interval * HZ);
901 rcu_torture_shuffle_tasks();
902 } while (!kthread_should_stop());
903 VERBOSE_PRINTK_STRING("rcu_torture_shuffle task stopping");
904 return 0;
905}
906
d120f65f
PM
907/* Cause the rcutorture test to "stutter", starting and stopping all
908 * threads periodically.
909 */
910static int
911rcu_torture_stutter(void *arg)
912{
913 VERBOSE_PRINTK_STRING("rcu_torture_stutter task started");
914 do {
915 schedule_timeout_interruptible(stutter * HZ);
916 stutter_pause_test = 1;
917 if (!kthread_should_stop())
918 schedule_timeout_interruptible(stutter * HZ);
919 stutter_pause_test = 0;
920 } while (!kthread_should_stop());
921 VERBOSE_PRINTK_STRING("rcu_torture_stutter task stopping");
922 return 0;
923}
924
95c38322
PM
925static inline void
926rcu_torture_print_module_parms(char *tag)
927{
b772e1dd
JT
928 printk(KERN_ALERT "%s" TORTURE_FLAG
929 "--- %s: nreaders=%d nfakewriters=%d "
95c38322 930 "stat_interval=%d verbose=%d test_no_idle_hz=%d "
0729fbf3 931 "shuffle_interval=%d stutter=%d irqreader=%d\n",
b772e1dd 932 torture_type, tag, nrealreaders, nfakewriters,
d120f65f 933 stat_interval, verbose, test_no_idle_hz, shuffle_interval,
0729fbf3 934 stutter, irqreader);
95c38322
PM
935}
936
a241ec65
PM
937static void
938rcu_torture_cleanup(void)
939{
940 int i;
941
942 fullstop = 1;
d120f65f
PM
943 if (stutter_task) {
944 VERBOSE_PRINTK_STRING("Stopping rcu_torture_stutter task");
945 kthread_stop(stutter_task);
946 }
947 stutter_task = NULL;
c8e5b163 948 if (shuffler_task) {
d84f5203
SV
949 VERBOSE_PRINTK_STRING("Stopping rcu_torture_shuffle task");
950 kthread_stop(shuffler_task);
951 }
952 shuffler_task = NULL;
953
c8e5b163 954 if (writer_task) {
a241ec65
PM
955 VERBOSE_PRINTK_STRING("Stopping rcu_torture_writer task");
956 kthread_stop(writer_task);
957 }
958 writer_task = NULL;
959
c8e5b163 960 if (reader_tasks) {
a241ec65 961 for (i = 0; i < nrealreaders; i++) {
c8e5b163 962 if (reader_tasks[i]) {
a241ec65
PM
963 VERBOSE_PRINTK_STRING(
964 "Stopping rcu_torture_reader task");
965 kthread_stop(reader_tasks[i]);
966 }
967 reader_tasks[i] = NULL;
968 }
969 kfree(reader_tasks);
970 reader_tasks = NULL;
971 }
972 rcu_torture_current = NULL;
973
c8e5b163 974 if (fakewriter_tasks) {
b772e1dd 975 for (i = 0; i < nfakewriters; i++) {
c8e5b163 976 if (fakewriter_tasks[i]) {
b772e1dd
JT
977 VERBOSE_PRINTK_STRING(
978 "Stopping rcu_torture_fakewriter task");
979 kthread_stop(fakewriter_tasks[i]);
980 }
981 fakewriter_tasks[i] = NULL;
982 }
983 kfree(fakewriter_tasks);
984 fakewriter_tasks = NULL;
985 }
986
c8e5b163 987 if (stats_task) {
a241ec65
PM
988 VERBOSE_PRINTK_STRING("Stopping rcu_torture_stats task");
989 kthread_stop(stats_task);
990 }
991 stats_task = NULL;
992
993 /* Wait for all RCU callbacks to fire. */
2326974d
PM
994
995 if (cur_ops->cb_barrier != NULL)
996 cur_ops->cb_barrier();
a241ec65 997
a241ec65 998 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
72e9bb54 999
c8e5b163 1000 if (cur_ops->cleanup)
72e9bb54 1001 cur_ops->cleanup();
95c38322
PM
1002 if (atomic_read(&n_rcu_torture_error))
1003 rcu_torture_print_module_parms("End of test: FAILURE");
1004 else
1005 rcu_torture_print_module_parms("End of test: SUCCESS");
a241ec65
PM
1006}
1007
6f8bc500 1008static int __init
a241ec65
PM
1009rcu_torture_init(void)
1010{
1011 int i;
1012 int cpu;
1013 int firsterr = 0;
ade5fb81
JT
1014 static struct rcu_torture_ops *torture_ops[] =
1015 { &rcu_ops, &rcu_sync_ops, &rcu_bh_ops, &rcu_bh_sync_ops,
2326974d 1016 &srcu_ops, &sched_ops, &sched_ops_sync, };
a241ec65
PM
1017
1018 /* Process args and tell the world that the torturer is on the job. */
ade5fb81 1019 for (i = 0; i < ARRAY_SIZE(torture_ops); i++) {
72e9bb54 1020 cur_ops = torture_ops[i];
ade5fb81 1021 if (strcmp(torture_type, cur_ops->name) == 0)
72e9bb54 1022 break;
72e9bb54 1023 }
ade5fb81 1024 if (i == ARRAY_SIZE(torture_ops)) {
72e9bb54
PM
1025 printk(KERN_ALERT "rcutorture: invalid torture type: \"%s\"\n",
1026 torture_type);
1027 return (-EINVAL);
1028 }
c8e5b163 1029 if (cur_ops->init)
72e9bb54
PM
1030 cur_ops->init(); /* no "goto unwind" prior to this point!!! */
1031
a241ec65
PM
1032 if (nreaders >= 0)
1033 nrealreaders = nreaders;
1034 else
1035 nrealreaders = 2 * num_online_cpus();
95c38322 1036 rcu_torture_print_module_parms("Start of test");
a241ec65
PM
1037 fullstop = 0;
1038
1039 /* Set up the freelist. */
1040
1041 INIT_LIST_HEAD(&rcu_torture_freelist);
788e770e 1042 for (i = 0; i < ARRAY_SIZE(rcu_tortures); i++) {
996417d2 1043 rcu_tortures[i].rtort_mbtest = 0;
a241ec65
PM
1044 list_add_tail(&rcu_tortures[i].rtort_free,
1045 &rcu_torture_freelist);
1046 }
1047
1048 /* Initialize the statistics so that each run gets its own numbers. */
1049
1050 rcu_torture_current = NULL;
1051 rcu_torture_current_version = 0;
1052 atomic_set(&n_rcu_torture_alloc, 0);
1053 atomic_set(&n_rcu_torture_alloc_fail, 0);
1054 atomic_set(&n_rcu_torture_free, 0);
996417d2
PM
1055 atomic_set(&n_rcu_torture_mberror, 0);
1056 atomic_set(&n_rcu_torture_error, 0);
a241ec65
PM
1057 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
1058 atomic_set(&rcu_torture_wcount[i], 0);
0a945022 1059 for_each_possible_cpu(cpu) {
a241ec65
PM
1060 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
1061 per_cpu(rcu_torture_count, cpu)[i] = 0;
1062 per_cpu(rcu_torture_batch, cpu)[i] = 0;
1063 }
1064 }
1065
1066 /* Start up the kthreads. */
1067
1068 VERBOSE_PRINTK_STRING("Creating rcu_torture_writer task");
1069 writer_task = kthread_run(rcu_torture_writer, NULL,
1070 "rcu_torture_writer");
1071 if (IS_ERR(writer_task)) {
1072 firsterr = PTR_ERR(writer_task);
1073 VERBOSE_PRINTK_ERRSTRING("Failed to create writer");
1074 writer_task = NULL;
1075 goto unwind;
1076 }
b772e1dd
JT
1077 fakewriter_tasks = kzalloc(nfakewriters * sizeof(fakewriter_tasks[0]),
1078 GFP_KERNEL);
1079 if (fakewriter_tasks == NULL) {
1080 VERBOSE_PRINTK_ERRSTRING("out of memory");
1081 firsterr = -ENOMEM;
1082 goto unwind;
1083 }
1084 for (i = 0; i < nfakewriters; i++) {
1085 VERBOSE_PRINTK_STRING("Creating rcu_torture_fakewriter task");
1086 fakewriter_tasks[i] = kthread_run(rcu_torture_fakewriter, NULL,
1087 "rcu_torture_fakewriter");
1088 if (IS_ERR(fakewriter_tasks[i])) {
1089 firsterr = PTR_ERR(fakewriter_tasks[i]);
1090 VERBOSE_PRINTK_ERRSTRING("Failed to create fakewriter");
1091 fakewriter_tasks[i] = NULL;
1092 goto unwind;
1093 }
1094 }
2860aaba 1095 reader_tasks = kzalloc(nrealreaders * sizeof(reader_tasks[0]),
a241ec65
PM
1096 GFP_KERNEL);
1097 if (reader_tasks == NULL) {
1098 VERBOSE_PRINTK_ERRSTRING("out of memory");
1099 firsterr = -ENOMEM;
1100 goto unwind;
1101 }
1102 for (i = 0; i < nrealreaders; i++) {
1103 VERBOSE_PRINTK_STRING("Creating rcu_torture_reader task");
1104 reader_tasks[i] = kthread_run(rcu_torture_reader, NULL,
1105 "rcu_torture_reader");
1106 if (IS_ERR(reader_tasks[i])) {
1107 firsterr = PTR_ERR(reader_tasks[i]);
1108 VERBOSE_PRINTK_ERRSTRING("Failed to create reader");
1109 reader_tasks[i] = NULL;
1110 goto unwind;
1111 }
1112 }
1113 if (stat_interval > 0) {
1114 VERBOSE_PRINTK_STRING("Creating rcu_torture_stats task");
1115 stats_task = kthread_run(rcu_torture_stats, NULL,
1116 "rcu_torture_stats");
1117 if (IS_ERR(stats_task)) {
1118 firsterr = PTR_ERR(stats_task);
1119 VERBOSE_PRINTK_ERRSTRING("Failed to create stats");
1120 stats_task = NULL;
1121 goto unwind;
1122 }
1123 }
d84f5203
SV
1124 if (test_no_idle_hz) {
1125 rcu_idle_cpu = num_online_cpus() - 1;
1126 /* Create the shuffler thread */
1127 shuffler_task = kthread_run(rcu_torture_shuffle, NULL,
1128 "rcu_torture_shuffle");
1129 if (IS_ERR(shuffler_task)) {
1130 firsterr = PTR_ERR(shuffler_task);
1131 VERBOSE_PRINTK_ERRSTRING("Failed to create shuffler");
1132 shuffler_task = NULL;
1133 goto unwind;
1134 }
1135 }
d120f65f
PM
1136 if (stutter < 0)
1137 stutter = 0;
1138 if (stutter) {
1139 /* Create the stutter thread */
1140 stutter_task = kthread_run(rcu_torture_stutter, NULL,
1141 "rcu_torture_stutter");
1142 if (IS_ERR(stutter_task)) {
1143 firsterr = PTR_ERR(stutter_task);
1144 VERBOSE_PRINTK_ERRSTRING("Failed to create stutter");
1145 stutter_task = NULL;
1146 goto unwind;
1147 }
1148 }
a241ec65
PM
1149 return 0;
1150
1151unwind:
1152 rcu_torture_cleanup();
1153 return firsterr;
1154}
1155
1156module_init(rcu_torture_init);
1157module_exit(rcu_torture_cleanup);