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