Skip to content

Commit 176d19e

Browse files
paulmckrcufbq
authored andcommitted
rcutorture: Add ability to test srcu_read_{,un}lock_fast()
This commit permits rcutorture to test srcu_read_{,un}lock_fast(), which is specified by the rcutorture.reader_flavor=0x8 kernel boot parameter. Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Andrii Nakryiko <andrii@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Kent Overstreet <kent.overstreet@linux.dev> Cc: <bpf@vger.kernel.org> Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
1 parent c402062 commit 176d19e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

kernel/rcu/rcutorture.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,7 @@ static void srcu_get_gp_data(int *flags, unsigned long *gp_seq)
677677
static int srcu_torture_read_lock(void)
678678
{
679679
int idx;
680+
struct srcu_ctr __percpu *scp;
680681
int ret = 0;
681682

682683
if ((reader_flavor & SRCU_READ_FLAVOR_NORMAL) || !(reader_flavor & SRCU_READ_FLAVOR_ALL)) {
@@ -694,6 +695,12 @@ static int srcu_torture_read_lock(void)
694695
WARN_ON_ONCE(idx & ~0x1);
695696
ret += idx << 2;
696697
}
698+
if (reader_flavor & SRCU_READ_FLAVOR_FAST) {
699+
scp = srcu_read_lock_fast(srcu_ctlp);
700+
idx = __srcu_ptr_to_ctr(srcu_ctlp, scp);
701+
WARN_ON_ONCE(idx & ~0x1);
702+
ret += idx << 3;
703+
}
697704
return ret;
698705
}
699706

@@ -719,6 +726,8 @@ srcu_read_delay(struct torture_random_state *rrsp, struct rt_read_seg *rtrsp)
719726
static void srcu_torture_read_unlock(int idx)
720727
{
721728
WARN_ON_ONCE((reader_flavor && (idx & ~reader_flavor)) || (!reader_flavor && (idx & ~0x1)));
729+
if (reader_flavor & SRCU_READ_FLAVOR_FAST)
730+
srcu_read_unlock_fast(srcu_ctlp, __srcu_ctr_to_ptr(srcu_ctlp, (idx & 0x8) >> 3));
722731
if (reader_flavor & SRCU_READ_FLAVOR_LITE)
723732
srcu_read_unlock_lite(srcu_ctlp, (idx & 0x4) >> 2);
724733
if (reader_flavor & SRCU_READ_FLAVOR_NMI)

0 commit comments

Comments
 (0)