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

tools/memory-model: Hardware checking for check{,all}litmus.sh

This commit makes checklitmus.sh and checkalllitmus.sh check to see
if a hardware verification was specified (via the --hw command-line
argument, which sets the LKMM_HW_MAP_FILE environment variable).
If so, the C-language litmus test is converted to the specified type
of assembly-language litmus test and herd is run on it. Hardware is
permitted to be stronger than LKMM requires, so "Always" and "Never"
verifications of "Sometimes" C-language litmus tests are forgiven.

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

+49 -16
+11 -12
tools/memory-model/scripts/checkalllitmus.sh
··· 1 - #!/bin/sh 1 + #!/bin/bash 2 2 # SPDX-License-Identifier: GPL-2.0+ 3 3 # 4 4 # Run herd7 tests on all .litmus files in the litmus-tests directory ··· 7 7 # in the litmus test, this script prints an error message prefixed with 8 8 # "^^^". It also outputs verification results to a file whose name is 9 9 # that of the specified litmus test, but with ".out" appended. 10 + # 11 + # If the --hw argument is specified, this script translates the .litmus 12 + # C-language file to the specified type of assembly and verifies that. 13 + # But in this case, litmus tests using complex synchronization (such as 14 + # locking, RCU, and SRCU) are cheerfully ignored. 10 15 # 11 16 # Usage: 12 17 # checkalllitmus.sh ··· 43 38 ( cd "$LKMM_DESTDIR"; sed -e 's/^/mkdir -p /' | sh ) 44 39 fi 45 40 46 - # Find the checklitmus script. If it is not where we expect it, then 47 - # assume that the caller has the PATH environment variable set 48 - # appropriately. 49 - if test -x scripts/checklitmus.sh 50 - then 51 - clscript=scripts/checklitmus.sh 52 - else 53 - clscript=checklitmus.sh 54 - fi 55 - 56 41 # Run the script on all the litmus tests in the specified directory 57 42 ret=0 58 43 for i in $litmusdir/*.litmus 59 44 do 60 - if ! $clscript $i 45 + if test -n "$LKMM_HW_MAP_FILE" && ! scripts/simpletest.sh $i 46 + then 47 + continue 48 + fi 49 + if ! scripts/checklitmus.sh $i 61 50 then 62 51 ret=1 63 52 fi
+38 -4
tools/memory-model/scripts/checklitmus.sh
··· 6 6 # results to a file whose name is that of the specified litmus test, but 7 7 # with ".out" appended. 8 8 # 9 + # If the --hw argument is specified, this script translates the .litmus 10 + # C-language file to the specified type of assembly and verifies that. 11 + # But in this case, litmus tests using complex synchronization (such as 12 + # locking, RCU, and SRCU) are cheerfully ignored. 13 + # 9 14 # Usage: 10 15 # checklitmus.sh file.litmus 11 16 # ··· 23 18 # Author: Paul E. McKenney <paulmck@linux.ibm.com> 24 19 25 20 litmus=$1 26 - herdoptions=${LKMM_HERD_OPTIONS--conf linux-kernel.cfg} 27 - 28 21 if test -f "$litmus" -a -r "$litmus" 29 22 then 30 23 : ··· 31 28 exit 255 32 29 fi 33 30 34 - echo Herd options: $herdoptions > $LKMM_DESTDIR/$litmus.out 35 - /usr/bin/time $LKMM_TIMEOUT_CMD herd7 $herdoptions $litmus >> $LKMM_DESTDIR/$litmus.out 2>&1 31 + if test -z "$LKMM_HW_MAP_FILE" 32 + then 33 + # LKMM run 34 + herdoptions=${LKMM_HERD_OPTIONS--conf linux-kernel.cfg} 35 + echo Herd options: $herdoptions > $LKMM_DESTDIR/$litmus.out 36 + /usr/bin/time $LKMM_TIMEOUT_CMD herd7 $herdoptions $litmus >> $LKMM_DESTDIR/$litmus.out 2>&1 37 + else 38 + # Hardware run 39 + 40 + T=/tmp/checklitmushw.sh.$$ 41 + trap 'rm -rf $T' 0 2 42 + mkdir $T 43 + 44 + # Generate filenames 45 + catfile="`echo $LKMM_HW_MAP_FILE | tr '[A-Z]' '[a-z]'`.cat" 46 + mapfile="Linux2${LKMM_HW_MAP_FILE}.map" 47 + themefile="$T/${LKMM_HW_MAP_FILE}.theme" 48 + herdoptions="-model $LKMM_HW_CAT_FILE" 49 + hwlitmus=`echo $litmus | sed -e 's/\.litmus$/.'${LKMM_HW_MAP_FILE}'.litmus/'` 50 + hwlitmusfile=`echo $hwlitmus | sed -e 's,^.*/,,'` 51 + 52 + # Don't run on litmus tests with complex synchronization 53 + if ! scripts/simpletest.sh $litmus 54 + then 55 + echo ' --- ' error: \"$litmus\" contains locking, RCU, or SRCU 56 + exit 254 57 + fi 58 + 59 + # Generate the assembly code and run herd7 on it. 60 + gen_theme7 -n 10 -map $mapfile -call Linux.call > $themefile 61 + jingle7 -theme $themefile $litmus > $T/$hwlitmusfile 2> $T/$hwlitmusfile.jingle7.out 62 + /usr/bin/time $LKMM_TIMEOUT_CMD herd7 -model $catfile $T/$hwlitmusfile > $LKMM_DESTDIR/$hwlitmus.out 2>&1 63 + fi 36 64 37 65 scripts/judgelitmus.sh $litmus