diff options
Diffstat (limited to 'kernel/rcutorture.c')
-rw-r--r-- | kernel/rcutorture.c | 789 |
1 files changed, 123 insertions, 666 deletions
diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c index 31dea01c85f..98f51b13bb7 100644 --- a/kernel/rcutorture.c +++ b/kernel/rcutorture.c | |||
@@ -49,27 +49,21 @@ | |||
49 | #include <asm/byteorder.h> | 49 | #include <asm/byteorder.h> |
50 | 50 | ||
51 | MODULE_LICENSE("GPL"); | 51 | MODULE_LICENSE("GPL"); |
52 | MODULE_AUTHOR("Paul E. McKenney <paulmck@us.ibm.com> and Josh Triplett <josh@freedesktop.org>"); | 52 | MODULE_AUTHOR("Paul E. McKenney <paulmck@us.ibm.com> and " |
53 | "Josh Triplett <josh@freedesktop.org>"); | ||
53 | 54 | ||
54 | static int nreaders = -1; /* # reader threads, defaults to 2*ncpus */ | 55 | static int nreaders = -1; /* # reader threads, defaults to 2*ncpus */ |
55 | static int nfakewriters = 4; /* # fake writer threads */ | 56 | static int nfakewriters = 4; /* # fake writer threads */ |
56 | static int stat_interval = 60; /* Interval between stats, in seconds. */ | 57 | static int stat_interval; /* Interval between stats, in seconds. */ |
57 | /* Zero means "only at end of test". */ | 58 | /* Defaults to "only at end of test". */ |
58 | static bool verbose; /* Print more debug info. */ | 59 | static int verbose; /* Print more debug info. */ |
59 | static bool test_no_idle_hz = true; | 60 | static int test_no_idle_hz; /* Test RCU's support for tickless idle CPUs. */ |
60 | /* Test RCU support for tickless idle CPUs. */ | ||
61 | static int shuffle_interval = 3; /* Interval between shuffles (in sec)*/ | 61 | static int shuffle_interval = 3; /* Interval between shuffles (in sec)*/ |
62 | static int stutter = 5; /* Start/stop testing interval (in sec) */ | 62 | static int stutter = 5; /* Start/stop testing interval (in sec) */ |
63 | static int irqreader = 1; /* RCU readers from irq (timers). */ | 63 | static int irqreader = 1; /* RCU readers from irq (timers). */ |
64 | static int fqs_duration; /* Duration of bursts (us), 0 to disable. */ | 64 | static int fqs_duration = 0; /* Duration of bursts (us), 0 to disable. */ |
65 | static int fqs_holdoff; /* Hold time within burst (us). */ | 65 | static int fqs_holdoff = 0; /* Hold time within burst (us). */ |
66 | static int fqs_stutter = 3; /* Wait time between bursts (s). */ | 66 | static int fqs_stutter = 3; /* Wait time between bursts (s). */ |
67 | static int n_barrier_cbs; /* Number of callbacks to test RCU barriers. */ | ||
68 | static int onoff_interval; /* Wait time between CPU hotplugs, 0=disable. */ | ||
69 | static int onoff_holdoff; /* Seconds after boot before CPU hotplugs. */ | ||
70 | static int shutdown_secs; /* Shutdown time (s). <=0 for no shutdown. */ | ||
71 | static int stall_cpu; /* CPU-stall duration (s). 0 for no stall. */ | ||
72 | static int stall_cpu_holdoff = 10; /* Time to wait until stall (s). */ | ||
73 | static int test_boost = 1; /* Test RCU prio boost: 0=no, 1=maybe, 2=yes. */ | 67 | static int test_boost = 1; /* Test RCU prio boost: 0=no, 1=maybe, 2=yes. */ |
74 | static int test_boost_interval = 7; /* Interval between boost tests, seconds. */ | 68 | static int test_boost_interval = 7; /* Interval between boost tests, seconds. */ |
75 | static int test_boost_duration = 4; /* Duration of each boost test, seconds. */ | 69 | static int test_boost_duration = 4; /* Duration of each boost test, seconds. */ |
@@ -79,7 +73,7 @@ module_param(nreaders, int, 0444); | |||
79 | MODULE_PARM_DESC(nreaders, "Number of RCU reader threads"); | 73 | MODULE_PARM_DESC(nreaders, "Number of RCU reader threads"); |
80 | module_param(nfakewriters, int, 0444); | 74 | module_param(nfakewriters, int, 0444); |
81 | MODULE_PARM_DESC(nfakewriters, "Number of RCU fake writer threads"); | 75 | MODULE_PARM_DESC(nfakewriters, "Number of RCU fake writer threads"); |
82 | module_param(stat_interval, int, 0644); | 76 | module_param(stat_interval, int, 0444); |
83 | MODULE_PARM_DESC(stat_interval, "Number of seconds between stats printk()s"); | 77 | MODULE_PARM_DESC(stat_interval, "Number of seconds between stats printk()s"); |
84 | module_param(verbose, bool, 0444); | 78 | module_param(verbose, bool, 0444); |
85 | MODULE_PARM_DESC(verbose, "Enable verbose debugging printk()s"); | 79 | MODULE_PARM_DESC(verbose, "Enable verbose debugging printk()s"); |
@@ -97,18 +91,6 @@ module_param(fqs_holdoff, int, 0444); | |||
97 | MODULE_PARM_DESC(fqs_holdoff, "Holdoff time within fqs bursts (us)"); | 91 | MODULE_PARM_DESC(fqs_holdoff, "Holdoff time within fqs bursts (us)"); |
98 | module_param(fqs_stutter, int, 0444); | 92 | module_param(fqs_stutter, int, 0444); |
99 | MODULE_PARM_DESC(fqs_stutter, "Wait time between fqs bursts (s)"); | 93 | MODULE_PARM_DESC(fqs_stutter, "Wait time between fqs bursts (s)"); |
100 | module_param(n_barrier_cbs, int, 0444); | ||
101 | MODULE_PARM_DESC(n_barrier_cbs, "# of callbacks/kthreads for barrier testing"); | ||
102 | module_param(onoff_interval, int, 0444); | ||
103 | MODULE_PARM_DESC(onoff_interval, "Time between CPU hotplugs (s), 0=disable"); | ||
104 | module_param(onoff_holdoff, int, 0444); | ||
105 | MODULE_PARM_DESC(onoff_holdoff, "Time after boot before CPU hotplugs (s)"); | ||
106 | module_param(shutdown_secs, int, 0444); | ||
107 | MODULE_PARM_DESC(shutdown_secs, "Shutdown time (s), zero to disable."); | ||
108 | module_param(stall_cpu, int, 0444); | ||
109 | MODULE_PARM_DESC(stall_cpu, "Stall duration (s), zero to disable."); | ||
110 | module_param(stall_cpu_holdoff, int, 0444); | ||
111 | MODULE_PARM_DESC(stall_cpu_holdoff, "Time to wait before starting stall (s)."); | ||
112 | module_param(test_boost, int, 0444); | 94 | module_param(test_boost, int, 0444); |
113 | MODULE_PARM_DESC(test_boost, "Test RCU prio boost: 0=no, 1=maybe, 2=yes."); | 95 | MODULE_PARM_DESC(test_boost, "Test RCU prio boost: 0=no, 1=maybe, 2=yes."); |
114 | module_param(test_boost_interval, int, 0444); | 96 | module_param(test_boost_interval, int, 0444); |
@@ -120,11 +102,11 @@ MODULE_PARM_DESC(torture_type, "Type of RCU to torture (rcu, rcu_bh, srcu)"); | |||
120 | 102 | ||
121 | #define TORTURE_FLAG "-torture:" | 103 | #define TORTURE_FLAG "-torture:" |
122 | #define PRINTK_STRING(s) \ | 104 | #define PRINTK_STRING(s) \ |
123 | do { pr_alert("%s" TORTURE_FLAG s "\n", torture_type); } while (0) | 105 | do { printk(KERN_ALERT "%s" TORTURE_FLAG s "\n", torture_type); } while (0) |
124 | #define VERBOSE_PRINTK_STRING(s) \ | 106 | #define VERBOSE_PRINTK_STRING(s) \ |
125 | do { if (verbose) pr_alert("%s" TORTURE_FLAG s "\n", torture_type); } while (0) | 107 | do { if (verbose) printk(KERN_ALERT "%s" TORTURE_FLAG s "\n", torture_type); } while (0) |
126 | #define VERBOSE_PRINTK_ERRSTRING(s) \ | 108 | #define VERBOSE_PRINTK_ERRSTRING(s) \ |
127 | do { if (verbose) pr_alert("%s" TORTURE_FLAG "!!! " s "\n", torture_type); } while (0) | 109 | do { if (verbose) printk(KERN_ALERT "%s" TORTURE_FLAG "!!! " s "\n", torture_type); } while (0) |
128 | 110 | ||
129 | static char printk_buf[4096]; | 111 | static char printk_buf[4096]; |
130 | 112 | ||
@@ -137,13 +119,6 @@ static struct task_struct *shuffler_task; | |||
137 | static struct task_struct *stutter_task; | 119 | static struct task_struct *stutter_task; |
138 | static struct task_struct *fqs_task; | 120 | static struct task_struct *fqs_task; |
139 | static struct task_struct *boost_tasks[NR_CPUS]; | 121 | static struct task_struct *boost_tasks[NR_CPUS]; |
140 | static struct task_struct *shutdown_task; | ||
141 | #ifdef CONFIG_HOTPLUG_CPU | ||
142 | static struct task_struct *onoff_task; | ||
143 | #endif /* #ifdef CONFIG_HOTPLUG_CPU */ | ||
144 | static struct task_struct *stall_task; | ||
145 | static struct task_struct **barrier_cbs_tasks; | ||
146 | static struct task_struct *barrier_task; | ||
147 | 122 | ||
148 | #define RCU_TORTURE_PIPE_LEN 10 | 123 | #define RCU_TORTURE_PIPE_LEN 10 |
149 | 124 | ||
@@ -169,24 +144,11 @@ static atomic_t n_rcu_torture_alloc_fail; | |||
169 | static atomic_t n_rcu_torture_free; | 144 | static atomic_t n_rcu_torture_free; |
170 | static atomic_t n_rcu_torture_mberror; | 145 | static atomic_t n_rcu_torture_mberror; |
171 | static atomic_t n_rcu_torture_error; | 146 | static atomic_t n_rcu_torture_error; |
172 | static long n_rcu_torture_barrier_error; | ||
173 | static long n_rcu_torture_boost_ktrerror; | 147 | static long n_rcu_torture_boost_ktrerror; |
174 | static long n_rcu_torture_boost_rterror; | 148 | static long n_rcu_torture_boost_rterror; |
175 | static long n_rcu_torture_boost_failure; | 149 | static long n_rcu_torture_boost_failure; |
176 | static long n_rcu_torture_boosts; | 150 | static long n_rcu_torture_boosts; |
177 | static long n_rcu_torture_timers; | 151 | static long n_rcu_torture_timers; |
178 | static long n_offline_attempts; | ||
179 | static long n_offline_successes; | ||
180 | static unsigned long sum_offline; | ||
181 | static int min_offline = -1; | ||
182 | static int max_offline; | ||
183 | static long n_online_attempts; | ||
184 | static long n_online_successes; | ||
185 | static unsigned long sum_online; | ||
186 | static int min_online = -1; | ||
187 | static int max_online; | ||
188 | static long n_barrier_attempts; | ||
189 | static long n_barrier_successes; | ||
190 | static struct list_head rcu_torture_removed; | 152 | static struct list_head rcu_torture_removed; |
191 | static cpumask_var_t shuffle_tmp_mask; | 153 | static cpumask_var_t shuffle_tmp_mask; |
192 | 154 | ||
@@ -198,8 +160,6 @@ static int stutter_pause_test; | |||
198 | #define RCUTORTURE_RUNNABLE_INIT 0 | 160 | #define RCUTORTURE_RUNNABLE_INIT 0 |
199 | #endif | 161 | #endif |
200 | int rcutorture_runnable = RCUTORTURE_RUNNABLE_INIT; | 162 | int rcutorture_runnable = RCUTORTURE_RUNNABLE_INIT; |
201 | module_param(rcutorture_runnable, int, 0444); | ||
202 | MODULE_PARM_DESC(rcutorture_runnable, "Start rcutorture at boot"); | ||
203 | 163 | ||
204 | #if defined(CONFIG_RCU_BOOST) && !defined(CONFIG_HOTPLUG_CPU) | 164 | #if defined(CONFIG_RCU_BOOST) && !defined(CONFIG_HOTPLUG_CPU) |
205 | #define rcu_can_boost() 1 | 165 | #define rcu_can_boost() 1 |
@@ -207,15 +167,9 @@ MODULE_PARM_DESC(rcutorture_runnable, "Start rcutorture at boot"); | |||
207 | #define rcu_can_boost() 0 | 167 | #define rcu_can_boost() 0 |
208 | #endif /* #else #if defined(CONFIG_RCU_BOOST) && !defined(CONFIG_HOTPLUG_CPU) */ | 168 | #endif /* #else #if defined(CONFIG_RCU_BOOST) && !defined(CONFIG_HOTPLUG_CPU) */ |
209 | 169 | ||
210 | static unsigned long shutdown_time; /* jiffies to system shutdown. */ | ||
211 | static unsigned long boost_starttime; /* jiffies of next boost test start. */ | 170 | static unsigned long boost_starttime; /* jiffies of next boost test start. */ |
212 | DEFINE_MUTEX(boost_mutex); /* protect setting boost_starttime */ | 171 | DEFINE_MUTEX(boost_mutex); /* protect setting boost_starttime */ |
213 | /* and boost task create/destroy. */ | 172 | /* and boost task create/destroy. */ |
214 | static atomic_t barrier_cbs_count; /* Barrier callbacks registered. */ | ||
215 | static bool barrier_phase; /* Test phase. */ | ||
216 | static atomic_t barrier_cbs_invoked; /* Barrier callbacks invoked. */ | ||
217 | static wait_queue_head_t *barrier_cbs_wq; /* Coordinate barrier testing. */ | ||
218 | static DECLARE_WAIT_QUEUE_HEAD(barrier_wq); | ||
219 | 173 | ||
220 | /* Mediate rmmod and system shutdown. Concurrent rmmod & shutdown illegal! */ | 174 | /* Mediate rmmod and system shutdown. Concurrent rmmod & shutdown illegal! */ |
221 | 175 | ||
@@ -228,9 +182,6 @@ static int fullstop = FULLSTOP_RMMOD; | |||
228 | */ | 182 | */ |
229 | static DEFINE_MUTEX(fullstop_mutex); | 183 | static DEFINE_MUTEX(fullstop_mutex); |
230 | 184 | ||
231 | /* Forward reference. */ | ||
232 | static void rcu_torture_cleanup(void); | ||
233 | |||
234 | /* | 185 | /* |
235 | * Detect and respond to a system shutdown. | 186 | * Detect and respond to a system shutdown. |
236 | */ | 187 | */ |
@@ -242,7 +193,7 @@ rcutorture_shutdown_notify(struct notifier_block *unused1, | |||
242 | if (fullstop == FULLSTOP_DONTSTOP) | 193 | if (fullstop == FULLSTOP_DONTSTOP) |
243 | fullstop = FULLSTOP_SHUTDOWN; | 194 | fullstop = FULLSTOP_SHUTDOWN; |
244 | else | 195 | else |
245 | pr_warn(/* but going down anyway, so... */ | 196 | printk(KERN_WARNING /* but going down anyway, so... */ |
246 | "Concurrent 'rmmod rcutorture' and shutdown illegal!\n"); | 197 | "Concurrent 'rmmod rcutorture' and shutdown illegal!\n"); |
247 | mutex_unlock(&fullstop_mutex); | 198 | mutex_unlock(&fullstop_mutex); |
248 | return NOTIFY_DONE; | 199 | return NOTIFY_DONE; |
@@ -255,7 +206,7 @@ rcutorture_shutdown_notify(struct notifier_block *unused1, | |||
255 | static void rcutorture_shutdown_absorb(char *title) | 206 | static void rcutorture_shutdown_absorb(char *title) |
256 | { | 207 | { |
257 | if (ACCESS_ONCE(fullstop) == FULLSTOP_SHUTDOWN) { | 208 | if (ACCESS_ONCE(fullstop) == FULLSTOP_SHUTDOWN) { |
258 | pr_notice( | 209 | printk(KERN_NOTICE |
259 | "rcutorture thread %s parking due to system shutdown\n", | 210 | "rcutorture thread %s parking due to system shutdown\n", |
260 | title); | 211 | title); |
261 | schedule_timeout_uninterruptible(MAX_SCHEDULE_TIMEOUT); | 212 | schedule_timeout_uninterruptible(MAX_SCHEDULE_TIMEOUT); |
@@ -339,13 +290,13 @@ rcu_stutter_wait(char *title) | |||
339 | 290 | ||
340 | struct rcu_torture_ops { | 291 | struct rcu_torture_ops { |
341 | void (*init)(void); | 292 | void (*init)(void); |
293 | void (*cleanup)(void); | ||
342 | int (*readlock)(void); | 294 | int (*readlock)(void); |
343 | void (*read_delay)(struct rcu_random_state *rrsp); | 295 | void (*read_delay)(struct rcu_random_state *rrsp); |
344 | void (*readunlock)(int idx); | 296 | void (*readunlock)(int idx); |
345 | int (*completed)(void); | 297 | int (*completed)(void); |
346 | void (*deferred_free)(struct rcu_torture *p); | 298 | void (*deferred_free)(struct rcu_torture *p); |
347 | void (*sync)(void); | 299 | void (*sync)(void); |
348 | void (*call)(struct rcu_head *head, void (*func)(struct rcu_head *rcu)); | ||
349 | void (*cb_barrier)(void); | 300 | void (*cb_barrier)(void); |
350 | void (*fqs)(void); | 301 | void (*fqs)(void); |
351 | int (*stats)(char *page); | 302 | int (*stats)(char *page); |
@@ -413,9 +364,8 @@ rcu_torture_cb(struct rcu_head *p) | |||
413 | if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) { | 364 | if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) { |
414 | rp->rtort_mbtest = 0; | 365 | rp->rtort_mbtest = 0; |
415 | rcu_torture_free(rp); | 366 | rcu_torture_free(rp); |
416 | } else { | 367 | } else |
417 | cur_ops->deferred_free(rp); | 368 | cur_ops->deferred_free(rp); |
418 | } | ||
419 | } | 369 | } |
420 | 370 | ||
421 | static int rcu_no_completed(void) | 371 | static int rcu_no_completed(void) |
@@ -430,13 +380,13 @@ static void rcu_torture_deferred_free(struct rcu_torture *p) | |||
430 | 380 | ||
431 | static struct rcu_torture_ops rcu_ops = { | 381 | static struct rcu_torture_ops rcu_ops = { |
432 | .init = NULL, | 382 | .init = NULL, |
383 | .cleanup = NULL, | ||
433 | .readlock = rcu_torture_read_lock, | 384 | .readlock = rcu_torture_read_lock, |
434 | .read_delay = rcu_read_delay, | 385 | .read_delay = rcu_read_delay, |
435 | .readunlock = rcu_torture_read_unlock, | 386 | .readunlock = rcu_torture_read_unlock, |
436 | .completed = rcu_torture_completed, | 387 | .completed = rcu_torture_completed, |
437 | .deferred_free = rcu_torture_deferred_free, | 388 | .deferred_free = rcu_torture_deferred_free, |
438 | .sync = synchronize_rcu, | 389 | .sync = synchronize_rcu, |
439 | .call = call_rcu, | ||
440 | .cb_barrier = rcu_barrier, | 390 | .cb_barrier = rcu_barrier, |
441 | .fqs = rcu_force_quiescent_state, | 391 | .fqs = rcu_force_quiescent_state, |
442 | .stats = NULL, | 392 | .stats = NULL, |
@@ -473,13 +423,13 @@ static void rcu_sync_torture_init(void) | |||
473 | 423 | ||
474 | static struct rcu_torture_ops rcu_sync_ops = { | 424 | static struct rcu_torture_ops rcu_sync_ops = { |
475 | .init = rcu_sync_torture_init, | 425 | .init = rcu_sync_torture_init, |
426 | .cleanup = NULL, | ||
476 | .readlock = rcu_torture_read_lock, | 427 | .readlock = rcu_torture_read_lock, |
477 | .read_delay = rcu_read_delay, | 428 | .read_delay = rcu_read_delay, |
478 | .readunlock = rcu_torture_read_unlock, | 429 | .readunlock = rcu_torture_read_unlock, |
479 | .completed = rcu_torture_completed, | 430 | .completed = rcu_torture_completed, |
480 | .deferred_free = rcu_sync_torture_deferred_free, | 431 | .deferred_free = rcu_sync_torture_deferred_free, |
481 | .sync = synchronize_rcu, | 432 | .sync = synchronize_rcu, |
482 | .call = NULL, | ||
483 | .cb_barrier = NULL, | 433 | .cb_barrier = NULL, |
484 | .fqs = rcu_force_quiescent_state, | 434 | .fqs = rcu_force_quiescent_state, |
485 | .stats = NULL, | 435 | .stats = NULL, |
@@ -490,13 +440,13 @@ static struct rcu_torture_ops rcu_sync_ops = { | |||
490 | 440 | ||
491 | static struct rcu_torture_ops rcu_expedited_ops = { | 441 | static struct rcu_torture_ops rcu_expedited_ops = { |
492 | .init = rcu_sync_torture_init, | 442 | .init = rcu_sync_torture_init, |
443 | .cleanup = NULL, | ||
493 | .readlock = rcu_torture_read_lock, | 444 | .readlock = rcu_torture_read_lock, |
494 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ | 445 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ |
495 | .readunlock = rcu_torture_read_unlock, | 446 | .readunlock = rcu_torture_read_unlock, |
496 | .completed = rcu_no_completed, | 447 | .completed = rcu_no_completed, |
497 | .deferred_free = rcu_sync_torture_deferred_free, | 448 | .deferred_free = rcu_sync_torture_deferred_free, |
498 | .sync = synchronize_rcu_expedited, | 449 | .sync = synchronize_rcu_expedited, |
499 | .call = NULL, | ||
500 | .cb_barrier = NULL, | 450 | .cb_barrier = NULL, |
501 | .fqs = rcu_force_quiescent_state, | 451 | .fqs = rcu_force_quiescent_state, |
502 | .stats = NULL, | 452 | .stats = NULL, |
@@ -530,15 +480,39 @@ static void rcu_bh_torture_deferred_free(struct rcu_torture *p) | |||
530 | call_rcu_bh(&p->rtort_rcu, rcu_torture_cb); | 480 | call_rcu_bh(&p->rtort_rcu, rcu_torture_cb); |
531 | } | 481 | } |
532 | 482 | ||
483 | struct rcu_bh_torture_synchronize { | ||
484 | struct rcu_head head; | ||
485 | struct completion completion; | ||
486 | }; | ||
487 | |||
488 | static void rcu_bh_torture_wakeme_after_cb(struct rcu_head *head) | ||
489 | { | ||
490 | struct rcu_bh_torture_synchronize *rcu; | ||
491 | |||
492 | rcu = container_of(head, struct rcu_bh_torture_synchronize, head); | ||
493 | complete(&rcu->completion); | ||
494 | } | ||
495 | |||
496 | static void rcu_bh_torture_synchronize(void) | ||
497 | { | ||
498 | struct rcu_bh_torture_synchronize rcu; | ||
499 | |||
500 | init_rcu_head_on_stack(&rcu.head); | ||
501 | init_completion(&rcu.completion); | ||
502 | call_rcu_bh(&rcu.head, rcu_bh_torture_wakeme_after_cb); | ||
503 | wait_for_completion(&rcu.completion); | ||
504 | destroy_rcu_head_on_stack(&rcu.head); | ||
505 | } | ||
506 | |||
533 | static struct rcu_torture_ops rcu_bh_ops = { | 507 | static struct rcu_torture_ops rcu_bh_ops = { |
534 | .init = NULL, | 508 | .init = NULL, |
509 | .cleanup = NULL, | ||
535 | .readlock = rcu_bh_torture_read_lock, | 510 | .readlock = rcu_bh_torture_read_lock, |
536 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ | 511 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ |
537 | .readunlock = rcu_bh_torture_read_unlock, | 512 | .readunlock = rcu_bh_torture_read_unlock, |
538 | .completed = rcu_bh_torture_completed, | 513 | .completed = rcu_bh_torture_completed, |
539 | .deferred_free = rcu_bh_torture_deferred_free, | 514 | .deferred_free = rcu_bh_torture_deferred_free, |
540 | .sync = synchronize_rcu_bh, | 515 | .sync = rcu_bh_torture_synchronize, |
541 | .call = call_rcu_bh, | ||
542 | .cb_barrier = rcu_barrier_bh, | 516 | .cb_barrier = rcu_barrier_bh, |
543 | .fqs = rcu_bh_force_quiescent_state, | 517 | .fqs = rcu_bh_force_quiescent_state, |
544 | .stats = NULL, | 518 | .stats = NULL, |
@@ -548,13 +522,13 @@ static struct rcu_torture_ops rcu_bh_ops = { | |||
548 | 522 | ||
549 | static struct rcu_torture_ops rcu_bh_sync_ops = { | 523 | static struct rcu_torture_ops rcu_bh_sync_ops = { |
550 | .init = rcu_sync_torture_init, | 524 | .init = rcu_sync_torture_init, |
525 | .cleanup = NULL, | ||
551 | .readlock = rcu_bh_torture_read_lock, | 526 | .readlock = rcu_bh_torture_read_lock, |
552 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ | 527 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ |
553 | .readunlock = rcu_bh_torture_read_unlock, | 528 | .readunlock = rcu_bh_torture_read_unlock, |
554 | .completed = rcu_bh_torture_completed, | 529 | .completed = rcu_bh_torture_completed, |
555 | .deferred_free = rcu_sync_torture_deferred_free, | 530 | .deferred_free = rcu_sync_torture_deferred_free, |
556 | .sync = synchronize_rcu_bh, | 531 | .sync = rcu_bh_torture_synchronize, |
557 | .call = NULL, | ||
558 | .cb_barrier = NULL, | 532 | .cb_barrier = NULL, |
559 | .fqs = rcu_bh_force_quiescent_state, | 533 | .fqs = rcu_bh_force_quiescent_state, |
560 | .stats = NULL, | 534 | .stats = NULL, |
@@ -562,27 +536,23 @@ static struct rcu_torture_ops rcu_bh_sync_ops = { | |||
562 | .name = "rcu_bh_sync" | 536 | .name = "rcu_bh_sync" |
563 | }; | 537 | }; |
564 | 538 | ||
565 | static struct rcu_torture_ops rcu_bh_expedited_ops = { | ||
566 | .init = rcu_sync_torture_init, | ||
567 | .readlock = rcu_bh_torture_read_lock, | ||
568 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ | ||
569 | .readunlock = rcu_bh_torture_read_unlock, | ||
570 | .completed = rcu_bh_torture_completed, | ||
571 | .deferred_free = rcu_sync_torture_deferred_free, | ||
572 | .sync = synchronize_rcu_bh_expedited, | ||
573 | .call = NULL, | ||
574 | .cb_barrier = NULL, | ||
575 | .fqs = rcu_bh_force_quiescent_state, | ||
576 | .stats = NULL, | ||
577 | .irq_capable = 1, | ||
578 | .name = "rcu_bh_expedited" | ||
579 | }; | ||
580 | |||
581 | /* | 539 | /* |
582 | * Definitions for srcu torture testing. | 540 | * Definitions for srcu torture testing. |
583 | */ | 541 | */ |
584 | 542 | ||
585 | DEFINE_STATIC_SRCU(srcu_ctl); | 543 | static struct srcu_struct srcu_ctl; |
544 | |||
545 | static void srcu_torture_init(void) | ||
546 | { | ||
547 | init_srcu_struct(&srcu_ctl); | ||
548 | rcu_sync_torture_init(); | ||
549 | } | ||
550 | |||
551 | static void srcu_torture_cleanup(void) | ||
552 | { | ||
553 | synchronize_srcu(&srcu_ctl); | ||
554 | cleanup_srcu_struct(&srcu_ctl); | ||
555 | } | ||
586 | 556 | ||
587 | static int srcu_torture_read_lock(void) __acquires(&srcu_ctl) | 557 | static int srcu_torture_read_lock(void) __acquires(&srcu_ctl) |
588 | { | 558 | { |
@@ -614,27 +584,11 @@ static int srcu_torture_completed(void) | |||
614 | return srcu_batches_completed(&srcu_ctl); | 584 | return srcu_batches_completed(&srcu_ctl); |
615 | } | 585 | } |
616 | 586 | ||
617 | static void srcu_torture_deferred_free(struct rcu_torture *rp) | ||
618 | { | ||
619 | call_srcu(&srcu_ctl, &rp->rtort_rcu, rcu_torture_cb); | ||
620 | } | ||
621 | |||
622 | static void srcu_torture_synchronize(void) | 587 | static void srcu_torture_synchronize(void) |
623 | { | 588 | { |
624 | synchronize_srcu(&srcu_ctl); | 589 | synchronize_srcu(&srcu_ctl); |
625 | } | 590 | } |
626 | 591 | ||
627 | static void srcu_torture_call(struct rcu_head *head, | ||
628 | void (*func)(struct rcu_head *head)) | ||
629 | { | ||
630 | call_srcu(&srcu_ctl, head, func); | ||
631 | } | ||
632 | |||
633 | static void srcu_torture_barrier(void) | ||
634 | { | ||
635 | srcu_barrier(&srcu_ctl); | ||
636 | } | ||
637 | |||
638 | static int srcu_torture_stats(char *page) | 592 | static int srcu_torture_stats(char *page) |
639 | { | 593 | { |
640 | int cnt = 0; | 594 | int cnt = 0; |
@@ -644,7 +598,7 @@ static int srcu_torture_stats(char *page) | |||
644 | cnt += sprintf(&page[cnt], "%s%s per-CPU(idx=%d):", | 598 | cnt += sprintf(&page[cnt], "%s%s per-CPU(idx=%d):", |
645 | torture_type, TORTURE_FLAG, idx); | 599 | torture_type, TORTURE_FLAG, idx); |
646 | for_each_possible_cpu(cpu) { | 600 | for_each_possible_cpu(cpu) { |
647 | cnt += sprintf(&page[cnt], " %d(%lu,%lu)", cpu, | 601 | cnt += sprintf(&page[cnt], " %d(%d,%d)", cpu, |
648 | per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[!idx], | 602 | per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[!idx], |
649 | per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[idx]); | 603 | per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[idx]); |
650 | } | 604 | } |
@@ -653,69 +607,17 @@ static int srcu_torture_stats(char *page) | |||
653 | } | 607 | } |
654 | 608 | ||
655 | static struct rcu_torture_ops srcu_ops = { | 609 | static struct rcu_torture_ops srcu_ops = { |
656 | .init = rcu_sync_torture_init, | 610 | .init = srcu_torture_init, |
611 | .cleanup = srcu_torture_cleanup, | ||
657 | .readlock = srcu_torture_read_lock, | 612 | .readlock = srcu_torture_read_lock, |
658 | .read_delay = srcu_read_delay, | 613 | .read_delay = srcu_read_delay, |
659 | .readunlock = srcu_torture_read_unlock, | 614 | .readunlock = srcu_torture_read_unlock, |
660 | .completed = srcu_torture_completed, | 615 | .completed = srcu_torture_completed, |
661 | .deferred_free = srcu_torture_deferred_free, | ||
662 | .sync = srcu_torture_synchronize, | ||
663 | .call = srcu_torture_call, | ||
664 | .cb_barrier = srcu_torture_barrier, | ||
665 | .stats = srcu_torture_stats, | ||
666 | .name = "srcu" | ||
667 | }; | ||
668 | |||
669 | static struct rcu_torture_ops srcu_sync_ops = { | ||
670 | .init = rcu_sync_torture_init, | ||
671 | .readlock = srcu_torture_read_lock, | ||
672 | .read_delay = srcu_read_delay, | ||
673 | .readunlock = srcu_torture_read_unlock, | ||
674 | .completed = srcu_torture_completed, | ||
675 | .deferred_free = rcu_sync_torture_deferred_free, | ||
676 | .sync = srcu_torture_synchronize, | ||
677 | .call = NULL, | ||
678 | .cb_barrier = NULL, | ||
679 | .stats = srcu_torture_stats, | ||
680 | .name = "srcu_sync" | ||
681 | }; | ||
682 | |||
683 | static int srcu_torture_read_lock_raw(void) __acquires(&srcu_ctl) | ||
684 | { | ||
685 | return srcu_read_lock_raw(&srcu_ctl); | ||
686 | } | ||
687 | |||
688 | static void srcu_torture_read_unlock_raw(int idx) __releases(&srcu_ctl) | ||
689 | { | ||
690 | srcu_read_unlock_raw(&srcu_ctl, idx); | ||
691 | } | ||
692 | |||
693 | static struct rcu_torture_ops srcu_raw_ops = { | ||
694 | .init = rcu_sync_torture_init, | ||
695 | .readlock = srcu_torture_read_lock_raw, | ||
696 | .read_delay = srcu_read_delay, | ||
697 | .readunlock = srcu_torture_read_unlock_raw, | ||
698 | .completed = srcu_torture_completed, | ||
699 | .deferred_free = srcu_torture_deferred_free, | ||
700 | .sync = srcu_torture_synchronize, | ||
701 | .call = NULL, | ||
702 | .cb_barrier = NULL, | ||
703 | .stats = srcu_torture_stats, | ||
704 | .name = "srcu_raw" | ||
705 | }; | ||
706 | |||
707 | static struct rcu_torture_ops srcu_raw_sync_ops = { | ||
708 | .init = rcu_sync_torture_init, | ||
709 | .readlock = srcu_torture_read_lock_raw, | ||
710 | .read_delay = srcu_read_delay, | ||
711 | .readunlock = srcu_torture_read_unlock_raw, | ||
712 | .completed = srcu_torture_completed, | ||
713 | .deferred_free = rcu_sync_torture_deferred_free, | 616 | .deferred_free = rcu_sync_torture_deferred_free, |
714 | .sync = srcu_torture_synchronize, | 617 | .sync = srcu_torture_synchronize, |
715 | .call = NULL, | ||
716 | .cb_barrier = NULL, | 618 | .cb_barrier = NULL, |
717 | .stats = srcu_torture_stats, | 619 | .stats = srcu_torture_stats, |
718 | .name = "srcu_raw_sync" | 620 | .name = "srcu" |
719 | }; | 621 | }; |
720 | 622 | ||
721 | static void srcu_torture_synchronize_expedited(void) | 623 | static void srcu_torture_synchronize_expedited(void) |
@@ -724,14 +626,14 @@ static void srcu_torture_synchronize_expedited(void) | |||
724 | } | 626 | } |
725 | 627 | ||
726 | static struct rcu_torture_ops srcu_expedited_ops = { | 628 | static struct rcu_torture_ops srcu_expedited_ops = { |
727 | .init = rcu_sync_torture_init, | 629 | .init = srcu_torture_init, |
630 | .cleanup = srcu_torture_cleanup, | ||
728 | .readlock = srcu_torture_read_lock, | 631 | .readlock = srcu_torture_read_lock, |
729 | .read_delay = srcu_read_delay, | 632 | .read_delay = srcu_read_delay, |
730 | .readunlock = srcu_torture_read_unlock, | 633 | .readunlock = srcu_torture_read_unlock, |
731 | .completed = srcu_torture_completed, | 634 | .completed = srcu_torture_completed, |
732 | .deferred_free = rcu_sync_torture_deferred_free, | 635 | .deferred_free = rcu_sync_torture_deferred_free, |
733 | .sync = srcu_torture_synchronize_expedited, | 636 | .sync = srcu_torture_synchronize_expedited, |
734 | .call = NULL, | ||
735 | .cb_barrier = NULL, | 637 | .cb_barrier = NULL, |
736 | .stats = srcu_torture_stats, | 638 | .stats = srcu_torture_stats, |
737 | .name = "srcu_expedited" | 639 | .name = "srcu_expedited" |
@@ -757,14 +659,20 @@ static void rcu_sched_torture_deferred_free(struct rcu_torture *p) | |||
757 | call_rcu_sched(&p->rtort_rcu, rcu_torture_cb); | 659 | call_rcu_sched(&p->rtort_rcu, rcu_torture_cb); |
758 | } | 660 | } |
759 | 661 | ||
662 | static void sched_torture_synchronize(void) | ||
663 | { | ||
664 | synchronize_sched(); | ||
665 | } | ||
666 | |||
760 | static struct rcu_torture_ops sched_ops = { | 667 | static struct rcu_torture_ops sched_ops = { |
761 | .init = rcu_sync_torture_init, | 668 | .init = rcu_sync_torture_init, |
669 | .cleanup = NULL, | ||
762 | .readlock = sched_torture_read_lock, | 670 | .readlock = sched_torture_read_lock, |
763 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ | 671 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ |
764 | .readunlock = sched_torture_read_unlock, | 672 | .readunlock = sched_torture_read_unlock, |
765 | .completed = rcu_no_completed, | 673 | .completed = rcu_no_completed, |
766 | .deferred_free = rcu_sched_torture_deferred_free, | 674 | .deferred_free = rcu_sched_torture_deferred_free, |
767 | .sync = synchronize_sched, | 675 | .sync = sched_torture_synchronize, |
768 | .cb_barrier = rcu_barrier_sched, | 676 | .cb_barrier = rcu_barrier_sched, |
769 | .fqs = rcu_sched_force_quiescent_state, | 677 | .fqs = rcu_sched_force_quiescent_state, |
770 | .stats = NULL, | 678 | .stats = NULL, |
@@ -774,12 +682,13 @@ static struct rcu_torture_ops sched_ops = { | |||
774 | 682 | ||
775 | static struct rcu_torture_ops sched_sync_ops = { | 683 | static struct rcu_torture_ops sched_sync_ops = { |
776 | .init = rcu_sync_torture_init, | 684 | .init = rcu_sync_torture_init, |
685 | .cleanup = NULL, | ||
777 | .readlock = sched_torture_read_lock, | 686 | .readlock = sched_torture_read_lock, |
778 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ | 687 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ |
779 | .readunlock = sched_torture_read_unlock, | 688 | .readunlock = sched_torture_read_unlock, |
780 | .completed = rcu_no_completed, | 689 | .completed = rcu_no_completed, |
781 | .deferred_free = rcu_sync_torture_deferred_free, | 690 | .deferred_free = rcu_sync_torture_deferred_free, |
782 | .sync = synchronize_sched, | 691 | .sync = sched_torture_synchronize, |
783 | .cb_barrier = NULL, | 692 | .cb_barrier = NULL, |
784 | .fqs = rcu_sched_force_quiescent_state, | 693 | .fqs = rcu_sched_force_quiescent_state, |
785 | .stats = NULL, | 694 | .stats = NULL, |
@@ -788,6 +697,7 @@ static struct rcu_torture_ops sched_sync_ops = { | |||
788 | 697 | ||
789 | static struct rcu_torture_ops sched_expedited_ops = { | 698 | static struct rcu_torture_ops sched_expedited_ops = { |
790 | .init = rcu_sync_torture_init, | 699 | .init = rcu_sync_torture_init, |
700 | .cleanup = NULL, | ||
791 | .readlock = sched_torture_read_lock, | 701 | .readlock = sched_torture_read_lock, |
792 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ | 702 | .read_delay = rcu_read_delay, /* just reuse rcu's version. */ |
793 | .readunlock = sched_torture_read_unlock, | 703 | .readunlock = sched_torture_read_unlock, |
@@ -844,7 +754,7 @@ static int rcu_torture_boost(void *arg) | |||
844 | do { | 754 | do { |
845 | /* Wait for the next test interval. */ | 755 | /* Wait for the next test interval. */ |
846 | oldstarttime = boost_starttime; | 756 | oldstarttime = boost_starttime; |
847 | while (ULONG_CMP_LT(jiffies, oldstarttime)) { | 757 | while (jiffies - oldstarttime > ULONG_MAX / 2) { |
848 | schedule_timeout_uninterruptible(1); | 758 | schedule_timeout_uninterruptible(1); |
849 | rcu_stutter_wait("rcu_torture_boost"); | 759 | rcu_stutter_wait("rcu_torture_boost"); |
850 | if (kthread_should_stop() || | 760 | if (kthread_should_stop() || |
@@ -855,7 +765,7 @@ static int rcu_torture_boost(void *arg) | |||
855 | /* Do one boost-test interval. */ | 765 | /* Do one boost-test interval. */ |
856 | endtime = oldstarttime + test_boost_duration * HZ; | 766 | endtime = oldstarttime + test_boost_duration * HZ; |
857 | call_rcu_time = jiffies; | 767 | call_rcu_time = jiffies; |
858 | while (ULONG_CMP_LT(jiffies, endtime)) { | 768 | while (jiffies - endtime > ULONG_MAX / 2) { |
859 | /* If we don't have a callback in flight, post one. */ | 769 | /* If we don't have a callback in flight, post one. */ |
860 | if (!rbi.inflight) { | 770 | if (!rbi.inflight) { |
861 | smp_mb(); /* RCU core before ->inflight = 1. */ | 771 | smp_mb(); /* RCU core before ->inflight = 1. */ |
@@ -882,8 +792,7 @@ static int rcu_torture_boost(void *arg) | |||
882 | * interval. Besides, we are running at RT priority, | 792 | * interval. Besides, we are running at RT priority, |
883 | * so delays should be relatively rare. | 793 | * so delays should be relatively rare. |
884 | */ | 794 | */ |
885 | while (oldstarttime == boost_starttime && | 795 | while (oldstarttime == boost_starttime) { |
886 | !kthread_should_stop()) { | ||
887 | if (mutex_trylock(&boost_mutex)) { | 796 | if (mutex_trylock(&boost_mutex)) { |
888 | boost_starttime = jiffies + | 797 | boost_starttime = jiffies + |
889 | test_boost_interval * HZ; | 798 | test_boost_interval * HZ; |
@@ -900,11 +809,11 @@ checkwait: rcu_stutter_wait("rcu_torture_boost"); | |||
900 | 809 | ||
901 | /* Clean up and exit. */ | 810 | /* Clean up and exit. */ |
902 | VERBOSE_PRINTK_STRING("rcu_torture_boost task stopping"); | 811 | VERBOSE_PRINTK_STRING("rcu_torture_boost task stopping"); |
812 | destroy_rcu_head_on_stack(&rbi.rcu); | ||
903 | rcutorture_shutdown_absorb("rcu_torture_boost"); | 813 | rcutorture_shutdown_absorb("rcu_torture_boost"); |
904 | while (!kthread_should_stop() || rbi.inflight) | 814 | while (!kthread_should_stop() || rbi.inflight) |
905 | schedule_timeout_uninterruptible(1); | 815 | schedule_timeout_uninterruptible(1); |
906 | smp_mb(); /* order accesses to ->inflight before stack-frame death. */ | 816 | smp_mb(); /* order accesses to ->inflight before stack-frame death. */ |
907 | destroy_rcu_head_on_stack(&rbi.rcu); | ||
908 | return 0; | 817 | return 0; |
909 | } | 818 | } |
910 | 819 | ||
@@ -922,13 +831,11 @@ rcu_torture_fqs(void *arg) | |||
922 | VERBOSE_PRINTK_STRING("rcu_torture_fqs task started"); | 831 | VERBOSE_PRINTK_STRING("rcu_torture_fqs task started"); |
923 | do { | 832 | do { |
924 | fqs_resume_time = jiffies + fqs_stutter * HZ; | 833 | fqs_resume_time = jiffies + fqs_stutter * HZ; |
925 | while (ULONG_CMP_LT(jiffies, fqs_resume_time) && | 834 | while (jiffies - fqs_resume_time > LONG_MAX) { |
926 | !kthread_should_stop()) { | ||
927 | schedule_timeout_interruptible(1); | 835 | schedule_timeout_interruptible(1); |
928 | } | 836 | } |
929 | fqs_burst_remaining = fqs_duration; | 837 | fqs_burst_remaining = fqs_duration; |
930 | while (fqs_burst_remaining > 0 && | 838 | while (fqs_burst_remaining > 0) { |
931 | !kthread_should_stop()) { | ||
932 | cur_ops->fqs(); | 839 | cur_ops->fqs(); |
933 | udelay(fqs_holdoff); | 840 | udelay(fqs_holdoff); |
934 | fqs_burst_remaining -= fqs_holdoff; | 841 | fqs_burst_remaining -= fqs_holdoff; |
@@ -1005,11 +912,7 @@ rcu_torture_fakewriter(void *arg) | |||
1005 | do { | 912 | do { |
1006 | schedule_timeout_uninterruptible(1 + rcu_random(&rand)%10); | 913 | schedule_timeout_uninterruptible(1 + rcu_random(&rand)%10); |
1007 | udelay(rcu_random(&rand) & 0x3ff); | 914 | udelay(rcu_random(&rand) & 0x3ff); |
1008 | if (cur_ops->cb_barrier != NULL && | 915 | cur_ops->sync(); |
1009 | rcu_random(&rand) % (nfakewriters * 8) == 0) | ||
1010 | cur_ops->cb_barrier(); | ||
1011 | else | ||
1012 | cur_ops->sync(); | ||
1013 | rcu_stutter_wait("rcu_torture_fakewriter"); | 916 | rcu_stutter_wait("rcu_torture_fakewriter"); |
1014 | } while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP); | 917 | } while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP); |
1015 | 918 | ||
@@ -1020,18 +923,6 @@ rcu_torture_fakewriter(void *arg) | |||
1020 | return 0; | 923 | return 0; |
1021 | } | 924 | } |
1022 | 925 | ||
1023 | void rcutorture_trace_dump(void) | ||
1024 | { | ||
1025 | static atomic_t beenhere = ATOMIC_INIT(0); | ||
1026 | |||
1027 | if (atomic_read(&beenhere)) | ||
1028 | return; | ||
1029 | if (atomic_xchg(&beenhere, 1) != 0) | ||
1030 | return; | ||
1031 | do_trace_rcu_torture_read(cur_ops->name, (struct rcu_head *)~0UL); | ||
1032 | ftrace_dump(DUMP_ALL); | ||
1033 | } | ||
1034 | |||
1035 | /* | 926 | /* |
1036 | * RCU torture reader from timer handler. Dereferences rcu_torture_current, | 927 | * RCU torture reader from timer handler. Dereferences rcu_torture_current, |
1037 | * incrementing the corresponding element of the pipeline array. The | 928 | * incrementing the corresponding element of the pipeline array. The |
@@ -1058,7 +949,6 @@ static void rcu_torture_timer(unsigned long unused) | |||
1058 | cur_ops->readunlock(idx); | 949 | cur_ops->readunlock(idx); |
1059 | return; | 950 | return; |
1060 | } | 951 | } |
1061 | do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu); | ||
1062 | if (p->rtort_mbtest == 0) | 952 | if (p->rtort_mbtest == 0) |
1063 | atomic_inc(&n_rcu_torture_mberror); | 953 | atomic_inc(&n_rcu_torture_mberror); |
1064 | spin_lock(&rand_lock); | 954 | spin_lock(&rand_lock); |
@@ -1071,8 +961,6 @@ static void rcu_torture_timer(unsigned long unused) | |||
1071 | /* Should not happen, but... */ | 961 | /* Should not happen, but... */ |
1072 | pipe_count = RCU_TORTURE_PIPE_LEN; | 962 | pipe_count = RCU_TORTURE_PIPE_LEN; |
1073 | } | 963 | } |
1074 | if (pipe_count > 1) | ||
1075 | rcutorture_trace_dump(); | ||
1076 | __this_cpu_inc(rcu_torture_count[pipe_count]); | 964 | __this_cpu_inc(rcu_torture_count[pipe_count]); |
1077 | completed = cur_ops->completed() - completed; | 965 | completed = cur_ops->completed() - completed; |
1078 | if (completed > RCU_TORTURE_PIPE_LEN) { | 966 | if (completed > RCU_TORTURE_PIPE_LEN) { |
@@ -1122,7 +1010,6 @@ rcu_torture_reader(void *arg) | |||
1122 | schedule_timeout_interruptible(HZ); | 1010 | schedule_timeout_interruptible(HZ); |
1123 | continue; | 1011 | continue; |
1124 | } | 1012 | } |
1125 | do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu); | ||
1126 | if (p->rtort_mbtest == 0) | 1013 | if (p->rtort_mbtest == 0) |
1127 | atomic_inc(&n_rcu_torture_mberror); | 1014 | atomic_inc(&n_rcu_torture_mberror); |
1128 | cur_ops->read_delay(&rand); | 1015 | cur_ops->read_delay(&rand); |
@@ -1132,8 +1019,6 @@ rcu_torture_reader(void *arg) | |||
1132 | /* Should not happen, but... */ | 1019 | /* Should not happen, but... */ |
1133 | pipe_count = RCU_TORTURE_PIPE_LEN; | 1020 | pipe_count = RCU_TORTURE_PIPE_LEN; |
1134 | } | 1021 | } |
1135 | if (pipe_count > 1) | ||
1136 | rcutorture_trace_dump(); | ||
1137 | __this_cpu_inc(rcu_torture_count[pipe_count]); | 1022 | __this_cpu_inc(rcu_torture_count[pipe_count]); |
1138 | completed = cur_ops->completed() - completed; | 1023 | completed = cur_ops->completed() - completed; |
1139 | if (completed > RCU_TORTURE_PIPE_LEN) { | 1024 | if (completed > RCU_TORTURE_PIPE_LEN) { |
@@ -1179,39 +1064,28 @@ rcu_torture_printk(char *page) | |||
1179 | } | 1064 | } |
1180 | cnt += sprintf(&page[cnt], "%s%s ", torture_type, TORTURE_FLAG); | 1065 | cnt += sprintf(&page[cnt], "%s%s ", torture_type, TORTURE_FLAG); |
1181 | cnt += sprintf(&page[cnt], | 1066 | cnt += sprintf(&page[cnt], |
1182 | "rtc: %p ver: %lu tfle: %d rta: %d rtaf: %d rtf: %d ", | 1067 | "rtc: %p ver: %lu tfle: %d rta: %d rtaf: %d rtf: %d " |
1068 | "rtmbe: %d rtbke: %ld rtbre: %ld " | ||
1069 | "rtbf: %ld rtb: %ld nt: %ld", | ||
1183 | rcu_torture_current, | 1070 | rcu_torture_current, |
1184 | rcu_torture_current_version, | 1071 | rcu_torture_current_version, |
1185 | list_empty(&rcu_torture_freelist), | 1072 | list_empty(&rcu_torture_freelist), |
1186 | atomic_read(&n_rcu_torture_alloc), | 1073 | atomic_read(&n_rcu_torture_alloc), |
1187 | atomic_read(&n_rcu_torture_alloc_fail), | 1074 | atomic_read(&n_rcu_torture_alloc_fail), |
1188 | atomic_read(&n_rcu_torture_free)); | 1075 | atomic_read(&n_rcu_torture_free), |
1189 | cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ", | ||
1190 | atomic_read(&n_rcu_torture_mberror), | 1076 | atomic_read(&n_rcu_torture_mberror), |
1191 | n_rcu_torture_boost_ktrerror, | 1077 | n_rcu_torture_boost_ktrerror, |
1192 | n_rcu_torture_boost_rterror); | 1078 | n_rcu_torture_boost_rterror, |
1193 | cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ", | ||
1194 | n_rcu_torture_boost_failure, | 1079 | n_rcu_torture_boost_failure, |
1195 | n_rcu_torture_boosts, | 1080 | n_rcu_torture_boosts, |
1196 | n_rcu_torture_timers); | 1081 | n_rcu_torture_timers); |
1197 | cnt += sprintf(&page[cnt], | ||
1198 | "onoff: %ld/%ld:%ld/%ld %d,%d:%d,%d %lu:%lu (HZ=%d) ", | ||
1199 | n_online_successes, n_online_attempts, | ||
1200 | n_offline_successes, n_offline_attempts, | ||
1201 | min_online, max_online, | ||
1202 | min_offline, max_offline, | ||
1203 | sum_online, sum_offline, HZ); | ||
1204 | cnt += sprintf(&page[cnt], "barrier: %ld/%ld:%ld", | ||
1205 | n_barrier_successes, | ||
1206 | n_barrier_attempts, | ||
1207 | n_rcu_torture_barrier_error); | ||
1208 | cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG); | ||
1209 | if (atomic_read(&n_rcu_torture_mberror) != 0 || | 1082 | if (atomic_read(&n_rcu_torture_mberror) != 0 || |
1210 | n_rcu_torture_barrier_error != 0 || | ||
1211 | n_rcu_torture_boost_ktrerror != 0 || | 1083 | n_rcu_torture_boost_ktrerror != 0 || |
1212 | n_rcu_torture_boost_rterror != 0 || | 1084 | n_rcu_torture_boost_rterror != 0 || |
1213 | n_rcu_torture_boost_failure != 0 || | 1085 | n_rcu_torture_boost_failure != 0) |
1214 | i > 1) { | 1086 | cnt += sprintf(&page[cnt], " !!!"); |
1087 | cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG); | ||
1088 | if (i > 1) { | ||
1215 | cnt += sprintf(&page[cnt], "!!! "); | 1089 | cnt += sprintf(&page[cnt], "!!! "); |
1216 | atomic_inc(&n_rcu_torture_error); | 1090 | atomic_inc(&n_rcu_torture_error); |
1217 | WARN_ON_ONCE(1); | 1091 | WARN_ON_ONCE(1); |
@@ -1249,7 +1123,7 @@ rcu_torture_stats_print(void) | |||
1249 | int cnt; | 1123 | int cnt; |
1250 | 1124 | ||
1251 | cnt = rcu_torture_printk(printk_buf); | 1125 | cnt = rcu_torture_printk(printk_buf); |
1252 | pr_alert("%s", printk_buf); | 1126 | printk(KERN_ALERT "%s", printk_buf); |
1253 | } | 1127 | } |
1254 | 1128 | ||
1255 | /* | 1129 | /* |
@@ -1362,24 +1236,18 @@ rcu_torture_stutter(void *arg) | |||
1362 | static inline void | 1236 | static inline void |
1363 | rcu_torture_print_module_parms(struct rcu_torture_ops *cur_ops, char *tag) | 1237 | rcu_torture_print_module_parms(struct rcu_torture_ops *cur_ops, char *tag) |
1364 | { | 1238 | { |
1365 | pr_alert("%s" TORTURE_FLAG | 1239 | printk(KERN_ALERT "%s" TORTURE_FLAG |
1366 | "--- %s: nreaders=%d nfakewriters=%d " | 1240 | "--- %s: nreaders=%d nfakewriters=%d " |
1367 | "stat_interval=%d verbose=%d test_no_idle_hz=%d " | 1241 | "stat_interval=%d verbose=%d test_no_idle_hz=%d " |
1368 | "shuffle_interval=%d stutter=%d irqreader=%d " | 1242 | "shuffle_interval=%d stutter=%d irqreader=%d " |
1369 | "fqs_duration=%d fqs_holdoff=%d fqs_stutter=%d " | 1243 | "fqs_duration=%d fqs_holdoff=%d fqs_stutter=%d " |
1370 | "test_boost=%d/%d test_boost_interval=%d " | 1244 | "test_boost=%d/%d test_boost_interval=%d " |
1371 | "test_boost_duration=%d shutdown_secs=%d " | 1245 | "test_boost_duration=%d\n", |
1372 | "stall_cpu=%d stall_cpu_holdoff=%d " | 1246 | torture_type, tag, nrealreaders, nfakewriters, |
1373 | "n_barrier_cbs=%d " | 1247 | stat_interval, verbose, test_no_idle_hz, shuffle_interval, |
1374 | "onoff_interval=%d onoff_holdoff=%d\n", | 1248 | stutter, irqreader, fqs_duration, fqs_holdoff, fqs_stutter, |
1375 | torture_type, tag, nrealreaders, nfakewriters, | 1249 | test_boost, cur_ops->can_boost, |
1376 | stat_interval, verbose, test_no_idle_hz, shuffle_interval, | 1250 | test_boost_interval, test_boost_duration); |
1377 | stutter, irqreader, fqs_duration, fqs_holdoff, fqs_stutter, | ||
1378 | test_boost, cur_ops->can_boost, | ||
1379 | test_boost_interval, test_boost_duration, shutdown_secs, | ||
1380 | stall_cpu, stall_cpu_holdoff, | ||
1381 | n_barrier_cbs, | ||
1382 | onoff_interval, onoff_holdoff); | ||
1383 | } | 1251 | } |
1384 | 1252 | ||
1385 | static struct notifier_block rcutorture_shutdown_nb = { | 1253 | static struct notifier_block rcutorture_shutdown_nb = { |
@@ -1400,7 +1268,6 @@ static void rcutorture_booster_cleanup(int cpu) | |||
1400 | 1268 | ||
1401 | /* This must be outside of the mutex, otherwise deadlock! */ | 1269 | /* This must be outside of the mutex, otherwise deadlock! */ |
1402 | kthread_stop(t); | 1270 | kthread_stop(t); |
1403 | boost_tasks[cpu] = NULL; | ||
1404 | } | 1271 | } |
1405 | 1272 | ||
1406 | static int rcutorture_booster_init(int cpu) | 1273 | static int rcutorture_booster_init(int cpu) |
@@ -1413,9 +1280,8 @@ static int rcutorture_booster_init(int cpu) | |||
1413 | /* Don't allow time recalculation while creating a new task. */ | 1280 | /* Don't allow time recalculation while creating a new task. */ |
1414 | mutex_lock(&boost_mutex); | 1281 | mutex_lock(&boost_mutex); |
1415 | VERBOSE_PRINTK_STRING("Creating rcu_torture_boost task"); | 1282 | VERBOSE_PRINTK_STRING("Creating rcu_torture_boost task"); |
1416 | boost_tasks[cpu] = kthread_create_on_node(rcu_torture_boost, NULL, | 1283 | boost_tasks[cpu] = kthread_create(rcu_torture_boost, NULL, |
1417 | cpu_to_node(cpu), | 1284 | "rcu_torture_boost"); |
1418 | "rcu_torture_boost"); | ||
1419 | if (IS_ERR(boost_tasks[cpu])) { | 1285 | if (IS_ERR(boost_tasks[cpu])) { |
1420 | retval = PTR_ERR(boost_tasks[cpu]); | 1286 | retval = PTR_ERR(boost_tasks[cpu]); |
1421 | VERBOSE_PRINTK_STRING("rcu_torture_boost task create failed"); | 1287 | VERBOSE_PRINTK_STRING("rcu_torture_boost task create failed"); |
@@ -1430,376 +1296,6 @@ static int rcutorture_booster_init(int cpu) | |||
1430 | return 0; | 1296 | return 0; |
1431 | } | 1297 | } |
1432 | 1298 | ||
1433 | /* | ||
1434 | * Cause the rcutorture test to shutdown the system after the test has | ||
1435 | * run for the time specified by the shutdown_secs module parameter. | ||
1436 | */ | ||
1437 | static int | ||
1438 | rcu_torture_shutdown(void *arg) | ||
1439 | { | ||
1440 | long delta; | ||
1441 | unsigned long jiffies_snap; | ||
1442 | |||
1443 | VERBOSE_PRINTK_STRING("rcu_torture_shutdown task started"); | ||
1444 | jiffies_snap = ACCESS_ONCE(jiffies); | ||
1445 | while (ULONG_CMP_LT(jiffies_snap, shutdown_time) && | ||
1446 | !kthread_should_stop()) { | ||
1447 | delta = shutdown_time - jiffies_snap; | ||
1448 | if (verbose) | ||
1449 | pr_alert("%s" TORTURE_FLAG | ||
1450 | "rcu_torture_shutdown task: %lu jiffies remaining\n", | ||
1451 | torture_type, delta); | ||
1452 | schedule_timeout_interruptible(delta); | ||
1453 | jiffies_snap = ACCESS_ONCE(jiffies); | ||
1454 | } | ||
1455 | if (kthread_should_stop()) { | ||
1456 | VERBOSE_PRINTK_STRING("rcu_torture_shutdown task stopping"); | ||
1457 | return 0; | ||
1458 | } | ||
1459 | |||
1460 | /* OK, shut down the system. */ | ||
1461 | |||
1462 | VERBOSE_PRINTK_STRING("rcu_torture_shutdown task shutting down system"); | ||
1463 | shutdown_task = NULL; /* Avoid self-kill deadlock. */ | ||
1464 | rcu_torture_cleanup(); /* Get the success/failure message. */ | ||
1465 | kernel_power_off(); /* Shut down the system. */ | ||
1466 | return 0; | ||
1467 | } | ||
1468 | |||
1469 | #ifdef CONFIG_HOTPLUG_CPU | ||
1470 | |||
1471 | /* | ||
1472 | * Execute random CPU-hotplug operations at the interval specified | ||
1473 | * by the onoff_interval. | ||
1474 | */ | ||
1475 | static int __cpuinit | ||
1476 | rcu_torture_onoff(void *arg) | ||
1477 | { | ||
1478 | int cpu; | ||
1479 | unsigned long delta; | ||
1480 | int maxcpu = -1; | ||
1481 | DEFINE_RCU_RANDOM(rand); | ||
1482 | int ret; | ||
1483 | unsigned long starttime; | ||
1484 | |||
1485 | VERBOSE_PRINTK_STRING("rcu_torture_onoff task started"); | ||
1486 | for_each_online_cpu(cpu) | ||
1487 | maxcpu = cpu; | ||
1488 | WARN_ON(maxcpu < 0); | ||
1489 | if (onoff_holdoff > 0) { | ||
1490 | VERBOSE_PRINTK_STRING("rcu_torture_onoff begin holdoff"); | ||
1491 | schedule_timeout_interruptible(onoff_holdoff * HZ); | ||
1492 | VERBOSE_PRINTK_STRING("rcu_torture_onoff end holdoff"); | ||
1493 | } | ||
1494 | while (!kthread_should_stop()) { | ||
1495 | cpu = (rcu_random(&rand) >> 4) % (maxcpu + 1); | ||
1496 | if (cpu_online(cpu) && cpu_is_hotpluggable(cpu)) { | ||
1497 | if (verbose) | ||
1498 | pr_alert("%s" TORTURE_FLAG | ||
1499 | "rcu_torture_onoff task: offlining %d\n", | ||
1500 | torture_type, cpu); | ||
1501 | starttime = jiffies; | ||
1502 | n_offline_attempts++; | ||
1503 | ret = cpu_down(cpu); | ||
1504 | if (ret) { | ||
1505 | if (verbose) | ||
1506 | pr_alert("%s" TORTURE_FLAG | ||
1507 | "rcu_torture_onoff task: offline %d failed: errno %d\n", | ||
1508 | torture_type, cpu, ret); | ||
1509 | } else { | ||
1510 | if (verbose) | ||
1511 | pr_alert("%s" TORTURE_FLAG | ||
1512 | "rcu_torture_onoff task: offlined %d\n", | ||
1513 | torture_type, cpu); | ||
1514 | n_offline_successes++; | ||
1515 | delta = jiffies - starttime; | ||
1516 | sum_offline += delta; | ||
1517 | if (min_offline < 0) { | ||
1518 | min_offline = delta; | ||
1519 | max_offline = delta; | ||
1520 | } | ||
1521 | if (min_offline > delta) | ||
1522 | min_offline = delta; | ||
1523 | if (max_offline < delta) | ||
1524 | max_offline = delta; | ||
1525 | } | ||
1526 | } else if (cpu_is_hotpluggable(cpu)) { | ||
1527 | if (verbose) | ||
1528 | pr_alert("%s" TORTURE_FLAG | ||
1529 | "rcu_torture_onoff task: onlining %d\n", | ||
1530 | torture_type, cpu); | ||
1531 | starttime = jiffies; | ||
1532 | n_online_attempts++; | ||
1533 | if (cpu_up(cpu) == 0) { | ||
1534 | if (verbose) | ||
1535 | pr_alert("%s" TORTURE_FLAG | ||
1536 | "rcu_torture_onoff task: onlined %d\n", | ||
1537 | torture_type, cpu); | ||
1538 | n_online_successes++; | ||
1539 | delta = jiffies - starttime; | ||
1540 | sum_online += delta; | ||
1541 | if (min_online < 0) { | ||
1542 | min_online = delta; | ||
1543 | max_online = delta; | ||
1544 | } | ||
1545 | if (min_online > delta) | ||
1546 | min_online = delta; | ||
1547 | if (max_online < delta) | ||
1548 | max_online = delta; | ||
1549 | } | ||
1550 | } | ||
1551 | schedule_timeout_interruptible(onoff_interval * HZ); | ||
1552 | } | ||
1553 | VERBOSE_PRINTK_STRING("rcu_torture_onoff task stopping"); | ||
1554 | return 0; | ||
1555 | } | ||
1556 | |||
1557 | static int __cpuinit | ||
1558 | rcu_torture_onoff_init(void) | ||
1559 | { | ||
1560 | int ret; | ||
1561 | |||
1562 | if (onoff_interval <= 0) | ||
1563 | return 0; | ||
1564 | onoff_task = kthread_run(rcu_torture_onoff, NULL, "rcu_torture_onoff"); | ||
1565 | if (IS_ERR(onoff_task)) { | ||
1566 | ret = PTR_ERR(onoff_task); | ||
1567 | onoff_task = NULL; | ||
1568 | return ret; | ||
1569 | } | ||
1570 | return 0; | ||
1571 | } | ||
1572 | |||
1573 | static void rcu_torture_onoff_cleanup(void) | ||
1574 | { | ||
1575 | if (onoff_task == NULL) | ||
1576 | return; | ||
1577 | VERBOSE_PRINTK_STRING("Stopping rcu_torture_onoff task"); | ||
1578 | kthread_stop(onoff_task); | ||
1579 | onoff_task = NULL; | ||
1580 | } | ||
1581 | |||
1582 | #else /* #ifdef CONFIG_HOTPLUG_CPU */ | ||
1583 | |||
1584 | static int | ||
1585 | rcu_torture_onoff_init(void) | ||
1586 | { | ||
1587 | return 0; | ||
1588 | } | ||
1589 | |||
1590 | static void rcu_torture_onoff_cleanup(void) | ||
1591 | { | ||
1592 | } | ||
1593 | |||
1594 | #endif /* #else #ifdef CONFIG_HOTPLUG_CPU */ | ||
1595 | |||
1596 | /* | ||
1597 | * CPU-stall kthread. It waits as specified by stall_cpu_holdoff, then | ||
1598 | * induces a CPU stall for the time specified by stall_cpu. | ||
1599 | */ | ||
1600 | static int __cpuinit rcu_torture_stall(void *args) | ||
1601 | { | ||
1602 | unsigned long stop_at; | ||
1603 | |||
1604 | VERBOSE_PRINTK_STRING("rcu_torture_stall task started"); | ||
1605 | if (stall_cpu_holdoff > 0) { | ||
1606 | VERBOSE_PRINTK_STRING("rcu_torture_stall begin holdoff"); | ||
1607 | schedule_timeout_interruptible(stall_cpu_holdoff * HZ); | ||
1608 | VERBOSE_PRINTK_STRING("rcu_torture_stall end holdoff"); | ||
1609 | } | ||
1610 | if (!kthread_should_stop()) { | ||
1611 | stop_at = get_seconds() + stall_cpu; | ||
1612 | /* RCU CPU stall is expected behavior in following code. */ | ||
1613 | pr_alert("rcu_torture_stall start.\n"); | ||
1614 | rcu_read_lock(); | ||
1615 | preempt_disable(); | ||
1616 | while (ULONG_CMP_LT(get_seconds(), stop_at)) | ||
1617 | continue; /* Induce RCU CPU stall warning. */ | ||
1618 | preempt_enable(); | ||
1619 | rcu_read_unlock(); | ||
1620 | pr_alert("rcu_torture_stall end.\n"); | ||
1621 | } | ||
1622 | rcutorture_shutdown_absorb("rcu_torture_stall"); | ||
1623 | while (!kthread_should_stop()) | ||
1624 | schedule_timeout_interruptible(10 * HZ); | ||
1625 | return 0; | ||
1626 | } | ||
1627 | |||
1628 | /* Spawn CPU-stall kthread, if stall_cpu specified. */ | ||
1629 | static int __init rcu_torture_stall_init(void) | ||
1630 | { | ||
1631 | int ret; | ||
1632 | |||
1633 | if (stall_cpu <= 0) | ||
1634 | return 0; | ||
1635 | stall_task = kthread_run(rcu_torture_stall, NULL, "rcu_torture_stall"); | ||
1636 | if (IS_ERR(stall_task)) { | ||
1637 | ret = PTR_ERR(stall_task); | ||
1638 | stall_task = NULL; | ||
1639 | return ret; | ||
1640 | } | ||
1641 | return 0; | ||
1642 | } | ||
1643 | |||
1644 | /* Clean up after the CPU-stall kthread, if one was spawned. */ | ||
1645 | static void rcu_torture_stall_cleanup(void) | ||
1646 | { | ||
1647 | if (stall_task == NULL) | ||
1648 | return; | ||
1649 | VERBOSE_PRINTK_STRING("Stopping rcu_torture_stall_task."); | ||
1650 | kthread_stop(stall_task); | ||
1651 | stall_task = NULL; | ||
1652 | } | ||
1653 | |||
1654 | /* Callback function for RCU barrier testing. */ | ||
1655 | void rcu_torture_barrier_cbf(struct rcu_head *rcu) | ||
1656 | { | ||
1657 | atomic_inc(&barrier_cbs_invoked); | ||
1658 | } | ||
1659 | |||
1660 | /* kthread function to register callbacks used to test RCU barriers. */ | ||
1661 | static int rcu_torture_barrier_cbs(void *arg) | ||
1662 | { | ||
1663 | long myid = (long)arg; | ||
1664 | bool lastphase = 0; | ||
1665 | struct rcu_head rcu; | ||
1666 | |||
1667 | init_rcu_head_on_stack(&rcu); | ||
1668 | VERBOSE_PRINTK_STRING("rcu_torture_barrier_cbs task started"); | ||
1669 | set_user_nice(current, 19); | ||
1670 | do { | ||
1671 | wait_event(barrier_cbs_wq[myid], | ||
1672 | barrier_phase != lastphase || | ||
1673 | kthread_should_stop() || | ||
1674 | fullstop != FULLSTOP_DONTSTOP); | ||
1675 | lastphase = barrier_phase; | ||
1676 | smp_mb(); /* ensure barrier_phase load before ->call(). */ | ||
1677 | if (kthread_should_stop() || fullstop != FULLSTOP_DONTSTOP) | ||
1678 | break; | ||
1679 | cur_ops->call(&rcu, rcu_torture_barrier_cbf); | ||
1680 | if (atomic_dec_and_test(&barrier_cbs_count)) | ||
1681 | wake_up(&barrier_wq); | ||
1682 | } while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP); | ||
1683 | VERBOSE_PRINTK_STRING("rcu_torture_barrier_cbs task stopping"); | ||
1684 | rcutorture_shutdown_absorb("rcu_torture_barrier_cbs"); | ||
1685 | while (!kthread_should_stop()) | ||
1686 | schedule_timeout_interruptible(1); | ||
1687 | cur_ops->cb_barrier(); | ||
1688 | destroy_rcu_head_on_stack(&rcu); | ||
1689 | return 0; | ||
1690 | } | ||
1691 | |||
1692 | /* kthread function to drive and coordinate RCU barrier testing. */ | ||
1693 | static int rcu_torture_barrier(void *arg) | ||
1694 | { | ||
1695 | int i; | ||
1696 | |||
1697 | VERBOSE_PRINTK_STRING("rcu_torture_barrier task starting"); | ||
1698 | do { | ||
1699 | atomic_set(&barrier_cbs_invoked, 0); | ||
1700 | atomic_set(&barrier_cbs_count, n_barrier_cbs); | ||
1701 | smp_mb(); /* Ensure barrier_phase after prior assignments. */ | ||
1702 | barrier_phase = !barrier_phase; | ||
1703 | for (i = 0; i < n_barrier_cbs; i++) | ||
1704 | wake_up(&barrier_cbs_wq[i]); | ||
1705 | wait_event(barrier_wq, | ||
1706 | atomic_read(&barrier_cbs_count) == 0 || | ||
1707 | kthread_should_stop() || | ||
1708 | fullstop != FULLSTOP_DONTSTOP); | ||
1709 | if (kthread_should_stop() || fullstop != FULLSTOP_DONTSTOP) | ||
1710 | break; | ||
1711 | n_barrier_attempts++; | ||
1712 | cur_ops->cb_barrier(); | ||
1713 | if (atomic_read(&barrier_cbs_invoked) != n_barrier_cbs) { | ||
1714 | n_rcu_torture_barrier_error++; | ||
1715 | WARN_ON_ONCE(1); | ||
1716 | } | ||
1717 | n_barrier_successes++; | ||
1718 | schedule_timeout_interruptible(HZ / 10); | ||
1719 | } while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP); | ||
1720 | VERBOSE_PRINTK_STRING("rcu_torture_barrier task stopping"); | ||
1721 | rcutorture_shutdown_absorb("rcu_torture_barrier"); | ||
1722 | while (!kthread_should_stop()) | ||
1723 | schedule_timeout_interruptible(1); | ||
1724 | return 0; | ||
1725 | } | ||
1726 | |||
1727 | /* Initialize RCU barrier testing. */ | ||
1728 | static int rcu_torture_barrier_init(void) | ||
1729 | { | ||
1730 | int i; | ||
1731 | int ret; | ||
1732 | |||
1733 | if (n_barrier_cbs == 0) | ||
1734 | return 0; | ||
1735 | if (cur_ops->call == NULL || cur_ops->cb_barrier == NULL) { | ||
1736 | pr_alert("%s" TORTURE_FLAG | ||
1737 | " Call or barrier ops missing for %s,\n", | ||
1738 | torture_type, cur_ops->name); | ||
1739 | pr_alert("%s" TORTURE_FLAG | ||
1740 | " RCU barrier testing omitted from run.\n", | ||
1741 | torture_type); | ||
1742 | return 0; | ||
1743 | } | ||
1744 | atomic_set(&barrier_cbs_count, 0); | ||
1745 | atomic_set(&barrier_cbs_invoked, 0); | ||
1746 | barrier_cbs_tasks = | ||
1747 | kzalloc(n_barrier_cbs * sizeof(barrier_cbs_tasks[0]), | ||
1748 | GFP_KERNEL); | ||
1749 | barrier_cbs_wq = | ||
1750 | kzalloc(n_barrier_cbs * sizeof(barrier_cbs_wq[0]), | ||
1751 | GFP_KERNEL); | ||
1752 | if (barrier_cbs_tasks == NULL || barrier_cbs_wq == 0) | ||
1753 | return -ENOMEM; | ||
1754 | for (i = 0; i < n_barrier_cbs; i++) { | ||
1755 | init_waitqueue_head(&barrier_cbs_wq[i]); | ||
1756 | barrier_cbs_tasks[i] = kthread_run(rcu_torture_barrier_cbs, | ||
1757 | (void *)(long)i, | ||
1758 | "rcu_torture_barrier_cbs"); | ||
1759 | if (IS_ERR(barrier_cbs_tasks[i])) { | ||
1760 | ret = PTR_ERR(barrier_cbs_tasks[i]); | ||
1761 | VERBOSE_PRINTK_ERRSTRING("Failed to create rcu_torture_barrier_cbs"); | ||
1762 | barrier_cbs_tasks[i] = NULL; | ||
1763 | return ret; | ||
1764 | } | ||
1765 | } | ||
1766 | barrier_task = kthread_run(rcu_torture_barrier, NULL, | ||
1767 | "rcu_torture_barrier"); | ||
1768 | if (IS_ERR(barrier_task)) { | ||
1769 | ret = PTR_ERR(barrier_task); | ||
1770 | VERBOSE_PRINTK_ERRSTRING("Failed to create rcu_torture_barrier"); | ||
1771 | barrier_task = NULL; | ||
1772 | } | ||
1773 | return 0; | ||
1774 | } | ||
1775 | |||
1776 | /* Clean up after RCU barrier testing. */ | ||
1777 | static void rcu_torture_barrier_cleanup(void) | ||
1778 | { | ||
1779 | int i; | ||
1780 | |||
1781 | if (barrier_task != NULL) { | ||
1782 | VERBOSE_PRINTK_STRING("Stopping rcu_torture_barrier task"); | ||
1783 | kthread_stop(barrier_task); | ||
1784 | barrier_task = NULL; | ||
1785 | } | ||
1786 | if (barrier_cbs_tasks != NULL) { | ||
1787 | for (i = 0; i < n_barrier_cbs; i++) { | ||
1788 | if (barrier_cbs_tasks[i] != NULL) { | ||
1789 | VERBOSE_PRINTK_STRING("Stopping rcu_torture_barrier_cbs task"); | ||
1790 | kthread_stop(barrier_cbs_tasks[i]); | ||
1791 | barrier_cbs_tasks[i] = NULL; | ||
1792 | } | ||
1793 | } | ||
1794 | kfree(barrier_cbs_tasks); | ||
1795 | barrier_cbs_tasks = NULL; | ||
1796 | } | ||
1797 | if (barrier_cbs_wq != NULL) { | ||
1798 | kfree(barrier_cbs_wq); | ||
1799 | barrier_cbs_wq = NULL; | ||
1800 | } | ||
1801 | } | ||
1802 | |||
1803 | static int rcutorture_cpu_notify(struct notifier_block *self, | 1299 | static int rcutorture_cpu_notify(struct notifier_block *self, |
1804 | unsigned long action, void *hcpu) | 1300 | unsigned long action, void *hcpu) |
1805 | { | 1301 | { |
@@ -1831,7 +1327,7 @@ rcu_torture_cleanup(void) | |||
1831 | mutex_lock(&fullstop_mutex); | 1327 | mutex_lock(&fullstop_mutex); |
1832 | rcutorture_record_test_transition(); | 1328 | rcutorture_record_test_transition(); |
1833 | if (fullstop == FULLSTOP_SHUTDOWN) { | 1329 | if (fullstop == FULLSTOP_SHUTDOWN) { |
1834 | pr_warn(/* but going down anyway, so... */ | 1330 | printk(KERN_WARNING /* but going down anyway, so... */ |
1835 | "Concurrent 'rmmod rcutorture' and shutdown illegal!\n"); | 1331 | "Concurrent 'rmmod rcutorture' and shutdown illegal!\n"); |
1836 | mutex_unlock(&fullstop_mutex); | 1332 | mutex_unlock(&fullstop_mutex); |
1837 | schedule_timeout_uninterruptible(10); | 1333 | schedule_timeout_uninterruptible(10); |
@@ -1842,8 +1338,6 @@ rcu_torture_cleanup(void) | |||
1842 | fullstop = FULLSTOP_RMMOD; | 1338 | fullstop = FULLSTOP_RMMOD; |
1843 | mutex_unlock(&fullstop_mutex); | 1339 | mutex_unlock(&fullstop_mutex); |
1844 | unregister_reboot_notifier(&rcutorture_shutdown_nb); | 1340 | unregister_reboot_notifier(&rcutorture_shutdown_nb); |
1845 | rcu_torture_barrier_cleanup(); | ||
1846 | rcu_torture_stall_cleanup(); | ||
1847 | if (stutter_task) { | 1341 | if (stutter_task) { |
1848 | VERBOSE_PRINTK_STRING("Stopping rcu_torture_stutter task"); | 1342 | VERBOSE_PRINTK_STRING("Stopping rcu_torture_stutter task"); |
1849 | kthread_stop(stutter_task); | 1343 | kthread_stop(stutter_task); |
@@ -1906,12 +1400,6 @@ rcu_torture_cleanup(void) | |||
1906 | for_each_possible_cpu(i) | 1400 | for_each_possible_cpu(i) |
1907 | rcutorture_booster_cleanup(i); | 1401 | rcutorture_booster_cleanup(i); |
1908 | } | 1402 | } |
1909 | if (shutdown_task != NULL) { | ||
1910 | VERBOSE_PRINTK_STRING("Stopping rcu_torture_shutdown task"); | ||
1911 | kthread_stop(shutdown_task); | ||
1912 | } | ||
1913 | shutdown_task = NULL; | ||
1914 | rcu_torture_onoff_cleanup(); | ||
1915 | 1403 | ||
1916 | /* Wait for all RCU callbacks to fire. */ | 1404 | /* Wait for all RCU callbacks to fire. */ |
1917 | 1405 | ||
@@ -1920,12 +1408,10 @@ rcu_torture_cleanup(void) | |||
1920 | 1408 | ||
1921 | rcu_torture_stats_print(); /* -After- the stats thread is stopped! */ | 1409 | rcu_torture_stats_print(); /* -After- the stats thread is stopped! */ |
1922 | 1410 | ||
1923 | if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error) | 1411 | if (cur_ops->cleanup) |
1412 | cur_ops->cleanup(); | ||
1413 | if (atomic_read(&n_rcu_torture_error)) | ||
1924 | rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE"); | 1414 | rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE"); |
1925 | else if (n_online_successes != n_online_attempts || | ||
1926 | n_offline_successes != n_offline_attempts) | ||
1927 | rcu_torture_print_module_parms(cur_ops, | ||
1928 | "End of test: RCU_HOTPLUG"); | ||
1929 | else | 1415 | else |
1930 | rcu_torture_print_module_parms(cur_ops, "End of test: SUCCESS"); | 1416 | rcu_torture_print_module_parms(cur_ops, "End of test: SUCCESS"); |
1931 | } | 1417 | } |
@@ -1936,12 +1422,10 @@ rcu_torture_init(void) | |||
1936 | int i; | 1422 | int i; |
1937 | int cpu; | 1423 | int cpu; |
1938 | int firsterr = 0; | 1424 | int firsterr = 0; |
1939 | int retval; | ||
1940 | static struct rcu_torture_ops *torture_ops[] = | 1425 | static struct rcu_torture_ops *torture_ops[] = |
1941 | { &rcu_ops, &rcu_sync_ops, &rcu_expedited_ops, | 1426 | { &rcu_ops, &rcu_sync_ops, &rcu_expedited_ops, |
1942 | &rcu_bh_ops, &rcu_bh_sync_ops, &rcu_bh_expedited_ops, | 1427 | &rcu_bh_ops, &rcu_bh_sync_ops, |
1943 | &srcu_ops, &srcu_sync_ops, &srcu_expedited_ops, | 1428 | &srcu_ops, &srcu_expedited_ops, |
1944 | &srcu_raw_ops, &srcu_raw_sync_ops, | ||
1945 | &sched_ops, &sched_sync_ops, &sched_expedited_ops, }; | 1429 | &sched_ops, &sched_sync_ops, &sched_expedited_ops, }; |
1946 | 1430 | ||
1947 | mutex_lock(&fullstop_mutex); | 1431 | mutex_lock(&fullstop_mutex); |
@@ -1953,17 +1437,18 @@ rcu_torture_init(void) | |||
1953 | break; | 1437 | break; |
1954 | } | 1438 | } |
1955 | if (i == ARRAY_SIZE(torture_ops)) { | 1439 | if (i == ARRAY_SIZE(torture_ops)) { |
1956 | pr_alert("rcu-torture: invalid torture type: \"%s\"\n", | 1440 | printk(KERN_ALERT "rcu-torture: invalid torture type: \"%s\"\n", |
1957 | torture_type); | 1441 | torture_type); |
1958 | pr_alert("rcu-torture types:"); | 1442 | printk(KERN_ALERT "rcu-torture types:"); |
1959 | for (i = 0; i < ARRAY_SIZE(torture_ops); i++) | 1443 | for (i = 0; i < ARRAY_SIZE(torture_ops); i++) |
1960 | pr_alert(" %s", torture_ops[i]->name); | 1444 | printk(KERN_ALERT " %s", torture_ops[i]->name); |
1961 | pr_alert("\n"); | 1445 | printk(KERN_ALERT "\n"); |
1962 | mutex_unlock(&fullstop_mutex); | 1446 | mutex_unlock(&fullstop_mutex); |
1963 | return -EINVAL; | 1447 | return -EINVAL; |
1964 | } | 1448 | } |
1965 | if (cur_ops->fqs == NULL && fqs_duration != 0) { | 1449 | if (cur_ops->fqs == NULL && fqs_duration != 0) { |
1966 | pr_alert("rcu-torture: ->fqs NULL and non-zero fqs_duration, fqs disabled.\n"); | 1450 | printk(KERN_ALERT "rcu-torture: ->fqs NULL and non-zero " |
1451 | "fqs_duration, fqs disabled.\n"); | ||
1967 | fqs_duration = 0; | 1452 | fqs_duration = 0; |
1968 | } | 1453 | } |
1969 | if (cur_ops->init) | 1454 | if (cur_ops->init) |
@@ -1994,7 +1479,6 @@ rcu_torture_init(void) | |||
1994 | atomic_set(&n_rcu_torture_free, 0); | 1479 | atomic_set(&n_rcu_torture_free, 0); |
1995 | atomic_set(&n_rcu_torture_mberror, 0); | 1480 | atomic_set(&n_rcu_torture_mberror, 0); |
1996 | atomic_set(&n_rcu_torture_error, 0); | 1481 | atomic_set(&n_rcu_torture_error, 0); |
1997 | n_rcu_torture_barrier_error = 0; | ||
1998 | n_rcu_torture_boost_ktrerror = 0; | 1482 | n_rcu_torture_boost_ktrerror = 0; |
1999 | n_rcu_torture_boost_rterror = 0; | 1483 | n_rcu_torture_boost_rterror = 0; |
2000 | n_rcu_torture_boost_failure = 0; | 1484 | n_rcu_torture_boost_failure = 0; |
@@ -2011,15 +1495,14 @@ rcu_torture_init(void) | |||
2011 | /* Start up the kthreads. */ | 1495 | /* Start up the kthreads. */ |
2012 | 1496 | ||
2013 | VERBOSE_PRINTK_STRING("Creating rcu_torture_writer task"); | 1497 | VERBOSE_PRINTK_STRING("Creating rcu_torture_writer task"); |
2014 | writer_task = kthread_create(rcu_torture_writer, NULL, | 1498 | writer_task = kthread_run(rcu_torture_writer, NULL, |
2015 | "rcu_torture_writer"); | 1499 | "rcu_torture_writer"); |
2016 | if (IS_ERR(writer_task)) { | 1500 | if (IS_ERR(writer_task)) { |
2017 | firsterr = PTR_ERR(writer_task); | 1501 | firsterr = PTR_ERR(writer_task); |
2018 | VERBOSE_PRINTK_ERRSTRING("Failed to create writer"); | 1502 | VERBOSE_PRINTK_ERRSTRING("Failed to create writer"); |
2019 | writer_task = NULL; | 1503 | writer_task = NULL; |
2020 | goto unwind; | 1504 | goto unwind; |
2021 | } | 1505 | } |
2022 | wake_up_process(writer_task); | ||
2023 | fakewriter_tasks = kzalloc(nfakewriters * sizeof(fakewriter_tasks[0]), | 1506 | fakewriter_tasks = kzalloc(nfakewriters * sizeof(fakewriter_tasks[0]), |
2024 | GFP_KERNEL); | 1507 | GFP_KERNEL); |
2025 | if (fakewriter_tasks == NULL) { | 1508 | if (fakewriter_tasks == NULL) { |
@@ -2119,6 +1602,7 @@ rcu_torture_init(void) | |||
2119 | test_boost_duration = 2; | 1602 | test_boost_duration = 2; |
2120 | if ((test_boost == 1 && cur_ops->can_boost) || | 1603 | if ((test_boost == 1 && cur_ops->can_boost) || |
2121 | test_boost == 2) { | 1604 | test_boost == 2) { |
1605 | int retval; | ||
2122 | 1606 | ||
2123 | boost_starttime = jiffies + test_boost_interval * HZ; | 1607 | boost_starttime = jiffies + test_boost_interval * HZ; |
2124 | register_cpu_notifier(&rcutorture_cpu_nb); | 1608 | register_cpu_notifier(&rcutorture_cpu_nb); |
@@ -2132,34 +1616,7 @@ rcu_torture_init(void) | |||
2132 | } | 1616 | } |
2133 | } | 1617 | } |
2134 | } | 1618 | } |
2135 | if (shutdown_secs > 0) { | ||
2136 | shutdown_time = jiffies + shutdown_secs * HZ; | ||
2137 | shutdown_task = kthread_create(rcu_torture_shutdown, NULL, | ||
2138 | "rcu_torture_shutdown"); | ||
2139 | if (IS_ERR(shutdown_task)) { | ||
2140 | firsterr = PTR_ERR(shutdown_task); | ||
2141 | VERBOSE_PRINTK_ERRSTRING("Failed to create shutdown"); | ||
2142 | shutdown_task = NULL; | ||
2143 | goto unwind; | ||
2144 | } | ||
2145 | wake_up_process(shutdown_task); | ||
2146 | } | ||
2147 | i = rcu_torture_onoff_init(); | ||
2148 | if (i != 0) { | ||
2149 | firsterr = i; | ||
2150 | goto unwind; | ||
2151 | } | ||
2152 | register_reboot_notifier(&rcutorture_shutdown_nb); | 1619 | register_reboot_notifier(&rcutorture_shutdown_nb); |
2153 | i = rcu_torture_stall_init(); | ||
2154 | if (i != 0) { | ||
2155 | firsterr = i; | ||
2156 | goto unwind; | ||
2157 | } | ||
2158 | retval = rcu_torture_barrier_init(); | ||
2159 | if (retval != 0) { | ||
2160 | firsterr = retval; | ||
2161 | goto unwind; | ||
2162 | } | ||
2163 | rcutorture_record_test_transition(); | 1620 | rcutorture_record_test_transition(); |
2164 | mutex_unlock(&fullstop_mutex); | 1621 | mutex_unlock(&fullstop_mutex); |
2165 | return 0; | 1622 | return 0; |