rcutorture.c (628edaa5062282b6e3d76c886fd2cbccae5cb87b) | rcutorture.c (e991dbc0770b01b7dc7d6d7660442e83ebd11828) |
---|---|
1/* 2 * Read-Copy Update module-based torture test facility 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 * --- 91 unchanged lines hidden (view full) --- 100 101static int nrealreaders; 102static struct task_struct *writer_task; 103static struct task_struct **fakewriter_tasks; 104static struct task_struct **reader_tasks; 105static struct task_struct *stats_task; 106static struct task_struct *fqs_task; 107static struct task_struct *boost_tasks[NR_CPUS]; | 1/* 2 * Read-Copy Update module-based torture test facility 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 * --- 91 unchanged lines hidden (view full) --- 100 101static int nrealreaders; 102static struct task_struct *writer_task; 103static struct task_struct **fakewriter_tasks; 104static struct task_struct **reader_tasks; 105static struct task_struct *stats_task; 106static struct task_struct *fqs_task; 107static struct task_struct *boost_tasks[NR_CPUS]; |
108static struct task_struct *shutdown_task; | |
109static struct task_struct *stall_task; 110static struct task_struct **barrier_cbs_tasks; 111static struct task_struct *barrier_task; 112 113#define RCU_TORTURE_PIPE_LEN 10 114 115struct rcu_torture { 116 struct rcu_head rtort_rcu; --- 51 unchanged lines hidden (view full) --- 168} 169#else /* #ifdef CONFIG_RCU_TRACE */ 170static u64 notrace rcu_trace_clock_local(void) 171{ 172 return 0ULL; 173} 174#endif /* #else #ifdef CONFIG_RCU_TRACE */ 175 | 108static struct task_struct *stall_task; 109static struct task_struct **barrier_cbs_tasks; 110static struct task_struct *barrier_task; 111 112#define RCU_TORTURE_PIPE_LEN 10 113 114struct rcu_torture { 115 struct rcu_head rtort_rcu; --- 51 unchanged lines hidden (view full) --- 167} 168#else /* #ifdef CONFIG_RCU_TRACE */ 169static u64 notrace rcu_trace_clock_local(void) 170{ 171 return 0ULL; 172} 173#endif /* #else #ifdef CONFIG_RCU_TRACE */ 174 |
176static unsigned long shutdown_time; /* jiffies to system shutdown. */ | |
177static unsigned long boost_starttime; /* jiffies of next boost test start. */ 178DEFINE_MUTEX(boost_mutex); /* protect setting boost_starttime */ 179 /* and boost task create/destroy. */ 180static atomic_t barrier_cbs_count; /* Barrier callbacks registered. */ 181static bool barrier_phase; /* Test phase. */ 182static atomic_t barrier_cbs_invoked; /* Barrier callbacks invoked. */ 183static wait_queue_head_t *barrier_cbs_wq; /* Coordinate barrier testing. */ 184static DECLARE_WAIT_QUEUE_HEAD(barrier_wq); 185 | 175static unsigned long boost_starttime; /* jiffies of next boost test start. */ 176DEFINE_MUTEX(boost_mutex); /* protect setting boost_starttime */ 177 /* and boost task create/destroy. */ 178static atomic_t barrier_cbs_count; /* Barrier callbacks registered. */ 179static bool barrier_phase; /* Test phase. */ 180static atomic_t barrier_cbs_invoked; /* Barrier callbacks invoked. */ 181static wait_queue_head_t *barrier_cbs_wq; /* Coordinate barrier testing. */ 182static DECLARE_WAIT_QUEUE_HEAD(barrier_wq); 183 |
186/* Forward reference. */ 187static void rcu_torture_cleanup(void); 188 | |
189/* 190 * Allocate an element from the rcu_tortures pool. 191 */ 192static struct rcu_torture * 193rcu_torture_alloc(void) 194{ 195 struct list_head *p; 196 --- 885 unchanged lines hidden (view full) --- 1082 } 1083 kthread_bind(boost_tasks[cpu], cpu); 1084 wake_up_process(boost_tasks[cpu]); 1085 mutex_unlock(&boost_mutex); 1086 return 0; 1087} 1088 1089/* | 184/* 185 * Allocate an element from the rcu_tortures pool. 186 */ 187static struct rcu_torture * 188rcu_torture_alloc(void) 189{ 190 struct list_head *p; 191 --- 885 unchanged lines hidden (view full) --- 1077 } 1078 kthread_bind(boost_tasks[cpu], cpu); 1079 wake_up_process(boost_tasks[cpu]); 1080 mutex_unlock(&boost_mutex); 1081 return 0; 1082} 1083 1084/* |
1090 * Cause the rcutorture test to shutdown the system after the test has 1091 * run for the time specified by the shutdown_secs module parameter. 1092 */ 1093static int 1094rcu_torture_shutdown(void *arg) 1095{ 1096 long delta; 1097 unsigned long jiffies_snap; 1098 1099 VERBOSE_TOROUT_STRING("rcu_torture_shutdown task started"); 1100 jiffies_snap = ACCESS_ONCE(jiffies); 1101 while (ULONG_CMP_LT(jiffies_snap, shutdown_time) && 1102 !kthread_should_stop()) { 1103 delta = shutdown_time - jiffies_snap; 1104 if (verbose) 1105 pr_alert("%s" TORTURE_FLAG 1106 "rcu_torture_shutdown task: %lu jiffies remaining\n", 1107 torture_type, delta); 1108 schedule_timeout_interruptible(delta); 1109 jiffies_snap = ACCESS_ONCE(jiffies); 1110 } 1111 if (kthread_should_stop()) { 1112 VERBOSE_TOROUT_STRING("rcu_torture_shutdown task stopping"); 1113 return 0; 1114 } 1115 1116 /* OK, shut down the system. */ 1117 1118 VERBOSE_TOROUT_STRING("rcu_torture_shutdown task shutting down system"); 1119 shutdown_task = NULL; /* Avoid self-kill deadlock. */ 1120 rcu_torture_cleanup(); /* Get the success/failure message. */ 1121 kernel_power_off(); /* Shut down the system. */ 1122 return 0; 1123} 1124 1125/* | |
1126 * CPU-stall kthread. It waits as specified by stall_cpu_holdoff, then 1127 * induces a CPU stall for the time specified by stall_cpu. 1128 */ 1129static int rcu_torture_stall(void *args) 1130{ 1131 unsigned long stop_at; 1132 1133 VERBOSE_TOROUT_STRING("rcu_torture_stall task started"); --- 282 unchanged lines hidden (view full) --- 1416 } 1417 fqs_task = NULL; 1418 if ((test_boost == 1 && cur_ops->can_boost) || 1419 test_boost == 2) { 1420 unregister_cpu_notifier(&rcutorture_cpu_nb); 1421 for_each_possible_cpu(i) 1422 rcutorture_booster_cleanup(i); 1423 } | 1085 * CPU-stall kthread. It waits as specified by stall_cpu_holdoff, then 1086 * induces a CPU stall for the time specified by stall_cpu. 1087 */ 1088static int rcu_torture_stall(void *args) 1089{ 1090 unsigned long stop_at; 1091 1092 VERBOSE_TOROUT_STRING("rcu_torture_stall task started"); --- 282 unchanged lines hidden (view full) --- 1375 } 1376 fqs_task = NULL; 1377 if ((test_boost == 1 && cur_ops->can_boost) || 1378 test_boost == 2) { 1379 unregister_cpu_notifier(&rcutorture_cpu_nb); 1380 for_each_possible_cpu(i) 1381 rcutorture_booster_cleanup(i); 1382 } |
1424 if (shutdown_task != NULL) { 1425 VERBOSE_TOROUT_STRING("Stopping rcu_torture_shutdown task"); 1426 kthread_stop(shutdown_task); 1427 } 1428 shutdown_task = NULL; | 1383 torture_shutdown_cleanup(); |
1429 1430 /* Wait for all RCU callbacks to fire. */ 1431 1432 if (cur_ops->cb_barrier != NULL) 1433 cur_ops->cb_barrier(); 1434 1435 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */ 1436 --- 239 unchanged lines hidden (view full) --- 1676 continue; /* Heuristic: CPU can go offline. */ 1677 retval = rcutorture_booster_init(i); 1678 if (retval < 0) { 1679 firsterr = retval; 1680 goto unwind; 1681 } 1682 } 1683 } | 1384 1385 /* Wait for all RCU callbacks to fire. */ 1386 1387 if (cur_ops->cb_barrier != NULL) 1388 cur_ops->cb_barrier(); 1389 1390 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */ 1391 --- 239 unchanged lines hidden (view full) --- 1631 continue; /* Heuristic: CPU can go offline. */ 1632 retval = rcutorture_booster_init(i); 1633 if (retval < 0) { 1634 firsterr = retval; 1635 goto unwind; 1636 } 1637 } 1638 } |
1684 if (shutdown_secs > 0) { 1685 shutdown_time = jiffies + shutdown_secs * HZ; 1686 shutdown_task = kthread_create(rcu_torture_shutdown, NULL, 1687 "rcu_torture_shutdown"); 1688 if (IS_ERR(shutdown_task)) { 1689 firsterr = PTR_ERR(shutdown_task); 1690 VERBOSE_TOROUT_ERRSTRING("Failed to create shutdown"); 1691 shutdown_task = NULL; 1692 goto unwind; 1693 } 1694 torture_shuffle_task_register(shutdown_task); 1695 wake_up_process(shutdown_task); | 1639 i = torture_shutdown_init(shutdown_secs, rcu_torture_cleanup); 1640 if (i != 0) { 1641 firsterr = i; 1642 goto unwind; |
1696 } 1697 i = torture_onoff_init(onoff_holdoff * HZ, onoff_interval * HZ); 1698 if (i != 0) { 1699 firsterr = i; 1700 goto unwind; 1701 } 1702 i = rcu_torture_stall_init(); 1703 if (i != 0) { --- 22 unchanged lines hidden --- | 1643 } 1644 i = torture_onoff_init(onoff_holdoff * HZ, onoff_interval * HZ); 1645 if (i != 0) { 1646 firsterr = i; 1647 goto unwind; 1648 } 1649 i = rcu_torture_stall_init(); 1650 if (i != 0) { --- 22 unchanged lines hidden --- |