Re: [PATCH 04/13] rcutorture: Add atomic-SRCU support to torture.sh
From: Paul E. McKenney
Date: Wed Sep 09 2026 - 23:50:18 EST
On Thu, Sep 10, 2026 at 09:30:48AM +0800, KunWu Chan wrote:
> On Thu, Sep 10, 2026 at 6:35 AM Paul E. McKenney <paulmck@xxxxxxxxxx> wrote:
> >
> > On Tue, Sep 08, 2026 at 04:34:41PM -0700, Paul E. McKenney wrote:
> > > On Mon, Sep 07, 2026 at 03:58:20PM +0800, Kunwu Chan wrote:
> > > > From: Kunwu Chan <kunwu.chan@xxxxxxxxx>
> > > >
> > > > Add the --do-atomic-srcu argument to torture.sh, which runs the
> > > > SRCU-N, SRCU-P, and SRCU-T scenarios, thus covering both Tree SRCU
> > > > (SRCU-N and SRCU-P) and Tiny SRCU (SRCU-T), with
> > > > rcutorture.reader_flavor=0x10 appended to the boot parameters so
> > > > that it takes precedence over each scenario's own reader-flavor
> > > > setting. This exercises srcu_read_lock_atomic(),
> > > > srcu_read_unlock_atomic(), and synchronize_srcu_atomic().
> > > >
> > > > As with other torture.sh tests, the --do-kcsan argument runs a
> > > > KCSAN+PROVE_LOCKING variant of this test.
> > > >
> > > > Signed-off-by: Kunwu Chan <kunwu.chan@xxxxxxxxx>
> > >
> > > Queued for testing and review, thank you!
> >
> > I did take the liberty of changing "do_atomic_srcu=no" to
> > "do_atomic_srcu=yes" in order to increase test coverage.
> >
>
> Thanks, no problem.
>
> I also found a couple of data races in other subsystems while running
> the tests. I’m still validating the fixes locally and will Cc you if I
> send patches for them.
Sounds good! Note that some maintainers are more friendly to such
patches than others. But it shouldn't hurt to send them. ;-)
Just please carefully check the design. For example, blindly applying
READ_ONCE() and WRITE_ONCE() is not a strategy to win.
Thanx, Paul
> Thanks,
> KunWu
>
> > Thanx, Paul
> >
> > > > ---
> > > > .../selftests/rcutorture/bin/torture.sh | 24 +++++++++++++++++++
> > > > 1 file changed, 24 insertions(+)
> > > >
> > > > diff --git a/tools/testing/selftests/rcutorture/bin/torture.sh b/tools/testing/selftests/rcutorture/bin/torture.sh
> > > > index f0083891ee81..8885812d866a 100755
> > > > --- a/tools/testing/selftests/rcutorture/bin/torture.sh
> > > > +++ b/tools/testing/selftests/rcutorture/bin/torture.sh
> > > > @@ -68,6 +68,7 @@ do_clocksourcewd="${ifnotaarch64}"
> > > > do_rt=yes
> > > > do_rcutasksflavors="${ifnotaarch64}" # FIXME: Back to "yes" when SMP=n auto-avoided
> > > > do_srcu_lockdep=yes
> > > > +do_atomic_srcu=no
> > > > do_rcu_rust=no
> > > >
> > > > # doyesno - Helper function for yes/no arguments
> > > > @@ -103,6 +104,7 @@ usage () {
> > > > echo " --do-rcu-rust / --do-no-rcu-rust / --no-rcu-rust"
> > > > echo " --do-scftorture / --do-no-scftorture / --no-scftorture"
> > > > echo " --do-srcu-lockdep / --do-no-srcu-lockdep / --no-srcu-lockdep"
> > > > + echo " --do-atomic-srcu / --do-no-atomic-srcu / --no-atomic-srcu"
> > > > echo " --duration [ <minutes> | <hours>h | <days>d ]"
> > > > echo " --guest-cpu-limit N"
> > > > echo " --kcsan-kmake-arg kernel-make-arguments"
> > > > @@ -148,6 +150,7 @@ do
> > > > do_kcsan=yes
> > > > do_clocksourcewd="${ifnotaarch64}"
> > > > do_srcu_lockdep=yes
> > > > + do_atomic_srcu=yes
> > > > ;;
> > > > --do-allmodconfig|--do-no-allmodconfig|--no-allmodconfig)
> > > > do_allmodconfig=`doyesno "$1" --do-allmodconfig`
> > > > @@ -183,6 +186,7 @@ do
> > > > do_kcsan=no
> > > > do_clocksourcewd=no
> > > > do_srcu_lockdep=no
> > > > + do_atomic_srcu=no
> > > > ;;
> > > > --do-normal|--do-norm|--do-no-normal|--do-no-norm|--no-normal|--no-norm)
> > > > do_normal=`doyesno "$1" --do-normal`
> > > > @@ -212,6 +216,9 @@ do
> > > > --do-srcu-lockdep|--do-no-srcu-lockdep|--no-srcu-lockdep)
> > > > do_srcu_lockdep=`doyesno "$1" --do-srcu-lockdep`
> > > > ;;
> > > > + --do-atomic-srcu|--do-no-atomic-srcu|--no-atomic-srcu)
> > > > + do_atomic_srcu=`doyesno "$1" --do-atomic-srcu`
> > > > + ;;
> > > > --duration)
> > > > checkarg --duration "(minutes)" $# "$2" '^[0-9][0-9]*\(m\|h\|d\|\)$' '^error'
> > > > mult=1
> > > > @@ -497,6 +504,23 @@ then
> > > > torture_set "rcutorture" tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration "$duration_rcutorture" --configs "$configs_rcutorture" --trust-make
> > > > fi
> > > >
> > > > +# Test atomic SRCU across Tree SRCU (SRCU-N and SRCU-P) and Tiny SRCU
> > > > +# (SRCU-T). The reader flavor selects srcu_read_lock_atomic() and
> > > > +# synchronize_srcu_atomic(). Tiny SRCU requires SMP=n, which aarch64
> > > > +# does not support.
> > > > +if test "$do_atomic_srcu" = "yes"
> > > > +then
> > > > + torture_bootargs="rcutorture.reader_flavor=0x10"
> > > > + configs_atomic_srcu="SRCU-N SRCU-P"
> > > > + if test "$ifnotaarch64" = yes
> > > > + then
> > > > + configs_atomic_srcu="$configs_atomic_srcu SRCU-T"
> > > > + fi
> > > > + torture_set "atomic-srcu" tools/testing/selftests/rcutorture/bin/kvm.sh \
> > > > + --allcpus --duration "$duration_rcutorture" \
> > > > + --configs "$configs_atomic_srcu" --trust-make
> > > > +fi
> > > > +
> > > > if test "$do_locktorture" = "yes"
> > > > then
> > > > torture_bootargs="torture.disable_onoff_at_boot"
> > > > --
> > > > 2.43.0
> > > >