rcutorture: Use DEFINE_STATIC_SRCU()
Use DEFINE_STATIC_SRCU() to simplify the rcutorture.c SRCU test code. Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> Reviewed-by: Josh Triplett <josh@joshtriplett.org> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
This commit is contained in:
parent
55c6659afa
commit
cda4dc8130
|
@ -339,7 +339,6 @@ rcu_stutter_wait(char *title)
|
||||||
|
|
||||||
struct rcu_torture_ops {
|
struct rcu_torture_ops {
|
||||||
void (*init)(void);
|
void (*init)(void);
|
||||||
void (*cleanup)(void);
|
|
||||||
int (*readlock)(void);
|
int (*readlock)(void);
|
||||||
void (*read_delay)(struct rcu_random_state *rrsp);
|
void (*read_delay)(struct rcu_random_state *rrsp);
|
||||||
void (*readunlock)(int idx);
|
void (*readunlock)(int idx);
|
||||||
|
@ -431,7 +430,6 @@ static void rcu_torture_deferred_free(struct rcu_torture *p)
|
||||||
|
|
||||||
static struct rcu_torture_ops rcu_ops = {
|
static struct rcu_torture_ops rcu_ops = {
|
||||||
.init = NULL,
|
.init = NULL,
|
||||||
.cleanup = NULL,
|
|
||||||
.readlock = rcu_torture_read_lock,
|
.readlock = rcu_torture_read_lock,
|
||||||
.read_delay = rcu_read_delay,
|
.read_delay = rcu_read_delay,
|
||||||
.readunlock = rcu_torture_read_unlock,
|
.readunlock = rcu_torture_read_unlock,
|
||||||
|
@ -475,7 +473,6 @@ static void rcu_sync_torture_init(void)
|
||||||
|
|
||||||
static struct rcu_torture_ops rcu_sync_ops = {
|
static struct rcu_torture_ops rcu_sync_ops = {
|
||||||
.init = rcu_sync_torture_init,
|
.init = rcu_sync_torture_init,
|
||||||
.cleanup = NULL,
|
|
||||||
.readlock = rcu_torture_read_lock,
|
.readlock = rcu_torture_read_lock,
|
||||||
.read_delay = rcu_read_delay,
|
.read_delay = rcu_read_delay,
|
||||||
.readunlock = rcu_torture_read_unlock,
|
.readunlock = rcu_torture_read_unlock,
|
||||||
|
@ -493,7 +490,6 @@ static struct rcu_torture_ops rcu_sync_ops = {
|
||||||
|
|
||||||
static struct rcu_torture_ops rcu_expedited_ops = {
|
static struct rcu_torture_ops rcu_expedited_ops = {
|
||||||
.init = rcu_sync_torture_init,
|
.init = rcu_sync_torture_init,
|
||||||
.cleanup = NULL,
|
|
||||||
.readlock = rcu_torture_read_lock,
|
.readlock = rcu_torture_read_lock,
|
||||||
.read_delay = rcu_read_delay, /* just reuse rcu's version. */
|
.read_delay = rcu_read_delay, /* just reuse rcu's version. */
|
||||||
.readunlock = rcu_torture_read_unlock,
|
.readunlock = rcu_torture_read_unlock,
|
||||||
|
@ -536,7 +532,6 @@ static void rcu_bh_torture_deferred_free(struct rcu_torture *p)
|
||||||
|
|
||||||
static struct rcu_torture_ops rcu_bh_ops = {
|
static struct rcu_torture_ops rcu_bh_ops = {
|
||||||
.init = NULL,
|
.init = NULL,
|
||||||
.cleanup = NULL,
|
|
||||||
.readlock = rcu_bh_torture_read_lock,
|
.readlock = rcu_bh_torture_read_lock,
|
||||||
.read_delay = rcu_read_delay, /* just reuse rcu's version. */
|
.read_delay = rcu_read_delay, /* just reuse rcu's version. */
|
||||||
.readunlock = rcu_bh_torture_read_unlock,
|
.readunlock = rcu_bh_torture_read_unlock,
|
||||||
|
@ -553,7 +548,6 @@ static struct rcu_torture_ops rcu_bh_ops = {
|
||||||
|
|
||||||
static struct rcu_torture_ops rcu_bh_sync_ops = {
|
static struct rcu_torture_ops rcu_bh_sync_ops = {
|
||||||
.init = rcu_sync_torture_init,
|
.init = rcu_sync_torture_init,
|
||||||
.cleanup = NULL,
|
|
||||||
.readlock = rcu_bh_torture_read_lock,
|
.readlock = rcu_bh_torture_read_lock,
|
||||||
.read_delay = rcu_read_delay, /* just reuse rcu's version. */
|
.read_delay = rcu_read_delay, /* just reuse rcu's version. */
|
||||||
.readunlock = rcu_bh_torture_read_unlock,
|
.readunlock = rcu_bh_torture_read_unlock,
|
||||||
|
@ -570,7 +564,6 @@ static struct rcu_torture_ops rcu_bh_sync_ops = {
|
||||||
|
|
||||||
static struct rcu_torture_ops rcu_bh_expedited_ops = {
|
static struct rcu_torture_ops rcu_bh_expedited_ops = {
|
||||||
.init = rcu_sync_torture_init,
|
.init = rcu_sync_torture_init,
|
||||||
.cleanup = NULL,
|
|
||||||
.readlock = rcu_bh_torture_read_lock,
|
.readlock = rcu_bh_torture_read_lock,
|
||||||
.read_delay = rcu_read_delay, /* just reuse rcu's version. */
|
.read_delay = rcu_read_delay, /* just reuse rcu's version. */
|
||||||
.readunlock = rcu_bh_torture_read_unlock,
|
.readunlock = rcu_bh_torture_read_unlock,
|
||||||
|
@ -589,19 +582,7 @@ static struct rcu_torture_ops rcu_bh_expedited_ops = {
|
||||||
* Definitions for srcu torture testing.
|
* Definitions for srcu torture testing.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static struct srcu_struct srcu_ctl;
|
DEFINE_STATIC_SRCU(srcu_ctl);
|
||||||
|
|
||||||
static void srcu_torture_init(void)
|
|
||||||
{
|
|
||||||
init_srcu_struct(&srcu_ctl);
|
|
||||||
rcu_sync_torture_init();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void srcu_torture_cleanup(void)
|
|
||||||
{
|
|
||||||
synchronize_srcu(&srcu_ctl);
|
|
||||||
cleanup_srcu_struct(&srcu_ctl);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int srcu_torture_read_lock(void) __acquires(&srcu_ctl)
|
static int srcu_torture_read_lock(void) __acquires(&srcu_ctl)
|
||||||
{
|
{
|
||||||
|
@ -672,8 +653,7 @@ static int srcu_torture_stats(char *page)
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct rcu_torture_ops srcu_ops = {
|
static struct rcu_torture_ops srcu_ops = {
|
||||||
.init = srcu_torture_init,
|
.init = rcu_sync_torture_init,
|
||||||
.cleanup = srcu_torture_cleanup,
|
|
||||||
.readlock = srcu_torture_read_lock,
|
.readlock = srcu_torture_read_lock,
|
||||||
.read_delay = srcu_read_delay,
|
.read_delay = srcu_read_delay,
|
||||||
.readunlock = srcu_torture_read_unlock,
|
.readunlock = srcu_torture_read_unlock,
|
||||||
|
@ -687,8 +667,7 @@ static struct rcu_torture_ops srcu_ops = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct rcu_torture_ops srcu_sync_ops = {
|
static struct rcu_torture_ops srcu_sync_ops = {
|
||||||
.init = srcu_torture_init,
|
.init = rcu_sync_torture_init,
|
||||||
.cleanup = srcu_torture_cleanup,
|
|
||||||
.readlock = srcu_torture_read_lock,
|
.readlock = srcu_torture_read_lock,
|
||||||
.read_delay = srcu_read_delay,
|
.read_delay = srcu_read_delay,
|
||||||
.readunlock = srcu_torture_read_unlock,
|
.readunlock = srcu_torture_read_unlock,
|
||||||
|
@ -712,8 +691,7 @@ static void srcu_torture_read_unlock_raw(int idx) __releases(&srcu_ctl)
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct rcu_torture_ops srcu_raw_ops = {
|
static struct rcu_torture_ops srcu_raw_ops = {
|
||||||
.init = srcu_torture_init,
|
.init = rcu_sync_torture_init,
|
||||||
.cleanup = srcu_torture_cleanup,
|
|
||||||
.readlock = srcu_torture_read_lock_raw,
|
.readlock = srcu_torture_read_lock_raw,
|
||||||
.read_delay = srcu_read_delay,
|
.read_delay = srcu_read_delay,
|
||||||
.readunlock = srcu_torture_read_unlock_raw,
|
.readunlock = srcu_torture_read_unlock_raw,
|
||||||
|
@ -727,8 +705,7 @@ static struct rcu_torture_ops srcu_raw_ops = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct rcu_torture_ops srcu_raw_sync_ops = {
|
static struct rcu_torture_ops srcu_raw_sync_ops = {
|
||||||
.init = srcu_torture_init,
|
.init = rcu_sync_torture_init,
|
||||||
.cleanup = srcu_torture_cleanup,
|
|
||||||
.readlock = srcu_torture_read_lock_raw,
|
.readlock = srcu_torture_read_lock_raw,
|
||||||
.read_delay = srcu_read_delay,
|
.read_delay = srcu_read_delay,
|
||||||
.readunlock = srcu_torture_read_unlock_raw,
|
.readunlock = srcu_torture_read_unlock_raw,
|
||||||
|
@ -747,8 +724,7 @@ static void srcu_torture_synchronize_expedited(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct rcu_torture_ops srcu_expedited_ops = {
|
static struct rcu_torture_ops srcu_expedited_ops = {
|
||||||
.init = srcu_torture_init,
|
.init = rcu_sync_torture_init,
|
||||||
.cleanup = srcu_torture_cleanup,
|
|
||||||
.readlock = srcu_torture_read_lock,
|
.readlock = srcu_torture_read_lock,
|
||||||
.read_delay = srcu_read_delay,
|
.read_delay = srcu_read_delay,
|
||||||
.readunlock = srcu_torture_read_unlock,
|
.readunlock = srcu_torture_read_unlock,
|
||||||
|
@ -783,7 +759,6 @@ static void rcu_sched_torture_deferred_free(struct rcu_torture *p)
|
||||||
|
|
||||||
static struct rcu_torture_ops sched_ops = {
|
static struct rcu_torture_ops sched_ops = {
|
||||||
.init = rcu_sync_torture_init,
|
.init = rcu_sync_torture_init,
|
||||||
.cleanup = NULL,
|
|
||||||
.readlock = sched_torture_read_lock,
|
.readlock = sched_torture_read_lock,
|
||||||
.read_delay = rcu_read_delay, /* just reuse rcu's version. */
|
.read_delay = rcu_read_delay, /* just reuse rcu's version. */
|
||||||
.readunlock = sched_torture_read_unlock,
|
.readunlock = sched_torture_read_unlock,
|
||||||
|
@ -799,7 +774,6 @@ static struct rcu_torture_ops sched_ops = {
|
||||||
|
|
||||||
static struct rcu_torture_ops sched_sync_ops = {
|
static struct rcu_torture_ops sched_sync_ops = {
|
||||||
.init = rcu_sync_torture_init,
|
.init = rcu_sync_torture_init,
|
||||||
.cleanup = NULL,
|
|
||||||
.readlock = sched_torture_read_lock,
|
.readlock = sched_torture_read_lock,
|
||||||
.read_delay = rcu_read_delay, /* just reuse rcu's version. */
|
.read_delay = rcu_read_delay, /* just reuse rcu's version. */
|
||||||
.readunlock = sched_torture_read_unlock,
|
.readunlock = sched_torture_read_unlock,
|
||||||
|
@ -814,7 +788,6 @@ static struct rcu_torture_ops sched_sync_ops = {
|
||||||
|
|
||||||
static struct rcu_torture_ops sched_expedited_ops = {
|
static struct rcu_torture_ops sched_expedited_ops = {
|
||||||
.init = rcu_sync_torture_init,
|
.init = rcu_sync_torture_init,
|
||||||
.cleanup = NULL,
|
|
||||||
.readlock = sched_torture_read_lock,
|
.readlock = sched_torture_read_lock,
|
||||||
.read_delay = rcu_read_delay, /* just reuse rcu's version. */
|
.read_delay = rcu_read_delay, /* just reuse rcu's version. */
|
||||||
.readunlock = sched_torture_read_unlock,
|
.readunlock = sched_torture_read_unlock,
|
||||||
|
@ -1936,8 +1909,6 @@ rcu_torture_cleanup(void)
|
||||||
|
|
||||||
rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
|
rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
|
||||||
|
|
||||||
if (cur_ops->cleanup)
|
|
||||||
cur_ops->cleanup();
|
|
||||||
if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
|
if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
|
||||||
rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
|
rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
|
||||||
else if (n_online_successes != n_online_attempts ||
|
else if (n_online_successes != n_online_attempts ||
|
||||||
|
|
Loading…
Reference in New Issue