Commit 1c67318b authored by Zqiang's avatar Zqiang Committed by Uladzislau Rezki (Sony)
Browse files

rcutorture: Use rcu_gp_slow_register/unregister() only for rcutype test



The rcu_gp_slow_register/unregister() is only useful in tests where
torture_type=rcu, so this commit therefore generates ->gp_slow_register()
and ->gp_slow_unregister() function pointers in the rcu_torture_ops
structure, and slows grace periods only when these function pointers
exist.

Signed-off-by: default avatarZqiang <qiang.zhang1211@gmail.com>
Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
Signed-off-by: default avatarUladzislau Rezki (Sony) <urezki@gmail.com>
parent 39988fdc
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -382,6 +382,8 @@ struct rcu_torture_ops {
	bool (*check_boost_failed)(unsigned long gp_state, int *cpup);
	int (*stall_dur)(void);
	void (*get_gp_data)(int *flags, unsigned long *gp_seq);
	void (*gp_slow_register)(atomic_t *rgssp);
	void (*gp_slow_unregister)(atomic_t *rgssp);
	long cbflood_max;
	int irq_capable;
	int can_boost;
@@ -570,6 +572,8 @@ static struct rcu_torture_ops rcu_ops = {
	.check_boost_failed	= rcu_check_boost_fail,
	.stall_dur		= rcu_jiffies_till_stall_check,
	.get_gp_data		= rcutorture_get_gp_data,
	.gp_slow_register	= rcu_gp_slow_register,
	.gp_slow_unregister	= rcu_gp_slow_unregister,
	.irq_capable		= 1,
	.can_boost		= IS_ENABLED(CONFIG_RCU_BOOST),
	.extendables		= RCUTORTURE_MAX_EXTEND,
@@ -3343,12 +3347,12 @@ rcu_torture_cleanup(void)
			pr_info("%s: Invoking %pS().\n", __func__, cur_ops->cb_barrier);
			cur_ops->cb_barrier();
		}
		rcu_gp_slow_unregister(NULL);
		if (cur_ops->gp_slow_unregister)
			cur_ops->gp_slow_unregister(NULL);
		return;
	}
	if (!cur_ops) {
		torture_cleanup_end();
		rcu_gp_slow_unregister(NULL);
		return;
	}

@@ -3447,7 +3451,8 @@ rcu_torture_cleanup(void)
	else
		rcu_torture_print_module_parms(cur_ops, "End of test: SUCCESS");
	torture_cleanup_end();
	rcu_gp_slow_unregister(&rcu_fwd_cb_nodelay);
	if (cur_ops->gp_slow_unregister)
		cur_ops->gp_slow_unregister(NULL);
}

#ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD
@@ -3929,7 +3934,8 @@ rcu_torture_init(void)
	if (object_debug)
		rcu_test_debug_objects();
	torture_init_end();
	rcu_gp_slow_register(&rcu_fwd_cb_nodelay);
	if (cur_ops->gp_slow_register && !WARN_ON_ONCE(!cur_ops->gp_slow_unregister))
		cur_ops->gp_slow_register(&rcu_fwd_cb_nodelay);
	return 0;

unwind: