aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/rcu
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>2014-02-03 14:52:27 -0500
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2014-02-23 12:03:24 -0500
commit47cf29b9e721967aac95ebda9e50408219755852 (patch)
tree9f35fcc13e7411c277094b9740d94fab14323a8b /kernel/rcu
parentbc8f83e2c0d585b201dfbb52e98f6f8741d324ea (diff)
rcutorture: Abstract torture_create_kthread()
Creation of kthreads is not RCU-specific, so this commit abstracts out torture_create_kthread(), saving a few tens of lines of code in the process. This change requires modifying VERBOSE_TOROUT_ERRSTRING() to take a non-const string, so that _torture_create_kthread() can avoid an open-coded substitute. 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.c98
1 files changed, 20 insertions, 78 deletions
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index 25e9b16fe7f0..a6f6c8418d87 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -1105,19 +1105,9 @@ static int rcu_torture_stall(void *args)
1105/* Spawn CPU-stall kthread, if stall_cpu specified. */ 1105/* Spawn CPU-stall kthread, if stall_cpu specified. */
1106static int __init rcu_torture_stall_init(void) 1106static int __init rcu_torture_stall_init(void)
1107{ 1107{
1108 int ret;
1109
1110 if (stall_cpu <= 0) 1108 if (stall_cpu <= 0)
1111 return 0; 1109 return 0;
1112 VERBOSE_TOROUT_STRING("Creating rcu_torture_stall task"); 1110 return torture_create_kthread(rcu_torture_stall, NULL, stall_task);
1113 stall_task = kthread_run(rcu_torture_stall, NULL, "rcu_torture_stall");
1114 if (IS_ERR(stall_task)) {
1115 ret = PTR_ERR(stall_task);
1116 stall_task = NULL;
1117 return ret;
1118 }
1119 torture_shuffle_task_register(stall_task);
1120 return 0;
1121} 1111}
1122 1112
1123/* Clean up after the CPU-stall kthread, if one was spawned. */ 1113/* Clean up after the CPU-stall kthread, if one was spawned. */
@@ -1226,29 +1216,13 @@ static int rcu_torture_barrier_init(void)
1226 return -ENOMEM; 1216 return -ENOMEM;
1227 for (i = 0; i < n_barrier_cbs; i++) { 1217 for (i = 0; i < n_barrier_cbs; i++) {
1228 init_waitqueue_head(&barrier_cbs_wq[i]); 1218 init_waitqueue_head(&barrier_cbs_wq[i]);
1229 VERBOSE_TOROUT_STRING("Creating rcu_torture_barrier_cbs task"); 1219 ret = torture_create_kthread(rcu_torture_barrier_cbs,
1230 barrier_cbs_tasks[i] = kthread_run(rcu_torture_barrier_cbs, 1220 (void *)(long)i,
1231 (void *)(long)i, 1221 barrier_cbs_tasks[i]);
1232 "rcu_torture_barrier_cbs"); 1222 if (ret)
1233 if (IS_ERR(barrier_cbs_tasks[i])) {
1234 ret = PTR_ERR(barrier_cbs_tasks[i]);
1235 VERBOSE_TOROUT_ERRSTRING("Failed to create rcu_torture_barrier_cbs");
1236 barrier_cbs_tasks[i] = NULL;
1237 return ret; 1223 return ret;
1238 }
1239 torture_shuffle_task_register(barrier_cbs_tasks[i]);
1240 } 1224 }
1241 VERBOSE_TOROUT_STRING("Creating rcu_torture_barrier task"); 1225 return torture_create_kthread(rcu_torture_barrier, NULL, barrier_task);
1242 barrier_task = kthread_run(rcu_torture_barrier, NULL,
1243 "rcu_torture_barrier");
1244 if (IS_ERR(barrier_task)) {
1245 ret = PTR_ERR(barrier_task);
1246 VERBOSE_TOROUT_ERRSTRING("Failed to create rcu_torture_barrier");
1247 barrier_task = NULL;
1248 return ret;
1249 }
1250 torture_shuffle_task_register(barrier_task);
1251 return 0;
1252} 1226}
1253 1227
1254/* Clean up after RCU barrier testing. */ 1228/* Clean up after RCU barrier testing. */
@@ -1516,17 +1490,10 @@ rcu_torture_init(void)
1516 1490
1517 /* Start up the kthreads. */ 1491 /* Start up the kthreads. */
1518 1492
1519 VERBOSE_TOROUT_STRING("Creating rcu_torture_writer task"); 1493 firsterr = torture_create_kthread(rcu_torture_writer, NULL,
1520 writer_task = kthread_create(rcu_torture_writer, NULL, 1494 writer_task);
1521 "rcu_torture_writer"); 1495 if (firsterr)
1522 if (IS_ERR(writer_task)) {
1523 firsterr = PTR_ERR(writer_task);
1524 VERBOSE_TOROUT_ERRSTRING("Failed to create writer");
1525 writer_task = NULL;
1526 goto unwind; 1496 goto unwind;
1527 }
1528 torture_shuffle_task_register(writer_task);
1529 wake_up_process(writer_task);
1530 fakewriter_tasks = kzalloc(nfakewriters * sizeof(fakewriter_tasks[0]), 1497 fakewriter_tasks = kzalloc(nfakewriters * sizeof(fakewriter_tasks[0]),
1531 GFP_KERNEL); 1498 GFP_KERNEL);
1532 if (fakewriter_tasks == NULL) { 1499 if (fakewriter_tasks == NULL) {
@@ -1535,16 +1502,10 @@ rcu_torture_init(void)
1535 goto unwind; 1502 goto unwind;
1536 } 1503 }
1537 for (i = 0; i < nfakewriters; i++) { 1504 for (i = 0; i < nfakewriters; i++) {
1538 VERBOSE_TOROUT_STRING("Creating rcu_torture_fakewriter task"); 1505 firsterr = torture_create_kthread(rcu_torture_fakewriter,
1539 fakewriter_tasks[i] = kthread_run(rcu_torture_fakewriter, NULL, 1506 NULL, fakewriter_tasks[i]);
1540 "rcu_torture_fakewriter"); 1507 if (firsterr)
1541 if (IS_ERR(fakewriter_tasks[i])) {
1542 firsterr = PTR_ERR(fakewriter_tasks[i]);
1543 VERBOSE_TOROUT_ERRSTRING("Failed to create fakewriter");
1544 fakewriter_tasks[i] = NULL;
1545 goto unwind; 1508 goto unwind;
1546 }
1547 torture_shuffle_task_register(fakewriter_tasks[i]);
1548 } 1509 }
1549 reader_tasks = kzalloc(nrealreaders * sizeof(reader_tasks[0]), 1510 reader_tasks = kzalloc(nrealreaders * sizeof(reader_tasks[0]),
1550 GFP_KERNEL); 1511 GFP_KERNEL);
@@ -1554,28 +1515,16 @@ rcu_torture_init(void)
1554 goto unwind; 1515 goto unwind;
1555 } 1516 }
1556 for (i = 0; i < nrealreaders; i++) { 1517 for (i = 0; i < nrealreaders; i++) {
1557 VERBOSE_TOROUT_STRING("Creating rcu_torture_reader task"); 1518 firsterr = torture_create_kthread(rcu_torture_reader, NULL,
1558 reader_tasks[i] = kthread_run(rcu_torture_reader, NULL, 1519 reader_tasks[i]);
1559 "rcu_torture_reader"); 1520 if (firsterr)
1560 if (IS_ERR(reader_tasks[i])) {
1561 firsterr = PTR_ERR(reader_tasks[i]);
1562 VERBOSE_TOROUT_ERRSTRING("Failed to create reader");
1563 reader_tasks[i] = NULL;
1564 goto unwind; 1521 goto unwind;
1565 }
1566 torture_shuffle_task_register(reader_tasks[i]);
1567 } 1522 }
1568 if (stat_interval > 0) { 1523 if (stat_interval > 0) {
1569 VERBOSE_TOROUT_STRING("Creating rcu_torture_stats task"); 1524 firsterr = torture_create_kthread(rcu_torture_stats, NULL,
1570 stats_task = kthread_run(rcu_torture_stats, NULL, 1525 stats_task);
1571 "rcu_torture_stats"); 1526 if (firsterr)
1572 if (IS_ERR(stats_task)) {
1573 firsterr = PTR_ERR(stats_task);
1574 VERBOSE_TOROUT_ERRSTRING("Failed to create stats");
1575 stats_task = NULL;
1576 goto unwind; 1527 goto unwind;
1577 }
1578 torture_shuffle_task_register(stats_task);
1579 } 1528 }
1580 if (test_no_idle_hz) { 1529 if (test_no_idle_hz) {
1581 firsterr = torture_shuffle_init(shuffle_interval * HZ); 1530 firsterr = torture_shuffle_init(shuffle_interval * HZ);
@@ -1593,16 +1542,9 @@ rcu_torture_init(void)
1593 fqs_duration = 0; 1542 fqs_duration = 0;
1594 if (fqs_duration) { 1543 if (fqs_duration) {
1595 /* Create the fqs thread */ 1544 /* Create the fqs thread */
1596 VERBOSE_TOROUT_STRING("Creating rcu_torture_fqs task"); 1545 torture_create_kthread(rcu_torture_fqs, NULL, fqs_task);
1597 fqs_task = kthread_run(rcu_torture_fqs, NULL, 1546 if (firsterr)
1598 "rcu_torture_fqs");
1599 if (IS_ERR(fqs_task)) {
1600 firsterr = PTR_ERR(fqs_task);
1601 VERBOSE_TOROUT_ERRSTRING("Failed to create fqs");
1602 fqs_task = NULL;
1603 goto unwind; 1547 goto unwind;
1604 }
1605 torture_shuffle_task_register(fqs_task);
1606 } 1548 }
1607 if (test_boost_interval < 1) 1549 if (test_boost_interval < 1)
1608 test_boost_interval = 1; 1550 test_boost_interval = 1;