diff mbox series

[rcu,7/7] rcutorture: Add srcu_lockdep.sh

Message ID 20230317031339.10277-8-boqun.feng@gmail.com
State Accepted
Commit 5c5552d6297a2a91464180d2790dffdca9ffc7de
Headers show
Series RCU-related lockdep changes for v6.4 | expand

Commit Message

Boqun Feng March 17, 2023, 3:13 a.m. UTC
From: "Paul E. McKenney" <paulmck@kernel.org>

This commit adds an srcu_lockdep.sh script that checks whether lockdep
correctly classifies SRCU-based, SRCU/mutex-based, and SRCU/rwsem-based
deadlocks.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
[ boqun: Fix "RCUTORTURE" with "$RCUTORTURE" ]
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
---
 .../selftests/rcutorture/bin/srcu_lockdep.sh  | 73 +++++++++++++++++++
 1 file changed, 73 insertions(+)
 create mode 100755 tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh

Comments

Boqun Feng March 20, 2023, 6:19 p.m. UTC | #1
Hi Paul,

On Thu, Mar 16, 2023 at 08:13:39PM -0700, Boqun Feng wrote:
> From: "Paul E. McKenney" <paulmck@kernel.org>
> 
> This commit adds an srcu_lockdep.sh script that checks whether lockdep
> correctly classifies SRCU-based, SRCU/mutex-based, and SRCU/rwsem-based
> deadlocks.
> 
> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> [ boqun: Fix "RCUTORTURE" with "$RCUTORTURE" ]
> Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
> ---
>  .../selftests/rcutorture/bin/srcu_lockdep.sh  | 73 +++++++++++++++++++
>  1 file changed, 73 insertions(+)
>  create mode 100755 tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh
> 
> diff --git a/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh b/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh
> new file mode 100755
> index 000000000000..961932754684
> --- /dev/null
> +++ b/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh

Could you provide the SPDX header and copyright bits for this newly
added file? For small changes I can do it myself, however this is about
licenses and copyright, so I need it from you, thanks!

Regards,
Boqun

> @@ -0,0 +1,73 @@
> +#!/bin/bash
> +#
> +# Run SRCU-lockdep tests and report any that fail to meet expectations.
> +
> +usage () {
> +	echo "Usage: $scriptname optional arguments:"
> +	echo "       --datestamp string"
> +	exit 1
> +}
> +
> +ds=`date +%Y.%m.%d-%H.%M.%S`-srcu_lockdep
> +scriptname="$0"
> +
> +T="`mktemp -d ${TMPDIR-/tmp}/srcu_lockdep.sh.XXXXXX`"
> +trap 'rm -rf $T' 0
> +
> +RCUTORTURE="`pwd`/tools/testing/selftests/rcutorture"; export RCUTORTURE
> +PATH=${RCUTORTURE}/bin:$PATH; export PATH
> +. functions.sh
> +
> +while test $# -gt 0
> +do
> +	case "$1" in
> +	--datestamp)
> +		checkarg --datestamp "(relative pathname)" "$#" "$2" '^[a-zA-Z0-9._/-]*$' '^--'
> +		ds=$2
> +		shift
> +		;;
> +	*)
> +		echo Unknown argument $1
> +		usage
> +		;;
> +	esac
> +	shift
> +done
> +
> +err=
> +nerrs=0
> +for d in 0 1
> +do
> +	for t in 0 1 2
> +	do
> +		for c in 1 2 3
> +		do
> +			err=
> +			val=$((d*1000+t*10+c))
> +			tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 5s --configs "SRCU-P" --bootargs "rcutorture.test_srcu_lockdep=$val" --trust-make --datestamp "$ds/$val" > "$T/kvm.sh.out" 2>&1
> +			ret=$?
> +			mv "$T/kvm.sh.out" "$RCUTORTURE/res/$ds/$val"
> +			if test "$d" -ne 0 && test "$ret" -eq 0
> +			then
> +				err=1
> +				echo -n Unexpected success for > "$RCUTORTURE/res/$ds/$val/kvm.sh.err"
> +			fi
> +			if test "$d" -eq 0 && test "$ret" -ne 0
> +			then
> +				err=1
> +				echo -n Unexpected failure for > "$RCUTORTURE/res/$ds/$val/kvm.sh.err"
> +			fi
> +			if test -n "$err"
> +			then
> +				grep "rcu_torture_init_srcu_lockdep: test_srcu_lockdep = " "$RCUTORTURE/res/$ds/$val/SRCU-P/console.log" | sed -e 's/^.*rcu_torture_init_srcu_lockdep://' >> "$RCUTORTURE/res/$ds/$val/kvm.sh.err"
> +				cat "$RCUTORTURE/res/$ds/$val/kvm.sh.err"
> +				nerrs=$((nerrs+1))
> +			fi
> +		done
> +	done
> +done
> +if test "$nerrs" -ne 0
> +then
> +	exit 1
> +fi
> +exit 0
> -- 
> 2.39.2
>
Paul E. McKenney March 20, 2023, 8:22 p.m. UTC | #2
On Mon, Mar 20, 2023 at 12:28:05PM -0700, Boqun Feng wrote:
> On Mon, Mar 20, 2023 at 12:09:00PM -0700, Paul E. McKenney wrote:
> > On Mon, Mar 20, 2023 at 11:19:05AM -0700, Boqun Feng wrote:
> > > Hi Paul,
> > > 
> > > On Thu, Mar 16, 2023 at 08:13:39PM -0700, Boqun Feng wrote:
> > > > From: "Paul E. McKenney" <paulmck@kernel.org>
> > > > 
> > > > This commit adds an srcu_lockdep.sh script that checks whether lockdep
> > > > correctly classifies SRCU-based, SRCU/mutex-based, and SRCU/rwsem-based
> > > > deadlocks.
> > > > 
> > > > Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> > > > [ boqun: Fix "RCUTORTURE" with "$RCUTORTURE" ]
> > > > Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
> > > > ---
> > > >  .../selftests/rcutorture/bin/srcu_lockdep.sh  | 73 +++++++++++++++++++
> > > >  1 file changed, 73 insertions(+)
> > > >  create mode 100755 tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh
> > > > 
> > > > diff --git a/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh b/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh
> > > > new file mode 100755
> > > > index 000000000000..961932754684
> > > > --- /dev/null
> > > > +++ b/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh
> > > 
> > > Could you provide the SPDX header and copyright bits for this newly
> > > added file? For small changes I can do it myself, however this is about
> > > licenses and copyright, so I need it from you, thanks!
> > 
> > Good catch, thank you!
> > 
> > Would you like a delta patch to merge into your existing one, or would
> > you prefer a replacement patch?  Either way works for me.
> > 
> 
> A delta patch if that's not much trouble. I will fold it into this one.

Here you go!

							Thanx, Paul

------------------------------------------------------------------------

rcutorture: Add proper comment header to srcu_lockdep.sh

This patch adds a proper comment header to srcu_lockdep.sh,
and is intended to be folded into 9dc68f40c665 ("rcutorture: Add
srcu_lockdep.sh").

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>

diff --git a/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh b/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh
index 961932754684..2e63ef009d59 100755
--- a/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh
+++ b/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh
@@ -1,6 +1,11 @@
 #!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
 #
 # Run SRCU-lockdep tests and report any that fail to meet expectations.
+#
+# Copyright (C) 2021 Meta Platforms, Inc.
+#
+# Authors: Paul E. McKenney <paulmck@kernel.org>
 
 usage () {
 	echo "Usage: $scriptname optional arguments:"
Paul E. McKenney March 20, 2023, 8:36 p.m. UTC | #3
On Mon, Mar 20, 2023 at 01:26:39PM -0700, Boqun Feng wrote:
> On Mon, Mar 20, 2023 at 01:22:24PM -0700, Paul E. McKenney wrote:
> > On Mon, Mar 20, 2023 at 12:28:05PM -0700, Boqun Feng wrote:
> > > On Mon, Mar 20, 2023 at 12:09:00PM -0700, Paul E. McKenney wrote:
> > > > On Mon, Mar 20, 2023 at 11:19:05AM -0700, Boqun Feng wrote:
> > > > > Hi Paul,
> > > > > 
> > > > > On Thu, Mar 16, 2023 at 08:13:39PM -0700, Boqun Feng wrote:
> > > > > > From: "Paul E. McKenney" <paulmck@kernel.org>
> > > > > > 
> > > > > > This commit adds an srcu_lockdep.sh script that checks whether lockdep
> > > > > > correctly classifies SRCU-based, SRCU/mutex-based, and SRCU/rwsem-based
> > > > > > deadlocks.
> > > > > > 
> > > > > > Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> > > > > > [ boqun: Fix "RCUTORTURE" with "$RCUTORTURE" ]
> > > > > > Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
> > > > > > ---
> > > > > >  .../selftests/rcutorture/bin/srcu_lockdep.sh  | 73 +++++++++++++++++++
> > > > > >  1 file changed, 73 insertions(+)
> > > > > >  create mode 100755 tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh
> > > > > > 
> > > > > > diff --git a/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh b/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh
> > > > > > new file mode 100755
> > > > > > index 000000000000..961932754684
> > > > > > --- /dev/null
> > > > > > +++ b/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh
> > > > > 
> > > > > Could you provide the SPDX header and copyright bits for this newly
> > > > > added file? For small changes I can do it myself, however this is about
> > > > > licenses and copyright, so I need it from you, thanks!
> > > > 
> > > > Good catch, thank you!
> > > > 
> > > > Would you like a delta patch to merge into your existing one, or would
> > > > you prefer a replacement patch?  Either way works for me.
> > > > 
> > > 
> > > A delta patch if that's not much trouble. I will fold it into this one.
> > 
> > Here you go!
> 
> Thanks! Fold it in patch #7.

Thank you!

And this might be a problem in my current process when handing off
to others.  I normally don't run checkpatch until just before a send
out the patches, which means that none of the commits I handed off to
you guys had been checkpatched.  There was I time I tried a checkpatch
hook in git, but the false-positive rate made that a non-starter.

							Thanx, Paul

> Regards,
> Boqun
> 
> > 							Thanx, Paul
> > 
> > ------------------------------------------------------------------------
> > 
> > rcutorture: Add proper comment header to srcu_lockdep.sh
> > 
> > This patch adds a proper comment header to srcu_lockdep.sh,
> > and is intended to be folded into 9dc68f40c665 ("rcutorture: Add
> > srcu_lockdep.sh").
> > 
> > Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> > 
> > diff --git a/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh b/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh
> > index 961932754684..2e63ef009d59 100755
> > --- a/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh
> > +++ b/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh
> > @@ -1,6 +1,11 @@
> >  #!/bin/bash
> > +# SPDX-License-Identifier: GPL-2.0+
> >  #
> >  # Run SRCU-lockdep tests and report any that fail to meet expectations.
> > +#
> > +# Copyright (C) 2021 Meta Platforms, Inc.
> > +#
> > +# Authors: Paul E. McKenney <paulmck@kernel.org>
> >  
> >  usage () {
> >  	echo "Usage: $scriptname optional arguments:"
diff mbox series

Patch

diff --git a/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh b/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh
new file mode 100755
index 000000000000..961932754684
--- /dev/null
+++ b/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh
@@ -0,0 +1,73 @@ 
+#!/bin/bash
+#
+# Run SRCU-lockdep tests and report any that fail to meet expectations.
+
+usage () {
+	echo "Usage: $scriptname optional arguments:"
+	echo "       --datestamp string"
+	exit 1
+}
+
+ds=`date +%Y.%m.%d-%H.%M.%S`-srcu_lockdep
+scriptname="$0"
+
+T="`mktemp -d ${TMPDIR-/tmp}/srcu_lockdep.sh.XXXXXX`"
+trap 'rm -rf $T' 0
+
+RCUTORTURE="`pwd`/tools/testing/selftests/rcutorture"; export RCUTORTURE
+PATH=${RCUTORTURE}/bin:$PATH; export PATH
+. functions.sh
+
+while test $# -gt 0
+do
+	case "$1" in
+	--datestamp)
+		checkarg --datestamp "(relative pathname)" "$#" "$2" '^[a-zA-Z0-9._/-]*$' '^--'
+		ds=$2
+		shift
+		;;
+	*)
+		echo Unknown argument $1
+		usage
+		;;
+	esac
+	shift
+done
+
+err=
+nerrs=0
+for d in 0 1
+do
+	for t in 0 1 2
+	do
+		for c in 1 2 3
+		do
+			err=
+			val=$((d*1000+t*10+c))
+			tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 5s --configs "SRCU-P" --bootargs "rcutorture.test_srcu_lockdep=$val" --trust-make --datestamp "$ds/$val" > "$T/kvm.sh.out" 2>&1
+			ret=$?
+			mv "$T/kvm.sh.out" "$RCUTORTURE/res/$ds/$val"
+			if test "$d" -ne 0 && test "$ret" -eq 0
+			then
+				err=1
+				echo -n Unexpected success for > "$RCUTORTURE/res/$ds/$val/kvm.sh.err"
+			fi
+			if test "$d" -eq 0 && test "$ret" -ne 0
+			then
+				err=1
+				echo -n Unexpected failure for > "$RCUTORTURE/res/$ds/$val/kvm.sh.err"
+			fi
+			if test -n "$err"
+			then
+				grep "rcu_torture_init_srcu_lockdep: test_srcu_lockdep = " "$RCUTORTURE/res/$ds/$val/SRCU-P/console.log" | sed -e 's/^.*rcu_torture_init_srcu_lockdep://' >> "$RCUTORTURE/res/$ds/$val/kvm.sh.err"
+				cat "$RCUTORTURE/res/$ds/$val/kvm.sh.err"
+				nerrs=$((nerrs+1))
+			fi
+		done
+	done
+done
+if test "$nerrs" -ne 0
+then
+	exit 1
+fi
+exit 0