Skip to content

Commit 8591994

Browse files
Thomas Richternamhyung
authored andcommitted
perf test: Fix perf record test for precise_max
On s390 the event instructions can not be used for recording. This event is only supported by perf stat. Test that each event cycles and instructions supports sampling. If the event can not be sampled, skip it. Signed-off-by: Thomas Richter <[email protected]> Suggested-by: James Clark <[email protected]> Reviewed-by: James Clark <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent 23e0a63 commit 8591994

File tree

1 file changed

+29
-14
lines changed

1 file changed

+29
-14
lines changed

tools/perf/tests/shell/record.sh

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -273,27 +273,42 @@ test_topdown_leader_sampling() {
273273
}
274274

275275
test_precise_max() {
276+
local -i skipped=0
277+
276278
echo "precise_max attribute test"
277-
if ! perf stat -e "cycles,instructions" true 2> /dev/null
279+
# Just to make sure event cycles is supported for sampling
280+
if perf record -o "${perfdata}" -e "cycles" true 2> /dev/null
278281
then
279-
echo "precise_max attribute [Skipped no hardware events]"
280-
return
282+
if ! perf record -o "${perfdata}" -e "cycles:P" true 2> /dev/null
283+
then
284+
echo "precise_max attribute [Failed cycles:P event]"
285+
err=1
286+
return
287+
fi
288+
else
289+
echo "precise_max attribute [Skipped no cycles:P event]"
290+
((skipped+=1))
281291
fi
282-
# Just to make sure it doesn't fail
283-
if ! perf record -o "${perfdata}" -e "cycles:P" true 2> /dev/null
292+
# On s390 event instructions is not supported for perf record
293+
if perf record -o "${perfdata}" -e "instructions" true 2> /dev/null
284294
then
285-
echo "precise_max attribute [Failed cycles:P event]"
286-
err=1
287-
return
295+
# On AMD, cycles and instructions events are treated differently
296+
if ! perf record -o "${perfdata}" -e "instructions:P" true 2> /dev/null
297+
then
298+
echo "precise_max attribute [Failed instructions:P event]"
299+
err=1
300+
return
301+
fi
302+
else
303+
echo "precise_max attribute [Skipped no instructions:P event]"
304+
((skipped+=1))
288305
fi
289-
# On AMD, cycles and instructions events are treated differently
290-
if ! perf record -o "${perfdata}" -e "instructions:P" true 2> /dev/null
306+
if [ $skipped -eq 2 ]
291307
then
292-
echo "precise_max attribute [Failed instructions:P event]"
293-
err=1
294-
return
308+
echo "precise_max attribute [Skipped no hardware events]"
309+
else
310+
echo "precise_max attribute test [Success]"
295311
fi
296-
echo "precise_max attribute test [Success]"
297312
}
298313

299314
# raise the limit of file descriptors to minimum

0 commit comments

Comments
 (0)