Skip to content

Commit 50d4b62

Browse files
committed
rcutorture: Make rcu_torture_barrier_cbs() post from corresponding CPU
Currently, rcu_torture_barrier_cbs() posts callbacks from whatever CPU it is running on, which means that all these kthreads might well be posting from the same CPU, which would drastically reduce the effectiveness of this test. This commit therefore uses IPIs to make the callbacks be posted from the corresponding CPU (given by local variable myid). If the IPI fails (which can happen if the target CPU is offline or does not exist at all), the callback is posted on whatever CPU is currently running. Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 12af660 commit 50d4b62

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

kernel/rcu/rcutorture.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,6 +2053,14 @@ static void rcu_torture_barrier_cbf(struct rcu_head *rcu)
20532053
atomic_inc(&barrier_cbs_invoked);
20542054
}
20552055

2056+
/* IPI handler to get callback posted on desired CPU, if online. */
2057+
static void rcu_torture_barrier1cb(void *rcu_void)
2058+
{
2059+
struct rcu_head *rhp = rcu_void;
2060+
2061+
cur_ops->call(rhp, rcu_torture_barrier_cbf);
2062+
}
2063+
20562064
/* kthread function to register callbacks used to test RCU barriers. */
20572065
static int rcu_torture_barrier_cbs(void *arg)
20582066
{
@@ -2076,9 +2084,11 @@ static int rcu_torture_barrier_cbs(void *arg)
20762084
* The above smp_load_acquire() ensures barrier_phase load
20772085
* is ordered before the following ->call().
20782086
*/
2079-
local_irq_disable(); /* Just to test no-irq call_rcu(). */
2080-
cur_ops->call(&rcu, rcu_torture_barrier_cbf);
2081-
local_irq_enable();
2087+
if (smp_call_function_single(myid, rcu_torture_barrier1cb,
2088+
&rcu, 1)) {
2089+
// IPI failed, so use direct call from current CPU.
2090+
cur_ops->call(&rcu, rcu_torture_barrier_cbf);
2091+
}
20822092
if (atomic_dec_and_test(&barrier_cbs_count))
20832093
wake_up(&barrier_wq);
20842094
} while (!torture_must_stop());

0 commit comments

Comments
 (0)