aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/rcu
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>2014-02-04 14:47:08 -0500
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2014-02-23 12:04:25 -0500
commit9c029b86098decd4660eec511b8d2d42da3e7dd9 (patch)
treea108dd697afee54ef25db8303aaa71c7b28e37aa /kernel/rcu
parent47cf29b9e721967aac95ebda9e50408219755852 (diff)
rcutorture: Abstract torture_stop_kthread()
Stopping of kthreads is not RCU-specific, so this commit abstracts out torture_stop_kthread(), saving a few lines of code in the process. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Diffstat (limited to 'kernel/rcu')
-rw-r--r--kernel/rcu/rcutorture.c72
1 files changed, 14 insertions, 58 deletions
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index a6f6c8418d87..37bd4beea198 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -1033,14 +1033,12 @@ static void rcutorture_booster_cleanup(int cpu)
1033 if (boost_tasks[cpu] == NULL) 1033 if (boost_tasks[cpu] == NULL)
1034 return; 1034 return;
1035 mutex_lock(&boost_mutex); 1035 mutex_lock(&boost_mutex);
1036 VERBOSE_TOROUT_STRING("Stopping rcu_torture_boost task");
1037 t = boost_tasks[cpu]; 1036 t = boost_tasks[cpu];
1038 boost_tasks[cpu] = NULL; 1037 boost_tasks[cpu] = NULL;
1039 mutex_unlock(&boost_mutex); 1038 mutex_unlock(&boost_mutex);
1040 1039
1041 /* This must be outside of the mutex, otherwise deadlock! */ 1040 /* This must be outside of the mutex, otherwise deadlock! */
1042 kthread_stop(t); 1041 torture_stop_kthread(rcu_torture_boost, t);
1043 boost_tasks[cpu] = NULL;
1044} 1042}
1045 1043
1046static int rcutorture_booster_init(int cpu) 1044static int rcutorture_booster_init(int cpu)
@@ -1110,16 +1108,6 @@ static int __init rcu_torture_stall_init(void)
1110 return torture_create_kthread(rcu_torture_stall, NULL, stall_task); 1108 return torture_create_kthread(rcu_torture_stall, NULL, stall_task);
1111} 1109}
1112 1110
1113/* Clean up after the CPU-stall kthread, if one was spawned. */
1114static void rcu_torture_stall_cleanup(void)
1115{
1116 if (stall_task == NULL)
1117 return;
1118 VERBOSE_TOROUT_STRING("Stopping rcu_torture_stall_task.");
1119 kthread_stop(stall_task);
1120 stall_task = NULL;
1121}
1122
1123/* Callback function for RCU barrier testing. */ 1111/* Callback function for RCU barrier testing. */
1124void rcu_torture_barrier_cbf(struct rcu_head *rcu) 1112void rcu_torture_barrier_cbf(struct rcu_head *rcu)
1125{ 1113{
@@ -1230,19 +1218,11 @@ static void rcu_torture_barrier_cleanup(void)
1230{ 1218{
1231 int i; 1219 int i;
1232 1220
1233 if (barrier_task != NULL) { 1221 torture_stop_kthread(rcu_torture_barrier, barrier_task);
1234 VERBOSE_TOROUT_STRING("Stopping rcu_torture_barrier task");
1235 kthread_stop(barrier_task);
1236 barrier_task = NULL;
1237 }
1238 if (barrier_cbs_tasks != NULL) { 1222 if (barrier_cbs_tasks != NULL) {
1239 for (i = 0; i < n_barrier_cbs; i++) { 1223 for (i = 0; i < n_barrier_cbs; i++)
1240 if (barrier_cbs_tasks[i] != NULL) { 1224 torture_stop_kthread(rcu_torture_barrier_cbs,
1241 VERBOSE_TOROUT_STRING("Stopping rcu_torture_barrier_cbs task"); 1225 barrier_cbs_tasks[i]);
1242 kthread_stop(barrier_cbs_tasks[i]);
1243 barrier_cbs_tasks[i] = NULL;
1244 }
1245 }
1246 kfree(barrier_cbs_tasks); 1226 kfree(barrier_cbs_tasks);
1247 barrier_cbs_tasks = NULL; 1227 barrier_cbs_tasks = NULL;
1248 } 1228 }
@@ -1288,53 +1268,29 @@ rcu_torture_cleanup(void)
1288 } 1268 }
1289 1269
1290 rcu_torture_barrier_cleanup(); 1270 rcu_torture_barrier_cleanup();
1291 rcu_torture_stall_cleanup(); 1271 torture_stop_kthread(rcu_torture_stall, stall_task);
1292 torture_stutter_cleanup(); 1272 torture_stutter_cleanup();
1293 1273 torture_stop_kthread(rcu_torture_writer, writer_task);
1294 if (writer_task) {
1295 VERBOSE_TOROUT_STRING("Stopping rcu_torture_writer task");
1296 kthread_stop(writer_task);
1297 }
1298 writer_task = NULL;
1299 1274
1300 if (reader_tasks) { 1275 if (reader_tasks) {
1301 for (i = 0; i < nrealreaders; i++) { 1276 for (i = 0; i < nrealreaders; i++)
1302 if (reader_tasks[i]) { 1277 torture_stop_kthread(rcu_torture_reader,
1303 VERBOSE_TOROUT_STRING( 1278 reader_tasks[i]);
1304 "Stopping rcu_torture_reader task");
1305 kthread_stop(reader_tasks[i]);
1306 }
1307 reader_tasks[i] = NULL;
1308 }
1309 kfree(reader_tasks); 1279 kfree(reader_tasks);
1310 reader_tasks = NULL;
1311 } 1280 }
1312 rcu_torture_current = NULL; 1281 rcu_torture_current = NULL;
1313 1282
1314 if (fakewriter_tasks) { 1283 if (fakewriter_tasks) {
1315 for (i = 0; i < nfakewriters; i++) { 1284 for (i = 0; i < nfakewriters; i++) {
1316 if (fakewriter_tasks[i]) { 1285 torture_stop_kthread(rcu_torture_fakewriter,
1317 VERBOSE_TOROUT_STRING( 1286 fakewriter_tasks[i]);
1318 "Stopping rcu_torture_fakewriter task");
1319 kthread_stop(fakewriter_tasks[i]);
1320 }
1321 fakewriter_tasks[i] = NULL;
1322 } 1287 }
1323 kfree(fakewriter_tasks); 1288 kfree(fakewriter_tasks);
1324 fakewriter_tasks = NULL; 1289 fakewriter_tasks = NULL;
1325 } 1290 }
1326 1291
1327 if (stats_task) { 1292 torture_stop_kthread(rcu_torture_stats, stats_task);
1328 VERBOSE_TOROUT_STRING("Stopping rcu_torture_stats task"); 1293 torture_stop_kthread(rcu_torture_fqs, fqs_task);
1329 kthread_stop(stats_task);
1330 }
1331 stats_task = NULL;
1332
1333 if (fqs_task) {
1334 VERBOSE_TOROUT_STRING("Stopping rcu_torture_fqs task");
1335 kthread_stop(fqs_task);
1336 }
1337 fqs_task = NULL;
1338 if ((test_boost == 1 && cur_ops->can_boost) || 1294 if ((test_boost == 1 && cur_ops->can_boost) ||
1339 test_boost == 2) { 1295 test_boost == 2) {
1340 unregister_cpu_notifier(&rcutorture_cpu_nb); 1296 unregister_cpu_notifier(&rcutorture_cpu_nb);