]>
Commit | Line | Data |
---|---|---|
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 <[email protected]> | |
a71fca58 | 21 | * Josh Triplett <[email protected]> |
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> | |
60063497 | 36 | #include <linux/atomic.h> |
a241ec65 | 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> | |
343e9099 | 42 | #include <linux/reboot.h> |
83144186 | 43 | #include <linux/freezer.h> |
a241ec65 | 44 | #include <linux/cpu.h> |
a241ec65 | 45 | #include <linux/delay.h> |
a241ec65 | 46 | #include <linux/stat.h> |
b2896d2e | 47 | #include <linux/srcu.h> |
1aeb272c | 48 | #include <linux/slab.h> |
52494535 | 49 | #include <linux/trace_clock.h> |
f07767fd | 50 | #include <asm/byteorder.h> |
a241ec65 PM |
51 | |
52 | MODULE_LICENSE("GPL"); | |
5cf05ad7 | 53 | MODULE_AUTHOR("Paul E. McKenney <[email protected]> and Josh Triplett <[email protected]>"); |
a241ec65 | 54 | |
4802211c | 55 | static int nreaders = -1; /* # reader threads, defaults to 2*ncpus */ |
b772e1dd | 56 | static int nfakewriters = 4; /* # fake writer threads */ |
ab840f7a PM |
57 | static int stat_interval = 60; /* Interval between stats, in seconds. */ |
58 | /* Zero means "only at end of test". */ | |
d8e8ed95 | 59 | static bool verbose; /* Print more debug info. */ |
ab840f7a PM |
60 | static bool test_no_idle_hz = true; |
61 | /* Test RCU support for tickless idle CPUs. */ | |
d120f65f PM |
62 | static int shuffle_interval = 3; /* Interval between shuffles (in sec)*/ |
63 | static int stutter = 5; /* Start/stop testing interval (in sec) */ | |
0729fbf3 | 64 | static int irqreader = 1; /* RCU readers from irq (timers). */ |
d5f546d8 PM |
65 | static int fqs_duration; /* Duration of bursts (us), 0 to disable. */ |
66 | static int fqs_holdoff; /* Hold time within burst (us). */ | |
bf66f18e | 67 | static int fqs_stutter = 3; /* Wait time between bursts (s). */ |
fae4b54f | 68 | static int n_barrier_cbs; /* Number of callbacks to test RCU barriers. */ |
b58bdcca | 69 | static int onoff_interval; /* Wait time between CPU hotplugs, 0=disable. */ |
9b9ec9b9 | 70 | static int onoff_holdoff; /* Seconds after boot before CPU hotplugs. */ |
d5f546d8 | 71 | static int shutdown_secs; /* Shutdown time (s). <=0 for no shutdown. */ |
c13f3757 PM |
72 | static int stall_cpu; /* CPU-stall duration (s). 0 for no stall. */ |
73 | static int stall_cpu_holdoff = 10; /* Time to wait until stall (s). */ | |
8e8be45e PM |
74 | static int test_boost = 1; /* Test RCU prio boost: 0=no, 1=maybe, 2=yes. */ |
75 | static int test_boost_interval = 7; /* Interval between boost tests, seconds. */ | |
76 | static int test_boost_duration = 4; /* Duration of each boost test, seconds. */ | |
20d2e428 | 77 | static char *torture_type = "rcu"; /* What RCU implementation to torture. */ |
a241ec65 | 78 | |
d6ad6711 | 79 | module_param(nreaders, int, 0444); |
a241ec65 | 80 | MODULE_PARM_DESC(nreaders, "Number of RCU reader threads"); |
d6ad6711 | 81 | module_param(nfakewriters, int, 0444); |
b772e1dd | 82 | MODULE_PARM_DESC(nfakewriters, "Number of RCU fake writer threads"); |
3721bc1d | 83 | module_param(stat_interval, int, 0644); |
a241ec65 | 84 | MODULE_PARM_DESC(stat_interval, "Number of seconds between stats printk()s"); |
d6ad6711 | 85 | module_param(verbose, bool, 0444); |
a241ec65 | 86 | MODULE_PARM_DESC(verbose, "Enable verbose debugging printk()s"); |
d6ad6711 | 87 | module_param(test_no_idle_hz, bool, 0444); |
d84f5203 | 88 | MODULE_PARM_DESC(test_no_idle_hz, "Test support for tickless idle CPUs"); |
d6ad6711 | 89 | module_param(shuffle_interval, int, 0444); |
d84f5203 | 90 | MODULE_PARM_DESC(shuffle_interval, "Number of seconds between shuffles"); |
d120f65f PM |
91 | module_param(stutter, int, 0444); |
92 | MODULE_PARM_DESC(stutter, "Number of seconds to run/halt test"); | |
0729fbf3 PM |
93 | module_param(irqreader, int, 0444); |
94 | MODULE_PARM_DESC(irqreader, "Allow RCU readers from irq handlers"); | |
bf66f18e PM |
95 | module_param(fqs_duration, int, 0444); |
96 | MODULE_PARM_DESC(fqs_duration, "Duration of fqs bursts (us)"); | |
97 | module_param(fqs_holdoff, int, 0444); | |
98 | MODULE_PARM_DESC(fqs_holdoff, "Holdoff time within fqs bursts (us)"); | |
99 | module_param(fqs_stutter, int, 0444); | |
100 | MODULE_PARM_DESC(fqs_stutter, "Wait time between fqs bursts (s)"); | |
fae4b54f PM |
101 | module_param(n_barrier_cbs, int, 0444); |
102 | MODULE_PARM_DESC(n_barrier_cbs, "# of callbacks/kthreads for barrier testing"); | |
b58bdcca PM |
103 | module_param(onoff_interval, int, 0444); |
104 | MODULE_PARM_DESC(onoff_interval, "Time between CPU hotplugs (s), 0=disable"); | |
9b9ec9b9 PM |
105 | module_param(onoff_holdoff, int, 0444); |
106 | MODULE_PARM_DESC(onoff_holdoff, "Time after boot before CPU hotplugs (s)"); | |
d5f546d8 PM |
107 | module_param(shutdown_secs, int, 0444); |
108 | MODULE_PARM_DESC(shutdown_secs, "Shutdown time (s), zero to disable."); | |
c13f3757 PM |
109 | module_param(stall_cpu, int, 0444); |
110 | MODULE_PARM_DESC(stall_cpu, "Stall duration (s), zero to disable."); | |
111 | module_param(stall_cpu_holdoff, int, 0444); | |
112 | MODULE_PARM_DESC(stall_cpu_holdoff, "Time to wait before starting stall (s)."); | |
8e8be45e PM |
113 | module_param(test_boost, int, 0444); |
114 | MODULE_PARM_DESC(test_boost, "Test RCU prio boost: 0=no, 1=maybe, 2=yes."); | |
115 | module_param(test_boost_interval, int, 0444); | |
116 | MODULE_PARM_DESC(test_boost_interval, "Interval between boost tests, seconds."); | |
117 | module_param(test_boost_duration, int, 0444); | |
118 | MODULE_PARM_DESC(test_boost_duration, "Duration of each boost test, seconds."); | |
d6ad6711 | 119 | module_param(torture_type, charp, 0444); |
b2896d2e | 120 | MODULE_PARM_DESC(torture_type, "Type of RCU to torture (rcu, rcu_bh, srcu)"); |
72e9bb54 PM |
121 | |
122 | #define TORTURE_FLAG "-torture:" | |
a241ec65 | 123 | #define PRINTK_STRING(s) \ |
2caa1e44 | 124 | do { pr_alert("%s" TORTURE_FLAG s "\n", torture_type); } while (0) |
a241ec65 | 125 | #define VERBOSE_PRINTK_STRING(s) \ |
2caa1e44 | 126 | do { if (verbose) pr_alert("%s" TORTURE_FLAG s "\n", torture_type); } while (0) |
a241ec65 | 127 | #define VERBOSE_PRINTK_ERRSTRING(s) \ |
2caa1e44 | 128 | do { if (verbose) pr_alert("%s" TORTURE_FLAG "!!! " s "\n", torture_type); } while (0) |
a241ec65 PM |
129 | |
130 | static char printk_buf[4096]; | |
131 | ||
132 | static int nrealreaders; | |
133 | static struct task_struct *writer_task; | |
b772e1dd | 134 | static struct task_struct **fakewriter_tasks; |
a241ec65 PM |
135 | static struct task_struct **reader_tasks; |
136 | static struct task_struct *stats_task; | |
d84f5203 | 137 | static struct task_struct *shuffler_task; |
d120f65f | 138 | static struct task_struct *stutter_task; |
bf66f18e | 139 | static struct task_struct *fqs_task; |
8e8be45e | 140 | static struct task_struct *boost_tasks[NR_CPUS]; |
d5f546d8 | 141 | static struct task_struct *shutdown_task; |
b58bdcca PM |
142 | #ifdef CONFIG_HOTPLUG_CPU |
143 | static struct task_struct *onoff_task; | |
144 | #endif /* #ifdef CONFIG_HOTPLUG_CPU */ | |
c13f3757 | 145 | static struct task_struct *stall_task; |
fae4b54f PM |
146 | static struct task_struct **barrier_cbs_tasks; |
147 | static struct task_struct *barrier_task; | |
a241ec65 PM |
148 | |
149 | #define RCU_TORTURE_PIPE_LEN 10 | |
150 | ||
151 | struct rcu_torture { | |
152 | struct rcu_head rtort_rcu; | |
153 | int rtort_pipe_count; | |
154 | struct list_head rtort_free; | |
996417d2 | 155 | int rtort_mbtest; |
a241ec65 PM |
156 | }; |
157 | ||
a241ec65 | 158 | static LIST_HEAD(rcu_torture_freelist); |
0ddea0ea | 159 | static struct rcu_torture __rcu *rcu_torture_current; |
4a298656 | 160 | static unsigned long rcu_torture_current_version; |
a241ec65 PM |
161 | static struct rcu_torture rcu_tortures[10 * RCU_TORTURE_PIPE_LEN]; |
162 | static DEFINE_SPINLOCK(rcu_torture_lock); | |
163 | static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) = | |
164 | { 0 }; | |
165 | static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) = | |
166 | { 0 }; | |
167 | static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1]; | |
b2896d2e PM |
168 | static atomic_t n_rcu_torture_alloc; |
169 | static atomic_t n_rcu_torture_alloc_fail; | |
170 | static atomic_t n_rcu_torture_free; | |
171 | static atomic_t n_rcu_torture_mberror; | |
172 | static atomic_t n_rcu_torture_error; | |
fae4b54f | 173 | static long n_rcu_torture_barrier_error; |
8e8be45e PM |
174 | static long n_rcu_torture_boost_ktrerror; |
175 | static long n_rcu_torture_boost_rterror; | |
8e8be45e PM |
176 | static long n_rcu_torture_boost_failure; |
177 | static long n_rcu_torture_boosts; | |
a71fca58 | 178 | static long n_rcu_torture_timers; |
b58bdcca PM |
179 | static long n_offline_attempts; |
180 | static long n_offline_successes; | |
13dbf914 PM |
181 | static unsigned long sum_offline; |
182 | static int min_offline = -1; | |
183 | static int max_offline; | |
b58bdcca PM |
184 | static long n_online_attempts; |
185 | static long n_online_successes; | |
13dbf914 PM |
186 | static unsigned long sum_online; |
187 | static int min_online = -1; | |
188 | static int max_online; | |
fae4b54f PM |
189 | static long n_barrier_attempts; |
190 | static long n_barrier_successes; | |
e3033736 | 191 | static struct list_head rcu_torture_removed; |
73d0a4b1 | 192 | static cpumask_var_t shuffle_tmp_mask; |
a241ec65 | 193 | |
a71fca58 | 194 | static int stutter_pause_test; |
d120f65f | 195 | |
31a72bce PM |
196 | #if defined(MODULE) || defined(CONFIG_RCU_TORTURE_TEST_RUNNABLE) |
197 | #define RCUTORTURE_RUNNABLE_INIT 1 | |
198 | #else | |
199 | #define RCUTORTURE_RUNNABLE_INIT 0 | |
200 | #endif | |
201 | int rcutorture_runnable = RCUTORTURE_RUNNABLE_INIT; | |
bb3bf705 PM |
202 | module_param(rcutorture_runnable, int, 0444); |
203 | MODULE_PARM_DESC(rcutorture_runnable, "Start rcutorture at boot"); | |
31a72bce | 204 | |
3acf4a9a | 205 | #if defined(CONFIG_RCU_BOOST) && !defined(CONFIG_HOTPLUG_CPU) |
8e8be45e | 206 | #define rcu_can_boost() 1 |
3acf4a9a | 207 | #else /* #if defined(CONFIG_RCU_BOOST) && !defined(CONFIG_HOTPLUG_CPU) */ |
8e8be45e | 208 | #define rcu_can_boost() 0 |
3acf4a9a | 209 | #endif /* #else #if defined(CONFIG_RCU_BOOST) && !defined(CONFIG_HOTPLUG_CPU) */ |
8e8be45e | 210 | |
e4aa0da3 SR |
211 | #ifdef CONFIG_RCU_TRACE |
212 | static u64 notrace rcu_trace_clock_local(void) | |
213 | { | |
214 | u64 ts = trace_clock_local(); | |
215 | unsigned long __maybe_unused ts_rem = do_div(ts, NSEC_PER_USEC); | |
216 | return ts; | |
217 | } | |
218 | #else /* #ifdef CONFIG_RCU_TRACE */ | |
219 | static u64 notrace rcu_trace_clock_local(void) | |
220 | { | |
221 | return 0ULL; | |
222 | } | |
223 | #endif /* #else #ifdef CONFIG_RCU_TRACE */ | |
224 | ||
d5f546d8 | 225 | static unsigned long shutdown_time; /* jiffies to system shutdown. */ |
8e8be45e PM |
226 | static unsigned long boost_starttime; /* jiffies of next boost test start. */ |
227 | DEFINE_MUTEX(boost_mutex); /* protect setting boost_starttime */ | |
228 | /* and boost task create/destroy. */ | |
fae4b54f | 229 | static atomic_t barrier_cbs_count; /* Barrier callbacks registered. */ |
c6ebcbb6 | 230 | static bool barrier_phase; /* Test phase. */ |
fae4b54f PM |
231 | static atomic_t barrier_cbs_invoked; /* Barrier callbacks invoked. */ |
232 | static wait_queue_head_t *barrier_cbs_wq; /* Coordinate barrier testing. */ | |
233 | static DECLARE_WAIT_QUEUE_HEAD(barrier_wq); | |
8e8be45e | 234 | |
c9d557c1 PM |
235 | /* Mediate rmmod and system shutdown. Concurrent rmmod & shutdown illegal! */ |
236 | ||
237 | #define FULLSTOP_DONTSTOP 0 /* Normal operation. */ | |
238 | #define FULLSTOP_SHUTDOWN 1 /* System shutdown with rcutorture running. */ | |
239 | #define FULLSTOP_RMMOD 2 /* Normal rmmod of rcutorture. */ | |
240 | static int fullstop = FULLSTOP_RMMOD; | |
0ddea0ea PM |
241 | /* |
242 | * Protect fullstop transitions and spawning of kthreads. | |
243 | */ | |
244 | static DEFINE_MUTEX(fullstop_mutex); | |
343e9099 | 245 | |
d5f546d8 PM |
246 | /* Forward reference. */ |
247 | static void rcu_torture_cleanup(void); | |
248 | ||
343e9099 | 249 | /* |
c9d557c1 | 250 | * Detect and respond to a system shutdown. |
343e9099 PM |
251 | */ |
252 | static int | |
253 | rcutorture_shutdown_notify(struct notifier_block *unused1, | |
254 | unsigned long unused2, void *unused3) | |
255 | { | |
c59ab97e | 256 | mutex_lock(&fullstop_mutex); |
c9d557c1 | 257 | if (fullstop == FULLSTOP_DONTSTOP) |
c59ab97e | 258 | fullstop = FULLSTOP_SHUTDOWN; |
c9d557c1 | 259 | else |
2caa1e44 | 260 | pr_warn(/* but going down anyway, so... */ |
c9d557c1 | 261 | "Concurrent 'rmmod rcutorture' and shutdown illegal!\n"); |
c59ab97e | 262 | mutex_unlock(&fullstop_mutex); |
343e9099 PM |
263 | return NOTIFY_DONE; |
264 | } | |
265 | ||
c9d557c1 PM |
266 | /* |
267 | * Absorb kthreads into a kernel function that won't return, so that | |
268 | * they won't ever access module text or data again. | |
269 | */ | |
270 | static void rcutorture_shutdown_absorb(char *title) | |
271 | { | |
272 | if (ACCESS_ONCE(fullstop) == FULLSTOP_SHUTDOWN) { | |
2caa1e44 | 273 | pr_notice( |
c9d557c1 PM |
274 | "rcutorture thread %s parking due to system shutdown\n", |
275 | title); | |
276 | schedule_timeout_uninterruptible(MAX_SCHEDULE_TIMEOUT); | |
277 | } | |
278 | } | |
279 | ||
a241ec65 PM |
280 | /* |
281 | * Allocate an element from the rcu_tortures pool. | |
282 | */ | |
97a41e26 | 283 | static struct rcu_torture * |
a241ec65 PM |
284 | rcu_torture_alloc(void) |
285 | { | |
286 | struct list_head *p; | |
287 | ||
adac1665 | 288 | spin_lock_bh(&rcu_torture_lock); |
a241ec65 PM |
289 | if (list_empty(&rcu_torture_freelist)) { |
290 | atomic_inc(&n_rcu_torture_alloc_fail); | |
adac1665 | 291 | spin_unlock_bh(&rcu_torture_lock); |
a241ec65 PM |
292 | return NULL; |
293 | } | |
294 | atomic_inc(&n_rcu_torture_alloc); | |
295 | p = rcu_torture_freelist.next; | |
296 | list_del_init(p); | |
adac1665 | 297 | spin_unlock_bh(&rcu_torture_lock); |
a241ec65 PM |
298 | return container_of(p, struct rcu_torture, rtort_free); |
299 | } | |
300 | ||
301 | /* | |
302 | * Free an element to the rcu_tortures pool. | |
303 | */ | |
304 | static void | |
305 | rcu_torture_free(struct rcu_torture *p) | |
306 | { | |
307 | atomic_inc(&n_rcu_torture_free); | |
adac1665 | 308 | spin_lock_bh(&rcu_torture_lock); |
a241ec65 | 309 | list_add_tail(&p->rtort_free, &rcu_torture_freelist); |
adac1665 | 310 | spin_unlock_bh(&rcu_torture_lock); |
a241ec65 PM |
311 | } |
312 | ||
a241ec65 PM |
313 | struct rcu_random_state { |
314 | unsigned long rrs_state; | |
75cfef32 | 315 | long rrs_count; |
a241ec65 PM |
316 | }; |
317 | ||
318 | #define RCU_RANDOM_MULT 39916801 /* prime */ | |
319 | #define RCU_RANDOM_ADD 479001701 /* prime */ | |
320 | #define RCU_RANDOM_REFRESH 10000 | |
321 | ||
322 | #define DEFINE_RCU_RANDOM(name) struct rcu_random_state name = { 0, 0 } | |
323 | ||
324 | /* | |
325 | * Crude but fast random-number generator. Uses a linear congruential | |
c17ac855 | 326 | * generator, with occasional help from cpu_clock(). |
a241ec65 | 327 | */ |
75cfef32 | 328 | static unsigned long |
a241ec65 PM |
329 | rcu_random(struct rcu_random_state *rrsp) |
330 | { | |
a241ec65 | 331 | if (--rrsp->rrs_count < 0) { |
c676329a | 332 | rrsp->rrs_state += (unsigned long)local_clock(); |
a241ec65 PM |
333 | rrsp->rrs_count = RCU_RANDOM_REFRESH; |
334 | } | |
335 | rrsp->rrs_state = rrsp->rrs_state * RCU_RANDOM_MULT + RCU_RANDOM_ADD; | |
336 | return swahw32(rrsp->rrs_state); | |
337 | } | |
338 | ||
d120f65f | 339 | static void |
c9d557c1 | 340 | rcu_stutter_wait(char *title) |
d120f65f | 341 | { |
c9d557c1 | 342 | while (stutter_pause_test || !rcutorture_runnable) { |
e3d7be27 PM |
343 | if (rcutorture_runnable) |
344 | schedule_timeout_interruptible(1); | |
345 | else | |
3ccf79f4 | 346 | schedule_timeout_interruptible(round_jiffies_relative(HZ)); |
c9d557c1 | 347 | rcutorture_shutdown_absorb(title); |
343e9099 | 348 | } |
d120f65f PM |
349 | } |
350 | ||
72e9bb54 PM |
351 | /* |
352 | * Operations vector for selecting different types of tests. | |
353 | */ | |
354 | ||
355 | struct rcu_torture_ops { | |
356 | void (*init)(void); | |
72e9bb54 | 357 | int (*readlock)(void); |
0acc512c | 358 | void (*read_delay)(struct rcu_random_state *rrsp); |
72e9bb54 PM |
359 | void (*readunlock)(int idx); |
360 | int (*completed)(void); | |
0acc512c | 361 | void (*deferred_free)(struct rcu_torture *p); |
b772e1dd | 362 | void (*sync)(void); |
fae4b54f | 363 | void (*call)(struct rcu_head *head, void (*func)(struct rcu_head *rcu)); |
2326974d | 364 | void (*cb_barrier)(void); |
bf66f18e | 365 | void (*fqs)(void); |
72e9bb54 | 366 | int (*stats)(char *page); |
0acc512c | 367 | int irq_capable; |
8e8be45e | 368 | int can_boost; |
72e9bb54 PM |
369 | char *name; |
370 | }; | |
a71fca58 PM |
371 | |
372 | static struct rcu_torture_ops *cur_ops; | |
72e9bb54 PM |
373 | |
374 | /* | |
375 | * Definitions for rcu torture testing. | |
376 | */ | |
377 | ||
a49a4af7 | 378 | static int rcu_torture_read_lock(void) __acquires(RCU) |
72e9bb54 PM |
379 | { |
380 | rcu_read_lock(); | |
381 | return 0; | |
382 | } | |
383 | ||
b2896d2e PM |
384 | static void rcu_read_delay(struct rcu_random_state *rrsp) |
385 | { | |
b8d57a76 JT |
386 | const unsigned long shortdelay_us = 200; |
387 | const unsigned long longdelay_ms = 50; | |
b2896d2e | 388 | |
b8d57a76 JT |
389 | /* We want a short delay sometimes to make a reader delay the grace |
390 | * period, and we want a long delay occasionally to trigger | |
391 | * force_quiescent_state. */ | |
b2896d2e | 392 | |
b8d57a76 JT |
393 | if (!(rcu_random(rrsp) % (nrealreaders * 2000 * longdelay_ms))) |
394 | mdelay(longdelay_ms); | |
395 | if (!(rcu_random(rrsp) % (nrealreaders * 2 * shortdelay_us))) | |
396 | udelay(shortdelay_us); | |
e546f485 LJ |
397 | #ifdef CONFIG_PREEMPT |
398 | if (!preempt_count() && !(rcu_random(rrsp) % (nrealreaders * 20000))) | |
399 | preempt_schedule(); /* No QS if preempt_disable() in effect */ | |
400 | #endif | |
b2896d2e PM |
401 | } |
402 | ||
a49a4af7 | 403 | static void rcu_torture_read_unlock(int idx) __releases(RCU) |
72e9bb54 PM |
404 | { |
405 | rcu_read_unlock(); | |
406 | } | |
407 | ||
408 | static int rcu_torture_completed(void) | |
409 | { | |
410 | return rcu_batches_completed(); | |
411 | } | |
412 | ||
413 | static void | |
414 | rcu_torture_cb(struct rcu_head *p) | |
415 | { | |
416 | int i; | |
417 | struct rcu_torture *rp = container_of(p, struct rcu_torture, rtort_rcu); | |
418 | ||
c9d557c1 | 419 | if (fullstop != FULLSTOP_DONTSTOP) { |
72e9bb54 PM |
420 | /* Test is ending, just drop callbacks on the floor. */ |
421 | /* The next initialization will pick up the pieces. */ | |
422 | return; | |
423 | } | |
424 | i = rp->rtort_pipe_count; | |
425 | if (i > RCU_TORTURE_PIPE_LEN) | |
426 | i = RCU_TORTURE_PIPE_LEN; | |
427 | atomic_inc(&rcu_torture_wcount[i]); | |
428 | if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) { | |
429 | rp->rtort_mbtest = 0; | |
430 | rcu_torture_free(rp); | |
c701d5d9 | 431 | } else { |
0acc512c | 432 | cur_ops->deferred_free(rp); |
c701d5d9 | 433 | } |
72e9bb54 PM |
434 | } |
435 | ||
d9a3da06 PM |
436 | static int rcu_no_completed(void) |
437 | { | |
438 | return 0; | |
439 | } | |
440 | ||
72e9bb54 PM |
441 | static void rcu_torture_deferred_free(struct rcu_torture *p) |
442 | { | |
443 | call_rcu(&p->rtort_rcu, rcu_torture_cb); | |
444 | } | |
445 | ||
446 | static struct rcu_torture_ops rcu_ops = { | |
0acc512c | 447 | .init = NULL, |
0acc512c PM |
448 | .readlock = rcu_torture_read_lock, |
449 | .read_delay = rcu_read_delay, | |
450 | .readunlock = rcu_torture_read_unlock, | |
451 | .completed = rcu_torture_completed, | |
452 | .deferred_free = rcu_torture_deferred_free, | |
453 | .sync = synchronize_rcu, | |
fae4b54f | 454 | .call = call_rcu, |
0acc512c | 455 | .cb_barrier = rcu_barrier, |
bf66f18e | 456 | .fqs = rcu_force_quiescent_state, |
0acc512c | 457 | .stats = NULL, |
a71fca58 | 458 | .irq_capable = 1, |
8e8be45e | 459 | .can_boost = rcu_can_boost(), |
a71fca58 | 460 | .name = "rcu" |
72e9bb54 PM |
461 | }; |
462 | ||
e3033736 JT |
463 | static void rcu_sync_torture_deferred_free(struct rcu_torture *p) |
464 | { | |
465 | int i; | |
466 | struct rcu_torture *rp; | |
467 | struct rcu_torture *rp1; | |
468 | ||
469 | cur_ops->sync(); | |
470 | list_add(&p->rtort_free, &rcu_torture_removed); | |
471 | list_for_each_entry_safe(rp, rp1, &rcu_torture_removed, rtort_free) { | |
472 | i = rp->rtort_pipe_count; | |
473 | if (i > RCU_TORTURE_PIPE_LEN) | |
474 | i = RCU_TORTURE_PIPE_LEN; | |
475 | atomic_inc(&rcu_torture_wcount[i]); | |
476 | if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) { | |
477 | rp->rtort_mbtest = 0; | |
478 | list_del(&rp->rtort_free); | |
479 | rcu_torture_free(rp); | |
480 | } | |
481 | } | |
482 | } | |
483 | ||
484 | static void rcu_sync_torture_init(void) | |
485 | { | |
486 | INIT_LIST_HEAD(&rcu_torture_removed); | |
487 | } | |
488 | ||
20d2e428 | 489 | static struct rcu_torture_ops rcu_sync_ops = { |
0acc512c | 490 | .init = rcu_sync_torture_init, |
0acc512c PM |
491 | .readlock = rcu_torture_read_lock, |
492 | .read_delay = rcu_read_delay, | |
493 | .readunlock = rcu_torture_read_unlock, | |
494 | .completed = rcu_torture_completed, | |
495 | .deferred_free = rcu_sync_torture_deferred_free, | |
496 | .sync = synchronize_rcu, | |
fae4b54f | 497 | .call = NULL, |
0acc512c | 498 | .cb_barrier = NULL, |
bf66f18e | 499 | .fqs = rcu_force_quiescent_state, |
0acc512c PM |
500 | .stats = NULL, |
501 | .irq_capable = 1, | |
8e8be45e | 502 | .can_boost = rcu_can_boost(), |
0acc512c | 503 | .name = "rcu_sync" |
20d2e428 JT |
504 | }; |
505 | ||
d9a3da06 PM |
506 | static struct rcu_torture_ops rcu_expedited_ops = { |
507 | .init = rcu_sync_torture_init, | |
d9a3da06 PM |
508 | .readlock = rcu_torture_read_lock, |
509 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ | |
510 | .readunlock = rcu_torture_read_unlock, | |
511 | .completed = rcu_no_completed, | |
512 | .deferred_free = rcu_sync_torture_deferred_free, | |
513 | .sync = synchronize_rcu_expedited, | |
fae4b54f | 514 | .call = NULL, |
d9a3da06 | 515 | .cb_barrier = NULL, |
bf66f18e | 516 | .fqs = rcu_force_quiescent_state, |
d9a3da06 PM |
517 | .stats = NULL, |
518 | .irq_capable = 1, | |
8e8be45e | 519 | .can_boost = rcu_can_boost(), |
d9a3da06 PM |
520 | .name = "rcu_expedited" |
521 | }; | |
522 | ||
c32e0660 PM |
523 | /* |
524 | * Definitions for rcu_bh torture testing. | |
525 | */ | |
526 | ||
a49a4af7 | 527 | static int rcu_bh_torture_read_lock(void) __acquires(RCU_BH) |
c32e0660 PM |
528 | { |
529 | rcu_read_lock_bh(); | |
530 | return 0; | |
531 | } | |
532 | ||
a49a4af7 | 533 | static void rcu_bh_torture_read_unlock(int idx) __releases(RCU_BH) |
c32e0660 PM |
534 | { |
535 | rcu_read_unlock_bh(); | |
536 | } | |
537 | ||
538 | static int rcu_bh_torture_completed(void) | |
539 | { | |
540 | return rcu_batches_completed_bh(); | |
541 | } | |
542 | ||
543 | static void rcu_bh_torture_deferred_free(struct rcu_torture *p) | |
544 | { | |
545 | call_rcu_bh(&p->rtort_rcu, rcu_torture_cb); | |
546 | } | |
547 | ||
548 | static struct rcu_torture_ops rcu_bh_ops = { | |
0acc512c | 549 | .init = NULL, |
0acc512c PM |
550 | .readlock = rcu_bh_torture_read_lock, |
551 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ | |
552 | .readunlock = rcu_bh_torture_read_unlock, | |
553 | .completed = rcu_bh_torture_completed, | |
554 | .deferred_free = rcu_bh_torture_deferred_free, | |
bdf2a436 | 555 | .sync = synchronize_rcu_bh, |
fae4b54f | 556 | .call = call_rcu_bh, |
0acc512c | 557 | .cb_barrier = rcu_barrier_bh, |
bf66f18e | 558 | .fqs = rcu_bh_force_quiescent_state, |
0acc512c PM |
559 | .stats = NULL, |
560 | .irq_capable = 1, | |
561 | .name = "rcu_bh" | |
c32e0660 PM |
562 | }; |
563 | ||
11a14701 | 564 | static struct rcu_torture_ops rcu_bh_sync_ops = { |
0acc512c | 565 | .init = rcu_sync_torture_init, |
0acc512c PM |
566 | .readlock = rcu_bh_torture_read_lock, |
567 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ | |
568 | .readunlock = rcu_bh_torture_read_unlock, | |
569 | .completed = rcu_bh_torture_completed, | |
570 | .deferred_free = rcu_sync_torture_deferred_free, | |
bdf2a436 | 571 | .sync = synchronize_rcu_bh, |
fae4b54f | 572 | .call = NULL, |
0acc512c | 573 | .cb_barrier = NULL, |
bf66f18e | 574 | .fqs = rcu_bh_force_quiescent_state, |
0acc512c PM |
575 | .stats = NULL, |
576 | .irq_capable = 1, | |
577 | .name = "rcu_bh_sync" | |
11a14701 JT |
578 | }; |
579 | ||
bdf2a436 PM |
580 | static struct rcu_torture_ops rcu_bh_expedited_ops = { |
581 | .init = rcu_sync_torture_init, | |
bdf2a436 PM |
582 | .readlock = rcu_bh_torture_read_lock, |
583 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ | |
584 | .readunlock = rcu_bh_torture_read_unlock, | |
585 | .completed = rcu_bh_torture_completed, | |
586 | .deferred_free = rcu_sync_torture_deferred_free, | |
587 | .sync = synchronize_rcu_bh_expedited, | |
fae4b54f | 588 | .call = NULL, |
bdf2a436 PM |
589 | .cb_barrier = NULL, |
590 | .fqs = rcu_bh_force_quiescent_state, | |
591 | .stats = NULL, | |
592 | .irq_capable = 1, | |
593 | .name = "rcu_bh_expedited" | |
594 | }; | |
595 | ||
b2896d2e PM |
596 | /* |
597 | * Definitions for srcu torture testing. | |
598 | */ | |
599 | ||
cda4dc81 | 600 | DEFINE_STATIC_SRCU(srcu_ctl); |
b2896d2e | 601 | |
012d3ca8 | 602 | static int srcu_torture_read_lock(void) __acquires(&srcu_ctl) |
b2896d2e PM |
603 | { |
604 | return srcu_read_lock(&srcu_ctl); | |
605 | } | |
606 | ||
607 | static void srcu_read_delay(struct rcu_random_state *rrsp) | |
608 | { | |
609 | long delay; | |
610 | const long uspertick = 1000000 / HZ; | |
611 | const long longdelay = 10; | |
612 | ||
613 | /* We want there to be long-running readers, but not all the time. */ | |
614 | ||
615 | delay = rcu_random(rrsp) % (nrealreaders * 2 * longdelay * uspertick); | |
616 | if (!delay) | |
617 | schedule_timeout_interruptible(longdelay); | |
e546f485 LJ |
618 | else |
619 | rcu_read_delay(rrsp); | |
b2896d2e PM |
620 | } |
621 | ||
012d3ca8 | 622 | static void srcu_torture_read_unlock(int idx) __releases(&srcu_ctl) |
b2896d2e PM |
623 | { |
624 | srcu_read_unlock(&srcu_ctl, idx); | |
625 | } | |
626 | ||
627 | static int srcu_torture_completed(void) | |
628 | { | |
629 | return srcu_batches_completed(&srcu_ctl); | |
630 | } | |
631 | ||
9059c940 LJ |
632 | static void srcu_torture_deferred_free(struct rcu_torture *rp) |
633 | { | |
634 | call_srcu(&srcu_ctl, &rp->rtort_rcu, rcu_torture_cb); | |
635 | } | |
636 | ||
b772e1dd JT |
637 | static void srcu_torture_synchronize(void) |
638 | { | |
639 | synchronize_srcu(&srcu_ctl); | |
640 | } | |
641 | ||
e3f8d378 PM |
642 | static void srcu_torture_call(struct rcu_head *head, |
643 | void (*func)(struct rcu_head *head)) | |
644 | { | |
645 | call_srcu(&srcu_ctl, head, func); | |
646 | } | |
647 | ||
648 | static void srcu_torture_barrier(void) | |
649 | { | |
650 | srcu_barrier(&srcu_ctl); | |
651 | } | |
652 | ||
b2896d2e PM |
653 | static int srcu_torture_stats(char *page) |
654 | { | |
655 | int cnt = 0; | |
656 | int cpu; | |
657 | int idx = srcu_ctl.completed & 0x1; | |
658 | ||
659 | cnt += sprintf(&page[cnt], "%s%s per-CPU(idx=%d):", | |
660 | torture_type, TORTURE_FLAG, idx); | |
661 | for_each_possible_cpu(cpu) { | |
cef50120 | 662 | cnt += sprintf(&page[cnt], " %d(%lu,%lu)", cpu, |
b2896d2e PM |
663 | per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[!idx], |
664 | per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[idx]); | |
665 | } | |
666 | cnt += sprintf(&page[cnt], "\n"); | |
667 | return cnt; | |
668 | } | |
669 | ||
670 | static struct rcu_torture_ops srcu_ops = { | |
cda4dc81 | 671 | .init = rcu_sync_torture_init, |
0acc512c PM |
672 | .readlock = srcu_torture_read_lock, |
673 | .read_delay = srcu_read_delay, | |
674 | .readunlock = srcu_torture_read_unlock, | |
675 | .completed = srcu_torture_completed, | |
9059c940 | 676 | .deferred_free = srcu_torture_deferred_free, |
0acc512c | 677 | .sync = srcu_torture_synchronize, |
e3f8d378 PM |
678 | .call = srcu_torture_call, |
679 | .cb_barrier = srcu_torture_barrier, | |
0acc512c PM |
680 | .stats = srcu_torture_stats, |
681 | .name = "srcu" | |
b2896d2e PM |
682 | }; |
683 | ||
9059c940 | 684 | static struct rcu_torture_ops srcu_sync_ops = { |
cda4dc81 | 685 | .init = rcu_sync_torture_init, |
9059c940 LJ |
686 | .readlock = srcu_torture_read_lock, |
687 | .read_delay = srcu_read_delay, | |
688 | .readunlock = srcu_torture_read_unlock, | |
689 | .completed = srcu_torture_completed, | |
690 | .deferred_free = rcu_sync_torture_deferred_free, | |
691 | .sync = srcu_torture_synchronize, | |
692 | .call = NULL, | |
693 | .cb_barrier = NULL, | |
694 | .stats = srcu_torture_stats, | |
695 | .name = "srcu_sync" | |
696 | }; | |
697 | ||
101db7b4 PM |
698 | static int srcu_torture_read_lock_raw(void) __acquires(&srcu_ctl) |
699 | { | |
700 | return srcu_read_lock_raw(&srcu_ctl); | |
701 | } | |
702 | ||
703 | static void srcu_torture_read_unlock_raw(int idx) __releases(&srcu_ctl) | |
704 | { | |
705 | srcu_read_unlock_raw(&srcu_ctl, idx); | |
706 | } | |
707 | ||
708 | static struct rcu_torture_ops srcu_raw_ops = { | |
cda4dc81 | 709 | .init = rcu_sync_torture_init, |
101db7b4 PM |
710 | .readlock = srcu_torture_read_lock_raw, |
711 | .read_delay = srcu_read_delay, | |
712 | .readunlock = srcu_torture_read_unlock_raw, | |
713 | .completed = srcu_torture_completed, | |
9059c940 | 714 | .deferred_free = srcu_torture_deferred_free, |
101db7b4 | 715 | .sync = srcu_torture_synchronize, |
fae4b54f | 716 | .call = NULL, |
101db7b4 PM |
717 | .cb_barrier = NULL, |
718 | .stats = srcu_torture_stats, | |
719 | .name = "srcu_raw" | |
720 | }; | |
721 | ||
9059c940 | 722 | static struct rcu_torture_ops srcu_raw_sync_ops = { |
cda4dc81 | 723 | .init = rcu_sync_torture_init, |
9059c940 LJ |
724 | .readlock = srcu_torture_read_lock_raw, |
725 | .read_delay = srcu_read_delay, | |
726 | .readunlock = srcu_torture_read_unlock_raw, | |
727 | .completed = srcu_torture_completed, | |
728 | .deferred_free = rcu_sync_torture_deferred_free, | |
729 | .sync = srcu_torture_synchronize, | |
730 | .call = NULL, | |
731 | .cb_barrier = NULL, | |
732 | .stats = srcu_torture_stats, | |
733 | .name = "srcu_raw_sync" | |
734 | }; | |
735 | ||
804bb837 PM |
736 | static void srcu_torture_synchronize_expedited(void) |
737 | { | |
738 | synchronize_srcu_expedited(&srcu_ctl); | |
739 | } | |
740 | ||
741 | static struct rcu_torture_ops srcu_expedited_ops = { | |
cda4dc81 | 742 | .init = rcu_sync_torture_init, |
804bb837 PM |
743 | .readlock = srcu_torture_read_lock, |
744 | .read_delay = srcu_read_delay, | |
745 | .readunlock = srcu_torture_read_unlock, | |
746 | .completed = srcu_torture_completed, | |
747 | .deferred_free = rcu_sync_torture_deferred_free, | |
748 | .sync = srcu_torture_synchronize_expedited, | |
fae4b54f | 749 | .call = NULL, |
804bb837 PM |
750 | .cb_barrier = NULL, |
751 | .stats = srcu_torture_stats, | |
752 | .name = "srcu_expedited" | |
753 | }; | |
754 | ||
4b6c2cca JT |
755 | /* |
756 | * Definitions for sched torture testing. | |
757 | */ | |
758 | ||
759 | static int sched_torture_read_lock(void) | |
760 | { | |
761 | preempt_disable(); | |
762 | return 0; | |
763 | } | |
764 | ||
765 | static void sched_torture_read_unlock(int idx) | |
766 | { | |
767 | preempt_enable(); | |
768 | } | |
769 | ||
2326974d PM |
770 | static void rcu_sched_torture_deferred_free(struct rcu_torture *p) |
771 | { | |
772 | call_rcu_sched(&p->rtort_rcu, rcu_torture_cb); | |
773 | } | |
774 | ||
4b6c2cca | 775 | static struct rcu_torture_ops sched_ops = { |
0acc512c | 776 | .init = rcu_sync_torture_init, |
0acc512c PM |
777 | .readlock = sched_torture_read_lock, |
778 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ | |
779 | .readunlock = sched_torture_read_unlock, | |
d9a3da06 | 780 | .completed = rcu_no_completed, |
0acc512c | 781 | .deferred_free = rcu_sched_torture_deferred_free, |
bdf2a436 | 782 | .sync = synchronize_sched, |
0acc512c | 783 | .cb_barrier = rcu_barrier_sched, |
bf66f18e | 784 | .fqs = rcu_sched_force_quiescent_state, |
0acc512c PM |
785 | .stats = NULL, |
786 | .irq_capable = 1, | |
787 | .name = "sched" | |
4b6c2cca JT |
788 | }; |
789 | ||
804bb837 | 790 | static struct rcu_torture_ops sched_sync_ops = { |
0acc512c | 791 | .init = rcu_sync_torture_init, |
0acc512c PM |
792 | .readlock = sched_torture_read_lock, |
793 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ | |
794 | .readunlock = sched_torture_read_unlock, | |
d9a3da06 | 795 | .completed = rcu_no_completed, |
0acc512c | 796 | .deferred_free = rcu_sync_torture_deferred_free, |
bdf2a436 | 797 | .sync = synchronize_sched, |
0acc512c | 798 | .cb_barrier = NULL, |
bf66f18e | 799 | .fqs = rcu_sched_force_quiescent_state, |
0acc512c PM |
800 | .stats = NULL, |
801 | .name = "sched_sync" | |
802 | }; | |
803 | ||
0acc512c PM |
804 | static struct rcu_torture_ops sched_expedited_ops = { |
805 | .init = rcu_sync_torture_init, | |
0acc512c PM |
806 | .readlock = sched_torture_read_lock, |
807 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ | |
808 | .readunlock = sched_torture_read_unlock, | |
d9a3da06 | 809 | .completed = rcu_no_completed, |
0acc512c PM |
810 | .deferred_free = rcu_sync_torture_deferred_free, |
811 | .sync = synchronize_sched_expedited, | |
812 | .cb_barrier = NULL, | |
bf66f18e | 813 | .fqs = rcu_sched_force_quiescent_state, |
969c7921 | 814 | .stats = NULL, |
0acc512c PM |
815 | .irq_capable = 1, |
816 | .name = "sched_expedited" | |
2326974d PM |
817 | }; |
818 | ||
8e8be45e PM |
819 | /* |
820 | * RCU torture priority-boost testing. Runs one real-time thread per | |
821 | * CPU for moderate bursts, repeatedly registering RCU callbacks and | |
822 | * spinning waiting for them to be invoked. If a given callback takes | |
823 | * too long to be invoked, we assume that priority inversion has occurred. | |
824 | */ | |
825 | ||
826 | struct rcu_boost_inflight { | |
827 | struct rcu_head rcu; | |
828 | int inflight; | |
829 | }; | |
830 | ||
831 | static void rcu_torture_boost_cb(struct rcu_head *head) | |
832 | { | |
833 | struct rcu_boost_inflight *rbip = | |
834 | container_of(head, struct rcu_boost_inflight, rcu); | |
835 | ||
836 | smp_mb(); /* Ensure RCU-core accesses precede clearing ->inflight */ | |
837 | rbip->inflight = 0; | |
838 | } | |
839 | ||
840 | static int rcu_torture_boost(void *arg) | |
841 | { | |
842 | unsigned long call_rcu_time; | |
843 | unsigned long endtime; | |
844 | unsigned long oldstarttime; | |
845 | struct rcu_boost_inflight rbi = { .inflight = 0 }; | |
846 | struct sched_param sp; | |
847 | ||
848 | VERBOSE_PRINTK_STRING("rcu_torture_boost started"); | |
849 | ||
850 | /* Set real-time priority. */ | |
851 | sp.sched_priority = 1; | |
852 | if (sched_setscheduler(current, SCHED_FIFO, &sp) < 0) { | |
853 | VERBOSE_PRINTK_STRING("rcu_torture_boost RT prio failed!"); | |
854 | n_rcu_torture_boost_rterror++; | |
855 | } | |
856 | ||
561190e3 | 857 | init_rcu_head_on_stack(&rbi.rcu); |
8e8be45e PM |
858 | /* Each pass through the following loop does one boost-test cycle. */ |
859 | do { | |
860 | /* Wait for the next test interval. */ | |
861 | oldstarttime = boost_starttime; | |
93898fb1 | 862 | while (ULONG_CMP_LT(jiffies, oldstarttime)) { |
0e11c8e8 | 863 | schedule_timeout_interruptible(oldstarttime - jiffies); |
8e8be45e PM |
864 | rcu_stutter_wait("rcu_torture_boost"); |
865 | if (kthread_should_stop() || | |
866 | fullstop != FULLSTOP_DONTSTOP) | |
867 | goto checkwait; | |
868 | } | |
869 | ||
870 | /* Do one boost-test interval. */ | |
871 | endtime = oldstarttime + test_boost_duration * HZ; | |
872 | call_rcu_time = jiffies; | |
93898fb1 | 873 | while (ULONG_CMP_LT(jiffies, endtime)) { |
8e8be45e PM |
874 | /* If we don't have a callback in flight, post one. */ |
875 | if (!rbi.inflight) { | |
876 | smp_mb(); /* RCU core before ->inflight = 1. */ | |
877 | rbi.inflight = 1; | |
878 | call_rcu(&rbi.rcu, rcu_torture_boost_cb); | |
879 | if (jiffies - call_rcu_time > | |
880 | test_boost_duration * HZ - HZ / 2) { | |
881 | VERBOSE_PRINTK_STRING("rcu_torture_boost boosting failed"); | |
882 | n_rcu_torture_boost_failure++; | |
883 | } | |
884 | call_rcu_time = jiffies; | |
885 | } | |
886 | cond_resched(); | |
887 | rcu_stutter_wait("rcu_torture_boost"); | |
888 | if (kthread_should_stop() || | |
889 | fullstop != FULLSTOP_DONTSTOP) | |
890 | goto checkwait; | |
891 | } | |
892 | ||
893 | /* | |
894 | * Set the start time of the next test interval. | |
895 | * Yes, this is vulnerable to long delays, but such | |
896 | * delays simply cause a false negative for the next | |
897 | * interval. Besides, we are running at RT priority, | |
898 | * so delays should be relatively rare. | |
899 | */ | |
ab8f11e5 PM |
900 | while (oldstarttime == boost_starttime && |
901 | !kthread_should_stop()) { | |
8e8be45e PM |
902 | if (mutex_trylock(&boost_mutex)) { |
903 | boost_starttime = jiffies + | |
904 | test_boost_interval * HZ; | |
905 | n_rcu_torture_boosts++; | |
906 | mutex_unlock(&boost_mutex); | |
907 | break; | |
908 | } | |
909 | schedule_timeout_uninterruptible(1); | |
910 | } | |
911 | ||
912 | /* Go do the stutter. */ | |
913 | checkwait: rcu_stutter_wait("rcu_torture_boost"); | |
914 | } while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP); | |
915 | ||
916 | /* Clean up and exit. */ | |
917 | VERBOSE_PRINTK_STRING("rcu_torture_boost task stopping"); | |
918 | rcutorture_shutdown_absorb("rcu_torture_boost"); | |
919 | while (!kthread_should_stop() || rbi.inflight) | |
920 | schedule_timeout_uninterruptible(1); | |
921 | smp_mb(); /* order accesses to ->inflight before stack-frame death. */ | |
9d68197c | 922 | destroy_rcu_head_on_stack(&rbi.rcu); |
8e8be45e PM |
923 | return 0; |
924 | } | |
925 | ||
bf66f18e PM |
926 | /* |
927 | * RCU torture force-quiescent-state kthread. Repeatedly induces | |
928 | * bursts of calls to force_quiescent_state(), increasing the probability | |
929 | * of occurrence of some important types of race conditions. | |
930 | */ | |
931 | static int | |
932 | rcu_torture_fqs(void *arg) | |
933 | { | |
934 | unsigned long fqs_resume_time; | |
935 | int fqs_burst_remaining; | |
936 | ||
937 | VERBOSE_PRINTK_STRING("rcu_torture_fqs task started"); | |
938 | do { | |
939 | fqs_resume_time = jiffies + fqs_stutter * HZ; | |
93898fb1 PM |
940 | while (ULONG_CMP_LT(jiffies, fqs_resume_time) && |
941 | !kthread_should_stop()) { | |
bf66f18e PM |
942 | schedule_timeout_interruptible(1); |
943 | } | |
944 | fqs_burst_remaining = fqs_duration; | |
93898fb1 PM |
945 | while (fqs_burst_remaining > 0 && |
946 | !kthread_should_stop()) { | |
bf66f18e PM |
947 | cur_ops->fqs(); |
948 | udelay(fqs_holdoff); | |
949 | fqs_burst_remaining -= fqs_holdoff; | |
950 | } | |
951 | rcu_stutter_wait("rcu_torture_fqs"); | |
952 | } while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP); | |
953 | VERBOSE_PRINTK_STRING("rcu_torture_fqs task stopping"); | |
954 | rcutorture_shutdown_absorb("rcu_torture_fqs"); | |
955 | while (!kthread_should_stop()) | |
956 | schedule_timeout_uninterruptible(1); | |
957 | return 0; | |
958 | } | |
959 | ||
a241ec65 PM |
960 | /* |
961 | * RCU torture writer kthread. Repeatedly substitutes a new structure | |
962 | * for that pointed to by rcu_torture_current, freeing the old structure | |
963 | * after a series of grace periods (the "pipeline"). | |
964 | */ | |
965 | static int | |
966 | rcu_torture_writer(void *arg) | |
967 | { | |
968 | int i; | |
969 | long oldbatch = rcu_batches_completed(); | |
970 | struct rcu_torture *rp; | |
971 | struct rcu_torture *old_rp; | |
972 | static DEFINE_RCU_RANDOM(rand); | |
973 | ||
974 | VERBOSE_PRINTK_STRING("rcu_torture_writer task started"); | |
dbdf65b1 IM |
975 | set_user_nice(current, 19); |
976 | ||
a241ec65 PM |
977 | do { |
978 | schedule_timeout_uninterruptible(1); | |
a71fca58 PM |
979 | rp = rcu_torture_alloc(); |
980 | if (rp == NULL) | |
a241ec65 PM |
981 | continue; |
982 | rp->rtort_pipe_count = 0; | |
983 | udelay(rcu_random(&rand) & 0x3ff); | |
0ddea0ea PM |
984 | old_rp = rcu_dereference_check(rcu_torture_current, |
985 | current == writer_task); | |
996417d2 | 986 | rp->rtort_mbtest = 1; |
a241ec65 | 987 | rcu_assign_pointer(rcu_torture_current, rp); |
9b2619af | 988 | smp_wmb(); /* Mods to old_rp must follow rcu_assign_pointer() */ |
c8e5b163 | 989 | if (old_rp) { |
a241ec65 PM |
990 | i = old_rp->rtort_pipe_count; |
991 | if (i > RCU_TORTURE_PIPE_LEN) | |
992 | i = RCU_TORTURE_PIPE_LEN; | |
993 | atomic_inc(&rcu_torture_wcount[i]); | |
994 | old_rp->rtort_pipe_count++; | |
0acc512c | 995 | cur_ops->deferred_free(old_rp); |
a241ec65 | 996 | } |
4a298656 | 997 | rcutorture_record_progress(++rcu_torture_current_version); |
72e9bb54 | 998 | oldbatch = cur_ops->completed(); |
c9d557c1 PM |
999 | rcu_stutter_wait("rcu_torture_writer"); |
1000 | } while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP); | |
a241ec65 | 1001 | VERBOSE_PRINTK_STRING("rcu_torture_writer task stopping"); |
c9d557c1 PM |
1002 | rcutorture_shutdown_absorb("rcu_torture_writer"); |
1003 | while (!kthread_should_stop()) | |
a241ec65 PM |
1004 | schedule_timeout_uninterruptible(1); |
1005 | return 0; | |
1006 | } | |
1007 | ||
b772e1dd JT |
1008 | /* |
1009 | * RCU torture fake writer kthread. Repeatedly calls sync, with a random | |
1010 | * delay between calls. | |
1011 | */ | |
1012 | static int | |
1013 | rcu_torture_fakewriter(void *arg) | |
1014 | { | |
1015 | DEFINE_RCU_RANDOM(rand); | |
1016 | ||
1017 | VERBOSE_PRINTK_STRING("rcu_torture_fakewriter task started"); | |
1018 | set_user_nice(current, 19); | |
1019 | ||
1020 | do { | |
1021 | schedule_timeout_uninterruptible(1 + rcu_random(&rand)%10); | |
1022 | udelay(rcu_random(&rand) & 0x3ff); | |
72472a02 PM |
1023 | if (cur_ops->cb_barrier != NULL && |
1024 | rcu_random(&rand) % (nfakewriters * 8) == 0) | |
1025 | cur_ops->cb_barrier(); | |
1026 | else | |
1027 | cur_ops->sync(); | |
c9d557c1 PM |
1028 | rcu_stutter_wait("rcu_torture_fakewriter"); |
1029 | } while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP); | |
b772e1dd JT |
1030 | |
1031 | VERBOSE_PRINTK_STRING("rcu_torture_fakewriter task stopping"); | |
c9d557c1 PM |
1032 | rcutorture_shutdown_absorb("rcu_torture_fakewriter"); |
1033 | while (!kthread_should_stop()) | |
b772e1dd JT |
1034 | schedule_timeout_uninterruptible(1); |
1035 | return 0; | |
1036 | } | |
1037 | ||
91afaf30 PM |
1038 | void rcutorture_trace_dump(void) |
1039 | { | |
1040 | static atomic_t beenhere = ATOMIC_INIT(0); | |
1041 | ||
1042 | if (atomic_read(&beenhere)) | |
1043 | return; | |
1044 | if (atomic_xchg(&beenhere, 1) != 0) | |
1045 | return; | |
91afaf30 PM |
1046 | ftrace_dump(DUMP_ALL); |
1047 | } | |
1048 | ||
0729fbf3 PM |
1049 | /* |
1050 | * RCU torture reader from timer handler. Dereferences rcu_torture_current, | |
1051 | * incrementing the corresponding element of the pipeline array. The | |
1052 | * counter in the element should never be greater than 1, otherwise, the | |
1053 | * RCU implementation is broken. | |
1054 | */ | |
1055 | static void rcu_torture_timer(unsigned long unused) | |
1056 | { | |
1057 | int idx; | |
1058 | int completed; | |
52494535 | 1059 | int completed_end; |
0729fbf3 PM |
1060 | static DEFINE_RCU_RANDOM(rand); |
1061 | static DEFINE_SPINLOCK(rand_lock); | |
1062 | struct rcu_torture *p; | |
1063 | int pipe_count; | |
52494535 | 1064 | unsigned long long ts; |
0729fbf3 PM |
1065 | |
1066 | idx = cur_ops->readlock(); | |
1067 | completed = cur_ops->completed(); | |
e4aa0da3 | 1068 | ts = rcu_trace_clock_local(); |
632ee200 | 1069 | p = rcu_dereference_check(rcu_torture_current, |
632ee200 PM |
1070 | rcu_read_lock_bh_held() || |
1071 | rcu_read_lock_sched_held() || | |
1072 | srcu_read_lock_held(&srcu_ctl)); | |
0729fbf3 PM |
1073 | if (p == NULL) { |
1074 | /* Leave because rcu_torture_writer is not yet underway */ | |
1075 | cur_ops->readunlock(idx); | |
1076 | return; | |
1077 | } | |
1078 | if (p->rtort_mbtest == 0) | |
1079 | atomic_inc(&n_rcu_torture_mberror); | |
1080 | spin_lock(&rand_lock); | |
0acc512c | 1081 | cur_ops->read_delay(&rand); |
0729fbf3 PM |
1082 | n_rcu_torture_timers++; |
1083 | spin_unlock(&rand_lock); | |
1084 | preempt_disable(); | |
1085 | pipe_count = p->rtort_pipe_count; | |
1086 | if (pipe_count > RCU_TORTURE_PIPE_LEN) { | |
1087 | /* Should not happen, but... */ | |
1088 | pipe_count = RCU_TORTURE_PIPE_LEN; | |
1089 | } | |
52494535 PM |
1090 | completed_end = cur_ops->completed(); |
1091 | if (pipe_count > 1) { | |
52494535 PM |
1092 | do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu, ts, |
1093 | completed, completed_end); | |
91afaf30 | 1094 | rcutorture_trace_dump(); |
52494535 | 1095 | } |
dd17c8f7 | 1096 | __this_cpu_inc(rcu_torture_count[pipe_count]); |
52494535 | 1097 | completed = completed_end - completed; |
0729fbf3 PM |
1098 | if (completed > RCU_TORTURE_PIPE_LEN) { |
1099 | /* Should not happen, but... */ | |
1100 | completed = RCU_TORTURE_PIPE_LEN; | |
1101 | } | |
dd17c8f7 | 1102 | __this_cpu_inc(rcu_torture_batch[completed]); |
0729fbf3 PM |
1103 | preempt_enable(); |
1104 | cur_ops->readunlock(idx); | |
1105 | } | |
1106 | ||
a241ec65 PM |
1107 | /* |
1108 | * RCU torture reader kthread. Repeatedly dereferences rcu_torture_current, | |
1109 | * incrementing the corresponding element of the pipeline array. The | |
1110 | * counter in the element should never be greater than 1, otherwise, the | |
1111 | * RCU implementation is broken. | |
1112 | */ | |
1113 | static int | |
1114 | rcu_torture_reader(void *arg) | |
1115 | { | |
1116 | int completed; | |
52494535 | 1117 | int completed_end; |
72e9bb54 | 1118 | int idx; |
a241ec65 PM |
1119 | DEFINE_RCU_RANDOM(rand); |
1120 | struct rcu_torture *p; | |
1121 | int pipe_count; | |
0729fbf3 | 1122 | struct timer_list t; |
52494535 | 1123 | unsigned long long ts; |
a241ec65 PM |
1124 | |
1125 | VERBOSE_PRINTK_STRING("rcu_torture_reader task started"); | |
dbdf65b1 | 1126 | set_user_nice(current, 19); |
0acc512c | 1127 | if (irqreader && cur_ops->irq_capable) |
0729fbf3 | 1128 | setup_timer_on_stack(&t, rcu_torture_timer, 0); |
dbdf65b1 | 1129 | |
a241ec65 | 1130 | do { |
0acc512c | 1131 | if (irqreader && cur_ops->irq_capable) { |
0729fbf3 | 1132 | if (!timer_pending(&t)) |
6155fec9 | 1133 | mod_timer(&t, jiffies + 1); |
0729fbf3 | 1134 | } |
72e9bb54 PM |
1135 | idx = cur_ops->readlock(); |
1136 | completed = cur_ops->completed(); | |
e4aa0da3 | 1137 | ts = rcu_trace_clock_local(); |
632ee200 | 1138 | p = rcu_dereference_check(rcu_torture_current, |
632ee200 PM |
1139 | rcu_read_lock_bh_held() || |
1140 | rcu_read_lock_sched_held() || | |
1141 | srcu_read_lock_held(&srcu_ctl)); | |
a241ec65 PM |
1142 | if (p == NULL) { |
1143 | /* Wait for rcu_torture_writer to get underway */ | |
72e9bb54 | 1144 | cur_ops->readunlock(idx); |
a241ec65 PM |
1145 | schedule_timeout_interruptible(HZ); |
1146 | continue; | |
1147 | } | |
996417d2 PM |
1148 | if (p->rtort_mbtest == 0) |
1149 | atomic_inc(&n_rcu_torture_mberror); | |
0acc512c | 1150 | cur_ops->read_delay(&rand); |
a241ec65 PM |
1151 | preempt_disable(); |
1152 | pipe_count = p->rtort_pipe_count; | |
1153 | if (pipe_count > RCU_TORTURE_PIPE_LEN) { | |
1154 | /* Should not happen, but... */ | |
1155 | pipe_count = RCU_TORTURE_PIPE_LEN; | |
1156 | } | |
52494535 PM |
1157 | completed_end = cur_ops->completed(); |
1158 | if (pipe_count > 1) { | |
52494535 PM |
1159 | do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu, |
1160 | ts, completed, completed_end); | |
91afaf30 | 1161 | rcutorture_trace_dump(); |
52494535 | 1162 | } |
dd17c8f7 | 1163 | __this_cpu_inc(rcu_torture_count[pipe_count]); |
52494535 | 1164 | completed = completed_end - completed; |
a241ec65 PM |
1165 | if (completed > RCU_TORTURE_PIPE_LEN) { |
1166 | /* Should not happen, but... */ | |
1167 | completed = RCU_TORTURE_PIPE_LEN; | |
1168 | } | |
dd17c8f7 | 1169 | __this_cpu_inc(rcu_torture_batch[completed]); |
a241ec65 | 1170 | preempt_enable(); |
72e9bb54 | 1171 | cur_ops->readunlock(idx); |
a241ec65 | 1172 | schedule(); |
c9d557c1 PM |
1173 | rcu_stutter_wait("rcu_torture_reader"); |
1174 | } while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP); | |
a241ec65 | 1175 | VERBOSE_PRINTK_STRING("rcu_torture_reader task stopping"); |
c9d557c1 | 1176 | rcutorture_shutdown_absorb("rcu_torture_reader"); |
0acc512c | 1177 | if (irqreader && cur_ops->irq_capable) |
0729fbf3 | 1178 | del_timer_sync(&t); |
c9d557c1 | 1179 | while (!kthread_should_stop()) |
a241ec65 PM |
1180 | schedule_timeout_uninterruptible(1); |
1181 | return 0; | |
1182 | } | |
1183 | ||
1184 | /* | |
1185 | * Create an RCU-torture statistics message in the specified buffer. | |
1186 | */ | |
1187 | static int | |
1188 | rcu_torture_printk(char *page) | |
1189 | { | |
1190 | int cnt = 0; | |
1191 | int cpu; | |
1192 | int i; | |
1193 | long pipesummary[RCU_TORTURE_PIPE_LEN + 1] = { 0 }; | |
1194 | long batchsummary[RCU_TORTURE_PIPE_LEN + 1] = { 0 }; | |
1195 | ||
0a945022 | 1196 | for_each_possible_cpu(cpu) { |
a241ec65 PM |
1197 | for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) { |
1198 | pipesummary[i] += per_cpu(rcu_torture_count, cpu)[i]; | |
1199 | batchsummary[i] += per_cpu(rcu_torture_batch, cpu)[i]; | |
1200 | } | |
1201 | } | |
1202 | for (i = RCU_TORTURE_PIPE_LEN - 1; i >= 0; i--) { | |
1203 | if (pipesummary[i] != 0) | |
1204 | break; | |
1205 | } | |
72e9bb54 | 1206 | cnt += sprintf(&page[cnt], "%s%s ", torture_type, TORTURE_FLAG); |
a241ec65 | 1207 | cnt += sprintf(&page[cnt], |
5cf05ad7 | 1208 | "rtc: %p ver: %lu tfle: %d rta: %d rtaf: %d rtf: %d ", |
a241ec65 PM |
1209 | rcu_torture_current, |
1210 | rcu_torture_current_version, | |
1211 | list_empty(&rcu_torture_freelist), | |
1212 | atomic_read(&n_rcu_torture_alloc), | |
1213 | atomic_read(&n_rcu_torture_alloc_fail), | |
5cf05ad7 PM |
1214 | atomic_read(&n_rcu_torture_free)); |
1215 | cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ", | |
0729fbf3 | 1216 | atomic_read(&n_rcu_torture_mberror), |
8e8be45e | 1217 | n_rcu_torture_boost_ktrerror, |
5cf05ad7 PM |
1218 | n_rcu_torture_boost_rterror); |
1219 | cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ", | |
8e8be45e PM |
1220 | n_rcu_torture_boost_failure, |
1221 | n_rcu_torture_boosts, | |
5cf05ad7 | 1222 | n_rcu_torture_timers); |
13dbf914 PM |
1223 | cnt += sprintf(&page[cnt], |
1224 | "onoff: %ld/%ld:%ld/%ld %d,%d:%d,%d %lu:%lu (HZ=%d) ", | |
1225 | n_online_successes, n_online_attempts, | |
1226 | n_offline_successes, n_offline_attempts, | |
1227 | min_online, max_online, | |
1228 | min_offline, max_offline, | |
1229 | sum_online, sum_offline, HZ); | |
5cf05ad7 | 1230 | cnt += sprintf(&page[cnt], "barrier: %ld/%ld:%ld", |
fae4b54f PM |
1231 | n_barrier_successes, |
1232 | n_barrier_attempts, | |
1233 | n_rcu_torture_barrier_error); | |
1234 | cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG); | |
8e8be45e | 1235 | if (atomic_read(&n_rcu_torture_mberror) != 0 || |
fae4b54f | 1236 | n_rcu_torture_barrier_error != 0 || |
8e8be45e PM |
1237 | n_rcu_torture_boost_ktrerror != 0 || |
1238 | n_rcu_torture_boost_rterror != 0 || | |
fae4b54f PM |
1239 | n_rcu_torture_boost_failure != 0 || |
1240 | i > 1) { | |
a241ec65 | 1241 | cnt += sprintf(&page[cnt], "!!! "); |
996417d2 | 1242 | atomic_inc(&n_rcu_torture_error); |
5af970a4 | 1243 | WARN_ON_ONCE(1); |
996417d2 | 1244 | } |
a241ec65 PM |
1245 | cnt += sprintf(&page[cnt], "Reader Pipe: "); |
1246 | for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) | |
1247 | cnt += sprintf(&page[cnt], " %ld", pipesummary[i]); | |
72e9bb54 | 1248 | cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG); |
a241ec65 | 1249 | cnt += sprintf(&page[cnt], "Reader Batch: "); |
72e9bb54 | 1250 | for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) |
a241ec65 | 1251 | cnt += sprintf(&page[cnt], " %ld", batchsummary[i]); |
72e9bb54 | 1252 | cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG); |
a241ec65 PM |
1253 | cnt += sprintf(&page[cnt], "Free-Block Circulation: "); |
1254 | for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) { | |
1255 | cnt += sprintf(&page[cnt], " %d", | |
1256 | atomic_read(&rcu_torture_wcount[i])); | |
1257 | } | |
1258 | cnt += sprintf(&page[cnt], "\n"); | |
c8e5b163 | 1259 | if (cur_ops->stats) |
72e9bb54 | 1260 | cnt += cur_ops->stats(&page[cnt]); |
a241ec65 PM |
1261 | return cnt; |
1262 | } | |
1263 | ||
1264 | /* | |
1265 | * Print torture statistics. Caller must ensure that there is only | |
1266 | * one call to this function at a given time!!! This is normally | |
1267 | * accomplished by relying on the module system to only have one copy | |
1268 | * of the module loaded, and then by giving the rcu_torture_stats | |
1269 | * kthread full control (or the init/cleanup functions when rcu_torture_stats | |
1270 | * thread is not running). | |
1271 | */ | |
1272 | static void | |
1273 | rcu_torture_stats_print(void) | |
1274 | { | |
1275 | int cnt; | |
1276 | ||
1277 | cnt = rcu_torture_printk(printk_buf); | |
2caa1e44 | 1278 | pr_alert("%s", printk_buf); |
a241ec65 PM |
1279 | } |
1280 | ||
1281 | /* | |
1282 | * Periodically prints torture statistics, if periodic statistics printing | |
1283 | * was specified via the stat_interval module parameter. | |
1284 | * | |
1285 | * No need to worry about fullstop here, since this one doesn't reference | |
1286 | * volatile state or register callbacks. | |
1287 | */ | |
1288 | static int | |
1289 | rcu_torture_stats(void *arg) | |
1290 | { | |
1291 | VERBOSE_PRINTK_STRING("rcu_torture_stats task started"); | |
1292 | do { | |
1293 | schedule_timeout_interruptible(stat_interval * HZ); | |
1294 | rcu_torture_stats_print(); | |
c9d557c1 PM |
1295 | rcutorture_shutdown_absorb("rcu_torture_stats"); |
1296 | } while (!kthread_should_stop()); | |
a241ec65 PM |
1297 | VERBOSE_PRINTK_STRING("rcu_torture_stats task stopping"); |
1298 | return 0; | |
1299 | } | |
1300 | ||
d84f5203 SV |
1301 | static int rcu_idle_cpu; /* Force all torture tasks off this CPU */ |
1302 | ||
1303 | /* Shuffle tasks such that we allow @rcu_idle_cpu to become idle. A special case | |
1304 | * is when @rcu_idle_cpu = -1, when we allow the tasks to run on all CPUs. | |
1305 | */ | |
b2896d2e | 1306 | static void rcu_torture_shuffle_tasks(void) |
d84f5203 | 1307 | { |
d84f5203 SV |
1308 | int i; |
1309 | ||
73d0a4b1 | 1310 | cpumask_setall(shuffle_tmp_mask); |
86ef5c9a | 1311 | get_online_cpus(); |
d84f5203 SV |
1312 | |
1313 | /* No point in shuffling if there is only one online CPU (ex: UP) */ | |
c9d557c1 PM |
1314 | if (num_online_cpus() == 1) { |
1315 | put_online_cpus(); | |
1316 | return; | |
1317 | } | |
d84f5203 SV |
1318 | |
1319 | if (rcu_idle_cpu != -1) | |
73d0a4b1 | 1320 | cpumask_clear_cpu(rcu_idle_cpu, shuffle_tmp_mask); |
d84f5203 | 1321 | |
73d0a4b1 | 1322 | set_cpus_allowed_ptr(current, shuffle_tmp_mask); |
d84f5203 | 1323 | |
c8e5b163 | 1324 | if (reader_tasks) { |
d84f5203 SV |
1325 | for (i = 0; i < nrealreaders; i++) |
1326 | if (reader_tasks[i]) | |
f70316da | 1327 | set_cpus_allowed_ptr(reader_tasks[i], |
73d0a4b1 | 1328 | shuffle_tmp_mask); |
d84f5203 | 1329 | } |
c8e5b163 | 1330 | if (fakewriter_tasks) { |
b772e1dd JT |
1331 | for (i = 0; i < nfakewriters; i++) |
1332 | if (fakewriter_tasks[i]) | |
f70316da | 1333 | set_cpus_allowed_ptr(fakewriter_tasks[i], |
73d0a4b1 | 1334 | shuffle_tmp_mask); |
b772e1dd | 1335 | } |
d84f5203 | 1336 | if (writer_task) |
73d0a4b1 | 1337 | set_cpus_allowed_ptr(writer_task, shuffle_tmp_mask); |
d84f5203 | 1338 | if (stats_task) |
73d0a4b1 | 1339 | set_cpus_allowed_ptr(stats_task, shuffle_tmp_mask); |
0e11c8e8 PM |
1340 | if (stutter_task) |
1341 | set_cpus_allowed_ptr(stutter_task, shuffle_tmp_mask); | |
1342 | if (fqs_task) | |
1343 | set_cpus_allowed_ptr(fqs_task, shuffle_tmp_mask); | |
1344 | if (shutdown_task) | |
1345 | set_cpus_allowed_ptr(shutdown_task, shuffle_tmp_mask); | |
1346 | #ifdef CONFIG_HOTPLUG_CPU | |
1347 | if (onoff_task) | |
1348 | set_cpus_allowed_ptr(onoff_task, shuffle_tmp_mask); | |
1349 | #endif /* #ifdef CONFIG_HOTPLUG_CPU */ | |
1350 | if (stall_task) | |
1351 | set_cpus_allowed_ptr(stall_task, shuffle_tmp_mask); | |
1352 | if (barrier_cbs_tasks) | |
1353 | for (i = 0; i < n_barrier_cbs; i++) | |
1354 | if (barrier_cbs_tasks[i]) | |
1355 | set_cpus_allowed_ptr(barrier_cbs_tasks[i], | |
1356 | shuffle_tmp_mask); | |
1357 | if (barrier_task) | |
1358 | set_cpus_allowed_ptr(barrier_task, shuffle_tmp_mask); | |
d84f5203 SV |
1359 | |
1360 | if (rcu_idle_cpu == -1) | |
1361 | rcu_idle_cpu = num_online_cpus() - 1; | |
1362 | else | |
1363 | rcu_idle_cpu--; | |
1364 | ||
86ef5c9a | 1365 | put_online_cpus(); |
d84f5203 SV |
1366 | } |
1367 | ||
1368 | /* Shuffle tasks across CPUs, with the intent of allowing each CPU in the | |
1369 | * system to become idle at a time and cut off its timer ticks. This is meant | |
1370 | * to test the support for such tickless idle CPU in RCU. | |
1371 | */ | |
1372 | static int | |
1373 | rcu_torture_shuffle(void *arg) | |
1374 | { | |
1375 | VERBOSE_PRINTK_STRING("rcu_torture_shuffle task started"); | |
1376 | do { | |
1377 | schedule_timeout_interruptible(shuffle_interval * HZ); | |
1378 | rcu_torture_shuffle_tasks(); | |
c9d557c1 PM |
1379 | rcutorture_shutdown_absorb("rcu_torture_shuffle"); |
1380 | } while (!kthread_should_stop()); | |
d84f5203 SV |
1381 | VERBOSE_PRINTK_STRING("rcu_torture_shuffle task stopping"); |
1382 | return 0; | |
1383 | } | |
1384 | ||
d120f65f PM |
1385 | /* Cause the rcutorture test to "stutter", starting and stopping all |
1386 | * threads periodically. | |
1387 | */ | |
1388 | static int | |
1389 | rcu_torture_stutter(void *arg) | |
1390 | { | |
1391 | VERBOSE_PRINTK_STRING("rcu_torture_stutter task started"); | |
1392 | do { | |
1393 | schedule_timeout_interruptible(stutter * HZ); | |
1394 | stutter_pause_test = 1; | |
c9d557c1 | 1395 | if (!kthread_should_stop()) |
d120f65f PM |
1396 | schedule_timeout_interruptible(stutter * HZ); |
1397 | stutter_pause_test = 0; | |
c9d557c1 PM |
1398 | rcutorture_shutdown_absorb("rcu_torture_stutter"); |
1399 | } while (!kthread_should_stop()); | |
d120f65f PM |
1400 | VERBOSE_PRINTK_STRING("rcu_torture_stutter task stopping"); |
1401 | return 0; | |
1402 | } | |
1403 | ||
95c38322 | 1404 | static inline void |
8e8be45e | 1405 | rcu_torture_print_module_parms(struct rcu_torture_ops *cur_ops, char *tag) |
95c38322 | 1406 | { |
2caa1e44 PM |
1407 | pr_alert("%s" TORTURE_FLAG |
1408 | "--- %s: nreaders=%d nfakewriters=%d " | |
1409 | "stat_interval=%d verbose=%d test_no_idle_hz=%d " | |
1410 | "shuffle_interval=%d stutter=%d irqreader=%d " | |
1411 | "fqs_duration=%d fqs_holdoff=%d fqs_stutter=%d " | |
1412 | "test_boost=%d/%d test_boost_interval=%d " | |
1413 | "test_boost_duration=%d shutdown_secs=%d " | |
67afeed2 PM |
1414 | "stall_cpu=%d stall_cpu_holdoff=%d " |
1415 | "n_barrier_cbs=%d " | |
2caa1e44 PM |
1416 | "onoff_interval=%d onoff_holdoff=%d\n", |
1417 | torture_type, tag, nrealreaders, nfakewriters, | |
1418 | stat_interval, verbose, test_no_idle_hz, shuffle_interval, | |
1419 | stutter, irqreader, fqs_duration, fqs_holdoff, fqs_stutter, | |
1420 | test_boost, cur_ops->can_boost, | |
1421 | test_boost_interval, test_boost_duration, shutdown_secs, | |
67afeed2 PM |
1422 | stall_cpu, stall_cpu_holdoff, |
1423 | n_barrier_cbs, | |
2caa1e44 | 1424 | onoff_interval, onoff_holdoff); |
95c38322 PM |
1425 | } |
1426 | ||
8e8be45e | 1427 | static struct notifier_block rcutorture_shutdown_nb = { |
343e9099 PM |
1428 | .notifier_call = rcutorture_shutdown_notify, |
1429 | }; | |
1430 | ||
8e8be45e PM |
1431 | static void rcutorture_booster_cleanup(int cpu) |
1432 | { | |
1433 | struct task_struct *t; | |
1434 | ||
1435 | if (boost_tasks[cpu] == NULL) | |
1436 | return; | |
1437 | mutex_lock(&boost_mutex); | |
1438 | VERBOSE_PRINTK_STRING("Stopping rcu_torture_boost task"); | |
1439 | t = boost_tasks[cpu]; | |
1440 | boost_tasks[cpu] = NULL; | |
1441 | mutex_unlock(&boost_mutex); | |
1442 | ||
1443 | /* This must be outside of the mutex, otherwise deadlock! */ | |
1444 | kthread_stop(t); | |
37e377d2 | 1445 | boost_tasks[cpu] = NULL; |
8e8be45e PM |
1446 | } |
1447 | ||
1448 | static int rcutorture_booster_init(int cpu) | |
1449 | { | |
1450 | int retval; | |
1451 | ||
1452 | if (boost_tasks[cpu] != NULL) | |
1453 | return 0; /* Already created, nothing more to do. */ | |
1454 | ||
1455 | /* Don't allow time recalculation while creating a new task. */ | |
1456 | mutex_lock(&boost_mutex); | |
1457 | VERBOSE_PRINTK_STRING("Creating rcu_torture_boost task"); | |
1f288094 ED |
1458 | boost_tasks[cpu] = kthread_create_on_node(rcu_torture_boost, NULL, |
1459 | cpu_to_node(cpu), | |
1460 | "rcu_torture_boost"); | |
8e8be45e PM |
1461 | if (IS_ERR(boost_tasks[cpu])) { |
1462 | retval = PTR_ERR(boost_tasks[cpu]); | |
1463 | VERBOSE_PRINTK_STRING("rcu_torture_boost task create failed"); | |
1464 | n_rcu_torture_boost_ktrerror++; | |
1465 | boost_tasks[cpu] = NULL; | |
1466 | mutex_unlock(&boost_mutex); | |
1467 | return retval; | |
1468 | } | |
1469 | kthread_bind(boost_tasks[cpu], cpu); | |
1470 | wake_up_process(boost_tasks[cpu]); | |
1471 | mutex_unlock(&boost_mutex); | |
1472 | return 0; | |
1473 | } | |
1474 | ||
d5f546d8 PM |
1475 | /* |
1476 | * Cause the rcutorture test to shutdown the system after the test has | |
1477 | * run for the time specified by the shutdown_secs module parameter. | |
1478 | */ | |
1479 | static int | |
1480 | rcu_torture_shutdown(void *arg) | |
1481 | { | |
1482 | long delta; | |
1483 | unsigned long jiffies_snap; | |
1484 | ||
1485 | VERBOSE_PRINTK_STRING("rcu_torture_shutdown task started"); | |
1486 | jiffies_snap = ACCESS_ONCE(jiffies); | |
1487 | while (ULONG_CMP_LT(jiffies_snap, shutdown_time) && | |
1488 | !kthread_should_stop()) { | |
1489 | delta = shutdown_time - jiffies_snap; | |
1490 | if (verbose) | |
2caa1e44 PM |
1491 | pr_alert("%s" TORTURE_FLAG |
1492 | "rcu_torture_shutdown task: %lu jiffies remaining\n", | |
1493 | torture_type, delta); | |
d5f546d8 PM |
1494 | schedule_timeout_interruptible(delta); |
1495 | jiffies_snap = ACCESS_ONCE(jiffies); | |
1496 | } | |
b58bdcca | 1497 | if (kthread_should_stop()) { |
d5f546d8 PM |
1498 | VERBOSE_PRINTK_STRING("rcu_torture_shutdown task stopping"); |
1499 | return 0; | |
1500 | } | |
1501 | ||
1502 | /* OK, shut down the system. */ | |
1503 | ||
1504 | VERBOSE_PRINTK_STRING("rcu_torture_shutdown task shutting down system"); | |
1505 | shutdown_task = NULL; /* Avoid self-kill deadlock. */ | |
1506 | rcu_torture_cleanup(); /* Get the success/failure message. */ | |
1507 | kernel_power_off(); /* Shut down the system. */ | |
1508 | return 0; | |
1509 | } | |
1510 | ||
b58bdcca PM |
1511 | #ifdef CONFIG_HOTPLUG_CPU |
1512 | ||
1513 | /* | |
1514 | * Execute random CPU-hotplug operations at the interval specified | |
1515 | * by the onoff_interval. | |
1516 | */ | |
44100306 | 1517 | static int __cpuinit |
b58bdcca PM |
1518 | rcu_torture_onoff(void *arg) |
1519 | { | |
1520 | int cpu; | |
13dbf914 | 1521 | unsigned long delta; |
b58bdcca PM |
1522 | int maxcpu = -1; |
1523 | DEFINE_RCU_RANDOM(rand); | |
48983260 | 1524 | int ret; |
13dbf914 | 1525 | unsigned long starttime; |
b58bdcca PM |
1526 | |
1527 | VERBOSE_PRINTK_STRING("rcu_torture_onoff task started"); | |
1528 | for_each_online_cpu(cpu) | |
1529 | maxcpu = cpu; | |
1530 | WARN_ON(maxcpu < 0); | |
9b9ec9b9 PM |
1531 | if (onoff_holdoff > 0) { |
1532 | VERBOSE_PRINTK_STRING("rcu_torture_onoff begin holdoff"); | |
1533 | schedule_timeout_interruptible(onoff_holdoff * HZ); | |
1534 | VERBOSE_PRINTK_STRING("rcu_torture_onoff end holdoff"); | |
1535 | } | |
b58bdcca PM |
1536 | while (!kthread_should_stop()) { |
1537 | cpu = (rcu_random(&rand) >> 4) % (maxcpu + 1); | |
f220242a | 1538 | if (cpu_online(cpu) && cpu_is_hotpluggable(cpu)) { |
b58bdcca | 1539 | if (verbose) |
2caa1e44 PM |
1540 | pr_alert("%s" TORTURE_FLAG |
1541 | "rcu_torture_onoff task: offlining %d\n", | |
1542 | torture_type, cpu); | |
13dbf914 | 1543 | starttime = jiffies; |
b58bdcca | 1544 | n_offline_attempts++; |
48983260 PM |
1545 | ret = cpu_down(cpu); |
1546 | if (ret) { | |
1547 | if (verbose) | |
1548 | pr_alert("%s" TORTURE_FLAG | |
1549 | "rcu_torture_onoff task: offline %d failed: errno %d\n", | |
1550 | torture_type, cpu, ret); | |
1551 | } else { | |
b58bdcca | 1552 | if (verbose) |
2caa1e44 PM |
1553 | pr_alert("%s" TORTURE_FLAG |
1554 | "rcu_torture_onoff task: offlined %d\n", | |
1555 | torture_type, cpu); | |
b58bdcca | 1556 | n_offline_successes++; |
13dbf914 PM |
1557 | delta = jiffies - starttime; |
1558 | sum_offline += delta; | |
1559 | if (min_offline < 0) { | |
1560 | min_offline = delta; | |
1561 | max_offline = delta; | |
1562 | } | |
1563 | if (min_offline > delta) | |
1564 | min_offline = delta; | |
1565 | if (max_offline < delta) | |
1566 | max_offline = delta; | |
b58bdcca | 1567 | } |
f220242a | 1568 | } else if (cpu_is_hotpluggable(cpu)) { |
b58bdcca | 1569 | if (verbose) |
2caa1e44 PM |
1570 | pr_alert("%s" TORTURE_FLAG |
1571 | "rcu_torture_onoff task: onlining %d\n", | |
1572 | torture_type, cpu); | |
13dbf914 | 1573 | starttime = jiffies; |
b58bdcca PM |
1574 | n_online_attempts++; |
1575 | if (cpu_up(cpu) == 0) { | |
1576 | if (verbose) | |
2caa1e44 PM |
1577 | pr_alert("%s" TORTURE_FLAG |
1578 | "rcu_torture_onoff task: onlined %d\n", | |
1579 | torture_type, cpu); | |
b58bdcca | 1580 | n_online_successes++; |
13dbf914 PM |
1581 | delta = jiffies - starttime; |
1582 | sum_online += delta; | |
1583 | if (min_online < 0) { | |
1584 | min_online = delta; | |
1585 | max_online = delta; | |
1586 | } | |
1587 | if (min_online > delta) | |
1588 | min_online = delta; | |
1589 | if (max_online < delta) | |
1590 | max_online = delta; | |
b58bdcca PM |
1591 | } |
1592 | } | |
1593 | schedule_timeout_interruptible(onoff_interval * HZ); | |
1594 | } | |
1595 | VERBOSE_PRINTK_STRING("rcu_torture_onoff task stopping"); | |
1596 | return 0; | |
1597 | } | |
1598 | ||
44100306 | 1599 | static int __cpuinit |
b58bdcca PM |
1600 | rcu_torture_onoff_init(void) |
1601 | { | |
3c1b1ce0 JL |
1602 | int ret; |
1603 | ||
b58bdcca PM |
1604 | if (onoff_interval <= 0) |
1605 | return 0; | |
1606 | onoff_task = kthread_run(rcu_torture_onoff, NULL, "rcu_torture_onoff"); | |
1607 | if (IS_ERR(onoff_task)) { | |
3c1b1ce0 | 1608 | ret = PTR_ERR(onoff_task); |
b58bdcca | 1609 | onoff_task = NULL; |
3c1b1ce0 | 1610 | return ret; |
b58bdcca PM |
1611 | } |
1612 | return 0; | |
1613 | } | |
1614 | ||
1615 | static void rcu_torture_onoff_cleanup(void) | |
1616 | { | |
1617 | if (onoff_task == NULL) | |
1618 | return; | |
1619 | VERBOSE_PRINTK_STRING("Stopping rcu_torture_onoff task"); | |
1620 | kthread_stop(onoff_task); | |
37e377d2 | 1621 | onoff_task = NULL; |
b58bdcca PM |
1622 | } |
1623 | ||
1624 | #else /* #ifdef CONFIG_HOTPLUG_CPU */ | |
1625 | ||
37e377d2 | 1626 | static int |
b58bdcca PM |
1627 | rcu_torture_onoff_init(void) |
1628 | { | |
37e377d2 | 1629 | return 0; |
b58bdcca PM |
1630 | } |
1631 | ||
1632 | static void rcu_torture_onoff_cleanup(void) | |
1633 | { | |
1634 | } | |
1635 | ||
1636 | #endif /* #else #ifdef CONFIG_HOTPLUG_CPU */ | |
1637 | ||
c13f3757 PM |
1638 | /* |
1639 | * CPU-stall kthread. It waits as specified by stall_cpu_holdoff, then | |
1640 | * induces a CPU stall for the time specified by stall_cpu. | |
1641 | */ | |
1642 | static int __cpuinit rcu_torture_stall(void *args) | |
1643 | { | |
1644 | unsigned long stop_at; | |
1645 | ||
1646 | VERBOSE_PRINTK_STRING("rcu_torture_stall task started"); | |
1647 | if (stall_cpu_holdoff > 0) { | |
1648 | VERBOSE_PRINTK_STRING("rcu_torture_stall begin holdoff"); | |
1649 | schedule_timeout_interruptible(stall_cpu_holdoff * HZ); | |
1650 | VERBOSE_PRINTK_STRING("rcu_torture_stall end holdoff"); | |
1651 | } | |
1652 | if (!kthread_should_stop()) { | |
1653 | stop_at = get_seconds() + stall_cpu; | |
1654 | /* RCU CPU stall is expected behavior in following code. */ | |
2caa1e44 | 1655 | pr_alert("rcu_torture_stall start.\n"); |
c13f3757 PM |
1656 | rcu_read_lock(); |
1657 | preempt_disable(); | |
1658 | while (ULONG_CMP_LT(get_seconds(), stop_at)) | |
1659 | continue; /* Induce RCU CPU stall warning. */ | |
1660 | preempt_enable(); | |
1661 | rcu_read_unlock(); | |
2caa1e44 | 1662 | pr_alert("rcu_torture_stall end.\n"); |
c13f3757 PM |
1663 | } |
1664 | rcutorture_shutdown_absorb("rcu_torture_stall"); | |
1665 | while (!kthread_should_stop()) | |
1666 | schedule_timeout_interruptible(10 * HZ); | |
1667 | return 0; | |
1668 | } | |
1669 | ||
1670 | /* Spawn CPU-stall kthread, if stall_cpu specified. */ | |
1671 | static int __init rcu_torture_stall_init(void) | |
1672 | { | |
1673 | int ret; | |
1674 | ||
1675 | if (stall_cpu <= 0) | |
1676 | return 0; | |
1677 | stall_task = kthread_run(rcu_torture_stall, NULL, "rcu_torture_stall"); | |
1678 | if (IS_ERR(stall_task)) { | |
1679 | ret = PTR_ERR(stall_task); | |
1680 | stall_task = NULL; | |
1681 | return ret; | |
1682 | } | |
1683 | return 0; | |
1684 | } | |
1685 | ||
1686 | /* Clean up after the CPU-stall kthread, if one was spawned. */ | |
1687 | static void rcu_torture_stall_cleanup(void) | |
1688 | { | |
1689 | if (stall_task == NULL) | |
1690 | return; | |
1691 | VERBOSE_PRINTK_STRING("Stopping rcu_torture_stall_task."); | |
1692 | kthread_stop(stall_task); | |
37e377d2 | 1693 | stall_task = NULL; |
c13f3757 PM |
1694 | } |
1695 | ||
fae4b54f PM |
1696 | /* Callback function for RCU barrier testing. */ |
1697 | void rcu_torture_barrier_cbf(struct rcu_head *rcu) | |
1698 | { | |
1699 | atomic_inc(&barrier_cbs_invoked); | |
1700 | } | |
1701 | ||
1702 | /* kthread function to register callbacks used to test RCU barriers. */ | |
1703 | static int rcu_torture_barrier_cbs(void *arg) | |
1704 | { | |
1705 | long myid = (long)arg; | |
c6ebcbb6 | 1706 | bool lastphase = 0; |
fae4b54f PM |
1707 | struct rcu_head rcu; |
1708 | ||
1709 | init_rcu_head_on_stack(&rcu); | |
1710 | VERBOSE_PRINTK_STRING("rcu_torture_barrier_cbs task started"); | |
1711 | set_user_nice(current, 19); | |
1712 | do { | |
1713 | wait_event(barrier_cbs_wq[myid], | |
c6ebcbb6 | 1714 | barrier_phase != lastphase || |
fae4b54f PM |
1715 | kthread_should_stop() || |
1716 | fullstop != FULLSTOP_DONTSTOP); | |
c6ebcbb6 PM |
1717 | lastphase = barrier_phase; |
1718 | smp_mb(); /* ensure barrier_phase load before ->call(). */ | |
fae4b54f PM |
1719 | if (kthread_should_stop() || fullstop != FULLSTOP_DONTSTOP) |
1720 | break; | |
1721 | cur_ops->call(&rcu, rcu_torture_barrier_cbf); | |
1722 | if (atomic_dec_and_test(&barrier_cbs_count)) | |
1723 | wake_up(&barrier_wq); | |
1724 | } while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP); | |
1725 | VERBOSE_PRINTK_STRING("rcu_torture_barrier_cbs task stopping"); | |
1726 | rcutorture_shutdown_absorb("rcu_torture_barrier_cbs"); | |
1727 | while (!kthread_should_stop()) | |
1728 | schedule_timeout_interruptible(1); | |
1729 | cur_ops->cb_barrier(); | |
1730 | destroy_rcu_head_on_stack(&rcu); | |
1731 | return 0; | |
1732 | } | |
1733 | ||
1734 | /* kthread function to drive and coordinate RCU barrier testing. */ | |
1735 | static int rcu_torture_barrier(void *arg) | |
1736 | { | |
1737 | int i; | |
1738 | ||
1739 | VERBOSE_PRINTK_STRING("rcu_torture_barrier task starting"); | |
1740 | do { | |
1741 | atomic_set(&barrier_cbs_invoked, 0); | |
1742 | atomic_set(&barrier_cbs_count, n_barrier_cbs); | |
c6ebcbb6 PM |
1743 | smp_mb(); /* Ensure barrier_phase after prior assignments. */ |
1744 | barrier_phase = !barrier_phase; | |
fae4b54f PM |
1745 | for (i = 0; i < n_barrier_cbs; i++) |
1746 | wake_up(&barrier_cbs_wq[i]); | |
1747 | wait_event(barrier_wq, | |
1748 | atomic_read(&barrier_cbs_count) == 0 || | |
1749 | kthread_should_stop() || | |
1750 | fullstop != FULLSTOP_DONTSTOP); | |
1751 | if (kthread_should_stop() || fullstop != FULLSTOP_DONTSTOP) | |
1752 | break; | |
1753 | n_barrier_attempts++; | |
1754 | cur_ops->cb_barrier(); | |
1755 | if (atomic_read(&barrier_cbs_invoked) != n_barrier_cbs) { | |
1756 | n_rcu_torture_barrier_error++; | |
1757 | WARN_ON_ONCE(1); | |
1758 | } | |
1759 | n_barrier_successes++; | |
1760 | schedule_timeout_interruptible(HZ / 10); | |
1761 | } while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP); | |
1762 | VERBOSE_PRINTK_STRING("rcu_torture_barrier task stopping"); | |
143aa672 | 1763 | rcutorture_shutdown_absorb("rcu_torture_barrier"); |
fae4b54f PM |
1764 | while (!kthread_should_stop()) |
1765 | schedule_timeout_interruptible(1); | |
1766 | return 0; | |
1767 | } | |
1768 | ||
1769 | /* Initialize RCU barrier testing. */ | |
1770 | static int rcu_torture_barrier_init(void) | |
1771 | { | |
1772 | int i; | |
1773 | int ret; | |
1774 | ||
1775 | if (n_barrier_cbs == 0) | |
1776 | return 0; | |
1777 | if (cur_ops->call == NULL || cur_ops->cb_barrier == NULL) { | |
2caa1e44 PM |
1778 | pr_alert("%s" TORTURE_FLAG |
1779 | " Call or barrier ops missing for %s,\n", | |
1780 | torture_type, cur_ops->name); | |
1781 | pr_alert("%s" TORTURE_FLAG | |
1782 | " RCU barrier testing omitted from run.\n", | |
1783 | torture_type); | |
fae4b54f PM |
1784 | return 0; |
1785 | } | |
1786 | atomic_set(&barrier_cbs_count, 0); | |
1787 | atomic_set(&barrier_cbs_invoked, 0); | |
1788 | barrier_cbs_tasks = | |
1789 | kzalloc(n_barrier_cbs * sizeof(barrier_cbs_tasks[0]), | |
1790 | GFP_KERNEL); | |
1791 | barrier_cbs_wq = | |
1792 | kzalloc(n_barrier_cbs * sizeof(barrier_cbs_wq[0]), | |
1793 | GFP_KERNEL); | |
de5e6437 | 1794 | if (barrier_cbs_tasks == NULL || !barrier_cbs_wq) |
fae4b54f PM |
1795 | return -ENOMEM; |
1796 | for (i = 0; i < n_barrier_cbs; i++) { | |
1797 | init_waitqueue_head(&barrier_cbs_wq[i]); | |
1798 | barrier_cbs_tasks[i] = kthread_run(rcu_torture_barrier_cbs, | |
9059c940 | 1799 | (void *)(long)i, |
fae4b54f PM |
1800 | "rcu_torture_barrier_cbs"); |
1801 | if (IS_ERR(barrier_cbs_tasks[i])) { | |
1802 | ret = PTR_ERR(barrier_cbs_tasks[i]); | |
1803 | VERBOSE_PRINTK_ERRSTRING("Failed to create rcu_torture_barrier_cbs"); | |
1804 | barrier_cbs_tasks[i] = NULL; | |
1805 | return ret; | |
1806 | } | |
1807 | } | |
1808 | barrier_task = kthread_run(rcu_torture_barrier, NULL, | |
1809 | "rcu_torture_barrier"); | |
1810 | if (IS_ERR(barrier_task)) { | |
1811 | ret = PTR_ERR(barrier_task); | |
1812 | VERBOSE_PRINTK_ERRSTRING("Failed to create rcu_torture_barrier"); | |
1813 | barrier_task = NULL; | |
1814 | } | |
1815 | return 0; | |
1816 | } | |
1817 | ||
1818 | /* Clean up after RCU barrier testing. */ | |
1819 | static void rcu_torture_barrier_cleanup(void) | |
1820 | { | |
1821 | int i; | |
1822 | ||
1823 | if (barrier_task != NULL) { | |
1824 | VERBOSE_PRINTK_STRING("Stopping rcu_torture_barrier task"); | |
1825 | kthread_stop(barrier_task); | |
1826 | barrier_task = NULL; | |
1827 | } | |
1828 | if (barrier_cbs_tasks != NULL) { | |
1829 | for (i = 0; i < n_barrier_cbs; i++) { | |
1830 | if (barrier_cbs_tasks[i] != NULL) { | |
1831 | VERBOSE_PRINTK_STRING("Stopping rcu_torture_barrier_cbs task"); | |
1832 | kthread_stop(barrier_cbs_tasks[i]); | |
1833 | barrier_cbs_tasks[i] = NULL; | |
1834 | } | |
1835 | } | |
1836 | kfree(barrier_cbs_tasks); | |
1837 | barrier_cbs_tasks = NULL; | |
1838 | } | |
1839 | if (barrier_cbs_wq != NULL) { | |
1840 | kfree(barrier_cbs_wq); | |
1841 | barrier_cbs_wq = NULL; | |
1842 | } | |
1843 | } | |
1844 | ||
8e8be45e PM |
1845 | static int rcutorture_cpu_notify(struct notifier_block *self, |
1846 | unsigned long action, void *hcpu) | |
1847 | { | |
1848 | long cpu = (long)hcpu; | |
1849 | ||
1850 | switch (action) { | |
1851 | case CPU_ONLINE: | |
1852 | case CPU_DOWN_FAILED: | |
1853 | (void)rcutorture_booster_init(cpu); | |
1854 | break; | |
1855 | case CPU_DOWN_PREPARE: | |
1856 | rcutorture_booster_cleanup(cpu); | |
1857 | break; | |
1858 | default: | |
1859 | break; | |
1860 | } | |
1861 | return NOTIFY_OK; | |
1862 | } | |
1863 | ||
1864 | static struct notifier_block rcutorture_cpu_nb = { | |
1865 | .notifier_call = rcutorture_cpu_notify, | |
1866 | }; | |
1867 | ||
a241ec65 PM |
1868 | static void |
1869 | rcu_torture_cleanup(void) | |
1870 | { | |
1871 | int i; | |
1872 | ||
343e9099 | 1873 | mutex_lock(&fullstop_mutex); |
4a298656 | 1874 | rcutorture_record_test_transition(); |
c9d557c1 | 1875 | if (fullstop == FULLSTOP_SHUTDOWN) { |
2caa1e44 | 1876 | pr_warn(/* but going down anyway, so... */ |
c9d557c1 | 1877 | "Concurrent 'rmmod rcutorture' and shutdown illegal!\n"); |
343e9099 | 1878 | mutex_unlock(&fullstop_mutex); |
c9d557c1 | 1879 | schedule_timeout_uninterruptible(10); |
343e9099 PM |
1880 | if (cur_ops->cb_barrier != NULL) |
1881 | cur_ops->cb_barrier(); | |
1882 | return; | |
1883 | } | |
c9d557c1 | 1884 | fullstop = FULLSTOP_RMMOD; |
343e9099 | 1885 | mutex_unlock(&fullstop_mutex); |
8e8be45e | 1886 | unregister_reboot_notifier(&rcutorture_shutdown_nb); |
fae4b54f | 1887 | rcu_torture_barrier_cleanup(); |
c13f3757 | 1888 | rcu_torture_stall_cleanup(); |
d120f65f PM |
1889 | if (stutter_task) { |
1890 | VERBOSE_PRINTK_STRING("Stopping rcu_torture_stutter task"); | |
1891 | kthread_stop(stutter_task); | |
1892 | } | |
1893 | stutter_task = NULL; | |
c8e5b163 | 1894 | if (shuffler_task) { |
d84f5203 SV |
1895 | VERBOSE_PRINTK_STRING("Stopping rcu_torture_shuffle task"); |
1896 | kthread_stop(shuffler_task); | |
73d0a4b1 | 1897 | free_cpumask_var(shuffle_tmp_mask); |
d84f5203 SV |
1898 | } |
1899 | shuffler_task = NULL; | |
1900 | ||
c8e5b163 | 1901 | if (writer_task) { |
a241ec65 PM |
1902 | VERBOSE_PRINTK_STRING("Stopping rcu_torture_writer task"); |
1903 | kthread_stop(writer_task); | |
1904 | } | |
1905 | writer_task = NULL; | |
1906 | ||
c8e5b163 | 1907 | if (reader_tasks) { |
a241ec65 | 1908 | for (i = 0; i < nrealreaders; i++) { |
c8e5b163 | 1909 | if (reader_tasks[i]) { |
a241ec65 PM |
1910 | VERBOSE_PRINTK_STRING( |
1911 | "Stopping rcu_torture_reader task"); | |
1912 | kthread_stop(reader_tasks[i]); | |
1913 | } | |
1914 | reader_tasks[i] = NULL; | |
1915 | } | |
1916 | kfree(reader_tasks); | |
1917 | reader_tasks = NULL; | |
1918 | } | |
1919 | rcu_torture_current = NULL; | |
1920 | ||
c8e5b163 | 1921 | if (fakewriter_tasks) { |
b772e1dd | 1922 | for (i = 0; i < nfakewriters; i++) { |
c8e5b163 | 1923 | if (fakewriter_tasks[i]) { |
b772e1dd JT |
1924 | VERBOSE_PRINTK_STRING( |
1925 | "Stopping rcu_torture_fakewriter task"); | |
1926 | kthread_stop(fakewriter_tasks[i]); | |
1927 | } | |
1928 | fakewriter_tasks[i] = NULL; | |
1929 | } | |
1930 | kfree(fakewriter_tasks); | |
1931 | fakewriter_tasks = NULL; | |
1932 | } | |
1933 | ||
c8e5b163 | 1934 | if (stats_task) { |
a241ec65 PM |
1935 | VERBOSE_PRINTK_STRING("Stopping rcu_torture_stats task"); |
1936 | kthread_stop(stats_task); | |
1937 | } | |
1938 | stats_task = NULL; | |
1939 | ||
bf66f18e PM |
1940 | if (fqs_task) { |
1941 | VERBOSE_PRINTK_STRING("Stopping rcu_torture_fqs task"); | |
1942 | kthread_stop(fqs_task); | |
1943 | } | |
1944 | fqs_task = NULL; | |
8e8be45e PM |
1945 | if ((test_boost == 1 && cur_ops->can_boost) || |
1946 | test_boost == 2) { | |
1947 | unregister_cpu_notifier(&rcutorture_cpu_nb); | |
1948 | for_each_possible_cpu(i) | |
1949 | rcutorture_booster_cleanup(i); | |
1950 | } | |
d5f546d8 PM |
1951 | if (shutdown_task != NULL) { |
1952 | VERBOSE_PRINTK_STRING("Stopping rcu_torture_shutdown task"); | |
1953 | kthread_stop(shutdown_task); | |
1954 | } | |
37e377d2 | 1955 | shutdown_task = NULL; |
b58bdcca | 1956 | rcu_torture_onoff_cleanup(); |
bf66f18e | 1957 | |
a241ec65 | 1958 | /* Wait for all RCU callbacks to fire. */ |
2326974d PM |
1959 | |
1960 | if (cur_ops->cb_barrier != NULL) | |
1961 | cur_ops->cb_barrier(); | |
a241ec65 | 1962 | |
a241ec65 | 1963 | rcu_torture_stats_print(); /* -After- the stats thread is stopped! */ |
72e9bb54 | 1964 | |
fae4b54f | 1965 | if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error) |
8e8be45e | 1966 | rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE"); |
091541bb PM |
1967 | else if (n_online_successes != n_online_attempts || |
1968 | n_offline_successes != n_offline_attempts) | |
1969 | rcu_torture_print_module_parms(cur_ops, | |
1970 | "End of test: RCU_HOTPLUG"); | |
95c38322 | 1971 | else |
8e8be45e | 1972 | rcu_torture_print_module_parms(cur_ops, "End of test: SUCCESS"); |
a241ec65 PM |
1973 | } |
1974 | ||
6f8bc500 | 1975 | static int __init |
a241ec65 PM |
1976 | rcu_torture_init(void) |
1977 | { | |
1978 | int i; | |
1979 | int cpu; | |
1980 | int firsterr = 0; | |
fae4b54f | 1981 | int retval; |
ade5fb81 | 1982 | static struct rcu_torture_ops *torture_ops[] = |
d9a3da06 | 1983 | { &rcu_ops, &rcu_sync_ops, &rcu_expedited_ops, |
bdf2a436 | 1984 | &rcu_bh_ops, &rcu_bh_sync_ops, &rcu_bh_expedited_ops, |
751a68b2 PM |
1985 | &srcu_ops, &srcu_sync_ops, &srcu_expedited_ops, |
1986 | &srcu_raw_ops, &srcu_raw_sync_ops, | |
804bb837 | 1987 | &sched_ops, &sched_sync_ops, &sched_expedited_ops, }; |
a241ec65 | 1988 | |
343e9099 PM |
1989 | mutex_lock(&fullstop_mutex); |
1990 | ||
a241ec65 | 1991 | /* Process args and tell the world that the torturer is on the job. */ |
ade5fb81 | 1992 | for (i = 0; i < ARRAY_SIZE(torture_ops); i++) { |
72e9bb54 | 1993 | cur_ops = torture_ops[i]; |
ade5fb81 | 1994 | if (strcmp(torture_type, cur_ops->name) == 0) |
72e9bb54 | 1995 | break; |
72e9bb54 | 1996 | } |
ade5fb81 | 1997 | if (i == ARRAY_SIZE(torture_ops)) { |
2caa1e44 PM |
1998 | pr_alert("rcu-torture: invalid torture type: \"%s\"\n", |
1999 | torture_type); | |
2000 | pr_alert("rcu-torture types:"); | |
cf886c44 | 2001 | for (i = 0; i < ARRAY_SIZE(torture_ops); i++) |
2caa1e44 PM |
2002 | pr_alert(" %s", torture_ops[i]->name); |
2003 | pr_alert("\n"); | |
343e9099 | 2004 | mutex_unlock(&fullstop_mutex); |
a71fca58 | 2005 | return -EINVAL; |
72e9bb54 | 2006 | } |
bf66f18e | 2007 | if (cur_ops->fqs == NULL && fqs_duration != 0) { |
2caa1e44 | 2008 | pr_alert("rcu-torture: ->fqs NULL and non-zero fqs_duration, fqs disabled.\n"); |
bf66f18e PM |
2009 | fqs_duration = 0; |
2010 | } | |
c8e5b163 | 2011 | if (cur_ops->init) |
72e9bb54 PM |
2012 | cur_ops->init(); /* no "goto unwind" prior to this point!!! */ |
2013 | ||
a241ec65 PM |
2014 | if (nreaders >= 0) |
2015 | nrealreaders = nreaders; | |
2016 | else | |
2017 | nrealreaders = 2 * num_online_cpus(); | |
8e8be45e | 2018 | rcu_torture_print_module_parms(cur_ops, "Start of test"); |
c9d557c1 | 2019 | fullstop = FULLSTOP_DONTSTOP; |
a241ec65 PM |
2020 | |
2021 | /* Set up the freelist. */ | |
2022 | ||
2023 | INIT_LIST_HEAD(&rcu_torture_freelist); | |
788e770e | 2024 | for (i = 0; i < ARRAY_SIZE(rcu_tortures); i++) { |
996417d2 | 2025 | rcu_tortures[i].rtort_mbtest = 0; |
a241ec65 PM |
2026 | list_add_tail(&rcu_tortures[i].rtort_free, |
2027 | &rcu_torture_freelist); | |
2028 | } | |
2029 | ||
2030 | /* Initialize the statistics so that each run gets its own numbers. */ | |
2031 | ||
2032 | rcu_torture_current = NULL; | |
2033 | rcu_torture_current_version = 0; | |
2034 | atomic_set(&n_rcu_torture_alloc, 0); | |
2035 | atomic_set(&n_rcu_torture_alloc_fail, 0); | |
2036 | atomic_set(&n_rcu_torture_free, 0); | |
996417d2 PM |
2037 | atomic_set(&n_rcu_torture_mberror, 0); |
2038 | atomic_set(&n_rcu_torture_error, 0); | |
fae4b54f | 2039 | n_rcu_torture_barrier_error = 0; |
8e8be45e PM |
2040 | n_rcu_torture_boost_ktrerror = 0; |
2041 | n_rcu_torture_boost_rterror = 0; | |
8e8be45e PM |
2042 | n_rcu_torture_boost_failure = 0; |
2043 | n_rcu_torture_boosts = 0; | |
a241ec65 PM |
2044 | for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) |
2045 | atomic_set(&rcu_torture_wcount[i], 0); | |
0a945022 | 2046 | for_each_possible_cpu(cpu) { |
a241ec65 PM |
2047 | for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) { |
2048 | per_cpu(rcu_torture_count, cpu)[i] = 0; | |
2049 | per_cpu(rcu_torture_batch, cpu)[i] = 0; | |
2050 | } | |
2051 | } | |
2052 | ||
2053 | /* Start up the kthreads. */ | |
2054 | ||
2055 | VERBOSE_PRINTK_STRING("Creating rcu_torture_writer task"); | |
60f53782 PM |
2056 | writer_task = kthread_create(rcu_torture_writer, NULL, |
2057 | "rcu_torture_writer"); | |
a241ec65 PM |
2058 | if (IS_ERR(writer_task)) { |
2059 | firsterr = PTR_ERR(writer_task); | |
2060 | VERBOSE_PRINTK_ERRSTRING("Failed to create writer"); | |
2061 | writer_task = NULL; | |
2062 | goto unwind; | |
2063 | } | |
60f53782 | 2064 | wake_up_process(writer_task); |
b772e1dd | 2065 | fakewriter_tasks = kzalloc(nfakewriters * sizeof(fakewriter_tasks[0]), |
a71fca58 | 2066 | GFP_KERNEL); |
b772e1dd JT |
2067 | if (fakewriter_tasks == NULL) { |
2068 | VERBOSE_PRINTK_ERRSTRING("out of memory"); | |
2069 | firsterr = -ENOMEM; | |
2070 | goto unwind; | |
2071 | } | |
2072 | for (i = 0; i < nfakewriters; i++) { | |
2073 | VERBOSE_PRINTK_STRING("Creating rcu_torture_fakewriter task"); | |
2074 | fakewriter_tasks[i] = kthread_run(rcu_torture_fakewriter, NULL, | |
a71fca58 | 2075 | "rcu_torture_fakewriter"); |
b772e1dd JT |
2076 | if (IS_ERR(fakewriter_tasks[i])) { |
2077 | firsterr = PTR_ERR(fakewriter_tasks[i]); | |
2078 | VERBOSE_PRINTK_ERRSTRING("Failed to create fakewriter"); | |
2079 | fakewriter_tasks[i] = NULL; | |
2080 | goto unwind; | |
2081 | } | |
2082 | } | |
2860aaba | 2083 | reader_tasks = kzalloc(nrealreaders * sizeof(reader_tasks[0]), |
a241ec65 PM |
2084 | GFP_KERNEL); |
2085 | if (reader_tasks == NULL) { | |
2086 | VERBOSE_PRINTK_ERRSTRING("out of memory"); | |
2087 | firsterr = -ENOMEM; | |
2088 | goto unwind; | |
2089 | } | |
2090 | for (i = 0; i < nrealreaders; i++) { | |
2091 | VERBOSE_PRINTK_STRING("Creating rcu_torture_reader task"); | |
2092 | reader_tasks[i] = kthread_run(rcu_torture_reader, NULL, | |
2093 | "rcu_torture_reader"); | |
2094 | if (IS_ERR(reader_tasks[i])) { | |
2095 | firsterr = PTR_ERR(reader_tasks[i]); | |
2096 | VERBOSE_PRINTK_ERRSTRING("Failed to create reader"); | |
2097 | reader_tasks[i] = NULL; | |
2098 | goto unwind; | |
2099 | } | |
2100 | } | |
2101 | if (stat_interval > 0) { | |
2102 | VERBOSE_PRINTK_STRING("Creating rcu_torture_stats task"); | |
2103 | stats_task = kthread_run(rcu_torture_stats, NULL, | |
2104 | "rcu_torture_stats"); | |
2105 | if (IS_ERR(stats_task)) { | |
2106 | firsterr = PTR_ERR(stats_task); | |
2107 | VERBOSE_PRINTK_ERRSTRING("Failed to create stats"); | |
2108 | stats_task = NULL; | |
2109 | goto unwind; | |
2110 | } | |
2111 | } | |
d84f5203 SV |
2112 | if (test_no_idle_hz) { |
2113 | rcu_idle_cpu = num_online_cpus() - 1; | |
73d0a4b1 RR |
2114 | |
2115 | if (!alloc_cpumask_var(&shuffle_tmp_mask, GFP_KERNEL)) { | |
2116 | firsterr = -ENOMEM; | |
2117 | VERBOSE_PRINTK_ERRSTRING("Failed to alloc mask"); | |
2118 | goto unwind; | |
2119 | } | |
2120 | ||
d84f5203 SV |
2121 | /* Create the shuffler thread */ |
2122 | shuffler_task = kthread_run(rcu_torture_shuffle, NULL, | |
2123 | "rcu_torture_shuffle"); | |
2124 | if (IS_ERR(shuffler_task)) { | |
73d0a4b1 | 2125 | free_cpumask_var(shuffle_tmp_mask); |
d84f5203 SV |
2126 | firsterr = PTR_ERR(shuffler_task); |
2127 | VERBOSE_PRINTK_ERRSTRING("Failed to create shuffler"); | |
2128 | shuffler_task = NULL; | |
2129 | goto unwind; | |
2130 | } | |
2131 | } | |
d120f65f PM |
2132 | if (stutter < 0) |
2133 | stutter = 0; | |
2134 | if (stutter) { | |
2135 | /* Create the stutter thread */ | |
2136 | stutter_task = kthread_run(rcu_torture_stutter, NULL, | |
2137 | "rcu_torture_stutter"); | |
2138 | if (IS_ERR(stutter_task)) { | |
2139 | firsterr = PTR_ERR(stutter_task); | |
2140 | VERBOSE_PRINTK_ERRSTRING("Failed to create stutter"); | |
2141 | stutter_task = NULL; | |
2142 | goto unwind; | |
2143 | } | |
2144 | } | |
bf66f18e PM |
2145 | if (fqs_duration < 0) |
2146 | fqs_duration = 0; | |
2147 | if (fqs_duration) { | |
2148 | /* Create the stutter thread */ | |
2149 | fqs_task = kthread_run(rcu_torture_fqs, NULL, | |
2150 | "rcu_torture_fqs"); | |
2151 | if (IS_ERR(fqs_task)) { | |
2152 | firsterr = PTR_ERR(fqs_task); | |
2153 | VERBOSE_PRINTK_ERRSTRING("Failed to create fqs"); | |
2154 | fqs_task = NULL; | |
2155 | goto unwind; | |
2156 | } | |
2157 | } | |
8e8be45e PM |
2158 | if (test_boost_interval < 1) |
2159 | test_boost_interval = 1; | |
2160 | if (test_boost_duration < 2) | |
2161 | test_boost_duration = 2; | |
2162 | if ((test_boost == 1 && cur_ops->can_boost) || | |
2163 | test_boost == 2) { | |
8e8be45e PM |
2164 | |
2165 | boost_starttime = jiffies + test_boost_interval * HZ; | |
2166 | register_cpu_notifier(&rcutorture_cpu_nb); | |
2167 | for_each_possible_cpu(i) { | |
2168 | if (cpu_is_offline(i)) | |
2169 | continue; /* Heuristic: CPU can go offline. */ | |
2170 | retval = rcutorture_booster_init(i); | |
2171 | if (retval < 0) { | |
2172 | firsterr = retval; | |
2173 | goto unwind; | |
2174 | } | |
2175 | } | |
2176 | } | |
d5f546d8 PM |
2177 | if (shutdown_secs > 0) { |
2178 | shutdown_time = jiffies + shutdown_secs * HZ; | |
60f53782 PM |
2179 | shutdown_task = kthread_create(rcu_torture_shutdown, NULL, |
2180 | "rcu_torture_shutdown"); | |
d5f546d8 PM |
2181 | if (IS_ERR(shutdown_task)) { |
2182 | firsterr = PTR_ERR(shutdown_task); | |
2183 | VERBOSE_PRINTK_ERRSTRING("Failed to create shutdown"); | |
2184 | shutdown_task = NULL; | |
2185 | goto unwind; | |
2186 | } | |
60f53782 | 2187 | wake_up_process(shutdown_task); |
d5f546d8 | 2188 | } |
37e377d2 PM |
2189 | i = rcu_torture_onoff_init(); |
2190 | if (i != 0) { | |
2191 | firsterr = i; | |
2192 | goto unwind; | |
2193 | } | |
8e8be45e | 2194 | register_reboot_notifier(&rcutorture_shutdown_nb); |
37e377d2 PM |
2195 | i = rcu_torture_stall_init(); |
2196 | if (i != 0) { | |
2197 | firsterr = i; | |
2198 | goto unwind; | |
2199 | } | |
fae4b54f PM |
2200 | retval = rcu_torture_barrier_init(); |
2201 | if (retval != 0) { | |
2202 | firsterr = retval; | |
2203 | goto unwind; | |
2204 | } | |
4a298656 | 2205 | rcutorture_record_test_transition(); |
343e9099 | 2206 | mutex_unlock(&fullstop_mutex); |
a241ec65 PM |
2207 | return 0; |
2208 | ||
2209 | unwind: | |
343e9099 | 2210 | mutex_unlock(&fullstop_mutex); |
a241ec65 PM |
2211 | rcu_torture_cleanup(); |
2212 | return firsterr; | |
2213 | } | |
2214 | ||
2215 | module_init(rcu_torture_init); | |
2216 | module_exit(rcu_torture_cleanup); |