blob: c224da41890cd3382b060ffb1567d3827f71e21c [file] [log] [blame]
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001/*
Paul E. McKenney29766f12006-06-27 02:54:02 -07002 * Read-Copy Update module-based torture test facility
Paul E. McKenneya241ec62005-10-30 15:03:12 -08003 *
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 *
Josh Triplettb772e1d2006-10-04 02:17:13 -070018 * Copyright (C) IBM Corporation, 2005, 2006
Paul E. McKenneya241ec62005-10-30 15:03:12 -080019 *
20 * Authors: Paul E. McKenney <paulmck@us.ibm.com>
Paul E. McKenneya71fca52009-09-18 10:28:19 -070021 * Josh Triplett <josh@freedesktop.org>
Paul E. McKenneya241ec62005-10-30 15:03:12 -080022 *
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>
Paul E. McKenneya241ec62005-10-30 15:03:12 -080038#include <linux/completion.h>
39#include <linux/moduleparam.h>
40#include <linux/percpu.h>
41#include <linux/notifier.h>
Paul E. McKenney343e9092008-12-15 16:13:07 -080042#include <linux/reboot.h>
Rafael J. Wysocki83144182007-07-17 04:03:35 -070043#include <linux/freezer.h>
Paul E. McKenneya241ec62005-10-30 15:03:12 -080044#include <linux/cpu.h>
Paul E. McKenneya241ec62005-10-30 15:03:12 -080045#include <linux/delay.h>
Paul E. McKenneya241ec62005-10-30 15:03:12 -080046#include <linux/stat.h>
Paul E. McKenneyb2896d22006-10-04 02:17:03 -070047#include <linux/srcu.h>
Robert P. J. Day1aeb2722008-04-29 00:59:25 -070048#include <linux/slab.h>
Harvey Harrisonf07767f2008-10-20 10:23:38 -070049#include <asm/byteorder.h>
Paul E. McKenneya241ec62005-10-30 15:03:12 -080050
51MODULE_LICENSE("GPL");
Josh Triplettb772e1d2006-10-04 02:17:13 -070052MODULE_AUTHOR("Paul E. McKenney <paulmck@us.ibm.com> and "
Paul E. McKenneya71fca52009-09-18 10:28:19 -070053 "Josh Triplett <josh@freedesktop.org>");
Paul E. McKenneya241ec62005-10-30 15:03:12 -080054
Josh Triplett48022112006-10-03 23:26:16 +020055static int nreaders = -1; /* # reader threads, defaults to 2*ncpus */
Josh Triplettb772e1d2006-10-04 02:17:13 -070056static int nfakewriters = 4; /* # fake writer threads */
Srivatsa Vaddagirid84f5202006-01-08 01:03:42 -080057static int stat_interval; /* Interval between stats, in seconds. */
Paul E. McKenneya241ec62005-10-30 15:03:12 -080058 /* Defaults to "only at end of test". */
Srivatsa Vaddagirid84f5202006-01-08 01:03:42 -080059static int verbose; /* Print more debug info. */
60static int test_no_idle_hz; /* Test RCU's support for tickless idle CPUs. */
Paul E. McKenneyd120f652008-06-18 05:21:44 -070061static int shuffle_interval = 3; /* Interval between shuffles (in sec)*/
62static int stutter = 5; /* Start/stop testing interval (in sec) */
Paul E. McKenney0729fbf2008-06-25 12:24:52 -070063static int irqreader = 1; /* RCU readers from irq (timers). */
Paul E. McKenneybf66f182010-01-04 15:09:10 -080064static int fqs_duration = 0; /* Duration of bursts (us), 0 to disable. */
65static int fqs_holdoff = 0; /* Hold time within burst (us). */
66static int fqs_stutter = 3; /* Wait time between bursts (s). */
Paul E. McKenney8e8be452010-09-02 16:16:14 -070067static int test_boost = 1; /* Test RCU prio boost: 0=no, 1=maybe, 2=yes. */
68static int test_boost_interval = 7; /* Interval between boost tests, seconds. */
69static int test_boost_duration = 4; /* Duration of each boost test, seconds. */
Josh Triplett20d2e422006-10-04 02:17:15 -070070static char *torture_type = "rcu"; /* What RCU implementation to torture. */
Paul E. McKenneya241ec62005-10-30 15:03:12 -080071
Josh Triplettd6ad6712007-03-06 01:42:13 -080072module_param(nreaders, int, 0444);
Paul E. McKenneya241ec62005-10-30 15:03:12 -080073MODULE_PARM_DESC(nreaders, "Number of RCU reader threads");
Josh Triplettd6ad6712007-03-06 01:42:13 -080074module_param(nfakewriters, int, 0444);
Josh Triplettb772e1d2006-10-04 02:17:13 -070075MODULE_PARM_DESC(nfakewriters, "Number of RCU fake writer threads");
Josh Triplettd6ad6712007-03-06 01:42:13 -080076module_param(stat_interval, int, 0444);
Paul E. McKenneya241ec62005-10-30 15:03:12 -080077MODULE_PARM_DESC(stat_interval, "Number of seconds between stats printk()s");
Josh Triplettd6ad6712007-03-06 01:42:13 -080078module_param(verbose, bool, 0444);
Paul E. McKenneya241ec62005-10-30 15:03:12 -080079MODULE_PARM_DESC(verbose, "Enable verbose debugging printk()s");
Josh Triplettd6ad6712007-03-06 01:42:13 -080080module_param(test_no_idle_hz, bool, 0444);
Srivatsa Vaddagirid84f5202006-01-08 01:03:42 -080081MODULE_PARM_DESC(test_no_idle_hz, "Test support for tickless idle CPUs");
Josh Triplettd6ad6712007-03-06 01:42:13 -080082module_param(shuffle_interval, int, 0444);
Srivatsa Vaddagirid84f5202006-01-08 01:03:42 -080083MODULE_PARM_DESC(shuffle_interval, "Number of seconds between shuffles");
Paul E. McKenneyd120f652008-06-18 05:21:44 -070084module_param(stutter, int, 0444);
85MODULE_PARM_DESC(stutter, "Number of seconds to run/halt test");
Paul E. McKenney0729fbf2008-06-25 12:24:52 -070086module_param(irqreader, int, 0444);
87MODULE_PARM_DESC(irqreader, "Allow RCU readers from irq handlers");
Paul E. McKenneybf66f182010-01-04 15:09:10 -080088module_param(fqs_duration, int, 0444);
89MODULE_PARM_DESC(fqs_duration, "Duration of fqs bursts (us)");
90module_param(fqs_holdoff, int, 0444);
91MODULE_PARM_DESC(fqs_holdoff, "Holdoff time within fqs bursts (us)");
92module_param(fqs_stutter, int, 0444);
93MODULE_PARM_DESC(fqs_stutter, "Wait time between fqs bursts (s)");
Paul E. McKenney8e8be452010-09-02 16:16:14 -070094module_param(test_boost, int, 0444);
95MODULE_PARM_DESC(test_boost, "Test RCU prio boost: 0=no, 1=maybe, 2=yes.");
96module_param(test_boost_interval, int, 0444);
97MODULE_PARM_DESC(test_boost_interval, "Interval between boost tests, seconds.");
98module_param(test_boost_duration, int, 0444);
99MODULE_PARM_DESC(test_boost_duration, "Duration of each boost test, seconds.");
Josh Triplettd6ad6712007-03-06 01:42:13 -0800100module_param(torture_type, charp, 0444);
Paul E. McKenneyb2896d22006-10-04 02:17:03 -0700101MODULE_PARM_DESC(torture_type, "Type of RCU to torture (rcu, rcu_bh, srcu)");
Paul E. McKenney72e9bb52006-06-27 02:54:03 -0700102
103#define TORTURE_FLAG "-torture:"
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800104#define PRINTK_STRING(s) \
Paul E. McKenney72e9bb52006-06-27 02:54:03 -0700105 do { printk(KERN_ALERT "%s" TORTURE_FLAG s "\n", torture_type); } while (0)
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800106#define VERBOSE_PRINTK_STRING(s) \
Paul E. McKenney72e9bb52006-06-27 02:54:03 -0700107 do { if (verbose) printk(KERN_ALERT "%s" TORTURE_FLAG s "\n", torture_type); } while (0)
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800108#define VERBOSE_PRINTK_ERRSTRING(s) \
Paul E. McKenney72e9bb52006-06-27 02:54:03 -0700109 do { if (verbose) printk(KERN_ALERT "%s" TORTURE_FLAG "!!! " s "\n", torture_type); } while (0)
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800110
111static char printk_buf[4096];
112
113static int nrealreaders;
114static struct task_struct *writer_task;
Josh Triplettb772e1d2006-10-04 02:17:13 -0700115static struct task_struct **fakewriter_tasks;
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800116static struct task_struct **reader_tasks;
117static struct task_struct *stats_task;
Srivatsa Vaddagirid84f5202006-01-08 01:03:42 -0800118static struct task_struct *shuffler_task;
Paul E. McKenneyd120f652008-06-18 05:21:44 -0700119static struct task_struct *stutter_task;
Paul E. McKenneybf66f182010-01-04 15:09:10 -0800120static struct task_struct *fqs_task;
Paul E. McKenney8e8be452010-09-02 16:16:14 -0700121static struct task_struct *boost_tasks[NR_CPUS];
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800122
123#define RCU_TORTURE_PIPE_LEN 10
124
125struct rcu_torture {
126 struct rcu_head rtort_rcu;
127 int rtort_pipe_count;
128 struct list_head rtort_free;
Paul E. McKenney996417d2005-11-18 01:10:50 -0800129 int rtort_mbtest;
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800130};
131
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800132static LIST_HEAD(rcu_torture_freelist);
Paul E. McKenney0ddea0e2010-09-19 21:06:14 -0700133static struct rcu_torture __rcu *rcu_torture_current;
Paul E. McKenneya71fca52009-09-18 10:28:19 -0700134static long rcu_torture_current_version;
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800135static struct rcu_torture rcu_tortures[10 * RCU_TORTURE_PIPE_LEN];
136static DEFINE_SPINLOCK(rcu_torture_lock);
137static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
138 { 0 };
139static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
140 { 0 };
141static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
Paul E. McKenneyb2896d22006-10-04 02:17:03 -0700142static atomic_t n_rcu_torture_alloc;
143static atomic_t n_rcu_torture_alloc_fail;
144static atomic_t n_rcu_torture_free;
145static atomic_t n_rcu_torture_mberror;
146static atomic_t n_rcu_torture_error;
Paul E. McKenney8e8be452010-09-02 16:16:14 -0700147static long n_rcu_torture_boost_ktrerror;
148static long n_rcu_torture_boost_rterror;
149static long n_rcu_torture_boost_allocerror;
150static long n_rcu_torture_boost_afferror;
151static long n_rcu_torture_boost_failure;
152static long n_rcu_torture_boosts;
Paul E. McKenneya71fca52009-09-18 10:28:19 -0700153static long n_rcu_torture_timers;
Josh Triplette3033732006-10-04 02:17:14 -0700154static struct list_head rcu_torture_removed;
Rusty Russell73d0a4b2009-03-30 22:05:16 -0600155static cpumask_var_t shuffle_tmp_mask;
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800156
Paul E. McKenneya71fca52009-09-18 10:28:19 -0700157static int stutter_pause_test;
Paul E. McKenneyd120f652008-06-18 05:21:44 -0700158
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700159#if defined(MODULE) || defined(CONFIG_RCU_TORTURE_TEST_RUNNABLE)
160#define RCUTORTURE_RUNNABLE_INIT 1
161#else
162#define RCUTORTURE_RUNNABLE_INIT 0
163#endif
164int rcutorture_runnable = RCUTORTURE_RUNNABLE_INIT;
165
Paul E. McKenney8e8be452010-09-02 16:16:14 -0700166#ifdef CONFIG_RCU_BOOST
167#define rcu_can_boost() 1
168#else /* #ifdef CONFIG_RCU_BOOST */
169#define rcu_can_boost() 0
170#endif /* #else #ifdef CONFIG_RCU_BOOST */
171
172static unsigned long boost_starttime; /* jiffies of next boost test start. */
173DEFINE_MUTEX(boost_mutex); /* protect setting boost_starttime */
174 /* and boost task create/destroy. */
175
Paul E. McKenneyc9d557c2009-01-07 14:33:30 -0800176/* Mediate rmmod and system shutdown. Concurrent rmmod & shutdown illegal! */
177
178#define FULLSTOP_DONTSTOP 0 /* Normal operation. */
179#define FULLSTOP_SHUTDOWN 1 /* System shutdown with rcutorture running. */
180#define FULLSTOP_RMMOD 2 /* Normal rmmod of rcutorture. */
181static int fullstop = FULLSTOP_RMMOD;
Paul E. McKenney0ddea0e2010-09-19 21:06:14 -0700182/*
183 * Protect fullstop transitions and spawning of kthreads.
184 */
185static DEFINE_MUTEX(fullstop_mutex);
Paul E. McKenney343e9092008-12-15 16:13:07 -0800186
187/*
Paul E. McKenneyc9d557c2009-01-07 14:33:30 -0800188 * Detect and respond to a system shutdown.
Paul E. McKenney343e9092008-12-15 16:13:07 -0800189 */
190static int
191rcutorture_shutdown_notify(struct notifier_block *unused1,
192 unsigned long unused2, void *unused3)
193{
Paul E. McKenneyc59ab972009-01-04 18:28:27 -0800194 mutex_lock(&fullstop_mutex);
Paul E. McKenneyc9d557c2009-01-07 14:33:30 -0800195 if (fullstop == FULLSTOP_DONTSTOP)
Paul E. McKenneyc59ab972009-01-04 18:28:27 -0800196 fullstop = FULLSTOP_SHUTDOWN;
Paul E. McKenneyc9d557c2009-01-07 14:33:30 -0800197 else
198 printk(KERN_WARNING /* but going down anyway, so... */
199 "Concurrent 'rmmod rcutorture' and shutdown illegal!\n");
Paul E. McKenneyc59ab972009-01-04 18:28:27 -0800200 mutex_unlock(&fullstop_mutex);
Paul E. McKenney343e9092008-12-15 16:13:07 -0800201 return NOTIFY_DONE;
202}
203
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800204/*
Paul E. McKenneyc9d557c2009-01-07 14:33:30 -0800205 * Absorb kthreads into a kernel function that won't return, so that
206 * they won't ever access module text or data again.
207 */
208static void rcutorture_shutdown_absorb(char *title)
209{
210 if (ACCESS_ONCE(fullstop) == FULLSTOP_SHUTDOWN) {
211 printk(KERN_NOTICE
212 "rcutorture thread %s parking due to system shutdown\n",
213 title);
214 schedule_timeout_uninterruptible(MAX_SCHEDULE_TIMEOUT);
215 }
216}
217
218/*
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800219 * Allocate an element from the rcu_tortures pool.
220 */
Adrian Bunk97a41e22006-01-08 01:02:17 -0800221static struct rcu_torture *
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800222rcu_torture_alloc(void)
223{
224 struct list_head *p;
225
Ingo Molnaradac1662006-01-25 19:50:12 +0100226 spin_lock_bh(&rcu_torture_lock);
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800227 if (list_empty(&rcu_torture_freelist)) {
228 atomic_inc(&n_rcu_torture_alloc_fail);
Ingo Molnaradac1662006-01-25 19:50:12 +0100229 spin_unlock_bh(&rcu_torture_lock);
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800230 return NULL;
231 }
232 atomic_inc(&n_rcu_torture_alloc);
233 p = rcu_torture_freelist.next;
234 list_del_init(p);
Ingo Molnaradac1662006-01-25 19:50:12 +0100235 spin_unlock_bh(&rcu_torture_lock);
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800236 return container_of(p, struct rcu_torture, rtort_free);
237}
238
239/*
240 * Free an element to the rcu_tortures pool.
241 */
242static void
243rcu_torture_free(struct rcu_torture *p)
244{
245 atomic_inc(&n_rcu_torture_free);
Ingo Molnaradac1662006-01-25 19:50:12 +0100246 spin_lock_bh(&rcu_torture_lock);
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800247 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
Ingo Molnaradac1662006-01-25 19:50:12 +0100248 spin_unlock_bh(&rcu_torture_lock);
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800249}
250
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800251struct rcu_random_state {
252 unsigned long rrs_state;
Josh Triplett75cfef32006-10-04 02:17:12 -0700253 long rrs_count;
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800254};
255
256#define RCU_RANDOM_MULT 39916801 /* prime */
257#define RCU_RANDOM_ADD 479001701 /* prime */
258#define RCU_RANDOM_REFRESH 10000
259
260#define DEFINE_RCU_RANDOM(name) struct rcu_random_state name = { 0, 0 }
261
262/*
263 * Crude but fast random-number generator. Uses a linear congruential
Paul E. McKenneyc17ac852007-10-16 23:27:19 -0700264 * generator, with occasional help from cpu_clock().
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800265 */
Josh Triplett75cfef32006-10-04 02:17:12 -0700266static unsigned long
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800267rcu_random(struct rcu_random_state *rrsp)
268{
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800269 if (--rrsp->rrs_count < 0) {
Peter Zijlstrac6763292010-05-25 10:48:51 +0200270 rrsp->rrs_state += (unsigned long)local_clock();
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800271 rrsp->rrs_count = RCU_RANDOM_REFRESH;
272 }
273 rrsp->rrs_state = rrsp->rrs_state * RCU_RANDOM_MULT + RCU_RANDOM_ADD;
274 return swahw32(rrsp->rrs_state);
275}
276
Paul E. McKenneyd120f652008-06-18 05:21:44 -0700277static void
Paul E. McKenneyc9d557c2009-01-07 14:33:30 -0800278rcu_stutter_wait(char *title)
Paul E. McKenneyd120f652008-06-18 05:21:44 -0700279{
Paul E. McKenneyc9d557c2009-01-07 14:33:30 -0800280 while (stutter_pause_test || !rcutorture_runnable) {
Paul E. McKenneye3d7be22008-06-22 13:06:38 -0700281 if (rcutorture_runnable)
282 schedule_timeout_interruptible(1);
283 else
Paul E. McKenney3ccf79f2008-06-22 14:02:55 -0700284 schedule_timeout_interruptible(round_jiffies_relative(HZ));
Paul E. McKenneyc9d557c2009-01-07 14:33:30 -0800285 rcutorture_shutdown_absorb(title);
Paul E. McKenney343e9092008-12-15 16:13:07 -0800286 }
Paul E. McKenneyd120f652008-06-18 05:21:44 -0700287}
288
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800289/*
Paul E. McKenney72e9bb52006-06-27 02:54:03 -0700290 * Operations vector for selecting different types of tests.
291 */
292
293struct rcu_torture_ops {
294 void (*init)(void);
295 void (*cleanup)(void);
296 int (*readlock)(void);
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700297 void (*read_delay)(struct rcu_random_state *rrsp);
Paul E. McKenney72e9bb52006-06-27 02:54:03 -0700298 void (*readunlock)(int idx);
299 int (*completed)(void);
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700300 void (*deferred_free)(struct rcu_torture *p);
Josh Triplettb772e1d2006-10-04 02:17:13 -0700301 void (*sync)(void);
Paul E. McKenney23269742008-05-12 21:21:05 +0200302 void (*cb_barrier)(void);
Paul E. McKenneybf66f182010-01-04 15:09:10 -0800303 void (*fqs)(void);
Paul E. McKenney72e9bb52006-06-27 02:54:03 -0700304 int (*stats)(char *page);
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700305 int irq_capable;
Paul E. McKenney8e8be452010-09-02 16:16:14 -0700306 int can_boost;
Paul E. McKenney72e9bb52006-06-27 02:54:03 -0700307 char *name;
308};
Paul E. McKenneya71fca52009-09-18 10:28:19 -0700309
310static struct rcu_torture_ops *cur_ops;
Paul E. McKenney72e9bb52006-06-27 02:54:03 -0700311
312/*
313 * Definitions for rcu torture testing.
314 */
315
Josh Tripletta49a4af2006-09-29 01:59:30 -0700316static int rcu_torture_read_lock(void) __acquires(RCU)
Paul E. McKenney72e9bb52006-06-27 02:54:03 -0700317{
318 rcu_read_lock();
319 return 0;
320}
321
Paul E. McKenneyb2896d22006-10-04 02:17:03 -0700322static void rcu_read_delay(struct rcu_random_state *rrsp)
323{
Josh Triplettb8d57a72009-09-08 15:54:35 -0700324 const unsigned long shortdelay_us = 200;
325 const unsigned long longdelay_ms = 50;
Paul E. McKenneyb2896d22006-10-04 02:17:03 -0700326
Josh Triplettb8d57a72009-09-08 15:54:35 -0700327 /* We want a short delay sometimes to make a reader delay the grace
328 * period, and we want a long delay occasionally to trigger
329 * force_quiescent_state. */
Paul E. McKenneyb2896d22006-10-04 02:17:03 -0700330
Josh Triplettb8d57a72009-09-08 15:54:35 -0700331 if (!(rcu_random(rrsp) % (nrealreaders * 2000 * longdelay_ms)))
332 mdelay(longdelay_ms);
333 if (!(rcu_random(rrsp) % (nrealreaders * 2 * shortdelay_us)))
334 udelay(shortdelay_us);
Lai Jiangshane546f482010-06-21 16:57:42 +0800335#ifdef CONFIG_PREEMPT
336 if (!preempt_count() && !(rcu_random(rrsp) % (nrealreaders * 20000)))
337 preempt_schedule(); /* No QS if preempt_disable() in effect */
338#endif
Paul E. McKenneyb2896d22006-10-04 02:17:03 -0700339}
340
Josh Tripletta49a4af2006-09-29 01:59:30 -0700341static void rcu_torture_read_unlock(int idx) __releases(RCU)
Paul E. McKenney72e9bb52006-06-27 02:54:03 -0700342{
343 rcu_read_unlock();
344}
345
346static int rcu_torture_completed(void)
347{
348 return rcu_batches_completed();
349}
350
351static void
352rcu_torture_cb(struct rcu_head *p)
353{
354 int i;
355 struct rcu_torture *rp = container_of(p, struct rcu_torture, rtort_rcu);
356
Paul E. McKenneyc9d557c2009-01-07 14:33:30 -0800357 if (fullstop != FULLSTOP_DONTSTOP) {
Paul E. McKenney72e9bb52006-06-27 02:54:03 -0700358 /* Test is ending, just drop callbacks on the floor. */
359 /* The next initialization will pick up the pieces. */
360 return;
361 }
362 i = rp->rtort_pipe_count;
363 if (i > RCU_TORTURE_PIPE_LEN)
364 i = RCU_TORTURE_PIPE_LEN;
365 atomic_inc(&rcu_torture_wcount[i]);
366 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
367 rp->rtort_mbtest = 0;
368 rcu_torture_free(rp);
369 } else
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700370 cur_ops->deferred_free(rp);
Paul E. McKenney72e9bb52006-06-27 02:54:03 -0700371}
372
Paul E. McKenneyd9a3da02009-12-02 12:10:15 -0800373static int rcu_no_completed(void)
374{
375 return 0;
376}
377
Paul E. McKenney72e9bb52006-06-27 02:54:03 -0700378static void rcu_torture_deferred_free(struct rcu_torture *p)
379{
380 call_rcu(&p->rtort_rcu, rcu_torture_cb);
381}
382
383static struct rcu_torture_ops rcu_ops = {
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700384 .init = NULL,
385 .cleanup = NULL,
386 .readlock = rcu_torture_read_lock,
387 .read_delay = rcu_read_delay,
388 .readunlock = rcu_torture_read_unlock,
389 .completed = rcu_torture_completed,
390 .deferred_free = rcu_torture_deferred_free,
391 .sync = synchronize_rcu,
392 .cb_barrier = rcu_barrier,
Paul E. McKenneybf66f182010-01-04 15:09:10 -0800393 .fqs = rcu_force_quiescent_state,
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700394 .stats = NULL,
Paul E. McKenneya71fca52009-09-18 10:28:19 -0700395 .irq_capable = 1,
Paul E. McKenney8e8be452010-09-02 16:16:14 -0700396 .can_boost = rcu_can_boost(),
Paul E. McKenneya71fca52009-09-18 10:28:19 -0700397 .name = "rcu"
Paul E. McKenney72e9bb52006-06-27 02:54:03 -0700398};
399
Josh Triplette3033732006-10-04 02:17:14 -0700400static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
401{
402 int i;
403 struct rcu_torture *rp;
404 struct rcu_torture *rp1;
405
406 cur_ops->sync();
407 list_add(&p->rtort_free, &rcu_torture_removed);
408 list_for_each_entry_safe(rp, rp1, &rcu_torture_removed, rtort_free) {
409 i = rp->rtort_pipe_count;
410 if (i > RCU_TORTURE_PIPE_LEN)
411 i = RCU_TORTURE_PIPE_LEN;
412 atomic_inc(&rcu_torture_wcount[i]);
413 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
414 rp->rtort_mbtest = 0;
415 list_del(&rp->rtort_free);
416 rcu_torture_free(rp);
417 }
418 }
419}
420
421static void rcu_sync_torture_init(void)
422{
423 INIT_LIST_HEAD(&rcu_torture_removed);
424}
425
Josh Triplett20d2e422006-10-04 02:17:15 -0700426static struct rcu_torture_ops rcu_sync_ops = {
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700427 .init = rcu_sync_torture_init,
428 .cleanup = NULL,
429 .readlock = rcu_torture_read_lock,
430 .read_delay = rcu_read_delay,
431 .readunlock = rcu_torture_read_unlock,
432 .completed = rcu_torture_completed,
433 .deferred_free = rcu_sync_torture_deferred_free,
434 .sync = synchronize_rcu,
435 .cb_barrier = NULL,
Paul E. McKenneybf66f182010-01-04 15:09:10 -0800436 .fqs = rcu_force_quiescent_state,
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700437 .stats = NULL,
438 .irq_capable = 1,
Paul E. McKenney8e8be452010-09-02 16:16:14 -0700439 .can_boost = rcu_can_boost(),
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700440 .name = "rcu_sync"
Josh Triplett20d2e422006-10-04 02:17:15 -0700441};
442
Paul E. McKenneyd9a3da02009-12-02 12:10:15 -0800443static struct rcu_torture_ops rcu_expedited_ops = {
444 .init = rcu_sync_torture_init,
445 .cleanup = NULL,
446 .readlock = rcu_torture_read_lock,
447 .read_delay = rcu_read_delay, /* just reuse rcu's version. */
448 .readunlock = rcu_torture_read_unlock,
449 .completed = rcu_no_completed,
450 .deferred_free = rcu_sync_torture_deferred_free,
451 .sync = synchronize_rcu_expedited,
452 .cb_barrier = NULL,
Paul E. McKenneybf66f182010-01-04 15:09:10 -0800453 .fqs = rcu_force_quiescent_state,
Paul E. McKenneyd9a3da02009-12-02 12:10:15 -0800454 .stats = NULL,
455 .irq_capable = 1,
Paul E. McKenney8e8be452010-09-02 16:16:14 -0700456 .can_boost = rcu_can_boost(),
Paul E. McKenneyd9a3da02009-12-02 12:10:15 -0800457 .name = "rcu_expedited"
458};
459
Paul E. McKenneyc32e0662006-06-27 02:54:04 -0700460/*
461 * Definitions for rcu_bh torture testing.
462 */
463
Josh Tripletta49a4af2006-09-29 01:59:30 -0700464static int rcu_bh_torture_read_lock(void) __acquires(RCU_BH)
Paul E. McKenneyc32e0662006-06-27 02:54:04 -0700465{
466 rcu_read_lock_bh();
467 return 0;
468}
469
Josh Tripletta49a4af2006-09-29 01:59:30 -0700470static void rcu_bh_torture_read_unlock(int idx) __releases(RCU_BH)
Paul E. McKenneyc32e0662006-06-27 02:54:04 -0700471{
472 rcu_read_unlock_bh();
473}
474
475static int rcu_bh_torture_completed(void)
476{
477 return rcu_batches_completed_bh();
478}
479
480static void rcu_bh_torture_deferred_free(struct rcu_torture *p)
481{
482 call_rcu_bh(&p->rtort_rcu, rcu_torture_cb);
483}
484
Josh Triplettb772e1d2006-10-04 02:17:13 -0700485struct rcu_bh_torture_synchronize {
486 struct rcu_head head;
487 struct completion completion;
488};
489
490static void rcu_bh_torture_wakeme_after_cb(struct rcu_head *head)
491{
492 struct rcu_bh_torture_synchronize *rcu;
493
494 rcu = container_of(head, struct rcu_bh_torture_synchronize, head);
495 complete(&rcu->completion);
496}
497
498static void rcu_bh_torture_synchronize(void)
499{
500 struct rcu_bh_torture_synchronize rcu;
501
Paul E. McKenney72d5a9f2010-05-10 17:12:17 -0700502 init_rcu_head_on_stack(&rcu.head);
Josh Triplettb772e1d2006-10-04 02:17:13 -0700503 init_completion(&rcu.completion);
504 call_rcu_bh(&rcu.head, rcu_bh_torture_wakeme_after_cb);
505 wait_for_completion(&rcu.completion);
Paul E. McKenney72d5a9f2010-05-10 17:12:17 -0700506 destroy_rcu_head_on_stack(&rcu.head);
Josh Triplettb772e1d2006-10-04 02:17:13 -0700507}
508
Paul E. McKenneyc32e0662006-06-27 02:54:04 -0700509static struct rcu_torture_ops rcu_bh_ops = {
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700510 .init = NULL,
511 .cleanup = NULL,
512 .readlock = rcu_bh_torture_read_lock,
513 .read_delay = rcu_read_delay, /* just reuse rcu's version. */
514 .readunlock = rcu_bh_torture_read_unlock,
515 .completed = rcu_bh_torture_completed,
516 .deferred_free = rcu_bh_torture_deferred_free,
517 .sync = rcu_bh_torture_synchronize,
518 .cb_barrier = rcu_barrier_bh,
Paul E. McKenneybf66f182010-01-04 15:09:10 -0800519 .fqs = rcu_bh_force_quiescent_state,
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700520 .stats = NULL,
521 .irq_capable = 1,
522 .name = "rcu_bh"
Paul E. McKenneyc32e0662006-06-27 02:54:04 -0700523};
524
Josh Triplett11a14702006-10-04 02:17:16 -0700525static struct rcu_torture_ops rcu_bh_sync_ops = {
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700526 .init = rcu_sync_torture_init,
527 .cleanup = NULL,
528 .readlock = rcu_bh_torture_read_lock,
529 .read_delay = rcu_read_delay, /* just reuse rcu's version. */
530 .readunlock = rcu_bh_torture_read_unlock,
531 .completed = rcu_bh_torture_completed,
532 .deferred_free = rcu_sync_torture_deferred_free,
533 .sync = rcu_bh_torture_synchronize,
534 .cb_barrier = NULL,
Paul E. McKenneybf66f182010-01-04 15:09:10 -0800535 .fqs = rcu_bh_force_quiescent_state,
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700536 .stats = NULL,
537 .irq_capable = 1,
538 .name = "rcu_bh_sync"
Josh Triplett11a14702006-10-04 02:17:16 -0700539};
540
Paul E. McKenneyb2896d22006-10-04 02:17:03 -0700541/*
542 * Definitions for srcu torture testing.
543 */
544
545static struct srcu_struct srcu_ctl;
Paul E. McKenneyb2896d22006-10-04 02:17:03 -0700546
547static void srcu_torture_init(void)
548{
549 init_srcu_struct(&srcu_ctl);
Josh Triplette3033732006-10-04 02:17:14 -0700550 rcu_sync_torture_init();
Paul E. McKenneyb2896d22006-10-04 02:17:03 -0700551}
552
553static void srcu_torture_cleanup(void)
554{
555 synchronize_srcu(&srcu_ctl);
556 cleanup_srcu_struct(&srcu_ctl);
557}
558
Josh Triplett012d3ca2006-12-06 20:40:19 -0800559static int srcu_torture_read_lock(void) __acquires(&srcu_ctl)
Paul E. McKenneyb2896d22006-10-04 02:17:03 -0700560{
561 return srcu_read_lock(&srcu_ctl);
562}
563
564static void srcu_read_delay(struct rcu_random_state *rrsp)
565{
566 long delay;
567 const long uspertick = 1000000 / HZ;
568 const long longdelay = 10;
569
570 /* We want there to be long-running readers, but not all the time. */
571
572 delay = rcu_random(rrsp) % (nrealreaders * 2 * longdelay * uspertick);
573 if (!delay)
574 schedule_timeout_interruptible(longdelay);
Lai Jiangshane546f482010-06-21 16:57:42 +0800575 else
576 rcu_read_delay(rrsp);
Paul E. McKenneyb2896d22006-10-04 02:17:03 -0700577}
578
Josh Triplett012d3ca2006-12-06 20:40:19 -0800579static void srcu_torture_read_unlock(int idx) __releases(&srcu_ctl)
Paul E. McKenneyb2896d22006-10-04 02:17:03 -0700580{
581 srcu_read_unlock(&srcu_ctl, idx);
582}
583
584static int srcu_torture_completed(void)
585{
586 return srcu_batches_completed(&srcu_ctl);
587}
588
Josh Triplettb772e1d2006-10-04 02:17:13 -0700589static void srcu_torture_synchronize(void)
590{
591 synchronize_srcu(&srcu_ctl);
592}
593
Paul E. McKenneyb2896d22006-10-04 02:17:03 -0700594static int srcu_torture_stats(char *page)
595{
596 int cnt = 0;
597 int cpu;
598 int idx = srcu_ctl.completed & 0x1;
599
600 cnt += sprintf(&page[cnt], "%s%s per-CPU(idx=%d):",
601 torture_type, TORTURE_FLAG, idx);
602 for_each_possible_cpu(cpu) {
603 cnt += sprintf(&page[cnt], " %d(%d,%d)", cpu,
604 per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[!idx],
605 per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[idx]);
606 }
607 cnt += sprintf(&page[cnt], "\n");
608 return cnt;
609}
610
611static struct rcu_torture_ops srcu_ops = {
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700612 .init = srcu_torture_init,
613 .cleanup = srcu_torture_cleanup,
614 .readlock = srcu_torture_read_lock,
615 .read_delay = srcu_read_delay,
616 .readunlock = srcu_torture_read_unlock,
617 .completed = srcu_torture_completed,
618 .deferred_free = rcu_sync_torture_deferred_free,
619 .sync = srcu_torture_synchronize,
620 .cb_barrier = NULL,
621 .stats = srcu_torture_stats,
622 .name = "srcu"
Paul E. McKenneyb2896d22006-10-04 02:17:03 -0700623};
624
Paul E. McKenney804bb832009-10-25 19:03:52 -0700625static void srcu_torture_synchronize_expedited(void)
626{
627 synchronize_srcu_expedited(&srcu_ctl);
628}
629
630static struct rcu_torture_ops srcu_expedited_ops = {
631 .init = srcu_torture_init,
632 .cleanup = srcu_torture_cleanup,
633 .readlock = srcu_torture_read_lock,
634 .read_delay = srcu_read_delay,
635 .readunlock = srcu_torture_read_unlock,
636 .completed = srcu_torture_completed,
637 .deferred_free = rcu_sync_torture_deferred_free,
638 .sync = srcu_torture_synchronize_expedited,
639 .cb_barrier = NULL,
640 .stats = srcu_torture_stats,
641 .name = "srcu_expedited"
642};
643
Josh Triplett4b6c2cc2006-10-04 02:17:16 -0700644/*
645 * Definitions for sched torture testing.
646 */
647
648static int sched_torture_read_lock(void)
649{
650 preempt_disable();
651 return 0;
652}
653
654static void sched_torture_read_unlock(int idx)
655{
656 preempt_enable();
657}
658
Paul E. McKenney23269742008-05-12 21:21:05 +0200659static void rcu_sched_torture_deferred_free(struct rcu_torture *p)
660{
661 call_rcu_sched(&p->rtort_rcu, rcu_torture_cb);
662}
663
Josh Triplett4b6c2cc2006-10-04 02:17:16 -0700664static void sched_torture_synchronize(void)
665{
666 synchronize_sched();
667}
668
669static struct rcu_torture_ops sched_ops = {
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700670 .init = rcu_sync_torture_init,
671 .cleanup = NULL,
672 .readlock = sched_torture_read_lock,
673 .read_delay = rcu_read_delay, /* just reuse rcu's version. */
674 .readunlock = sched_torture_read_unlock,
Paul E. McKenneyd9a3da02009-12-02 12:10:15 -0800675 .completed = rcu_no_completed,
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700676 .deferred_free = rcu_sched_torture_deferred_free,
677 .sync = sched_torture_synchronize,
678 .cb_barrier = rcu_barrier_sched,
Paul E. McKenneybf66f182010-01-04 15:09:10 -0800679 .fqs = rcu_sched_force_quiescent_state,
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700680 .stats = NULL,
681 .irq_capable = 1,
682 .name = "sched"
Josh Triplett4b6c2cc2006-10-04 02:17:16 -0700683};
684
Paul E. McKenney804bb832009-10-25 19:03:52 -0700685static struct rcu_torture_ops sched_sync_ops = {
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700686 .init = rcu_sync_torture_init,
687 .cleanup = NULL,
688 .readlock = sched_torture_read_lock,
689 .read_delay = rcu_read_delay, /* just reuse rcu's version. */
690 .readunlock = sched_torture_read_unlock,
Paul E. McKenneyd9a3da02009-12-02 12:10:15 -0800691 .completed = rcu_no_completed,
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700692 .deferred_free = rcu_sync_torture_deferred_free,
693 .sync = sched_torture_synchronize,
694 .cb_barrier = NULL,
Paul E. McKenneybf66f182010-01-04 15:09:10 -0800695 .fqs = rcu_sched_force_quiescent_state,
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700696 .stats = NULL,
697 .name = "sched_sync"
698};
699
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700700static struct rcu_torture_ops sched_expedited_ops = {
701 .init = rcu_sync_torture_init,
702 .cleanup = NULL,
703 .readlock = sched_torture_read_lock,
704 .read_delay = rcu_read_delay, /* just reuse rcu's version. */
705 .readunlock = sched_torture_read_unlock,
Paul E. McKenneyd9a3da02009-12-02 12:10:15 -0800706 .completed = rcu_no_completed,
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700707 .deferred_free = rcu_sync_torture_deferred_free,
708 .sync = synchronize_sched_expedited,
709 .cb_barrier = NULL,
Paul E. McKenneybf66f182010-01-04 15:09:10 -0800710 .fqs = rcu_sched_force_quiescent_state,
Tejun Heo969c7922010-05-06 18:49:21 +0200711 .stats = NULL,
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700712 .irq_capable = 1,
713 .name = "sched_expedited"
Paul E. McKenney23269742008-05-12 21:21:05 +0200714};
715
Paul E. McKenney72e9bb52006-06-27 02:54:03 -0700716/*
Paul E. McKenney8e8be452010-09-02 16:16:14 -0700717 * RCU torture priority-boost testing. Runs one real-time thread per
718 * CPU for moderate bursts, repeatedly registering RCU callbacks and
719 * spinning waiting for them to be invoked. If a given callback takes
720 * too long to be invoked, we assume that priority inversion has occurred.
721 */
722
723struct rcu_boost_inflight {
724 struct rcu_head rcu;
725 int inflight;
726};
727
728static void rcu_torture_boost_cb(struct rcu_head *head)
729{
730 struct rcu_boost_inflight *rbip =
731 container_of(head, struct rcu_boost_inflight, rcu);
732
733 smp_mb(); /* Ensure RCU-core accesses precede clearing ->inflight */
734 rbip->inflight = 0;
735}
736
737static int rcu_torture_boost(void *arg)
738{
739 unsigned long call_rcu_time;
740 unsigned long endtime;
741 unsigned long oldstarttime;
742 struct rcu_boost_inflight rbi = { .inflight = 0 };
743 struct sched_param sp;
744
745 VERBOSE_PRINTK_STRING("rcu_torture_boost started");
746
747 /* Set real-time priority. */
748 sp.sched_priority = 1;
749 if (sched_setscheduler(current, SCHED_FIFO, &sp) < 0) {
750 VERBOSE_PRINTK_STRING("rcu_torture_boost RT prio failed!");
751 n_rcu_torture_boost_rterror++;
752 }
753
754 /* Each pass through the following loop does one boost-test cycle. */
755 do {
756 /* Wait for the next test interval. */
757 oldstarttime = boost_starttime;
758 while (jiffies - oldstarttime > ULONG_MAX / 2) {
759 schedule_timeout_uninterruptible(1);
760 rcu_stutter_wait("rcu_torture_boost");
761 if (kthread_should_stop() ||
762 fullstop != FULLSTOP_DONTSTOP)
763 goto checkwait;
764 }
765
766 /* Do one boost-test interval. */
767 endtime = oldstarttime + test_boost_duration * HZ;
768 call_rcu_time = jiffies;
769 while (jiffies - endtime > ULONG_MAX / 2) {
770 /* If we don't have a callback in flight, post one. */
771 if (!rbi.inflight) {
772 smp_mb(); /* RCU core before ->inflight = 1. */
773 rbi.inflight = 1;
774 call_rcu(&rbi.rcu, rcu_torture_boost_cb);
775 if (jiffies - call_rcu_time >
776 test_boost_duration * HZ - HZ / 2) {
777 VERBOSE_PRINTK_STRING("rcu_torture_boost boosting failed");
778 n_rcu_torture_boost_failure++;
779 }
780 call_rcu_time = jiffies;
781 }
782 cond_resched();
783 rcu_stutter_wait("rcu_torture_boost");
784 if (kthread_should_stop() ||
785 fullstop != FULLSTOP_DONTSTOP)
786 goto checkwait;
787 }
788
789 /*
790 * Set the start time of the next test interval.
791 * Yes, this is vulnerable to long delays, but such
792 * delays simply cause a false negative for the next
793 * interval. Besides, we are running at RT priority,
794 * so delays should be relatively rare.
795 */
796 while (oldstarttime == boost_starttime) {
797 if (mutex_trylock(&boost_mutex)) {
798 boost_starttime = jiffies +
799 test_boost_interval * HZ;
800 n_rcu_torture_boosts++;
801 mutex_unlock(&boost_mutex);
802 break;
803 }
804 schedule_timeout_uninterruptible(1);
805 }
806
807 /* Go do the stutter. */
808checkwait: rcu_stutter_wait("rcu_torture_boost");
809 } while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP);
810
811 /* Clean up and exit. */
812 VERBOSE_PRINTK_STRING("rcu_torture_boost task stopping");
813 rcutorture_shutdown_absorb("rcu_torture_boost");
814 while (!kthread_should_stop() || rbi.inflight)
815 schedule_timeout_uninterruptible(1);
816 smp_mb(); /* order accesses to ->inflight before stack-frame death. */
817 return 0;
818}
819
820/*
Paul E. McKenneybf66f182010-01-04 15:09:10 -0800821 * RCU torture force-quiescent-state kthread. Repeatedly induces
822 * bursts of calls to force_quiescent_state(), increasing the probability
823 * of occurrence of some important types of race conditions.
824 */
825static int
826rcu_torture_fqs(void *arg)
827{
828 unsigned long fqs_resume_time;
829 int fqs_burst_remaining;
830
831 VERBOSE_PRINTK_STRING("rcu_torture_fqs task started");
832 do {
833 fqs_resume_time = jiffies + fqs_stutter * HZ;
834 while (jiffies - fqs_resume_time > LONG_MAX) {
835 schedule_timeout_interruptible(1);
836 }
837 fqs_burst_remaining = fqs_duration;
838 while (fqs_burst_remaining > 0) {
839 cur_ops->fqs();
840 udelay(fqs_holdoff);
841 fqs_burst_remaining -= fqs_holdoff;
842 }
843 rcu_stutter_wait("rcu_torture_fqs");
844 } while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP);
845 VERBOSE_PRINTK_STRING("rcu_torture_fqs task stopping");
846 rcutorture_shutdown_absorb("rcu_torture_fqs");
847 while (!kthread_should_stop())
848 schedule_timeout_uninterruptible(1);
849 return 0;
850}
851
852/*
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800853 * RCU torture writer kthread. Repeatedly substitutes a new structure
854 * for that pointed to by rcu_torture_current, freeing the old structure
855 * after a series of grace periods (the "pipeline").
856 */
857static int
858rcu_torture_writer(void *arg)
859{
860 int i;
861 long oldbatch = rcu_batches_completed();
862 struct rcu_torture *rp;
863 struct rcu_torture *old_rp;
864 static DEFINE_RCU_RANDOM(rand);
865
866 VERBOSE_PRINTK_STRING("rcu_torture_writer task started");
Ingo Molnardbdf65b2005-11-13 16:07:22 -0800867 set_user_nice(current, 19);
868
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800869 do {
870 schedule_timeout_uninterruptible(1);
Paul E. McKenneya71fca52009-09-18 10:28:19 -0700871 rp = rcu_torture_alloc();
872 if (rp == NULL)
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800873 continue;
874 rp->rtort_pipe_count = 0;
875 udelay(rcu_random(&rand) & 0x3ff);
Paul E. McKenney0ddea0e2010-09-19 21:06:14 -0700876 old_rp = rcu_dereference_check(rcu_torture_current,
877 current == writer_task);
Paul E. McKenney996417d2005-11-18 01:10:50 -0800878 rp->rtort_mbtest = 1;
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800879 rcu_assign_pointer(rcu_torture_current, rp);
Paul E. McKenney9b2619a2009-09-23 09:50:43 -0700880 smp_wmb(); /* Mods to old_rp must follow rcu_assign_pointer() */
Josh Triplettc8e5b162007-05-08 00:33:20 -0700881 if (old_rp) {
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800882 i = old_rp->rtort_pipe_count;
883 if (i > RCU_TORTURE_PIPE_LEN)
884 i = RCU_TORTURE_PIPE_LEN;
885 atomic_inc(&rcu_torture_wcount[i]);
886 old_rp->rtort_pipe_count++;
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700887 cur_ops->deferred_free(old_rp);
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800888 }
889 rcu_torture_current_version++;
Paul E. McKenney72e9bb52006-06-27 02:54:03 -0700890 oldbatch = cur_ops->completed();
Paul E. McKenneyc9d557c2009-01-07 14:33:30 -0800891 rcu_stutter_wait("rcu_torture_writer");
892 } while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP);
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800893 VERBOSE_PRINTK_STRING("rcu_torture_writer task stopping");
Paul E. McKenneyc9d557c2009-01-07 14:33:30 -0800894 rcutorture_shutdown_absorb("rcu_torture_writer");
895 while (!kthread_should_stop())
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800896 schedule_timeout_uninterruptible(1);
897 return 0;
898}
899
900/*
Josh Triplettb772e1d2006-10-04 02:17:13 -0700901 * RCU torture fake writer kthread. Repeatedly calls sync, with a random
902 * delay between calls.
903 */
904static int
905rcu_torture_fakewriter(void *arg)
906{
907 DEFINE_RCU_RANDOM(rand);
908
909 VERBOSE_PRINTK_STRING("rcu_torture_fakewriter task started");
910 set_user_nice(current, 19);
911
912 do {
913 schedule_timeout_uninterruptible(1 + rcu_random(&rand)%10);
914 udelay(rcu_random(&rand) & 0x3ff);
915 cur_ops->sync();
Paul E. McKenneyc9d557c2009-01-07 14:33:30 -0800916 rcu_stutter_wait("rcu_torture_fakewriter");
917 } while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP);
Josh Triplettb772e1d2006-10-04 02:17:13 -0700918
919 VERBOSE_PRINTK_STRING("rcu_torture_fakewriter task stopping");
Paul E. McKenneyc9d557c2009-01-07 14:33:30 -0800920 rcutorture_shutdown_absorb("rcu_torture_fakewriter");
921 while (!kthread_should_stop())
Josh Triplettb772e1d2006-10-04 02:17:13 -0700922 schedule_timeout_uninterruptible(1);
923 return 0;
924}
925
926/*
Paul E. McKenney0729fbf2008-06-25 12:24:52 -0700927 * RCU torture reader from timer handler. Dereferences rcu_torture_current,
928 * incrementing the corresponding element of the pipeline array. The
929 * counter in the element should never be greater than 1, otherwise, the
930 * RCU implementation is broken.
931 */
932static void rcu_torture_timer(unsigned long unused)
933{
934 int idx;
935 int completed;
936 static DEFINE_RCU_RANDOM(rand);
937 static DEFINE_SPINLOCK(rand_lock);
938 struct rcu_torture *p;
939 int pipe_count;
940
941 idx = cur_ops->readlock();
942 completed = cur_ops->completed();
Paul E. McKenney632ee202010-02-22 17:04:45 -0800943 p = rcu_dereference_check(rcu_torture_current,
944 rcu_read_lock_held() ||
945 rcu_read_lock_bh_held() ||
946 rcu_read_lock_sched_held() ||
947 srcu_read_lock_held(&srcu_ctl));
Paul E. McKenney0729fbf2008-06-25 12:24:52 -0700948 if (p == NULL) {
949 /* Leave because rcu_torture_writer is not yet underway */
950 cur_ops->readunlock(idx);
951 return;
952 }
953 if (p->rtort_mbtest == 0)
954 atomic_inc(&n_rcu_torture_mberror);
955 spin_lock(&rand_lock);
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700956 cur_ops->read_delay(&rand);
Paul E. McKenney0729fbf2008-06-25 12:24:52 -0700957 n_rcu_torture_timers++;
958 spin_unlock(&rand_lock);
959 preempt_disable();
960 pipe_count = p->rtort_pipe_count;
961 if (pipe_count > RCU_TORTURE_PIPE_LEN) {
962 /* Should not happen, but... */
963 pipe_count = RCU_TORTURE_PIPE_LEN;
964 }
Rusty Russelldd17c8f2009-10-29 22:34:15 +0900965 __this_cpu_inc(rcu_torture_count[pipe_count]);
Paul E. McKenney0729fbf2008-06-25 12:24:52 -0700966 completed = cur_ops->completed() - completed;
967 if (completed > RCU_TORTURE_PIPE_LEN) {
968 /* Should not happen, but... */
969 completed = RCU_TORTURE_PIPE_LEN;
970 }
Rusty Russelldd17c8f2009-10-29 22:34:15 +0900971 __this_cpu_inc(rcu_torture_batch[completed]);
Paul E. McKenney0729fbf2008-06-25 12:24:52 -0700972 preempt_enable();
973 cur_ops->readunlock(idx);
974}
975
976/*
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800977 * RCU torture reader kthread. Repeatedly dereferences rcu_torture_current,
978 * incrementing the corresponding element of the pipeline array. The
979 * counter in the element should never be greater than 1, otherwise, the
980 * RCU implementation is broken.
981 */
982static int
983rcu_torture_reader(void *arg)
984{
985 int completed;
Paul E. McKenney72e9bb52006-06-27 02:54:03 -0700986 int idx;
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800987 DEFINE_RCU_RANDOM(rand);
988 struct rcu_torture *p;
989 int pipe_count;
Paul E. McKenney0729fbf2008-06-25 12:24:52 -0700990 struct timer_list t;
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800991
992 VERBOSE_PRINTK_STRING("rcu_torture_reader task started");
Ingo Molnardbdf65b2005-11-13 16:07:22 -0800993 set_user_nice(current, 19);
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700994 if (irqreader && cur_ops->irq_capable)
Paul E. McKenney0729fbf2008-06-25 12:24:52 -0700995 setup_timer_on_stack(&t, rcu_torture_timer, 0);
Ingo Molnardbdf65b2005-11-13 16:07:22 -0800996
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800997 do {
Paul E. McKenney0acc5122009-06-25 09:08:17 -0700998 if (irqreader && cur_ops->irq_capable) {
Paul E. McKenney0729fbf2008-06-25 12:24:52 -0700999 if (!timer_pending(&t))
Paul E. McKenney6155fec2010-02-22 17:05:04 -08001000 mod_timer(&t, jiffies + 1);
Paul E. McKenney0729fbf2008-06-25 12:24:52 -07001001 }
Paul E. McKenney72e9bb52006-06-27 02:54:03 -07001002 idx = cur_ops->readlock();
1003 completed = cur_ops->completed();
Paul E. McKenney632ee202010-02-22 17:04:45 -08001004 p = rcu_dereference_check(rcu_torture_current,
1005 rcu_read_lock_held() ||
1006 rcu_read_lock_bh_held() ||
1007 rcu_read_lock_sched_held() ||
1008 srcu_read_lock_held(&srcu_ctl));
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001009 if (p == NULL) {
1010 /* Wait for rcu_torture_writer to get underway */
Paul E. McKenney72e9bb52006-06-27 02:54:03 -07001011 cur_ops->readunlock(idx);
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001012 schedule_timeout_interruptible(HZ);
1013 continue;
1014 }
Paul E. McKenney996417d2005-11-18 01:10:50 -08001015 if (p->rtort_mbtest == 0)
1016 atomic_inc(&n_rcu_torture_mberror);
Paul E. McKenney0acc5122009-06-25 09:08:17 -07001017 cur_ops->read_delay(&rand);
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001018 preempt_disable();
1019 pipe_count = p->rtort_pipe_count;
1020 if (pipe_count > RCU_TORTURE_PIPE_LEN) {
1021 /* Should not happen, but... */
1022 pipe_count = RCU_TORTURE_PIPE_LEN;
1023 }
Rusty Russelldd17c8f2009-10-29 22:34:15 +09001024 __this_cpu_inc(rcu_torture_count[pipe_count]);
Paul E. McKenney72e9bb52006-06-27 02:54:03 -07001025 completed = cur_ops->completed() - completed;
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001026 if (completed > RCU_TORTURE_PIPE_LEN) {
1027 /* Should not happen, but... */
1028 completed = RCU_TORTURE_PIPE_LEN;
1029 }
Rusty Russelldd17c8f2009-10-29 22:34:15 +09001030 __this_cpu_inc(rcu_torture_batch[completed]);
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001031 preempt_enable();
Paul E. McKenney72e9bb52006-06-27 02:54:03 -07001032 cur_ops->readunlock(idx);
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001033 schedule();
Paul E. McKenneyc9d557c2009-01-07 14:33:30 -08001034 rcu_stutter_wait("rcu_torture_reader");
1035 } while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP);
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001036 VERBOSE_PRINTK_STRING("rcu_torture_reader task stopping");
Paul E. McKenneyc9d557c2009-01-07 14:33:30 -08001037 rcutorture_shutdown_absorb("rcu_torture_reader");
Paul E. McKenney0acc5122009-06-25 09:08:17 -07001038 if (irqreader && cur_ops->irq_capable)
Paul E. McKenney0729fbf2008-06-25 12:24:52 -07001039 del_timer_sync(&t);
Paul E. McKenneyc9d557c2009-01-07 14:33:30 -08001040 while (!kthread_should_stop())
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001041 schedule_timeout_uninterruptible(1);
1042 return 0;
1043}
1044
1045/*
1046 * Create an RCU-torture statistics message in the specified buffer.
1047 */
1048static int
1049rcu_torture_printk(char *page)
1050{
1051 int cnt = 0;
1052 int cpu;
1053 int i;
1054 long pipesummary[RCU_TORTURE_PIPE_LEN + 1] = { 0 };
1055 long batchsummary[RCU_TORTURE_PIPE_LEN + 1] = { 0 };
1056
KAMEZAWA Hiroyuki0a945022006-03-28 01:56:37 -08001057 for_each_possible_cpu(cpu) {
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001058 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
1059 pipesummary[i] += per_cpu(rcu_torture_count, cpu)[i];
1060 batchsummary[i] += per_cpu(rcu_torture_batch, cpu)[i];
1061 }
1062 }
1063 for (i = RCU_TORTURE_PIPE_LEN - 1; i >= 0; i--) {
1064 if (pipesummary[i] != 0)
1065 break;
1066 }
Paul E. McKenney72e9bb52006-06-27 02:54:03 -07001067 cnt += sprintf(&page[cnt], "%s%s ", torture_type, TORTURE_FLAG);
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001068 cnt += sprintf(&page[cnt],
Paul E. McKenney996417d2005-11-18 01:10:50 -08001069 "rtc: %p ver: %ld tfle: %d rta: %d rtaf: %d rtf: %d "
Paul E. McKenney8e8be452010-09-02 16:16:14 -07001070 "rtmbe: %d rtbke: %ld rtbre: %ld rtbae: %ld rtbafe: %ld "
1071 "rtbf: %ld rtb: %ld nt: %ld",
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001072 rcu_torture_current,
1073 rcu_torture_current_version,
1074 list_empty(&rcu_torture_freelist),
1075 atomic_read(&n_rcu_torture_alloc),
1076 atomic_read(&n_rcu_torture_alloc_fail),
Paul E. McKenney996417d2005-11-18 01:10:50 -08001077 atomic_read(&n_rcu_torture_free),
Paul E. McKenney0729fbf2008-06-25 12:24:52 -07001078 atomic_read(&n_rcu_torture_mberror),
Paul E. McKenney8e8be452010-09-02 16:16:14 -07001079 n_rcu_torture_boost_ktrerror,
1080 n_rcu_torture_boost_rterror,
1081 n_rcu_torture_boost_allocerror,
1082 n_rcu_torture_boost_afferror,
1083 n_rcu_torture_boost_failure,
1084 n_rcu_torture_boosts,
Paul E. McKenney0729fbf2008-06-25 12:24:52 -07001085 n_rcu_torture_timers);
Paul E. McKenney8e8be452010-09-02 16:16:14 -07001086 if (atomic_read(&n_rcu_torture_mberror) != 0 ||
1087 n_rcu_torture_boost_ktrerror != 0 ||
1088 n_rcu_torture_boost_rterror != 0 ||
1089 n_rcu_torture_boost_allocerror != 0 ||
1090 n_rcu_torture_boost_afferror != 0 ||
1091 n_rcu_torture_boost_failure != 0)
Paul E. McKenney996417d2005-11-18 01:10:50 -08001092 cnt += sprintf(&page[cnt], " !!!");
Paul E. McKenney72e9bb52006-06-27 02:54:03 -07001093 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
Paul E. McKenney996417d2005-11-18 01:10:50 -08001094 if (i > 1) {
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001095 cnt += sprintf(&page[cnt], "!!! ");
Paul E. McKenney996417d2005-11-18 01:10:50 -08001096 atomic_inc(&n_rcu_torture_error);
Ingo Molnar5af970a2008-06-18 10:09:48 +02001097 WARN_ON_ONCE(1);
Paul E. McKenney996417d2005-11-18 01:10:50 -08001098 }
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001099 cnt += sprintf(&page[cnt], "Reader Pipe: ");
1100 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
1101 cnt += sprintf(&page[cnt], " %ld", pipesummary[i]);
Paul E. McKenney72e9bb52006-06-27 02:54:03 -07001102 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001103 cnt += sprintf(&page[cnt], "Reader Batch: ");
Paul E. McKenney72e9bb52006-06-27 02:54:03 -07001104 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001105 cnt += sprintf(&page[cnt], " %ld", batchsummary[i]);
Paul E. McKenney72e9bb52006-06-27 02:54:03 -07001106 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001107 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
1108 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
1109 cnt += sprintf(&page[cnt], " %d",
1110 atomic_read(&rcu_torture_wcount[i]));
1111 }
1112 cnt += sprintf(&page[cnt], "\n");
Josh Triplettc8e5b162007-05-08 00:33:20 -07001113 if (cur_ops->stats)
Paul E. McKenney72e9bb52006-06-27 02:54:03 -07001114 cnt += cur_ops->stats(&page[cnt]);
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001115 return cnt;
1116}
1117
1118/*
1119 * Print torture statistics. Caller must ensure that there is only
1120 * one call to this function at a given time!!! This is normally
1121 * accomplished by relying on the module system to only have one copy
1122 * of the module loaded, and then by giving the rcu_torture_stats
1123 * kthread full control (or the init/cleanup functions when rcu_torture_stats
1124 * thread is not running).
1125 */
1126static void
1127rcu_torture_stats_print(void)
1128{
1129 int cnt;
1130
1131 cnt = rcu_torture_printk(printk_buf);
1132 printk(KERN_ALERT "%s", printk_buf);
1133}
1134
1135/*
1136 * Periodically prints torture statistics, if periodic statistics printing
1137 * was specified via the stat_interval module parameter.
1138 *
1139 * No need to worry about fullstop here, since this one doesn't reference
1140 * volatile state or register callbacks.
1141 */
1142static int
1143rcu_torture_stats(void *arg)
1144{
1145 VERBOSE_PRINTK_STRING("rcu_torture_stats task started");
1146 do {
1147 schedule_timeout_interruptible(stat_interval * HZ);
1148 rcu_torture_stats_print();
Paul E. McKenneyc9d557c2009-01-07 14:33:30 -08001149 rcutorture_shutdown_absorb("rcu_torture_stats");
1150 } while (!kthread_should_stop());
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001151 VERBOSE_PRINTK_STRING("rcu_torture_stats task stopping");
1152 return 0;
1153}
1154
Srivatsa Vaddagirid84f5202006-01-08 01:03:42 -08001155static int rcu_idle_cpu; /* Force all torture tasks off this CPU */
1156
1157/* Shuffle tasks such that we allow @rcu_idle_cpu to become idle. A special case
1158 * is when @rcu_idle_cpu = -1, when we allow the tasks to run on all CPUs.
1159 */
Paul E. McKenneyb2896d22006-10-04 02:17:03 -07001160static void rcu_torture_shuffle_tasks(void)
Srivatsa Vaddagirid84f5202006-01-08 01:03:42 -08001161{
Srivatsa Vaddagirid84f5202006-01-08 01:03:42 -08001162 int i;
1163
Rusty Russell73d0a4b2009-03-30 22:05:16 -06001164 cpumask_setall(shuffle_tmp_mask);
Gautham R Shenoy86ef5c92008-01-25 21:08:02 +01001165 get_online_cpus();
Srivatsa Vaddagirid84f5202006-01-08 01:03:42 -08001166
1167 /* No point in shuffling if there is only one online CPU (ex: UP) */
Paul E. McKenneyc9d557c2009-01-07 14:33:30 -08001168 if (num_online_cpus() == 1) {
1169 put_online_cpus();
1170 return;
1171 }
Srivatsa Vaddagirid84f5202006-01-08 01:03:42 -08001172
1173 if (rcu_idle_cpu != -1)
Rusty Russell73d0a4b2009-03-30 22:05:16 -06001174 cpumask_clear_cpu(rcu_idle_cpu, shuffle_tmp_mask);
Srivatsa Vaddagirid84f5202006-01-08 01:03:42 -08001175
Rusty Russell73d0a4b2009-03-30 22:05:16 -06001176 set_cpus_allowed_ptr(current, shuffle_tmp_mask);
Srivatsa Vaddagirid84f5202006-01-08 01:03:42 -08001177
Josh Triplettc8e5b162007-05-08 00:33:20 -07001178 if (reader_tasks) {
Srivatsa Vaddagirid84f5202006-01-08 01:03:42 -08001179 for (i = 0; i < nrealreaders; i++)
1180 if (reader_tasks[i])
Mike Travisf70316d2008-04-04 18:11:06 -07001181 set_cpus_allowed_ptr(reader_tasks[i],
Rusty Russell73d0a4b2009-03-30 22:05:16 -06001182 shuffle_tmp_mask);
Srivatsa Vaddagirid84f5202006-01-08 01:03:42 -08001183 }
1184
Josh Triplettc8e5b162007-05-08 00:33:20 -07001185 if (fakewriter_tasks) {
Josh Triplettb772e1d2006-10-04 02:17:13 -07001186 for (i = 0; i < nfakewriters; i++)
1187 if (fakewriter_tasks[i])
Mike Travisf70316d2008-04-04 18:11:06 -07001188 set_cpus_allowed_ptr(fakewriter_tasks[i],
Rusty Russell73d0a4b2009-03-30 22:05:16 -06001189 shuffle_tmp_mask);
Josh Triplettb772e1d2006-10-04 02:17:13 -07001190 }
1191
Srivatsa Vaddagirid84f5202006-01-08 01:03:42 -08001192 if (writer_task)
Rusty Russell73d0a4b2009-03-30 22:05:16 -06001193 set_cpus_allowed_ptr(writer_task, shuffle_tmp_mask);
Srivatsa Vaddagirid84f5202006-01-08 01:03:42 -08001194
1195 if (stats_task)
Rusty Russell73d0a4b2009-03-30 22:05:16 -06001196 set_cpus_allowed_ptr(stats_task, shuffle_tmp_mask);
Srivatsa Vaddagirid84f5202006-01-08 01:03:42 -08001197
1198 if (rcu_idle_cpu == -1)
1199 rcu_idle_cpu = num_online_cpus() - 1;
1200 else
1201 rcu_idle_cpu--;
1202
Gautham R Shenoy86ef5c92008-01-25 21:08:02 +01001203 put_online_cpus();
Srivatsa Vaddagirid84f5202006-01-08 01:03:42 -08001204}
1205
1206/* Shuffle tasks across CPUs, with the intent of allowing each CPU in the
1207 * system to become idle at a time and cut off its timer ticks. This is meant
1208 * to test the support for such tickless idle CPU in RCU.
1209 */
1210static int
1211rcu_torture_shuffle(void *arg)
1212{
1213 VERBOSE_PRINTK_STRING("rcu_torture_shuffle task started");
1214 do {
1215 schedule_timeout_interruptible(shuffle_interval * HZ);
1216 rcu_torture_shuffle_tasks();
Paul E. McKenneyc9d557c2009-01-07 14:33:30 -08001217 rcutorture_shutdown_absorb("rcu_torture_shuffle");
1218 } while (!kthread_should_stop());
Srivatsa Vaddagirid84f5202006-01-08 01:03:42 -08001219 VERBOSE_PRINTK_STRING("rcu_torture_shuffle task stopping");
1220 return 0;
1221}
1222
Paul E. McKenneyd120f652008-06-18 05:21:44 -07001223/* Cause the rcutorture test to "stutter", starting and stopping all
1224 * threads periodically.
1225 */
1226static int
1227rcu_torture_stutter(void *arg)
1228{
1229 VERBOSE_PRINTK_STRING("rcu_torture_stutter task started");
1230 do {
1231 schedule_timeout_interruptible(stutter * HZ);
1232 stutter_pause_test = 1;
Paul E. McKenneyc9d557c2009-01-07 14:33:30 -08001233 if (!kthread_should_stop())
Paul E. McKenneyd120f652008-06-18 05:21:44 -07001234 schedule_timeout_interruptible(stutter * HZ);
1235 stutter_pause_test = 0;
Paul E. McKenneyc9d557c2009-01-07 14:33:30 -08001236 rcutorture_shutdown_absorb("rcu_torture_stutter");
1237 } while (!kthread_should_stop());
Paul E. McKenneyd120f652008-06-18 05:21:44 -07001238 VERBOSE_PRINTK_STRING("rcu_torture_stutter task stopping");
1239 return 0;
1240}
1241
Paul E. McKenney95c38322006-03-24 03:15:58 -08001242static inline void
Paul E. McKenney8e8be452010-09-02 16:16:14 -07001243rcu_torture_print_module_parms(struct rcu_torture_ops *cur_ops, char *tag)
Paul E. McKenney95c38322006-03-24 03:15:58 -08001244{
Josh Triplettb772e1d2006-10-04 02:17:13 -07001245 printk(KERN_ALERT "%s" TORTURE_FLAG
1246 "--- %s: nreaders=%d nfakewriters=%d "
Paul E. McKenney95c38322006-03-24 03:15:58 -08001247 "stat_interval=%d verbose=%d test_no_idle_hz=%d "
Paul E. McKenneybf66f182010-01-04 15:09:10 -08001248 "shuffle_interval=%d stutter=%d irqreader=%d "
Paul E. McKenney8e8be452010-09-02 16:16:14 -07001249 "fqs_duration=%d fqs_holdoff=%d fqs_stutter=%d "
1250 "test_boost=%d/%d test_boost_interval=%d "
1251 "test_boost_duration=%d\n",
Josh Triplettb772e1d2006-10-04 02:17:13 -07001252 torture_type, tag, nrealreaders, nfakewriters,
Paul E. McKenneyd120f652008-06-18 05:21:44 -07001253 stat_interval, verbose, test_no_idle_hz, shuffle_interval,
Paul E. McKenney8e8be452010-09-02 16:16:14 -07001254 stutter, irqreader, fqs_duration, fqs_holdoff, fqs_stutter,
1255 test_boost, cur_ops->can_boost,
1256 test_boost_interval, test_boost_duration);
Paul E. McKenney95c38322006-03-24 03:15:58 -08001257}
1258
Paul E. McKenney8e8be452010-09-02 16:16:14 -07001259static struct notifier_block rcutorture_shutdown_nb = {
Paul E. McKenney343e9092008-12-15 16:13:07 -08001260 .notifier_call = rcutorture_shutdown_notify,
1261};
1262
Paul E. McKenney8e8be452010-09-02 16:16:14 -07001263static void rcutorture_booster_cleanup(int cpu)
1264{
1265 struct task_struct *t;
1266
1267 if (boost_tasks[cpu] == NULL)
1268 return;
1269 mutex_lock(&boost_mutex);
1270 VERBOSE_PRINTK_STRING("Stopping rcu_torture_boost task");
1271 t = boost_tasks[cpu];
1272 boost_tasks[cpu] = NULL;
1273 mutex_unlock(&boost_mutex);
1274
1275 /* This must be outside of the mutex, otherwise deadlock! */
1276 kthread_stop(t);
1277}
1278
1279static int rcutorture_booster_init(int cpu)
1280{
1281 int retval;
1282
1283 if (boost_tasks[cpu] != NULL)
1284 return 0; /* Already created, nothing more to do. */
1285
1286 /* Don't allow time recalculation while creating a new task. */
1287 mutex_lock(&boost_mutex);
1288 VERBOSE_PRINTK_STRING("Creating rcu_torture_boost task");
1289 boost_tasks[cpu] = kthread_create(rcu_torture_boost, NULL,
1290 "rcu_torture_boost");
1291 if (IS_ERR(boost_tasks[cpu])) {
1292 retval = PTR_ERR(boost_tasks[cpu]);
1293 VERBOSE_PRINTK_STRING("rcu_torture_boost task create failed");
1294 n_rcu_torture_boost_ktrerror++;
1295 boost_tasks[cpu] = NULL;
1296 mutex_unlock(&boost_mutex);
1297 return retval;
1298 }
1299 kthread_bind(boost_tasks[cpu], cpu);
1300 wake_up_process(boost_tasks[cpu]);
1301 mutex_unlock(&boost_mutex);
1302 return 0;
1303}
1304
1305static int rcutorture_cpu_notify(struct notifier_block *self,
1306 unsigned long action, void *hcpu)
1307{
1308 long cpu = (long)hcpu;
1309
1310 switch (action) {
1311 case CPU_ONLINE:
1312 case CPU_DOWN_FAILED:
1313 (void)rcutorture_booster_init(cpu);
1314 break;
1315 case CPU_DOWN_PREPARE:
1316 rcutorture_booster_cleanup(cpu);
1317 break;
1318 default:
1319 break;
1320 }
1321 return NOTIFY_OK;
1322}
1323
1324static struct notifier_block rcutorture_cpu_nb = {
1325 .notifier_call = rcutorture_cpu_notify,
1326};
1327
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001328static void
1329rcu_torture_cleanup(void)
1330{
1331 int i;
1332
Paul E. McKenney343e9092008-12-15 16:13:07 -08001333 mutex_lock(&fullstop_mutex);
Paul E. McKenneyc9d557c2009-01-07 14:33:30 -08001334 if (fullstop == FULLSTOP_SHUTDOWN) {
1335 printk(KERN_WARNING /* but going down anyway, so... */
1336 "Concurrent 'rmmod rcutorture' and shutdown illegal!\n");
Paul E. McKenney343e9092008-12-15 16:13:07 -08001337 mutex_unlock(&fullstop_mutex);
Paul E. McKenneyc9d557c2009-01-07 14:33:30 -08001338 schedule_timeout_uninterruptible(10);
Paul E. McKenney343e9092008-12-15 16:13:07 -08001339 if (cur_ops->cb_barrier != NULL)
1340 cur_ops->cb_barrier();
1341 return;
1342 }
Paul E. McKenneyc9d557c2009-01-07 14:33:30 -08001343 fullstop = FULLSTOP_RMMOD;
Paul E. McKenney343e9092008-12-15 16:13:07 -08001344 mutex_unlock(&fullstop_mutex);
Paul E. McKenney8e8be452010-09-02 16:16:14 -07001345 unregister_reboot_notifier(&rcutorture_shutdown_nb);
Paul E. McKenneyd120f652008-06-18 05:21:44 -07001346 if (stutter_task) {
1347 VERBOSE_PRINTK_STRING("Stopping rcu_torture_stutter task");
1348 kthread_stop(stutter_task);
1349 }
1350 stutter_task = NULL;
Josh Triplettc8e5b162007-05-08 00:33:20 -07001351 if (shuffler_task) {
Srivatsa Vaddagirid84f5202006-01-08 01:03:42 -08001352 VERBOSE_PRINTK_STRING("Stopping rcu_torture_shuffle task");
1353 kthread_stop(shuffler_task);
Rusty Russell73d0a4b2009-03-30 22:05:16 -06001354 free_cpumask_var(shuffle_tmp_mask);
Srivatsa Vaddagirid84f5202006-01-08 01:03:42 -08001355 }
1356 shuffler_task = NULL;
1357
Josh Triplettc8e5b162007-05-08 00:33:20 -07001358 if (writer_task) {
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001359 VERBOSE_PRINTK_STRING("Stopping rcu_torture_writer task");
1360 kthread_stop(writer_task);
1361 }
1362 writer_task = NULL;
1363
Josh Triplettc8e5b162007-05-08 00:33:20 -07001364 if (reader_tasks) {
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001365 for (i = 0; i < nrealreaders; i++) {
Josh Triplettc8e5b162007-05-08 00:33:20 -07001366 if (reader_tasks[i]) {
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001367 VERBOSE_PRINTK_STRING(
1368 "Stopping rcu_torture_reader task");
1369 kthread_stop(reader_tasks[i]);
1370 }
1371 reader_tasks[i] = NULL;
1372 }
1373 kfree(reader_tasks);
1374 reader_tasks = NULL;
1375 }
1376 rcu_torture_current = NULL;
1377
Josh Triplettc8e5b162007-05-08 00:33:20 -07001378 if (fakewriter_tasks) {
Josh Triplettb772e1d2006-10-04 02:17:13 -07001379 for (i = 0; i < nfakewriters; i++) {
Josh Triplettc8e5b162007-05-08 00:33:20 -07001380 if (fakewriter_tasks[i]) {
Josh Triplettb772e1d2006-10-04 02:17:13 -07001381 VERBOSE_PRINTK_STRING(
1382 "Stopping rcu_torture_fakewriter task");
1383 kthread_stop(fakewriter_tasks[i]);
1384 }
1385 fakewriter_tasks[i] = NULL;
1386 }
1387 kfree(fakewriter_tasks);
1388 fakewriter_tasks = NULL;
1389 }
1390
Josh Triplettc8e5b162007-05-08 00:33:20 -07001391 if (stats_task) {
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001392 VERBOSE_PRINTK_STRING("Stopping rcu_torture_stats task");
1393 kthread_stop(stats_task);
1394 }
1395 stats_task = NULL;
1396
Paul E. McKenneybf66f182010-01-04 15:09:10 -08001397 if (fqs_task) {
1398 VERBOSE_PRINTK_STRING("Stopping rcu_torture_fqs task");
1399 kthread_stop(fqs_task);
1400 }
1401 fqs_task = NULL;
Paul E. McKenney8e8be452010-09-02 16:16:14 -07001402 if ((test_boost == 1 && cur_ops->can_boost) ||
1403 test_boost == 2) {
1404 unregister_cpu_notifier(&rcutorture_cpu_nb);
1405 for_each_possible_cpu(i)
1406 rcutorture_booster_cleanup(i);
1407 }
Paul E. McKenneybf66f182010-01-04 15:09:10 -08001408
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001409 /* Wait for all RCU callbacks to fire. */
Paul E. McKenney23269742008-05-12 21:21:05 +02001410
1411 if (cur_ops->cb_barrier != NULL)
1412 cur_ops->cb_barrier();
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001413
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001414 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
Paul E. McKenney72e9bb52006-06-27 02:54:03 -07001415
Josh Triplettc8e5b162007-05-08 00:33:20 -07001416 if (cur_ops->cleanup)
Paul E. McKenney72e9bb52006-06-27 02:54:03 -07001417 cur_ops->cleanup();
Paul E. McKenney95c38322006-03-24 03:15:58 -08001418 if (atomic_read(&n_rcu_torture_error))
Paul E. McKenney8e8be452010-09-02 16:16:14 -07001419 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
Paul E. McKenney95c38322006-03-24 03:15:58 -08001420 else
Paul E. McKenney8e8be452010-09-02 16:16:14 -07001421 rcu_torture_print_module_parms(cur_ops, "End of test: SUCCESS");
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001422}
1423
Josh Triplett6f8bc502007-05-08 00:25:24 -07001424static int __init
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001425rcu_torture_init(void)
1426{
1427 int i;
1428 int cpu;
1429 int firsterr = 0;
Josh Triplettade5fb82007-05-08 00:33:22 -07001430 static struct rcu_torture_ops *torture_ops[] =
Paul E. McKenneyd9a3da02009-12-02 12:10:15 -08001431 { &rcu_ops, &rcu_sync_ops, &rcu_expedited_ops,
1432 &rcu_bh_ops, &rcu_bh_sync_ops,
Paul E. McKenney804bb832009-10-25 19:03:52 -07001433 &srcu_ops, &srcu_expedited_ops,
1434 &sched_ops, &sched_sync_ops, &sched_expedited_ops, };
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001435
Paul E. McKenney343e9092008-12-15 16:13:07 -08001436 mutex_lock(&fullstop_mutex);
1437
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001438 /* Process args and tell the world that the torturer is on the job. */
Josh Triplettade5fb82007-05-08 00:33:22 -07001439 for (i = 0; i < ARRAY_SIZE(torture_ops); i++) {
Paul E. McKenney72e9bb52006-06-27 02:54:03 -07001440 cur_ops = torture_ops[i];
Josh Triplettade5fb82007-05-08 00:33:22 -07001441 if (strcmp(torture_type, cur_ops->name) == 0)
Paul E. McKenney72e9bb52006-06-27 02:54:03 -07001442 break;
Paul E. McKenney72e9bb52006-06-27 02:54:03 -07001443 }
Josh Triplettade5fb82007-05-08 00:33:22 -07001444 if (i == ARRAY_SIZE(torture_ops)) {
Paul E. McKenneycf886c42009-10-25 19:03:54 -07001445 printk(KERN_ALERT "rcu-torture: invalid torture type: \"%s\"\n",
Paul E. McKenney72e9bb52006-06-27 02:54:03 -07001446 torture_type);
Paul E. McKenneycf886c42009-10-25 19:03:54 -07001447 printk(KERN_ALERT "rcu-torture types:");
1448 for (i = 0; i < ARRAY_SIZE(torture_ops); i++)
1449 printk(KERN_ALERT " %s", torture_ops[i]->name);
1450 printk(KERN_ALERT "\n");
Paul E. McKenney343e9092008-12-15 16:13:07 -08001451 mutex_unlock(&fullstop_mutex);
Paul E. McKenneya71fca52009-09-18 10:28:19 -07001452 return -EINVAL;
Paul E. McKenney72e9bb52006-06-27 02:54:03 -07001453 }
Paul E. McKenneybf66f182010-01-04 15:09:10 -08001454 if (cur_ops->fqs == NULL && fqs_duration != 0) {
1455 printk(KERN_ALERT "rcu-torture: ->fqs NULL and non-zero "
1456 "fqs_duration, fqs disabled.\n");
1457 fqs_duration = 0;
1458 }
Josh Triplettc8e5b162007-05-08 00:33:20 -07001459 if (cur_ops->init)
Paul E. McKenney72e9bb52006-06-27 02:54:03 -07001460 cur_ops->init(); /* no "goto unwind" prior to this point!!! */
1461
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001462 if (nreaders >= 0)
1463 nrealreaders = nreaders;
1464 else
1465 nrealreaders = 2 * num_online_cpus();
Paul E. McKenney8e8be452010-09-02 16:16:14 -07001466 rcu_torture_print_module_parms(cur_ops, "Start of test");
Paul E. McKenneyc9d557c2009-01-07 14:33:30 -08001467 fullstop = FULLSTOP_DONTSTOP;
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001468
1469 /* Set up the freelist. */
1470
1471 INIT_LIST_HEAD(&rcu_torture_freelist);
Ahmed S. Darwish788e7702007-05-08 00:33:14 -07001472 for (i = 0; i < ARRAY_SIZE(rcu_tortures); i++) {
Paul E. McKenney996417d2005-11-18 01:10:50 -08001473 rcu_tortures[i].rtort_mbtest = 0;
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001474 list_add_tail(&rcu_tortures[i].rtort_free,
1475 &rcu_torture_freelist);
1476 }
1477
1478 /* Initialize the statistics so that each run gets its own numbers. */
1479
1480 rcu_torture_current = NULL;
1481 rcu_torture_current_version = 0;
1482 atomic_set(&n_rcu_torture_alloc, 0);
1483 atomic_set(&n_rcu_torture_alloc_fail, 0);
1484 atomic_set(&n_rcu_torture_free, 0);
Paul E. McKenney996417d2005-11-18 01:10:50 -08001485 atomic_set(&n_rcu_torture_mberror, 0);
1486 atomic_set(&n_rcu_torture_error, 0);
Paul E. McKenney8e8be452010-09-02 16:16:14 -07001487 n_rcu_torture_boost_ktrerror = 0;
1488 n_rcu_torture_boost_rterror = 0;
1489 n_rcu_torture_boost_allocerror = 0;
1490 n_rcu_torture_boost_afferror = 0;
1491 n_rcu_torture_boost_failure = 0;
1492 n_rcu_torture_boosts = 0;
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001493 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
1494 atomic_set(&rcu_torture_wcount[i], 0);
KAMEZAWA Hiroyuki0a945022006-03-28 01:56:37 -08001495 for_each_possible_cpu(cpu) {
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001496 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
1497 per_cpu(rcu_torture_count, cpu)[i] = 0;
1498 per_cpu(rcu_torture_batch, cpu)[i] = 0;
1499 }
1500 }
1501
1502 /* Start up the kthreads. */
1503
1504 VERBOSE_PRINTK_STRING("Creating rcu_torture_writer task");
1505 writer_task = kthread_run(rcu_torture_writer, NULL,
1506 "rcu_torture_writer");
1507 if (IS_ERR(writer_task)) {
1508 firsterr = PTR_ERR(writer_task);
1509 VERBOSE_PRINTK_ERRSTRING("Failed to create writer");
1510 writer_task = NULL;
1511 goto unwind;
1512 }
Josh Triplettb772e1d2006-10-04 02:17:13 -07001513 fakewriter_tasks = kzalloc(nfakewriters * sizeof(fakewriter_tasks[0]),
Paul E. McKenneya71fca52009-09-18 10:28:19 -07001514 GFP_KERNEL);
Josh Triplettb772e1d2006-10-04 02:17:13 -07001515 if (fakewriter_tasks == NULL) {
1516 VERBOSE_PRINTK_ERRSTRING("out of memory");
1517 firsterr = -ENOMEM;
1518 goto unwind;
1519 }
1520 for (i = 0; i < nfakewriters; i++) {
1521 VERBOSE_PRINTK_STRING("Creating rcu_torture_fakewriter task");
1522 fakewriter_tasks[i] = kthread_run(rcu_torture_fakewriter, NULL,
Paul E. McKenneya71fca52009-09-18 10:28:19 -07001523 "rcu_torture_fakewriter");
Josh Triplettb772e1d2006-10-04 02:17:13 -07001524 if (IS_ERR(fakewriter_tasks[i])) {
1525 firsterr = PTR_ERR(fakewriter_tasks[i]);
1526 VERBOSE_PRINTK_ERRSTRING("Failed to create fakewriter");
1527 fakewriter_tasks[i] = NULL;
1528 goto unwind;
1529 }
1530 }
Josh Triplett2860aab2006-10-04 02:17:11 -07001531 reader_tasks = kzalloc(nrealreaders * sizeof(reader_tasks[0]),
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001532 GFP_KERNEL);
1533 if (reader_tasks == NULL) {
1534 VERBOSE_PRINTK_ERRSTRING("out of memory");
1535 firsterr = -ENOMEM;
1536 goto unwind;
1537 }
1538 for (i = 0; i < nrealreaders; i++) {
1539 VERBOSE_PRINTK_STRING("Creating rcu_torture_reader task");
1540 reader_tasks[i] = kthread_run(rcu_torture_reader, NULL,
1541 "rcu_torture_reader");
1542 if (IS_ERR(reader_tasks[i])) {
1543 firsterr = PTR_ERR(reader_tasks[i]);
1544 VERBOSE_PRINTK_ERRSTRING("Failed to create reader");
1545 reader_tasks[i] = NULL;
1546 goto unwind;
1547 }
1548 }
1549 if (stat_interval > 0) {
1550 VERBOSE_PRINTK_STRING("Creating rcu_torture_stats task");
1551 stats_task = kthread_run(rcu_torture_stats, NULL,
1552 "rcu_torture_stats");
1553 if (IS_ERR(stats_task)) {
1554 firsterr = PTR_ERR(stats_task);
1555 VERBOSE_PRINTK_ERRSTRING("Failed to create stats");
1556 stats_task = NULL;
1557 goto unwind;
1558 }
1559 }
Srivatsa Vaddagirid84f5202006-01-08 01:03:42 -08001560 if (test_no_idle_hz) {
1561 rcu_idle_cpu = num_online_cpus() - 1;
Rusty Russell73d0a4b2009-03-30 22:05:16 -06001562
1563 if (!alloc_cpumask_var(&shuffle_tmp_mask, GFP_KERNEL)) {
1564 firsterr = -ENOMEM;
1565 VERBOSE_PRINTK_ERRSTRING("Failed to alloc mask");
1566 goto unwind;
1567 }
1568
Srivatsa Vaddagirid84f5202006-01-08 01:03:42 -08001569 /* Create the shuffler thread */
1570 shuffler_task = kthread_run(rcu_torture_shuffle, NULL,
1571 "rcu_torture_shuffle");
1572 if (IS_ERR(shuffler_task)) {
Rusty Russell73d0a4b2009-03-30 22:05:16 -06001573 free_cpumask_var(shuffle_tmp_mask);
Srivatsa Vaddagirid84f5202006-01-08 01:03:42 -08001574 firsterr = PTR_ERR(shuffler_task);
1575 VERBOSE_PRINTK_ERRSTRING("Failed to create shuffler");
1576 shuffler_task = NULL;
1577 goto unwind;
1578 }
1579 }
Paul E. McKenneyd120f652008-06-18 05:21:44 -07001580 if (stutter < 0)
1581 stutter = 0;
1582 if (stutter) {
1583 /* Create the stutter thread */
1584 stutter_task = kthread_run(rcu_torture_stutter, NULL,
1585 "rcu_torture_stutter");
1586 if (IS_ERR(stutter_task)) {
1587 firsterr = PTR_ERR(stutter_task);
1588 VERBOSE_PRINTK_ERRSTRING("Failed to create stutter");
1589 stutter_task = NULL;
1590 goto unwind;
1591 }
1592 }
Paul E. McKenneybf66f182010-01-04 15:09:10 -08001593 if (fqs_duration < 0)
1594 fqs_duration = 0;
1595 if (fqs_duration) {
1596 /* Create the stutter thread */
1597 fqs_task = kthread_run(rcu_torture_fqs, NULL,
1598 "rcu_torture_fqs");
1599 if (IS_ERR(fqs_task)) {
1600 firsterr = PTR_ERR(fqs_task);
1601 VERBOSE_PRINTK_ERRSTRING("Failed to create fqs");
1602 fqs_task = NULL;
1603 goto unwind;
1604 }
1605 }
Paul E. McKenney8e8be452010-09-02 16:16:14 -07001606 if (test_boost_interval < 1)
1607 test_boost_interval = 1;
1608 if (test_boost_duration < 2)
1609 test_boost_duration = 2;
1610 if ((test_boost == 1 && cur_ops->can_boost) ||
1611 test_boost == 2) {
1612 int retval;
1613
1614 boost_starttime = jiffies + test_boost_interval * HZ;
1615 register_cpu_notifier(&rcutorture_cpu_nb);
1616 for_each_possible_cpu(i) {
1617 if (cpu_is_offline(i))
1618 continue; /* Heuristic: CPU can go offline. */
1619 retval = rcutorture_booster_init(i);
1620 if (retval < 0) {
1621 firsterr = retval;
1622 goto unwind;
1623 }
1624 }
1625 }
1626 register_reboot_notifier(&rcutorture_shutdown_nb);
Paul E. McKenney343e9092008-12-15 16:13:07 -08001627 mutex_unlock(&fullstop_mutex);
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001628 return 0;
1629
1630unwind:
Paul E. McKenney343e9092008-12-15 16:13:07 -08001631 mutex_unlock(&fullstop_mutex);
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001632 rcu_torture_cleanup();
1633 return firsterr;
1634}
1635
1636module_init(rcu_torture_init);
1637module_exit(rcu_torture_cleanup);