Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools/memory-model: Implement --hw support for checkghlitmus.sh

This commits enables the "--hw" argument for the checkghlitmus.sh script,
causing it to convert any applicable C-language litmus tests to the
specified flavor of assembly language, to verify these assembly-language
litmus tests, and checking compatibility of the outcomes.

Note that the conversion does not yet handle locking, RCU, SRCU, plain
C-language memory accesses, or casts.

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

+42 -14
+5 -4
tools/memory-model/scripts/checkghlitmus.sh
··· 10 10 # parseargs.sh scripts for arguments. 11 11 12 12 . scripts/parseargs.sh 13 + . scripts/hwfnseg.sh 13 14 14 15 T=/tmp/checkghlitmus.sh.$$ 15 16 trap 'rm -rf $T' 0 ··· 33 32 ( cd "$LKMM_DESTDIR"; sed -e 's/^/mkdir -p /' | sh ) 34 33 fi 35 34 36 - # Create a list of the C-language litmus tests previously run. 37 - ( cd $LKMM_DESTDIR; find litmus -name '*.litmus.out' -print ) | 38 - sed -e 's/\.out$//' | 35 + # Create a list of the specified litmus tests previously run. 36 + ( cd $LKMM_DESTDIR; find litmus -name "*.litmus${hwfnseg}.out" -print ) | 37 + sed -e "s/${hwfnseg}"'\.out$//' | 39 38 xargs -r egrep -l '^ \* Result: (Never|Sometimes|Always|DEADLOCK)' | 40 39 xargs -r grep -L "^P${LKMM_PROCS}"> $T/list-C-already 41 40 ··· 45 44 xargs < $T/list-C -r egrep -l '^ \* Result: (Never|Sometimes|Always|DEADLOCK)' > $T/list-C-result 46 45 xargs < $T/list-C-result -r grep -L "^P${LKMM_PROCS}" > $T/list-C-result-short 47 46 48 - # Form list of tests without corresponding .litmus.out files 47 + # Form list of tests without corresponding .out files 49 48 sort $T/list-C-already $T/list-C-result-short | uniq -u > $T/list-C-needed 50 49 51 50 # Run any needed tests.
+20
tools/memory-model/scripts/hwfnseg.sh
··· 1 + #!/bin/sh 2 + # SPDX-License-Identifier: GPL-2.0+ 3 + # 4 + # Generate the hardware extension to the litmus-test filename, or the 5 + # empty string if this is an LKMM run. The extension is placed in 6 + # the shell variable hwfnseg. 7 + # 8 + # Usage: 9 + # . hwfnseg.sh 10 + # 11 + # Copyright IBM Corporation, 2019 12 + # 13 + # Author: Paul E. McKenney <paulmck@linux.ibm.com> 14 + 15 + if test -z "$LKMM_HW_MAP_FILE" 16 + then 17 + hwfnseg= 18 + else 19 + hwfnseg=".$LKMM_HW_MAP_FILE" 20 + fi
+17 -10
tools/memory-model/scripts/runlitmushist.sh
··· 15 15 # 16 16 # Author: Paul E. McKenney <paulmck@linux.ibm.com> 17 17 18 + . scripts/hwfnseg.sh 19 + 18 20 T=/tmp/runlitmushist.sh.$$ 19 21 trap 'rm -rf $T' 0 20 22 mkdir $T ··· 32 30 # Prefixes for per-CPU scripts 33 31 for ((i=0;i<$LKMM_JOBS;i++)) 34 32 do 35 - echo dir="$LKMM_DESTDIR" > $T/$i.sh 36 33 echo T=$T >> $T/$i.sh 37 - echo herdoptions=\"$LKMM_HERD_OPTIONS\" >> $T/$i.sh 38 34 cat << '___EOF___' >> $T/$i.sh 39 35 runtest () { 40 - echo ' ... ' /usr/bin/time $LKMM_TIMEOUT_CMD herd7 $herdoptions $1 '>' $dir/$1.out '2>&1' 41 - if /usr/bin/time $LKMM_TIMEOUT_CMD herd7 $herdoptions $1 > $dir/$1.out 2>&1 36 + if scripts/runlitmus.sh $1 42 37 then 43 - if ! grep -q '^Observation ' $dir/$1.out 38 + if ! grep -q '^Observation ' $LKMM_DESTDIR/$1$2.out 44 39 then 45 40 echo ' !!! Herd failed, no Observation:' $1 46 41 fi ··· 46 47 if test "$exitcode" -eq 124 47 48 then 48 49 exitmsg="timed out" 50 + elif test "$exitcode" -eq 253 51 + then 52 + exitmsg= 49 53 else 50 54 exitmsg="failed, exit code $exitcode" 51 55 fi 52 - echo ' !!! Herd' ${exitmsg}: $1 56 + if test -n "$exitmsg" 57 + then 58 + echo ' !!! Herd' ${exitmsg}: $1 59 + fi 53 60 fi 54 61 } 55 62 ___EOF___ ··· 64 59 awk -v q="'" -v b='\\' ' 65 60 { 66 61 print "echo `grep " q "^P[0-9]" b "+(" q " " $0 " | tail -1 | sed -e " q "s/^P" b "([0-9]" b "+" b ")(.*$/" b "1/" q "` " $0 67 - }' | bash | 68 - sort -k1n | 69 - awk -v ncpu=$LKMM_JOBS -v t=$T ' 62 + }' | sh | sort -k1n | 63 + awk -v dq='"' -v hwfnseg="$hwfnseg" -v ncpu="$LKMM_JOBS" -v t="$T" ' 70 64 { 71 - print "runtest " $2 >> t "/" NR % ncpu ".sh"; 65 + print "if test -z " dq hwfnseg dq " || scripts/simpletest.sh " dq $2 dq 66 + print "then" 67 + print "\techo runtest " dq $2 dq " " hwfnseg " >> " t "/" NR % ncpu ".sh"; 68 + print "fi" 72 69 } 73 70 74 71 END {