We need a simple method to test Perf with Arm CoreSight drivers, this could be used for smoke testing when new patch is coming for perf or CoreSight drivers, and we also can use the test to confirm if the CoreSight has been enabled successfully on new platforms.
This patch introduces the shell script record+script_arm_cs_etm.sh, it's under the 'pert test' framework. The testing rationale is firstly to search ETR devices under the folder '/sys/bus/coresight/devices/', then traverse for every ETR device to verify trace data recording and decoding. If any ETR device fails for the testing, the test will report failure with directly exiting. This test will be only applied on the platform with PMU event 'cs_etm//', otherwise will skip this testing.
Below is detailed usage for it:
# cd $linux/tools/perf -> This is important so can use shell script # perf test list
[...]
61: Check open filename arg using perf trace + vfs_getname 62: Check Arm CoreSight trace data recording and branch samples 63: Add vfs_getname probe to get syscall args filenames 64: Use vfs_getname probe to get syscall args filenames
# perf test 62
62: Check Arm CoreSight trace data recording and branch samples: Ok
Signed-off-by: Leo Yan leo.yan@linaro.org --- .../tests/shell/record+script_arm_cs_etm.sh | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 tools/perf/tests/shell/record+script_arm_cs_etm.sh
diff --git a/tools/perf/tests/shell/record+script_arm_cs_etm.sh b/tools/perf/tests/shell/record+script_arm_cs_etm.sh new file mode 100755 index 000000000000..5f1940f57e1f --- /dev/null +++ b/tools/perf/tests/shell/record+script_arm_cs_etm.sh @@ -0,0 +1,47 @@ +#!/bin/sh +# Check Arm CoreSight trace data recording and branch samples + +# Uses the 'perf record' to record trace data with Arm CoreSight ETR as the +# output, then checks if there have any branch samples are generated by +# CoreSight with 'perf script' command. + +# Leo Yan leo.yan@linaro.org, 2019 + +perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX) +file=$(mktemp /tmp/temporary_file.XXXXX) + +skip_if_no_cs_etm_event() { + perf list | grep -q 'cs_etm//' && return 0 + + # cs_etm event doesn't exist + return 2 +} + +skip_if_no_cs_etm_event || exit 2 + +record_touch_file() { + echo "Recording open file: $1" + perf record -o ${perfdata} -e cs_etm/@$1/ --per-thread touch $file +} + +perf_script_filenames() { + echo "Looking at perf.data file for branch samples:" + perf script -F,-time -i ${perfdata} | \ + egrep " +touch +[0-9]+ .* +branches: +" +} + +arm_cs_etr_test() { + for i in /sys/bus/coresight/devices/*.etr; do + record_touch_file `basename $i` && perf_script_filenames + err=$? + + rm -f ${perfdata} + rm -f ${file} + + # Exit when find failure + [ $err != 0 ] && exit $err + done +} + +arm_cs_etr_test +exit 0
Hi all,
On Wed, Apr 24, 2019 at 02:42:39PM +0800, Leo Yan wrote:
We need a simple method to test Perf with Arm CoreSight drivers, this could be used for smoke testing when new patch is coming for perf or CoreSight drivers, and we also can use the test to confirm if the CoreSight has been enabled successfully on new platforms.
This patch introduces the shell script record+script_arm_cs_etm.sh, it's under the 'pert test' framework. The testing rationale is firstly to search ETR devices under the folder '/sys/bus/coresight/devices/', then traverse for every ETR device to verify trace data recording and decoding. If any ETR device fails for the testing, the test will report failure with directly exiting. This test will be only applied on the platform with PMU event 'cs_etm//', otherwise will skip this testing.
Below is detailed usage for it:
# cd $linux/tools/perf -> This is important so can use shell script # perf test list
[...] 61: Check open filename arg using perf trace + vfs_getname 62: Check Arm CoreSight trace data recording and branch samples 63: Add vfs_getname probe to get syscall args filenames 64: Use vfs_getname probe to get syscall args filenames
# perf test 62
62: Check Arm CoreSight trace data recording and branch samples: Ok
As we discussed in connect, this is drafted testing script based on 'perf test' framework; the first step is to keep the test as simple as possible.
The main purpose for this script is to enable a simple smoke test for perf + CoreSight on the mainline kernel. This could help us easily to find regression and verify new patches. This patch also tries to work without platform dependency.
Please let me know what's you think about this. If we agree with this is the right direction to go, I will send the patch to LKML for wider reviewing.
P.s. this patch has below two warning with checkpatch.pl, I think we can ignore these two warnings after I reviewed them; especially for the second warning, the second line in the script must be used by 'perf test' to read out the testing name so this is conflict with the Lincense. Will check this with Arnaldo when send patch to LKML.
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #42: new file mode 100755
WARNING: Missing or malformed SPDX-License-Identifier tag in line 2 #48: FILE: tools/perf/tests/shell/record+script_arm_cs_etm.sh:2: +# Check Arm CoreSight trace data recording and branch samples
total: 0 errors, 2 warnings, 47 lines checked
[...]
Thanks, Leo Yan
Hi,
On 24/04/2019 07:55, Leo Yan wrote:
Hi all,
On Wed, Apr 24, 2019 at 02:42:39PM +0800, Leo Yan wrote:
We need a simple method to test Perf with Arm CoreSight drivers, this could be used for smoke testing when new patch is coming for perf or CoreSight drivers, and we also can use the test to confirm if the CoreSight has been enabled successfully on new platforms.
This patch introduces the shell script record+script_arm_cs_etm.sh, it's under the 'pert test' framework. The testing rationale is firstly to search ETR devices under the folder '/sys/bus/coresight/devices/', then traverse for every ETR device to verify trace data recording and decoding. If any ETR device fails for the testing, the test will report failure with directly exiting. This test will be only applied on the platform with PMU event 'cs_etm//', otherwise will skip this testing.
Below is detailed usage for it:
# cd $linux/tools/perf -> This is important so can use shell script # perf test list
[...] 61: Check open filename arg using perf trace + vfs_getname 62: Check Arm CoreSight trace data recording and branch samples 63: Add vfs_getname probe to get syscall args filenames 64: Use vfs_getname probe to get syscall args filenames
# perf test 62
62: Check Arm CoreSight trace data recording and branch samples: Ok
As we discussed in connect, this is drafted testing script based on 'perf test' framework; the first step is to keep the test as simple as possible.
The main purpose for this script is to enable a simple smoke test for perf + CoreSight on the mainline kernel. This could help us easily to find regression and verify new patches. This patch also tries to work without platform dependency.
Please let me know what's you think about this. If we agree with this is the right direction to go, I will send the patch to LKML for wider reviewing.
Adding tests is a good idea. It would be great if we could extend it to cover some of the other commands which use CoreSight trace (e.g. perf report / inject) and some of the other options for trace decode - e.g. branch histories on instruction samples ('l' flag) and other combinations of trace flags (see my other email about crashes :) )
Regards
Rob
On Thu, Apr 25, 2019 at 01:54:52PM +0100, Robert Walker wrote:
[...]
Adding tests is a good idea. It would be great if we could extend it to cover some of the other commands which use CoreSight trace (e.g. perf report / inject) and some of the other options for trace decode - e.g. branch histories on instruction samples ('l' flag) and other combinations of trace flags (see my other email about crashes :) )
Yes, very makes sense for me :)
After I finish the the basic testing (as discussed in another email), will try to add inject related testing cases.
Thanks, Leo Yan