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

tools/memory-model: Add data-race capabilities to judgelitmus.sh

This commit adds functionality to judgelitmus.sh to allow it to handle
both the "DATARACE" markers in the "Result:" comments in litmus tests
and the "Flag data-race" markers in LKMM output. For C-language tests,
if either marker is present, the other must also be as well, at least for
litmus tests having a "Result:" comment. If the LKMM output indicates
a data race, then failures of the Always/Sometimes/Never portion of the
"Result:" prediction are forgiven.

The reason for forgiving "Result:" mispredictions is that data races can
result in "interesting" compiler optimizations, so that all bets are off
in the data-race case.

[ paulmck: Apply Akira Yokosawa feedback. ]
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>

+32 -8
+32 -8
tools/memory-model/scripts/judgelitmus.sh
··· 4 4 # Given a .litmus test and the corresponding litmus output file, check 5 5 # the .litmus.out file against the "Result:" comment to judge whether the 6 6 # test ran correctly. If the --hw argument is omitted, check against the 7 - # LKMM output, which is assumed to be in file.litmus.out. If this argument 8 - # is provided, this is assumed to be a hardware test, and the output is 9 - # assumed to be in file.litmus.HW.out, where "HW" is the --hw argument. 10 - # In addition, non-Sometimes verification results will be noted, but 11 - # forgiven. Furthermore, if there is no "Result:" comment but there is 12 - # an LKMM .litmus.out file, the observation in that file will be used 13 - # to judge the assembly-language verification. 7 + # LKMM output, which is assumed to be in file.litmus.out. If either a 8 + # "DATARACE" marker in the "Result:" comment or a "Flag data-race" marker 9 + # in the LKMM output is present, the other must also be as well, at least 10 + # for litmus tests having a "Result:" comment. In this case, a failure of 11 + # the Always/Sometimes/Never portion of the "Result:" prediction will be 12 + # noted, but forgiven. 13 + # 14 + # If the --hw argument is provided, this is assumed to be a hardware 15 + # test, and the output is assumed to be in file.litmus.HW.out, where 16 + # "HW" is the --hw argument. In addition, non-Sometimes verification 17 + # results will be noted, but forgiven. Furthermore, if there is no 18 + # "Result:" comment but there is an LKMM .litmus.out file, the observation 19 + # in that file will be used to judge the assembly-language verification. 14 20 # 15 21 # Usage: 16 22 # judgelitmus.sh file.litmus ··· 53 47 echo ' --- ' error: \"$LKMM_DESTDIR/$litmusout is not a readable file 54 48 exit 255 55 49 fi 50 + if grep -q '^Flag data-race$' "$LKMM_DESTDIR/$litmusout" 51 + then 52 + datarace_modeled=1 53 + fi 56 54 if grep -q '^ \* Result: ' $litmus 57 55 then 58 56 outcome=`grep -m 1 '^ \* Result: ' $litmus | awk '{ print $3 }'` 57 + if grep -m1 '^ \* Result: .* DATARACE' $litmus 58 + then 59 + datarace_predicted=1 60 + fi 61 + if test -n "$datarace_predicted" -a -z "$datarace_modeled" -a -z "$LKMM_HW_MAP_FILE" 62 + then 63 + echo '!!! Predicted data race not modeled' $litmus 64 + exit 252 65 + elif test -z "$datarace_predicted" -a -n "$datarace_modeled" 66 + then 67 + # Note that hardware models currently don't model data races 68 + echo '!!! Unexpected data race modeled' $litmus 69 + exit 253 70 + fi 59 71 elif test -n "$LKMM_HW_MAP_FILE" && grep -q '^Observation' $LKMM_DESTDIR/$lkmmout > /dev/null 2>&1 60 72 then 61 73 outcome=`grep -m 1 '^Observation ' $LKMM_DESTDIR/$lkmmout | awk '{ print $3 }'` ··· 138 114 then 139 115 ret=0 140 116 else 141 - if test -n "$LKMM_HW_MAP_FILE" -a "$outcome" = Sometimes 117 + if test \( -n "$LKMM_HW_MAP_FILE" -a "$outcome" = Sometimes \) -o -n "$datarace_modeled" 142 118 then 143 119 flag="--- Forgiven" 144 120 ret=0