This patch set tries to add support Arm CoreSight testing with perf tool. Since the testings might be very diverse according to different requirements, to keep the testing as simple as possible from the start point, I'd like to define the testings to fulfil below duties:
- Sanity testing for integration perf tool with CoreSight tracing; - Trace source oriented testing, it needs to test for every source and iterate the paths from the source to its possible sinks; - Test with 'perf script' for branch samples; - Test with 'perf report' for branch samples and synthesized instruction samples.
Before started this work, we need a reliable and simple method to help us to analysis every possible path from one specific source to its output sinks. Suzuki has one the patch [1] which creates sysfs in/out nodes in CoreSight device folders, based on this it's convenient to use depth-first search (DFS) to traverse the paths from ETM to its connected sink devices.
Patch 0001 introduces shell script, which based on sysfs in/out nodes to find every feasible path from one CPU to one sink, then we can specify the sink in perf record command and use taskset command to bind task to the target CPU. Use this way it can very if the target CPU can generate trace data and output to the specific sink successfully or not, below is the iteration flow in Juno board:
Recording trace with path: CPU0 => 20010000.etf Recording trace with path: CPU0 => 20070000.etr Recording trace with path: CPU1 => 20010000.etf Recording trace with path: CPU1 => 20070000.etr Recording trace with path: CPU2 => 20010000.etf Recording trace with path: CPU2 => 20070000.etr Recording trace with path: CPU3 => 20010000.etf Recording trace with path: CPU3 => 20070000.etr Recording trace with path: CPU4 => 20010000.etf Recording trace with path: CPU4 => 20070000.etr Recording trace with path: CPU5 => 20010000.etf Recording trace with path: CPU5 => 20070000.etr
Patch 0002 adds two testings for 'perf report', one is the general testing and the second is testing with option '-itrace'.
I verified this patch set on Juno board, the code is based on CoreSight next branch, and applied Suzuki's the patch set 'coresight: Support for ACPI bindings' (have applied the total 36 patches) [2].
[1] https://archive.armlinux.org.uk/lurker/message/20190415.160419.bed67191.en.h... [2] https://archive.armlinux.org.uk/lurker/message/20190415.160343.cdd208bb.en.h...
Leo Yan (2): perf test: Introduce script for Arm CoreSight testing perf test: Add 'perf report' testing for Arm CoreSight
.../shell/record+script+report_arm_cs_etm.sh | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100755 tools/perf/tests/shell/record+script+report_arm_cs_etm.sh
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. Simply to say, the testing rationale is source oriented testing, it traverses every source (now only refers to ETM device) and test its all possible sinks. To search the complete paths from one specific source to its sinks, this patch relies on the sysfs '/sys/bus/coresight/devices/devX/out:Y' for depth-first search (DFS) for iteration connected device nodes, if the output device is detected as one of ETR, ETF, or ETB types it will verify trace data recording and decoding.
If any device fails for the testing, the test will report failure and directly exit with error. This test will be only applied on the platform with PMU event 'cs_etm//', otherwise will skip the 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 | 81 +++++++++++++++++++ 1 file changed, 81 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..108604984867 --- /dev/null +++ b/tools/perf/tests/shell/record+script_arm_cs_etm.sh @@ -0,0 +1,81 @@ +#!/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 trace with path: CPU$2 => $1" + perf record -o ${perfdata} -e cs_etm/@$1/ --per-thread \ + -- taskset -c $2 touch $file +} + +perf_script_branch_samples() { + echo "Looking at perf.data file for dumping branch samples:" + perf script -F,-time -i ${perfdata} | \ + egrep " +touch +[0-9]+ .* +branches: +" +} + +arm_cs_iterate_devices() { + for dev in $1/out:*; do + + # Skip testing if it's not a directory + ! [ -d $dev ] && continue; + + # Read out its symbol link file name + path=`readlink -f $dev` + + # Extract device name from path, e.g. + # path = '/sys/devices/platform/20010000.etf/tmc_etf0' + # `> device_name = '20010000.etf' + device_name=`echo $path | awk -F/ '{print $(NF-1)}'` + + echo $device_name | egrep -q "etr|etb|etf" + + # Only test if the output device is ETR/ETB/ETF + if [ $? -eq 0 ]; then + record_touch_file $device_name $2 && + perf_script_branch_samples + + err=$? + + rm -f ${perfdata} + rm -f ${file} + + # Exit when find failure + [ $err != 0 ] && exit $err + fi + + arm_cs_iterate_devices $dev $2 + done +} + +arm_cs_etm_test() { + # Iterate for every ETM device + for dev in /sys/bus/coresight/devices/etm*; do + + # Find the ETM device belonging to which CPU + cpu=`cat $dev/cpu` + + # Use depth-first search (DFS) to iterate outputs + arm_cs_iterate_devices $dev $cpu + done +} + +arm_cs_etm_test +exit 0
This patch adds two testings for 'perf report' command.
The first testing is a general report testing with branch samples, the second testing is to use option '--itrace=i1000i' to insert synthesized instructions events and the script will check if perf can output the percentage value successfully based on the instruction samples.
Signed-off-by: Leo Yan leo.yan@linaro.org --- ...etm.sh => record+script+report_arm_cs_etm.sh} | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) rename tools/perf/tests/shell/{record+script_arm_cs_etm.sh => record+script+report_arm_cs_etm.sh} (79%)
diff --git a/tools/perf/tests/shell/record+script_arm_cs_etm.sh b/tools/perf/tests/shell/record+script+report_arm_cs_etm.sh similarity index 79% rename from tools/perf/tests/shell/record+script_arm_cs_etm.sh rename to tools/perf/tests/shell/record+script+report_arm_cs_etm.sh index 108604984867..ea053ed4bbb1 100755 --- a/tools/perf/tests/shell/record+script_arm_cs_etm.sh +++ b/tools/perf/tests/shell/record+script+report_arm_cs_etm.sh @@ -31,6 +31,18 @@ perf_script_branch_samples() { egrep " +touch +[0-9]+ .* +branches: +" }
+perf_report_branch_samples() { + echo "Looking at perf.data file for reporting branch samples:" + perf report --stdio -i ${perfdata} | \ + egrep " +[0-9]+.[0-9]+% +[0-9]+.[0-9]+% +touch " +} + +perf_report_instruction_samples() { + echo "Looking at perf.data file for instruction samples:" + perf report --itrace=i1000i --stdio -i ${perfdata} | \ + egrep " +[0-9]+.[0-9]+% +touch" +} + arm_cs_iterate_devices() { for dev in $1/out:*; do
@@ -50,7 +62,9 @@ arm_cs_iterate_devices() { # Only test if the output device is ETR/ETB/ETF if [ $? -eq 0 ]; then record_touch_file $device_name $2 && - perf_script_branch_samples + perf_script_branch_samples && + perf_report_branch_samples && + perf_report_instruction_samples
err=$?
On Mon, 6 May 2019 at 03:41, Leo Yan leo.yan@linaro.org wrote:
This patch adds two testings for 'perf report' command.
The first testing is a general report testing with branch samples, the second testing is to use option '--itrace=i1000i' to insert synthesized instructions events and the script will check if perf can output the percentage value successfully based on the instruction samples.
Signed-off-by: Leo Yan leo.yan@linaro.org
...etm.sh => record+script+report_arm_cs_etm.sh} | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) rename tools/perf/tests/shell/{record+script_arm_cs_etm.sh => record+script+report_arm_cs_etm.sh} (79%)
Wouldn't it be better to just name the script "test_arm_coresight.sh" so that we can make any changes we want to it without having to rethink the name every time?
diff --git a/tools/perf/tests/shell/record+script_arm_cs_etm.sh b/tools/perf/tests/shell/record+script+report_arm_cs_etm.sh similarity index 79% rename from tools/perf/tests/shell/record+script_arm_cs_etm.sh rename to tools/perf/tests/shell/record+script+report_arm_cs_etm.sh index 108604984867..ea053ed4bbb1 100755 --- a/tools/perf/tests/shell/record+script_arm_cs_etm.sh +++ b/tools/perf/tests/shell/record+script+report_arm_cs_etm.sh @@ -31,6 +31,18 @@ perf_script_branch_samples() { egrep " +touch +[0-9]+ .* +branches: +" }
+perf_report_branch_samples() {
echo "Looking at perf.data file for reporting branch samples:"
perf report --stdio -i ${perfdata} | \
egrep " +[0-9]+\.[0-9]+% +[0-9]+\.[0-9]+% +touch "
Please document the the 'egrep' is looking for with an example of the 'report' output.
+}
+perf_report_instruction_samples() {
echo "Looking at perf.data file for instruction samples:"
perf report --itrace=i1000i --stdio -i ${perfdata} | \
egrep " +[0-9]+\.[0-9]+% +touch"
Same here. You should also consider merging the patches together.
I tested this and things work quite well.
Thanks, Mathieu
+}
arm_cs_iterate_devices() { for dev in $1/out:*; do
@@ -50,7 +62,9 @@ arm_cs_iterate_devices() { # Only test if the output device is ETR/ETB/ETF if [ $? -eq 0 ]; then record_touch_file $device_name $2 &&
perf_script_branch_samples
perf_script_branch_samples &&
perf_report_branch_samples &&
perf_report_instruction_samples err=$?
-- 2.17.1
Hi Mathieu,
On Wed, May 15, 2019 at 02:36:29PM -0600, Mathieu Poirier wrote:
On Mon, 6 May 2019 at 03:41, Leo Yan leo.yan@linaro.org wrote:
This patch adds two testings for 'perf report' command.
The first testing is a general report testing with branch samples, the second testing is to use option '--itrace=i1000i' to insert synthesized instructions events and the script will check if perf can output the percentage value successfully based on the instruction samples.
Signed-off-by: Leo Yan leo.yan@linaro.org
...etm.sh => record+script+report_arm_cs_etm.sh} | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) rename tools/perf/tests/shell/{record+script_arm_cs_etm.sh => record+script+report_arm_cs_etm.sh} (79%)
Wouldn't it be better to just name the script "test_arm_coresight.sh" so that we can make any changes we want to it without having to rethink the name every time?
Will fix it.
diff --git a/tools/perf/tests/shell/record+script_arm_cs_etm.sh b/tools/perf/tests/shell/record+script+report_arm_cs_etm.sh similarity index 79% rename from tools/perf/tests/shell/record+script_arm_cs_etm.sh rename to tools/perf/tests/shell/record+script+report_arm_cs_etm.sh index 108604984867..ea053ed4bbb1 100755 --- a/tools/perf/tests/shell/record+script_arm_cs_etm.sh +++ b/tools/perf/tests/shell/record+script+report_arm_cs_etm.sh @@ -31,6 +31,18 @@ perf_script_branch_samples() { egrep " +touch +[0-9]+ .* +branches: +" }
+perf_report_branch_samples() {
echo "Looking at perf.data file for reporting branch samples:"
perf report --stdio -i ${perfdata} | \
egrep " +[0-9]+\.[0-9]+% +[0-9]+\.[0-9]+% +touch "
Please document the the 'egrep' is looking for with an example of the 'report' output.
Will add.
+}
+perf_report_instruction_samples() {
echo "Looking at perf.data file for instruction samples:"
perf report --itrace=i1000i --stdio -i ${perfdata} | \
egrep " +[0-9]+\.[0-9]+% +touch"
Same here. You should also consider merging the patches together.
Will add the example output and merge two patches.
I tested this and things work quite well.
Thanks a lot for reviewing and testing!
Will wait for a bit time in case others have more suggestion for this, then I will send patch to LKML for wider reviewing.
Thanks, Leo Yan
On Wed, 15 May 2019 at 19:08, Leo Yan leo.yan@linaro.org wrote:
Hi Mathieu,
On Wed, May 15, 2019 at 02:36:29PM -0600, Mathieu Poirier wrote:
On Mon, 6 May 2019 at 03:41, Leo Yan leo.yan@linaro.org wrote:
This patch adds two testings for 'perf report' command.
The first testing is a general report testing with branch samples, the second testing is to use option '--itrace=i1000i' to insert synthesized instructions events and the script will check if perf can output the percentage value successfully based on the instruction samples.
Signed-off-by: Leo Yan leo.yan@linaro.org
...etm.sh => record+script+report_arm_cs_etm.sh} | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) rename tools/perf/tests/shell/{record+script_arm_cs_etm.sh => record+script+report_arm_cs_etm.sh} (79%)
Wouldn't it be better to just name the script "test_arm_coresight.sh" so that we can make any changes we want to it without having to rethink the name every time?
Will fix it.
diff --git a/tools/perf/tests/shell/record+script_arm_cs_etm.sh b/tools/perf/tests/shell/record+script+report_arm_cs_etm.sh similarity index 79% rename from tools/perf/tests/shell/record+script_arm_cs_etm.sh rename to tools/perf/tests/shell/record+script+report_arm_cs_etm.sh index 108604984867..ea053ed4bbb1 100755 --- a/tools/perf/tests/shell/record+script_arm_cs_etm.sh +++ b/tools/perf/tests/shell/record+script+report_arm_cs_etm.sh @@ -31,6 +31,18 @@ perf_script_branch_samples() { egrep " +touch +[0-9]+ .* +branches: +" }
+perf_report_branch_samples() {
echo "Looking at perf.data file for reporting branch samples:"
perf report --stdio -i ${perfdata} | \
egrep " +[0-9]+\.[0-9]+% +[0-9]+\.[0-9]+% +touch "
Please document the the 'egrep' is looking for with an example of the 'report' output.
Will add.
+}
+perf_report_instruction_samples() {
echo "Looking at perf.data file for instruction samples:"
perf report --itrace=i1000i --stdio -i ${perfdata} | \
egrep " +[0-9]+\.[0-9]+% +touch"
Same here. You should also consider merging the patches together.
Will add the example output and merge two patches.
I tested this and things work quite well.
Thanks a lot for reviewing and testing!
Will wait for a bit time in case others have more suggestion for this, then I will send patch to LKML for wider reviewing.
For now there is no point in making this public on LKML since the topology information in sysfs isn't completely settled. Mike and Suzuki are currently working on finding a representation that will be suitable for both data and signal components. In the mean time I suggest you rebase your work on 5.2-rc1 when it comes out and send another revision that addresses the above comment. I would also prepare a branch for people to clone and test.
Mathieu
Thanks, Leo Yan