A patch series improving data quality of perf test for CoreSight
Subsystems (3)
v5 cover A patch series improving data quality of perf test for CoreSight
From: "Carsten Haitzler (Rasterman)" <[email protected]>
This is a prelude to adding more tests to shell tests and in order to support putting those tests into subdirectories, I need to change the test code that scans/finds and runs them.
To support subdirs I have to recurse so it's time to refactor the code to allow this and centralize the shell script finding into one location and only one single scan that builds a list of all the found tests in memory instead of it being duplicated in 3 places.
This code also optimizes things like knowing the max width of desciption strings (as we can do that while we scan instead of a whole new pass of opening files). It also more cleanly filters scripts to see only *.sh files thus skipping random other files in directories like *~ backup files, other random junk/data files that may appear and the scripts must be executable to make the cut (this ensures the script lib dir is not seen as scripts to run). This avoids perf test running previous older versions of test scripts that are editor backup files as well as skipping perf.data files that may appear and so on.
Carsten Haitzler (Rasterman) (14):
perf test: Refactor shell tests allowing subdirs
perf test: Add CoreSight shell lib shared code for future tests perf test: Add build infra for perf test tools for CoreSight tests perf test: Add asm pureloop test tool
perf test: Add asm pureloop test shell script
perf test: Add git ignore for perf data generated by the CoreSight
tests
perf test: Add memcpy thread test tool
perf test: Add memcpy thread test shell script
perf test: Add thread loop test tool
perf test: Add thread loop test shell scripts
perf test: Add unroll thread test tool
perf test: Add unroll thread test shell script
perf test: Add git ignore for tmp and output files of CoreSight tests perf test: Add relevant documentation about CoreSight testing
.../trace/coresight/coresight-perf.rst | 160 ++++++++++++++ MAINTAINERS | 1 + tools/perf/.gitignore | 6 +- tools/perf/Documentation/arm-coresight.txt | 5 + tools/perf/Makefile.perf | 18 +- tools/perf/tests/Build | 1 + tools/perf/tests/builtin-test-list.c | 207 ++++++++++++++++++ tools/perf/tests/builtin-test-list.h | 12 + tools/perf/tests/builtin-test.c | 152 ++----------- tools/perf/tests/shell/coresight/Makefile | 30 +++ .../tests/shell/coresight/Makefile.miniconfig | 24 ++ .../tests/shell/coresight/asm_pure_loop.sh | 18 ++ .../shell/coresight/asm_pure_loop/.gitignore | 1 + .../shell/coresight/asm_pure_loop/Makefile | 34 +++ .../coresight/asm_pure_loop/asm_pure_loop.S | 28 +++ .../shell/coresight/memcpy_thread/.gitignore | 1 + .../shell/coresight/memcpy_thread/Makefile | 33 +++ .../coresight/memcpy_thread/memcpy_thread.c | 79 +++++++ .../shell/coresight/memcpy_thread_16k_10.sh | 18 ++ .../shell/coresight/thread_loop/.gitignore | 1 + .../shell/coresight/thread_loop/Makefile | 33 +++ .../shell/coresight/thread_loop/thread_loop.c | 86 ++++++++ .../coresight/thread_loop_check_tid_10.sh | 19 ++ .../coresight/thread_loop_check_tid_2.sh | 19 ++ .../coresight/unroll_loop_thread/.gitignore | 1 + .../coresight/unroll_loop_thread/Makefile | 33 +++ .../unroll_loop_thread/unroll_loop_thread.c | 74 +++++++ .../shell/coresight/unroll_loop_thread_10.sh | 18 ++ tools/perf/tests/shell/lib/coresight.sh | 132 +++++++++++ 29 files changed, 1105 insertions(+), 139 deletions(-) create mode 100644 Documentation/trace/coresight/coresight-perf.rst create mode 100644 tools/perf/Documentation/arm-coresight.txt create mode 100644 tools/perf/tests/builtin-test-list.c create mode 100644 tools/perf/tests/builtin-test-list.h create mode 100644 tools/perf/tests/shell/coresight/Makefile create mode 100644 tools/perf/tests/shell/coresight/Makefile.miniconfig create mode 100755 tools/perf/tests/shell/coresight/asm_pure_loop.sh create mode 100644 tools/perf/tests/shell/coresight/asm_pure_loop/.gitignore create mode 100644 tools/perf/tests/shell/coresight/asm_pure_loop/Makefile create mode 100644 tools/perf/tests/shell/coresight/asm_pure_loop/asm_pure_loop.S create mode 100644 tools/perf/tests/shell/coresight/memcpy_thread/.gitignore create mode 100644 tools/perf/tests/shell/coresight/memcpy_thread/Makefile create mode 100644 tools/perf/tests/shell/coresight/memcpy_thread/memcpy_thread.c create mode 100755 tools/perf/tests/shell/coresight/memcpy_thread_16k_10.sh create mode 100644 tools/perf/tests/shell/coresight/thread_loop/.gitignore create mode 100644 tools/perf/tests/shell/coresight/thread_loop/Makefile create mode 100644 tools/perf/tests/shell/coresight/thread_loop/thread_loop.c create mode 100755 tools/perf/tests/shell/coresight/thread_loop_check_tid_10.sh create mode 100755 tools/perf/tests/shell/coresight/thread_loop_check_tid_2.sh create mode 100644 tools/perf/tests/shell/coresight/unroll_loop_thread/.gitignore create mode 100644 tools/perf/tests/shell/coresight/unroll_loop_thread/Makefile create mode 100644 tools/perf/tests/shell/coresight/unroll_loop_thread/unroll_loop_thread.c create mode 100755 tools/perf/tests/shell/coresight/unroll_loop_thread_10.sh create mode 100644 tools/perf/tests/shell/lib/coresight.sh
Signature · 1 line
2.32.0
PATCH v5 1/14 perf test: Refactor shell tests allowing subdirs
From: "Carsten Haitzler (Rasterman)" <[email protected]>
This is a prelude to adding more tests to shell tests and in order to support putting those tests into subdirectories, I need to change the test code that scans/finds and runs them.
To support subdirs I have to recurse so it's time to refactor the code to allow this and centralize the shell script finding into one location and only one single scan that builds a list of all the found tests in memory instead of it being duplicated in 3 places.
This code also optimizes things like knowing the max width of desciption strings (as we can do that while we scan instead of a whole new pass of opening files). It also more cleanly filters scripts to see only *.sh files thus skipping random other files in directories like *~ backup files, other random junk/data files that may appear and the scripts must be executable to make the cut (this ensures the script lib dir is not seen as scripts to run). This avoids perf test running previous older versions of test scripts that are editor backup files as well as skipping perf.data files that may appear and so on.
--- tools/perf/tests/Build | 1 + tools/perf/tests/builtin-test-list.c | 207 +++++++++++++++++++++++++++ tools/perf/tests/builtin-test-list.h | 12 ++ tools/perf/tests/builtin-test.c | 152 +++----------------- 4 files changed, 238 insertions(+), 134 deletions(-) create mode 100644 tools/perf/tests/builtin-test-list.c create mode 100644 tools/perf/tests/builtin-test-list.h
tools/perf/tests/Build +1 -0
@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 perf-y += builtin-test.o +perf-y += builtin-test-list.o perf-y += parse-events.o perf-y += dso-data.o perf-y += attr.o
tools/perf/tests/builtin-test-list.c new file +207 -0
207 lines not on this page · raw message
tools/perf/tests/builtin-test-list.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +struct script_file { +char *dir; +char *file; +char *desc; +}; + +/* List available script tests to run - singleton - never freed */ +const struct script_file *list_script_files (void ); +/* Get maximum width of description string */ +int list_script_max_width (void );
tools/perf/tests/builtin-test.c +18 -134
213 lines not on this page · raw message
Signature · 1 line
2.32.0
Re: [PATCH v5 01/14] perf test: Refactor shell tests allowing subdirs
On Thu, Jul 28, 2022 at 03:52:43PM +0100, [email protected] wrote:
[...]
tools/perf/tests/builtin-test-list.c line 205
Quoted 3 lines
tools/perf/tests/builtin-test-list.c new file +3
-0+int list_script_max_width (void ) +{ +list_script_files ();/* Ensure we have scanned all scriptd */
s/scriptd/scripts/
Quoted 2 lines
tools/perf/tests/builtin-test-list.c new file +2
-0+return files_max_width; +}
[...]
Quoted 46 lines
struct
shell_test{tools/perf/tests/builtin-test.c +7
-23const char *dir;const char *file;@@ -385,33 +302,17 @@ static int shell_test__run(struct test_suite *test, int subdir __maybe_unused)static int run_shell_tests (int argc,const char *argv[],int i,int width,struct intlist *skiplist) { -struct dirent **entlist; -struct dirent *ent; -int n_dirs, e; -char path_dir[PATH_MAX ]; -struct shell_test st = { - .dir =shell_tests__dir (path_dir,sizeof (path_dir)), - }; - -if (st.dir ==NULL ) -return -1 ; +struct shell_test st; +const struct script_file *files, *file; - n_dirs =scandir (st.dir, &entlist,NULL , alphasort); -if (n_dirs ==-1 ) { -pr_err ("failed to open shell test directory: %s\n" , - st.dir); -return -1 ; - } - -for_each_shell_test (entlist, n_dirs, st.dir, ent) { + files =list_script_files (); +if (!files) +return 0 ; +for (file = files; file->dir; file++) {int curr = i++; -char desc[256 ];struct test_case test_cases[] = { { - .desc =shell_test__description (desc, -sizeof (desc), - st.dir, - ent->d_name), + .desc = file->desc, .run_case = shell_test__run, }, { .name = NULL, }@@ -421,12 +322,13 @@ static int run_shell_tests(int argc, const char *argv[], int i, int width, .test_cases = test_cases,
tools/perf/tests/builtin-test.c static int run_shell_tests(int argc, const char *argv[], int i, int width, · line 331
Quoted 10 lines
tools/perf/tests/builtin-test.c +2
-1.priv = &st, }; + st.dir = file->dir;if (test_suite.desc ==NULL || !perf_test__matches (test_suite.desc, curr, argc, argv))continue ; - st.file = ent->d_name; + st.file = file->file;
I am just wandering if we can remove "st" in this function, finally I found you are right, the "st" (struct shell_test) will be used in the function shell_test__run(), so let's keep as it is.
Quoted 55 lines
tools/perf/tests/builtin-test.c +7
-20pr_info ("%3d: %-*s:" , i, width, test_suite.desc);if (intlist__find (skiplist, i)) {@@ -436,10 +338,6 @@ static int run_shell_tests(int argc, const char *argv[], int i, int width,test_and_print (&test_suite,0 ); } - -for (e =0 ; e < n_dirs; e++) -zfree (&entlist[e]); -free (entlist);return 0 ; }@@ -448,7 +346,7 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)struct test_suite *t;unsigned int j, k;int i =0 ; -int width =shell_tests__max_desc_width (); +int width =list_script_max_width ();for_each_test (j, k, t) {int len =strlen (test_description (t,-1 ));@@ -529,36 +427,22 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)static int perf_test__list_shell (int argc,const char **argv,int i) { -struct dirent **entlist; -struct dirent *ent; -int n_dirs, e; -char path_dir[PATH_MAX ]; -const char *path =shell_tests__dir (path_dir,sizeof (path_dir)); - -if (path ==NULL ) -return -1 ; +const struct script_file *files, *file; - n_dirs =scandir (path, &entlist,NULL , alphasort); -if (n_dirs ==-1 ) -return -1 ; - -for_each_shell_test (entlist, n_dirs, path, ent) { + files =list_script_files (); +if (!files) +return 0 ; +for (file = files; file->dir; file++) {int curr = i++; -char bf[256 ];struct test_suite t = { - .desc =shell_test__description (bf,sizeof (bf), path, ent->d_name), + .desc = file->desc };if (!perf_test__matches (t.desc, curr, argc, argv))continue ;
tools/perf/tests/builtin-test.c static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) · line 447
Quoted 10 lines
tools/perf/tests/builtin-test.c +0
-5pr_info ("%3d: %s\n" , i, t.desc); - } - -for (e =0 ; e < n_dirs; e++) -zfree (&entlist[e]); -free (entlist);return 0 ; }
Except a minor typo, the patch looks good to me, it's a good refactoring and enhancement for shell script testing.
I reviewed the change one by one line, at least I cannot find any logic error.
With typo fixing:
I'd leave this patch for maintainers to review it. Just a caveat, given it's a big patch, as Carsten replied it's good that take the patch as a total new code for searching shell scripts, this would be easier for understanding the change.
Thanks,
Leo
Re: [PATCH v5 01/14] perf test: Refactor shell tests allowing subdirs
Quoted 9 lines · Leo Yan
On Thu, Jul 28, 2022 at 03:52:43PM +0100, [email protected] wrote:
[...]
tools/perf/tests/builtin-test-list.c line 205
Quoted 3 lines
tools/perf/tests/builtin-test-list.c new file +3
-0+int list_script_max_width (void ) +{ +list_script_files ();/* Ensure we have scanned all scriptd */ s/scriptd/scripts/
oops. fixed. v6 will come with that.
Quoted 149 lines
Quoted 2 lines
tools/perf/tests/builtin-test-list.c new file +2
-0+return files_max_width; +}[...]
Quoted 46 lines
struct shell_test { const char *dir; const char *file;tools/perf/tests/builtin-test.c +7
-23@@ -385,33 +302,17 @@ static int shell_test__run(struct test_suite *test, int subdir __maybe_unused)static int run_shell_tests (int argc,const char *argv[],int i,int width,struct intlist *skiplist) { -struct dirent **entlist; -struct dirent *ent; -int n_dirs, e; -char path_dir[PATH_MAX ]; -struct shell_test st = { - .dir =shell_tests__dir (path_dir,sizeof (path_dir)), - }; - -if (st.dir ==NULL ) -return -1 ; +struct shell_test st; +const struct script_file *files, *file; - n_dirs =scandir (st.dir, &entlist,NULL , alphasort); -if (n_dirs ==-1 ) { -pr_err ("failed to open shell test directory: %s\n" , - st.dir); -return -1 ; - } - -for_each_shell_test (entlist, n_dirs, st.dir, ent) { + files =list_script_files (); +if (!files) +return 0 ; +for (file = files; file->dir; file++) {int curr = i++; -char desc[256 ];struct test_case test_cases[] = { { - .desc =shell_test__description (desc, -sizeof (desc), - st.dir, - ent->d_name), + .desc = file->desc, .run_case = shell_test__run, }, { .name = NULL, }@@ -421,12 +322,13 @@ static int run_shell_tests(int argc, const char *argv[], int i, int width, .test_cases = test_cases,tools/perf/tests/builtin-test.c static int run_shell_tests(int argc, const char *argv[], int i, int width, · line 331
Quoted 10 lines
tools/perf/tests/builtin-test.c +2
-1.priv = &st, }; + st.dir = file->dir;if (test_suite.desc ==NULL || !perf_test__matches (test_suite.desc, curr, argc, argv))continue ; - st.file = ent->d_name; + st.file = file->file;I am just wandering if we can remove "st" in this function, finally I found you are right, the "st" (struct
shell_test) will be used in the functionshell_test__run(), so let's keep as it is.Quoted 55 lines
tools/perf/tests/builtin-test.c +7
-20pr_info ("%3d: %-*s:" , i, width, test_suite.desc);if (intlist__find (skiplist, i)) {@@ -436,10 +338,6 @@ static int run_shell_tests(int argc, const char *argv[], int i, int width,test_and_print (&test_suite,0 ); } - -for (e =0 ; e < n_dirs; e++) -zfree (&entlist[e]); -free (entlist);return 0 ; }@@ -448,7 +346,7 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)struct test_suite *t;unsigned int j, k;int i =0 ; -int width =shell_tests__max_desc_width (); +int width =list_script_max_width ();for_each_test (j, k, t) {int len =strlen (test_description (t,-1 ));@@ -529,36 +427,22 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)static int perf_test__list_shell (int argc,const char **argv,int i) { -struct dirent **entlist; -struct dirent *ent; -int n_dirs, e; -char path_dir[PATH_MAX ]; -const char *path =shell_tests__dir (path_dir,sizeof (path_dir)); - -if (path ==NULL ) -return -1 ; +const struct script_file *files, *file; - n_dirs =scandir (path, &entlist,NULL , alphasort); -if (n_dirs ==-1 ) -return -1 ; - -for_each_shell_test (entlist, n_dirs, path, ent) { + files =list_script_files (); +if (!files) +return 0 ; +for (file = files; file->dir; file++) {int curr = i++; -char bf[256 ];struct test_suite t = { - .desc =shell_test__description (bf,sizeof (bf), path, ent->d_name), + .desc = file->desc };if (!perf_test__matches (t.desc, curr, argc, argv))continue ;tools/perf/tests/builtin-test.c static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) · line 447
Quoted 10 lines
tools/perf/tests/builtin-test.c +0
-5pr_info ("%3d: %s\n" , i, t.desc); - } - -for (e =0 ; e < n_dirs; e++) -zfree (&entlist[e]); -free (entlist);return 0 ; }Except a minor typo, the patch looks good to me, it's a good refactoring and enhancement for shell script testing.
I reviewed the change one by one line, at least I cannot find any logic error.
With typo fixing:
Reviewed-by Leo Yan <[email protected]>I'd leave this patch for maintainers to review it. Just a caveat, given it's a big patch, as Carsten replied it's good that take the patch as a total new code for searching shell scripts, this would be easier for understanding the change.
Thanks,
Leo
PATCH v5 2/14 perf test: Add CoreSight shell lib shared code for future tests
In reply to [email protected]From: "Carsten Haitzler (Rasterman)" <[email protected]>
This adds a library of shell "code" to be shared and used by future tests that target quality testing for Arm CoreSight support in perf and the Linux kernel.
--- tools/perf/tests/shell/lib/coresight.sh | 132 ++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 tools/perf/tests/shell/lib/coresight.sh
tools/perf/tests/shell/lib/coresight.sh new file +132 -0
@@ -0,0 +1,132 @@ +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <[email protected]>, 2021 + +# This is sourced from a driver script so no need for #!/bin... etc. at the +# top - the assumption below is that it runs as part of sourcing after the +# test sets up some basic env vars to say what it is. + +# This currently works with ETMv4 / ETF not any other packet types at thi +# point. This will need changes if that changes. + +# perf record options for the perf tests to use +PERFRECMEM="-m ,16M" +PERFRECOPT="$PERFRECMEM -e cs_etm//u" + +TOOLS=$(dirname $0) +DIR="$TOOLS/$TEST" +BIN="$DIR/$TEST" +# If the test tool/binary does not exist and is executable then skip the test +if ! test -x "$BIN"; then exit 2; fi +DATD="." +# If the data dir env is set then make the data dir use that instead of ./ +if test -n "$PERF_TEST_CORESIGHT_DATADIR"; then + DATD="$PERF_TEST_CORESIGHT_DATADIR"; +fi +# If the stat dir env is set then make the data dir use that instead of ./ +STATD="." +if test -n "$PERF_TEST_CORESIGHT_STATDIR"; then + STATD="$PERF_TEST_CORESIGHT_STATDIR"; +fi + +# Called if the test fails - error code 1 +err() { + echo "$1" + exit 1 +} + +# Check that some statistics from our perf +check_val_min() { + STATF="$4" + if test "$2" -lt "$3"; then + echo ", FAILED" >> "$STATF" + err "Sanity check number of $1 is too low ($2 < $3)" + fi +} + +perf_dump_aux_verify() { + # Some basic checking that the AUX chunk contains some sensible data + # to see that we are recording something and at least a minimum + # amount of it. We should almost always see Fn packets in just about + # anything but certainly we will see some trace info and async + # packets + DUMP="$DATD/perf-tmp-aux-dump.txt" + perf report --stdio --dump -i "$1" | \ + grep -o -e I_ATOM_F -e I_ASYNC -e I_TRACE_INFO > "$DUMP" + # Simply count how many of these packets we find to see that we are + # producing a reasonable amount of data - exact checks are not sane + # as this is a lossy process where we may lose some blocks and the + # compiler may produce different code depending on the compiler and + # optimization options, so this is rough just to see if we're + # either missing almost all the data or all of it + ATOM_FX_NUM=`grep I_ATOM_F "$DUMP" | wc -l` + ASYNC_NUM=`grep I_ASYNC "$DUMP" | wc -l` + TRACE_INFO_NUM=`grep I_TRACE_INFO "$DUMP" | wc -l` + rm -f "$DUMP" + + # Arguments provide minimums for a pass + CHECK_FX_MIN="$2" + CHECK_ASYNC_MIN="$3" + CHECK_TRACE_INFO_MIN="$4" + + # Write out statistics, so over time you can track results to see if + # there is a pattern - for example we have less "noisy" results that + # produce more consistent amounts of data each run, to see if over + # time any techinques to minimize data loss are having an effect or + # not + STATF="$STATD/stats-$TEST-$DATV.csv" + if ! test -f "$STATF"; then + echo "ATOM Fx Count, Minimum, ASYNC Count, Minimum, TRACE INFO Count, Minimum" > "$STATF" + fi + echo -n "$ATOM_FX_NUM, $CHECK_FX_MIN, $ASYNC_NUM, $CHECK_ASYNC_MIN, $TRACE_INFO_NUM, $CHECK_TRACE_INFO_MIN" >> "$STATF" + + # Actually check to see if we passed or failed. + check_val_min "ATOM_FX" "$ATOM_FX_NUM" "$CHECK_FX_MIN" "$STATF" + check_val_min "ASYNC" "$ASYNC_NUM" "$CHECK_ASYNC_MIN" "$STATF" + check_val_min "TRACE_INFO" "$TRACE_INFO_NUM" "$CHECK_TRACE_INFO_MIN" "$STATF" + echo ", Ok" >> "$STATF" +} + +perf_dump_aux_tid_verify() { + # Specifically crafted test will produce a list of Tread ID's to + # stdout that need to be checked to see that they have had trace + # info collected in AUX blocks in the perf data. This will go + # through all the TID's that are listed as CID=0xabcdef and see + # that all the Thread IDs the test tool reports are in the perf + # data AUX chunks + + # The TID test tools will print a TID per stdout line that are being + # tested + TIDS=`cat "$2"` + # Scan the perf report to find the TIDs that are actually CID in hex + # and build a list of the ones found + FOUND_TIDS=`perf report --stdio --dump -i "$1" | \ + grep -o "CID=0x[0-9a-z]\+" | sed 's/CID=//g' | \ + uniq | sort | uniq` + # No CID=xxx found - maybe your kernel is reporting these as + # VMID=xxx so look there + if test -z "$FOUND_TIDS"; then + FOUND_TIDS=`perf report --stdio --dump -i "$1" | \ + grep -o "VMID=0x[0-9a-z]\+" | sed 's/VMID=//g' | \ + uniq | sort | uniq` + fi + + # Iterate over the list of TIDs that the test says it has and find + # them in the TIDs found in the perf report + MISSING="" + for TID2 in $TIDS; do + FOUND="" + for TIDHEX in $FOUND_TIDS; do + TID=`printf "%i" $TIDHEX` + if test "$TID" -eq "$TID2"; then + FOUND="y" + break + fi + done + if test -z "$FOUND"; then + MISSING="$MISSING $TID" + fi + done + if test -n "$MISSING"; then + err "Thread IDs $MISSING not found in perf AUX data" + fi +}
Signature · 1 line
2.32.0
Re: [PATCH v5 02/14] perf test: Add CoreSight shell lib shared code for future tests
tools/perf/tests/shell/lib/coresight.sh
Quoted 14 lines · On Thu, Jul 28, 2022 at 03:52:44PM +0100, [email protected] wrote:
From: "Carsten Haitzler (Rasterman)" <[email protected]>
This adds a library of shell "code" to be shared and used by future tests that target quality testing for Arm CoreSight support in perf and the Linux kernel.
Signed-off-by Carsten Haitzler <[email protected]>--- tools/perf/tests/shell/lib/coresight.sh | 132 ++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 tools/perf/tests/shell/lib/coresight.shtools/perf/tests/shell/lib/coresight.sh new file +0
-0
Now one thing is tricky. Since we scan sub directories, all scripts under the folder "tools/perf/tests/shell/lib/" are not added into the test list, this is because the scripts under this folder have no the executable (X) permission:
-rw-rw-r-- 1 leoy leoy 4675 Aug 6 17:03 coresight.sh -rw-rw-r-- 1 leoy leoy 329 Jul 27 09:37 probe.sh -rw-rw-r-- 1 leoy leoy 812 Jul 27 09:37 probe_vfs_getname.sh
I verified with command "perf list" and it works as expected.
Quoted 105 lines
index 000000000000..45a1477256b6
tools/perf/tests/shell/lib/coresight.sh new file +101
-0@@ -0,0 +1,132 @@ +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <[email protected]>, 2021 + +# This is sourced from a driver script so no need for #!/bin... etc. at the +# top - the assumption below is that it runs as part of sourcing after the +# test sets up some basic env vars to say what it is. + +# This currently works with ETMv4 / ETF not any other packet types at thi +# point. This will need changes if that changes. + +# perf record options for the perf tests to use +PERFRECMEM="-m ,16M" +PERFRECOPT="$PERFRECMEM -e cs_etm//u" + +TOOLS=$(dirname $0) +DIR="$TOOLS/$TEST" +BIN="$DIR/$TEST" +# If the test tool/binary does not exist and is executable then skip the test +if ! test -x "$BIN"; then exit 2; fi +DATD="." +# If the data dir env is set then make the data dir use that instead of ./ +if test -n "$PERF_TEST_CORESIGHT_DATADIR"; then + DATD="$PERF_TEST_CORESIGHT_DATADIR"; +fi +# If the stat dir env is set then make the data dir use that instead of ./ +STATD="." +if test -n "$PERF_TEST_CORESIGHT_STATDIR"; then + STATD="$PERF_TEST_CORESIGHT_STATDIR"; +fi + +# Called if the test fails - error code 1 +err() { + echo "$1" + exit 1 +} + +# Check that some statistics from our perf +check_val_min() { + STATF="$4" + if test "$2" -lt "$3"; then + echo ", FAILED" >> "$STATF" + err "Sanity check number of $1 is too low ($2 < $3)" + fi +} + +perf_dump_aux_verify() { + # Some basic checking that the AUX chunk contains some sensible data + # to see that we are recording something and at least a minimum + # amount of it. We should almost always see Fn packets in just about + # anything but certainly we will see some trace info and async + # packets + DUMP="$DATD/perf-tmp-aux-dump.txt" + perf report --stdio --dump -i "$1" | \ + grep -o -e I_ATOM_F -e I_ASYNC -e I_TRACE_INFO > "$DUMP" + # Simply count how many of these packets we find to see that we are + # producing a reasonable amount of data - exact checks are not sane + # as this is a lossy process where we may lose some blocks and the + # compiler may produce different code depending on the compiler and + # optimization options, so this is rough just to see if we're + # either missing almost all the data or all of it + ATOM_FX_NUM=`grep I_ATOM_F "$DUMP" | wc -l` + ASYNC_NUM=`grep I_ASYNC "$DUMP" | wc -l` + TRACE_INFO_NUM=`grep I_TRACE_INFO "$DUMP" | wc -l` + rm -f "$DUMP" + + # Arguments provide minimums for a pass + CHECK_FX_MIN="$2" + CHECK_ASYNC_MIN="$3" + CHECK_TRACE_INFO_MIN="$4" + + # Write out statistics, so over time you can track results to see if + # there is a pattern - for example we have less "noisy" results that + # produce more consistent amounts of data each run, to see if over + # time any techinques to minimize data loss are having an effect or + # not + STATF="$STATD/stats-$TEST-$DATV.csv" + if ! test -f "$STATF"; then + echo "ATOM Fx Count, Minimum, ASYNC Count, Minimum, TRACE INFO Count, Minimum" > "$STATF" + fi + echo -n "$ATOM_FX_NUM, $CHECK_FX_MIN, $ASYNC_NUM, $CHECK_ASYNC_MIN, $TRACE_INFO_NUM, $CHECK_TRACE_INFO_MIN" >> "$STATF" + + # Actually check to see if we passed or failed. + check_val_min "ATOM_FX" "$ATOM_FX_NUM" "$CHECK_FX_MIN" "$STATF" + check_val_min "ASYNC" "$ASYNC_NUM" "$CHECK_ASYNC_MIN" "$STATF" + check_val_min "TRACE_INFO" "$TRACE_INFO_NUM" "$CHECK_TRACE_INFO_MIN" "$STATF" + echo ", Ok" >> "$STATF" +} + +perf_dump_aux_tid_verify() { + # Specifically crafted test will produce a list of Tread ID's to + # stdout that need to be checked to see that they have had trace + # info collected in AUX blocks in the perf data. This will go + # through all the TID's that are listed as CID=0xabcdef and see + # that all the Thread IDs the test tool reports are in the perf + # data AUX chunks + + # The TID test tools will print a TID per stdout line that are being + # tested + TIDS=`cat "$2"` + # Scan the perf report to find the TIDs that are actually CID in hex + # and build a list of the ones found
tools/perf/tests/shell/lib/coresight.sh line 111
Quoted 10 lines
tools/perf/tests/shell/lib/coresight.sh new file +10
-0+ FOUND_TIDS=`perf report --stdio --dump -i "$1" | \ + grep -o "CID=0x[0-9a-z]\+" | sed 's/CID=//g' | \ + uniq | sort | uniq` + # No CID=xxx found - maybe your kernel is reporting these as + # VMID=xxx so look there + if test -z "$FOUND_TIDS"; then + FOUND_TIDS=`perf report --stdio --dump -i "$1" | \ + grep -o "VMID=0x[0-9a-z]\+" | sed 's/VMID=//g' | \ + uniq | sort | uniq` + fi
Just note, in theory we can check perf meta data and decide if use VMID or CID as thread ID in the trace data. But perf meta data doesn't give direct info and need to parse the "TRCIDR2" field, this would introduce complexity.
Current approach is simple, so let's keep it.
Quoted 11 lines
tools/perf/tests/shell/lib/coresight.sh new file +11
-0+ + # Iterate over the list of TIDs that the test says it has and find + # them in the TIDs found in the perf report + MISSING="" + for TID2 in $TIDS; do + FOUND="" + for TIDHEX in $FOUND_TIDS; do + TID=`printf "%i" $TIDHEX` + if test "$TID" -eq "$TID2"; then + FOUND="y" + break
tools/perf/tests/shell/lib/coresight.sh line 132
Quoted 10 lines
tools/perf/tests/shell/lib/coresight.sh new file +10
-0+ fi + done + if test -z "$FOUND"; then + MISSING="$MISSING $TID" + fi + done + if test -n "$MISSING"; then + err "Thread IDs $MISSING not found in perf AUX data" + fi +}
The patch LGTM:
Quoted 3 lines
Signature · 1 line
2.32.0
Re: [PATCH v5 02/14] perf test: Add CoreSight shell lib shared code for future tests
Quoted 25 lines · Leo Yan
tools/perf/tests/shell/lib/coresight.sh
Quoted 14 lines · On Thu, Jul 28, 2022 at 03:52:44PM +0100, [email protected] wrote:
From: "Carsten Haitzler (Rasterman)" <[email protected]>
This adds a library of shell "code" to be shared and used by future tests that target quality testing for Arm CoreSight support in perf and the Linux kernel.
Signed-off-by Carsten Haitzler <[email protected]>--- tools/perf/tests/shell/lib/coresight.sh | 132 ++++++++++++++++++++++++ 1 file changed, 132 insertions(+)create mode 100644
tools/perf/tests/shell/lib/coresight.shtools/perf/tests/shell/lib/coresight.sh new file +0
-0Now one thing is tricky. Since we scan sub directories, all scripts under the folder "
tools/perf/tests/shell/lib/" are not added into the test list, this is because the scripts under this folder have no the executable (X) permission:(quoted diff) +0
-3-rw-rw-r-- 1 leoy leoy 4675 Aug 6 17:03 coresight.sh -rw-rw-r-- 1 leoy leoy 329 Jul 27 09:37 probe.sh -rw-rw-r-- 1 leoy leoy 812 Jul 27 09:37 probe_vfs_getname.sh
Quoted 1 line
I verified with command "perf list" and it works as expected.
Correct. the code takes advantage of this and skips things that are not +x as these will be assumed to be "library files".
Quoted 121 lines
Quoted 105 lines
index 000000000000..45a1477256b6
tools/perf/tests/shell/lib/coresight.sh new file +101
-0@@ -0,0 +1,132 @@ +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <[email protected]>, 2021 + +# This is sourced from a driver script so no need for #!/bin... etc. at the +# top - the assumption below is that it runs as part of sourcing after the +# test sets up some basic env vars to say what it is. + +# This currently works with ETMv4 / ETF not any other packet types at thi +# point. This will need changes if that changes. + +# perf record options for the perf tests to use +PERFRECMEM="-m ,16M" +PERFRECOPT="$PERFRECMEM -e cs_etm//u" + +TOOLS=$(dirname $0) +DIR="$TOOLS/$TEST" +BIN="$DIR/$TEST" +# If the test tool/binary does not exist and is executable then skip the test +if ! test -x "$BIN"; then exit 2; fi +DATD="." +# If the data dir env is set then make the data dir use that instead of ./ +if test -n "$PERF_TEST_CORESIGHT_DATADIR"; then + DATD="$PERF_TEST_CORESIGHT_DATADIR"; +fi +# If the stat dir env is set then make the data dir use that instead of ./ +STATD="." +if test -n "$PERF_TEST_CORESIGHT_STATDIR"; then + STATD="$PERF_TEST_CORESIGHT_STATDIR"; +fi + +# Called if the test fails - error code 1 +err() { + echo "$1" + exit 1 +} + +# Check that some statistics from our perf +check_val_min() { + STATF="$4" + if test "$2" -lt "$3"; then + echo ", FAILED" >> "$STATF" + err "Sanity check number of $1 is too low ($2 < $3)" + fi +} + +perf_dump_aux_verify() { + # Some basic checking that the AUX chunk contains some sensible data + # to see that we are recording something and at least a minimum + # amount of it. We should almost always see Fn packets in just about + # anything but certainly we will see some trace info and async + # packets + DUMP="$DATD/perf-tmp-aux-dump.txt" + perf report --stdio --dump -i "$1" | \ + grep -o -e I_ATOM_F -e I_ASYNC -e I_TRACE_INFO > "$DUMP" + # Simply count how many of these packets we find to see that we are + # producing a reasonable amount of data - exact checks are not sane + # as this is a lossy process where we may lose some blocks and the + # compiler may produce different code depending on the compiler and + # optimization options, so this is rough just to see if we're + # either missing almost all the data or all of it + ATOM_FX_NUM=`grep I_ATOM_F "$DUMP" | wc -l` + ASYNC_NUM=`grep I_ASYNC "$DUMP" | wc -l` + TRACE_INFO_NUM=`grep I_TRACE_INFO "$DUMP" | wc -l` + rm -f "$DUMP" + + # Arguments provide minimums for a pass + CHECK_FX_MIN="$2" + CHECK_ASYNC_MIN="$3" + CHECK_TRACE_INFO_MIN="$4" + + # Write out statistics, so over time you can track results to see if + # there is a pattern - for example we have less "noisy" results that + # produce more consistent amounts of data each run, to see if over + # time any techinques to minimize data loss are having an effect or + # not + STATF="$STATD/stats-$TEST-$DATV.csv" + if ! test -f "$STATF"; then + echo "ATOM Fx Count, Minimum, ASYNC Count, Minimum, TRACE INFO Count, Minimum" > "$STATF" + fi + echo -n "$ATOM_FX_NUM, $CHECK_FX_MIN, $ASYNC_NUM, $CHECK_ASYNC_MIN, $TRACE_INFO_NUM, $CHECK_TRACE_INFO_MIN" >> "$STATF" + + # Actually check to see if we passed or failed. + check_val_min "ATOM_FX" "$ATOM_FX_NUM" "$CHECK_FX_MIN" "$STATF" + check_val_min "ASYNC" "$ASYNC_NUM" "$CHECK_ASYNC_MIN" "$STATF" + check_val_min "TRACE_INFO" "$TRACE_INFO_NUM" "$CHECK_TRACE_INFO_MIN" "$STATF" + echo ", Ok" >> "$STATF" +} + +perf_dump_aux_tid_verify() { + # Specifically crafted test will produce a list of Tread ID's to + # stdout that need to be checked to see that they have had trace + # info collected in AUX blocks in the perf data. This will go + # through all the TID's that are listed as CID=0xabcdef and see + # that all the Thread IDs the test tool reports are in the perf + # data AUX chunks + + # The TID test tools will print a TID per stdout line that are being + # tested + TIDS=`cat "$2"` + # Scan the perf report to find the TIDs that are actually CID in hex + # and build a list of the ones foundtools/perf/tests/shell/lib/coresight.sh line 111
Quoted 10 lines
tools/perf/tests/shell/lib/coresight.sh new file +10
-0+ FOUND_TIDS=`perf report --stdio --dump -i "$1" | \ + grep -o "CID=0x[0-9a-z]\+" | sed 's/CID=//g' | \ + uniq | sort | uniq` + # No CID=xxx found - maybe your kernel is reporting these as + # VMID=xxx so look there + if test -z "$FOUND_TIDS"; then + FOUND_TIDS=`perf report --stdio --dump -i "$1" | \ + grep -o "VMID=0x[0-9a-z]\+" | sed 's/VMID=//g' | \ + uniq | sort | uniq` + fiJust note, in theory we can check perf meta data and decide if use VMID or CID as thread ID in the trace data. But perf meta data doesn't give direct info and need to parse the "TRCIDR2" field, this would introduce complexity.
Quoted 1 line
Current approach is simple, so let's keep it.
A simple approach at least is easier to maintain here. so we're in agreement. :)
Quoted 29 lines
Quoted 11 lines
tools/perf/tests/shell/lib/coresight.sh new file +11
-0+ + # Iterate over the list of TIDs that the test says it has and find + # them in the TIDs found in the perf report + MISSING="" + for TID2 in $TIDS; do + FOUND="" + for TIDHEX in $FOUND_TIDS; do + TID=`printf "%i" $TIDHEX` + if test "$TID" -eq "$TID2"; then + FOUND="y" + breaktools/perf/tests/shell/lib/coresight.sh line 132
Quoted 10 lines
tools/perf/tests/shell/lib/coresight.sh new file +10
-0+ fi + done + if test -z "$FOUND"; then + MISSING="$MISSING $TID" + fi + done + if test -n "$MISSING"; then + err "Thread IDs $MISSING not found in perf AUX data" + fi +}The patch LGTM:
Reviewed-by Leo Yan <[email protected]>Quoted 3 lines
Signature · 1 line
2.32.0
PATCH v5 3/14 perf test: Add build infra for perf test tools for CoreSight tests
In reply to [email protected]From: "Carsten Haitzler (Rasterman)" <[email protected]>
This adds the initial build infrastructure (makefiles maintainers information) for adding follow-on tests for CoreSight.
--- MAINTAINERS | 1 + tools/perf/Makefile.perf | 18 ++++++++++--- tools/perf/tests/shell/coresight/Makefile | 26 +++++++++++++++++++ .../tests/shell/coresight/Makefile.miniconfig | 24 +++++++++++++++++ 4 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 tools/perf/tests/shell/coresight/Makefile create mode 100644 tools/perf/tests/shell/coresight/Makefile.miniconfig
MAINTAINERS +1 -0
@@ -1989,6 +1989,7 @@ F: drivers/hwtracing/coresight/* F: include/dt-bindings/arm/coresight-cti-dt.h F: include/linux/coresight* F: samples/coresight/* +F: tools/perf/tests/shell/coresight/* F: tools/perf/arch/arm/util/auxtrace.c F: tools/perf/arch/arm/util/cs-etm.c F: tools/perf/arch/arm/util/cs-etm.h
tools/perf/Makefile.perf +15 -3
@@ -629,7 +629,15 @@ sync_file_range_tbls := $(srctree)/tools/perf/trace/beauty/sync_file_range.sh $(sync_file_range_arrays): $(linux_uapi_dir)/fs.h $(sync_file_range_tbls) $(Q)$(SHELL) '$(sync_file_range_tbls)' $(linux_uapi_dir) > $@ -all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS) +TESTS_CORESIGHT_DIR := $(srctree)/tools/perf/tests/shell/coresight + +tests-coresight-targets: FORCE + $(Q)$(MAKE) -C $(TESTS_CORESIGHT_DIR) + +tests-coresight-targets-clean: + $(Q)$(MAKE) -C $(TESTS_CORESIGHT_DIR) clean + +all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS) tests-coresight-targets # Create python binding output directory if not already present _dummy := $(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python')
@@ -1015,7 +1023,10 @@ install-tests: all install-gtk $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \ $(INSTALL) tests/shell/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'; \ - $(INSTALL) tests/shell/lib/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib' + $(INSTALL) tests/shell/lib/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'; \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/coresight'; \ + $(INSTALL) tests/shell/coresight/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/coresight' + $(Q)$(MAKE) -C tests/shell/coresight install-tests install-bin: install-tools install-tests install-traceevent-plugins
@@ -1085,7 +1096,7 @@ endif # BUILD_BPF_SKEL bpf-skel-clean: $(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKELETONS) -clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBPERF)-clean fixdep-clean python-clean bpf-skel-clean +clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBPERF)-clean fixdep-clean python-clean bpf-skel-clean tests-coresight-targets-clean $(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-iostat $(LANG_BINDINGS) $(Q)find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete $(Q)$(RM) $(OUTPUT).config-detected
@@ -1143,5 +1154,6 @@ FORCE: .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell .PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope FORCE prepare .PHONY: libtraceevent_plugins archheaders +.PHONY: $(TESTS_CORESIGHT_TARGETS) endif # force_fixdep
tools/perf/tests/shell/coresight/Makefile new file +26 -0
@@ -0,0 +1,26 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Carsten Haitzler <[email protected]>, 2021 +include ../../../../../tools/scripts/Makefile.include +include ../../../../../tools/scripts/Makefile.arch +include ../../../../../tools/scripts/utilities.mak + +SUBDIRS = + +all: $(SUBDIRS) +$(SUBDIRS): + $(Q)$(MAKE) -C $@ + +INSTALLDIRS = $(SUBDIRS:%=install-%) + +install-tests: $(INSTALLDIRS) +$(INSTALLDIRS): + $(Q)$(MAKE) -C $(@:install-%=%) install-tests + +CLEANDIRS = $(SUBDIRS:%=clean-%) + +clean: $(CLEANDIRS) +$(CLEANDIRS): + $(Q)$(MAKE) -C $(@:clean-%=%) clean >/dev/null + +.PHONY: all clean $(SUBDIRS) $(CLEANDIRS) $(INSTALLDIRS) +
tools/perf/tests/shell/coresight/Makefile.miniconfig new file +24 -0
@@ -0,0 +1,24 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Carsten Haitzler <[email protected]>, 2021 + +ifndef DESTDIR +prefix ?= $(HOME) +endif + +DESTDIR_SQ = $(subst ','\'',$(DESTDIR)) +perfexecdir = libexec/perf-core +perfexec_instdir = $(perfexecdir) + +ifneq ($(filter /%,$(firstword $(perfexecdir))),) +perfexec_instdir = $(perfexecdir) +else +perfexec_instdir = $(prefix)/$(perfexecdir) +endif + +perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir)) +INSTALL = install +INSTDIR_SUB = tests/shell/coresight + +include ../../../../../scripts/Makefile.include +include ../../../../../scripts/Makefile.arch +include ../../../../../scripts/utilities.mak
Signature · 1 line
2.32.0
Re: [PATCH v5 03/14] perf test: Add build infra for perf test tools for CoreSight tests
Quoted 70 lines · On Thu, Jul 28, 2022 at 03:52:45PM +0100, [email protected] wrote:
From: "Carsten Haitzler (Rasterman)" <[email protected]>
This adds the initial build infrastructure (makefiles maintainers information) for adding follow-on tests for CoreSight.
Signed-off-by Carsten Haitzler <[email protected]>--- MAINTAINERS | 1 + tools/perf/Makefile.perf | 18 ++++++++++--- tools/perf/tests/shell/coresight/Makefile | 26 +++++++++++++++++++ .../tests/shell/coresight/Makefile.miniconfig | 24 +++++++++++++++++ 4 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 tools/perf/tests/shell/coresight/Makefile create mode 100644 tools/perf/tests/shell/coresight/Makefile.miniconfigMAINTAINERS +1
-0@@ -1989,6 +1989,7 @@ F: drivers/hwtracing/coresight/* F: include/dt-bindings/arm/coresight-cti-dt.h F: include/linux/coresight* F: samples/coresight/* +F: tools/perf/tests/shell/coresight/* F: tools/perf/arch/arm/util/auxtrace.c F: tools/perf/arch/arm/util/cs-etm.c F: tools/perf/arch/arm/util/cs-etm.htools/perf/Makefile.perf +14
-3@@ -629,7 +629,15 @@ sync_file_range_tbls := $(srctree)/tools/perf/trace/beauty/sync_file_range.sh $(sync_file_range_arrays): $(linux_uapi_dir)/fs.h $(sync_file_range_tbls) $(Q)$(SHELL) '$(sync_file_range_tbls)' $(linux_uapi_dir) > $@ -all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS) +TESTS_CORESIGHT_DIR := $(srctree)/tools/perf/tests/shell/coresight + +tests-coresight-targets: FORCE + $(Q)$(MAKE) -C $(TESTS_CORESIGHT_DIR) + +tests-coresight-targets-clean: + $(Q)$(MAKE) -C $(TESTS_CORESIGHT_DIR) clean + +all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS) tests-coresight-targets # Create python binding output directory if not already present _dummy := $(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python')@@ -1015,7 +1023,10 @@ install-tests: all install-gtk $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \ $(INSTALL) tests/shell/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'; \ - $(INSTALL) tests/shell/lib/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib' + $(INSTALL) tests/shell/lib/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'; \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/coresight'; \ + $(INSTALL) tests/shell/coresight/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/coresight' + $(Q)$(MAKE) -C tests/shell/coresight install-tests install-bin: install-tools install-tests install-traceevent-plugins@@ -1085,7 +1096,7 @@ endif # BUILD_BPF_SKEL bpf-skel-clean: $(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKELETONS) -clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBPERF)-clean fixdep-clean python-clean bpf-skel-clean +clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBPERF)-clean fixdep-clean python-clean bpf-skel-clean tests-coresight-targets-clean $(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-iostat $(LANG_BINDINGS) $(Q)find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete $(Q)$(RM) $(OUTPUT).config-detected
tools/perf/Makefile.perf FORCE: · line 1157
Quoted 4 lines
tools/perf/Makefile.perf +1
-0@@ -1143,5 +1154,6 @@ FORCE: .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell .PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope FORCE prepare .PHONY: libtraceevent_plugins archheaders +.PHONY: $(TESTS_CORESIGHT_TARGETS)
TESTS_CORESIGHT_TARGETS is not used anywhere else, should remove it?
Quoted 14 lines
tools/perf/Makefile.perf +0
-0endif # force_fixdeptools/perf/tests/shell/coresight/Makefile new file +7
-0@@ -0,0 +1,26 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Carsten Haitzler <[email protected]>, 2021 +include ../../../../../tools/scripts/Makefile.include +include ../../../../../tools/scripts/Makefile.arch +include ../../../../../tools/scripts/utilities.mak + +SUBDIRS =
tools/perf/tests/shell/coresight/Makefile line 17
Quoted 10 lines
tools/perf/tests/shell/coresight/Makefile new file +10
-0+ +all: $(SUBDIRS) +$(SUBDIRS): + $(Q)$(MAKE) -C $@ + +INSTALLDIRS = $(SUBDIRS:%=install-%) + +install-tests: $(INSTALLDIRS) +$(INSTALLDIRS): + $(Q)$(MAKE) -C $(@:install-%=%) install-tests
I can see here you add a prefix "install-" for every sub directory string, and then removed this prefix when invoke "make -C" command.
I know you have reason for doing this way, could you explain why not directly use $(SUBDIRS) for INSTALLDIRS?
tools/perf/tests/shell/coresight/Makefile line 23
Quoted 6 lines
tools/perf/tests/shell/coresight/Makefile new file +6
-0+ +CLEANDIRS = $(SUBDIRS:%=clean-%) + +clean: $(CLEANDIRS) +$(CLEANDIRS): + $(Q)$(MAKE) -C $(@:clean-%=%) clean >/dev/null
Same question of using prefix "clean-" for variable CLEANDIRS.
Quoted 17 lines
tools/perf/tests/shell/coresight/Makefile new file +3
-0+ +.PHONY: all clean $(SUBDIRS) $(CLEANDIRS) $(INSTALLDIRS) +tools/perf/tests/shell/coresight/Makefile.miniconfig new file +8
-0@@ -0,0 +1,24 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Carsten Haitzler <[email protected]>, 2021 + +ifndef DESTDIR +prefix ?= $(HOME) +endif + +DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
tools/perf/tests/shell/coresight/Makefile.miniconfig line 18
Quoted 10 lines
tools/perf/tests/shell/coresight/Makefile.miniconfig new file +10
-0+perfexecdir = libexec/perf-core +perfexec_instdir = $(perfexecdir) + +ifneq ($(filter /%,$(firstword $(perfexecdir))),) +perfexec_instdir = $(perfexecdir) +else +perfexec_instdir = $(prefix)/$(perfexecdir) +endif + +perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
I know these variables are copied from Makefile.config, just wandering if we can directly export these variables from high level makefile, so the sub-make can inherit the variables.
E.g. we can add below line in Makefile.config:
export perfexec_instdir_SQ
Please let me know if you observe any issue for this.
Thanks,
Leo
Quoted 9 lines
tools/perf/tests/shell/coresight/Makefile.miniconfig new file +6
-0+INSTALL = install +INSTDIR_SUB = tests/shell/coresight + +include ../../../../../scripts/Makefile.include +include ../../../../../scripts/Makefile.arch +include ../../../../../scripts/utilities.makSignature · 1 line
2.32.0
Re: [PATCH v5 03/14] perf test: Add build infra for perf test tools for CoreSight tests
Quoted 65 lines · Leo Yan
Quoted 64 lines · On Thu, Jul 28, 2022 at 03:52:45PM +0100, [email protected] wrote:
From: "Carsten Haitzler (Rasterman)" <[email protected]>
This adds the initial build infrastructure (makefiles maintainers information) for adding follow-on tests for CoreSight.
Signed-off-by Carsten Haitzler <[email protected]>--- MAINTAINERS | 1 + tools/perf/Makefile.perf | 18 ++++++++++--- tools/perf/tests/shell/coresight/Makefile | 26 +++++++++++++++++++ .../tests/shell/coresight/Makefile.miniconfig | 24 +++++++++++++++++ 4 files changed, 66 insertions(+), 3 deletions(-)create mode 100644
tools/perf/tests/shell/coresight/Makefilecreate mode 100644tools/perf/tests/shell/coresight/Makefile.miniconfigMAINTAINERS +1
-0@@ -1989,6 +1989,7 @@ F: drivers/hwtracing/coresight/* F: include/dt-bindings/arm/coresight-cti-dt.h F: include/linux/coresight* F: samples/coresight/* +F: tools/perf/tests/shell/coresight/* F: tools/perf/arch/arm/util/auxtrace.c F: tools/perf/arch/arm/util/cs-etm.c F: tools/perf/arch/arm/util/cs-etm.htools/perf/Makefile.perf +13
-2@@ -629,7 +629,15 @@ sync_file_range_tbls := $(srctree)/tools/perf/trace/beauty/sync_file_range.sh $(sync_file_range_arrays): $(linux_uapi_dir)/fs.h $(sync_file_range_tbls) $(Q)$(SHELL) '$(sync_file_range_tbls)' $(linux_uapi_dir) > $@ -all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS) +TESTS_CORESIGHT_DIR := $(srctree)/tools/perf/tests/shell/coresight + +tests-coresight-targets: FORCE + $(Q)$(MAKE) -C $(TESTS_CORESIGHT_DIR) + +tests-coresight-targets-clean: + $(Q)$(MAKE) -C $(TESTS_CORESIGHT_DIR) clean + +all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS) tests-coresight-targets # Create python binding output directory if not already present _dummy := $(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python')@@ -1015,7 +1023,10 @@ install-tests: all install-gtk $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \ $(INSTALL) tests/shell/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'; \ - $(INSTALL) tests/shell/lib/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib' + $(INSTALL) tests/shell/lib/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'; \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/coresight'; \ + $(INSTALL) tests/shell/coresight/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/coresight' + $(Q)$(MAKE) -C tests/shell/coresight install-tests install-bin: install-tools install-tests install-traceevent-plugins@@ -1085,7 +1096,7 @@ endif # BUILD_BPF_SKEL bpf-skel-clean: $(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKELETONS)
Quoted 12 lines
tools/perf/Makefile.perf FORCE: · line 1157
Quoted 10 lines
tools/perf/Makefile.perf +2
-1-clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBPERF)-clean fixdep-clean python-clean bpf-skel-clean +clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBPERF)-clean fixdep-clean python-clean bpf-skel-clean tests-coresight-targets-clean $(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-iostat $(LANG_BINDINGS) $(Q)find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete $(Q)$(RM) $(OUTPUT).config-detected@@ -1143,5 +1154,6 @@ FORCE: .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell .PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope FORCE prepare .PHONY: libtraceevent_plugins archheaders +.PHONY: $(TESTS_CORESIGHT_TARGETS)
TESTS_CORESIGHT_TARGETSis not used anywhere else, should remove it?
I think this was left over from a previous iteration of this work and I removed it later on and forgot about this.
Quoted 19 lines
Quoted 19 lines
tools/perf/Makefile.perf +0
-0endif # force_fixdeptools/perf/tests/shell/coresight/Makefile new file +12
-0@@ -0,0 +1,26 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Carsten Haitzler <[email protected]>, 2021 +include ../../../../../tools/scripts/Makefile.include +include ../../../../../tools/scripts/Makefile.arch +include ../../../../../tools/scripts/utilities.mak + +SUBDIRS = + +all: $(SUBDIRS) +$(SUBDIRS): + $(Q)$(MAKE) -C $@ +
Quoted 8 lines
tools/perf/tests/shell/coresight/Makefile line 17
Quoted 5 lines
tools/perf/tests/shell/coresight/Makefile new file +5
-0+INSTALLDIRS = $(SUBDIRS:%=install-%) + +install-tests: $(INSTALLDIRS) +$(INSTALLDIRS): + $(Q)$(MAKE) -C $(@:install-%=%) install-testsI can see here you add a prefix "install-" for every sub directory string, and then removed this prefix when invoke "make -C" command.
install-tests is a target to install the tests on the host in a known location. it was already there. i added handling of this. there are other install- taregts like install-doc, install-bin and so on. i passed that through so *IF* there is a doc: or similar rule to generate docs then it runs the doc rule first to ensure docs are built before doing the install. this isn't actually used but it's passing along rules. i.e. make install-doc -> make doc etc.
Quoted 11 lines
I know you have reason for doing this way, could you explain why not directly use $(SUBDIRS) for INSTALLDIRS?
tools/perf/tests/shell/coresight/Makefile line 23
Quoted 6 lines
tools/perf/tests/shell/coresight/Makefile new file +6
-0+ +CLEANDIRS = $(SUBDIRS:%=clean-%) + +clean: $(CLEANDIRS) +$(CLEANDIRS): + $(Q)$(MAKE) -C $(@:clean-%=%) clean >/dev/nullSame question of using prefix "clean-" for variable CLEANDIRS.
Same answer as above.
Quoted 32 lines
Quoted 17 lines
tools/perf/tests/shell/coresight/Makefile new file +3
-0+ +.PHONY: all clean $(SUBDIRS) $(CLEANDIRS) $(INSTALLDIRS) +tools/perf/tests/shell/coresight/Makefile.miniconfig new file +8
-0@@ -0,0 +1,24 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Carsten Haitzler <[email protected]>, 2021 + +ifndef DESTDIR +prefix ?= $(HOME) +endif + +DESTDIR_SQ = $(subst ','\'',$(DESTDIR))tools/perf/tests/shell/coresight/Makefile.miniconfig line 18
Quoted 10 lines
tools/perf/tests/shell/coresight/Makefile.miniconfig new file +10
-0+perfexecdir = libexec/perf-core +perfexec_instdir = $(perfexecdir) + +ifneq ($(filter /%,$(firstword $(perfexecdir))),) +perfexec_instdir = $(perfexecdir) +else +perfexec_instdir = $(prefix)/$(perfexecdir) +endif + +perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))I know these variables are copied from Makefile.config, just wandering if we can directly export these variables from high level makefile, so the sub-make can inherit the variables.
Quoted 5 lines
E.g. we can add below line in Makefile.config:
export
perfexec_instdir_SQPlease let me know if you observe any issue for this.
I can indeed simplify that a bit and remove a few lines.
Quoted 12 lines
Thanks,
LeoQuoted 9 lines
tools/perf/tests/shell/coresight/Makefile.miniconfig new file +6
-0+INSTALL = install +INSTDIR_SUB = tests/shell/coresight + +include ../../../../../scripts/Makefile.include +include ../../../../../scripts/Makefile.arch +include ../../../../../scripts/utilities.makSignature · 1 line
2.32.0
PATCH v5 4/14 perf test: Add asm pureloop test tool
In reply to [email protected]From: "Carsten Haitzler (Rasterman)" <[email protected]>
Add test tool to be driven by further test scripts. This tool is pure arm64 ASM with no libc usage to ensure it is the same exact binary/code every time so it can also be re-used for many uses. It just loops for a given fixed number of loops.
--- tools/perf/tests/shell/coresight/Makefile | 3 +- .../shell/coresight/asm_pure_loop/.gitignore | 1 + .../shell/coresight/asm_pure_loop/Makefile | 34 +++++++++++++++++++ .../coresight/asm_pure_loop/asm_pure_loop.S | 28 +++++++++++++++ 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 tools/perf/tests/shell/coresight/asm_pure_loop/.gitignore create mode 100644 tools/perf/tests/shell/coresight/asm_pure_loop/Makefile create mode 100644 tools/perf/tests/shell/coresight/asm_pure_loop/asm_pure_loop.S
tools/perf/tests/shell/coresight/Makefile +2 -1
@@ -4,7 +4,8 @@ include ../../../../../tools/scripts/Makefile.include include ../../../../../tools/scripts/Makefile.arch include ../../../../../tools/scripts/utilities.mak -SUBDIRS = +SUBDIRS = \ + asm_pure_loop all: $(SUBDIRS) $(SUBDIRS):
tools/perf/tests/shell/coresight/asm_pure_loop/.gitignore new file +1 -0
@@ -0,0 +1 @@ +asm_pure_loop
tools/perf/tests/shell/coresight/asm_pure_loop/Makefile new file +34 -0
@@ -0,0 +1,34 @@ +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <[email protected]>, 2021 + +include ../Makefile.miniconfig + +# Binary to produce +BIN=asm_pure_loop +# Any linking/libraries needed for the binary - empty if none needed +LIB= + +all: $(BIN) + +$(BIN): $(BIN).S +ifdef CORESIGHT +ifeq ($(ARCH),arm64) +# Build line - this is raw asm with no libc to have an always exact binary + $(Q)$(CC) $(BIN).S -nostdlib -static -o $(BIN) $(LIB) +endif +endif + +install-tests: all +ifdef CORESIGHT +ifeq ($(ARCH),arm64) +# Install the test tool in the right place + $(call QUIET_INSTALL, tests) \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/$(INSTDIR_SUB)/$(BIN)'; \ + $(INSTALL) $(BIN) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/$(INSTDIR_SUB)/$(BIN)/$(BIN)' +endif +endif + +clean: + $(Q)$(RM) -f $(BIN) + +.PHONY: all clean install-tests
tools/perf/tests/shell/coresight/asm_pure_loop/asm_pure_loop.S new file +28 -0
@@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Tamas Zsoldos <[email protected]>, 2021 */ + +.globl _start +_start: + mov x0, 0x0000ffff + mov x1, xzr +loop: + nop + nop + cbnz x1, noskip + nop + nop + adrp x2, skip + add x2, x2, :lo12:skip + br x2 + nop + nop +noskip: + nop + nop +skip: + sub x0, x0, 1 + cbnz x0, loop + + mov x0, #0 + mov x8, #93 // __NR_exit syscall + svc #0
Signature · 1 line
2.32.0
Re: [PATCH v5 04/14] perf test: Add asm pureloop test tool
Quoted 8 lines · On Thu, Jul 28, 2022 at 03:52:46PM +0100, [email protected] wrote:
From: "Carsten Haitzler (Rasterman)" <[email protected]>
Add test tool to be driven by further test scripts. This tool is pure arm64 ASM with no libc usage to ensure it is the same exact binary/code every time so it can also be re-used for many uses. It just loops for a given fixed number of loops.
Signed-off-by Carsten Haitzler <[email protected]>
PATCH v5 5/14 perf test: Add asm pureloop test shell script
In reply to [email protected]From: "Carsten Haitzler (Rasterman)" <[email protected]>
Add a script to drive the asm pureloop test for arm64/CoreSight that gathers data so it passes a minimum bar for amount and quality of content that we extract from the kernel's perf support.
--- .../tests/shell/coresight/asm_pure_loop.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 tools/perf/tests/shell/coresight/asm_pure_loop.sh
tools/perf/tests/shell/coresight/asm_pure_loop.sh new file +18 -0
@@ -0,0 +1,18 @@ +#!/bin/sh -e +# CoreSight / ASM Pure Loop + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <[email protected]>, 2021 + +TEST="asm_pure_loop" +. $(dirname $0)/../lib/coresight.sh +ARGS="" +DATV="out" +DATA="$DATD/perf-$TEST-$DATV.data" + +perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS + +perf_dump_aux_verify "$DATA" 10 10 10 + +err=$? +exit $err
Signature · 1 line
2.32.0
Re: [PATCH v5 05/14] perf test: Add asm pureloop test shell script
Quoted 7 lines · On Thu, Jul 28, 2022 at 03:52:47PM +0100, [email protected] wrote:
From: "Carsten Haitzler (Rasterman)" <[email protected]>
Add a script to drive the asm pureloop test for arm64/CoreSight that gathers data so it passes a minimum bar for amount and quality of content that we extract from the kernel's perf support.
Signed-off-by Carsten Haitzler <[email protected]>
PATCH v5 6/14 perf test: Add git ignore for perf data generated by the CoreSight tests
In reply to [email protected]From: "Carsten Haitzler (Rasterman)" <[email protected]>
Ignore perf output data files generated by perf tests for cleaner git status.
--- tools/perf/.gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/.gitignore +2 -2
@@ -15,8 +15,8 @@ perf*.1 perf*.xml perf*.html common-cmds.h -perf.data -perf.data.old +perf*.data +perf*.data.old output.svg perf-archive perf-iostat
Signature · 1 line
2.32.0
Re: [PATCH v5 06/14] perf test: Add git ignore for perf data generated by the CoreSight tests
Quoted 6 lines · On Thu, Jul 28, 2022 at 03:52:48PM +0100, [email protected] wrote:
From: "Carsten Haitzler (Rasterman)" <[email protected]>
Ignore perf output data files generated by perf tests for cleaner git status.
Signed-off-by Carsten Haitzler <[email protected]>
PATCH v5 7/14 perf test: Add memcpy thread test tool
In reply to [email protected]From: "Carsten Haitzler (Rasterman)" <[email protected]>
Add test tool to be driven by further test scripts. This is a simple C based memcpy with threads test to drive from scripts.
--- tools/perf/tests/shell/coresight/Makefile | 3 +- .../shell/coresight/memcpy_thread/.gitignore | 1 + .../shell/coresight/memcpy_thread/Makefile | 33 ++++++++ .../coresight/memcpy_thread/memcpy_thread.c | 79 +++++++++++++++++++ 4 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 tools/perf/tests/shell/coresight/memcpy_thread/.gitignore create mode 100644 tools/perf/tests/shell/coresight/memcpy_thread/Makefile create mode 100644 tools/perf/tests/shell/coresight/memcpy_thread/memcpy_thread.c
tools/perf/tests/shell/coresight/Makefile +2 -1
@@ -5,7 +5,8 @@ include ../../../../../tools/scripts/Makefile.arch include ../../../../../tools/scripts/utilities.mak SUBDIRS = \ - asm_pure_loop + asm_pure_loop \ + memcpy_thread all: $(SUBDIRS) $(SUBDIRS):
tools/perf/tests/shell/coresight/memcpy_thread/.gitignore new file +1 -0
@@ -0,0 +1 @@ +memcpy_thread
tools/perf/tests/shell/coresight/memcpy_thread/Makefile new file +33 -0
@@ -0,0 +1,33 @@ +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <[email protected]>, 2021 +include ../Makefile.miniconfig + +# Binary to produce +BIN=memcpy_thread +# Any linking/libraries needed for the binary - empty if none needed +LIB=-pthread + +all: $(BIN) + +$(BIN): $(BIN).c +ifdef CORESIGHT +ifeq ($(ARCH),arm64) +# Build line + $(Q)$(CC) $(BIN).c -o $(BIN) $(LIB) +endif +endif + +install-tests: all +ifdef CORESIGHT +ifeq ($(ARCH),arm64) +# Install the test tool in the right place + $(call QUIET_INSTALL, tests) \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/$(INSTDIR_SUB)/$(BIN)'; \ + $(INSTALL) $(BIN) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/$(INSTDIR_SUB)/$(BIN)/$(BIN)' +endif +endif + +clean: + $(Q)$(RM) -f $(BIN) + +.PHONY: all clean install-tests
tools/perf/tests/shell/coresight/memcpy_thread/memcpy_thread.c new file +79 -0
79 lines not on this page · raw message
Signature · 1 line
2.32.0
Re: [PATCH v5 07/14] perf test: Add memcpy thread test tool
Quoted 6 lines · On Thu, Jul 28, 2022 at 03:52:49PM +0100, [email protected] wrote:
From: "Carsten Haitzler (Rasterman)" <[email protected]>
Add test tool to be driven by further test scripts. This is a simple C based memcpy with threads test to drive from scripts.
Signed-off-by Carsten Haitzler <[email protected]>
PATCH v5 8/14 perf test: Add memcpy thread test shell script
In reply to [email protected]From: "Carsten Haitzler (Rasterman)" <[email protected]>
Add a script to drive the threaded memcpy test that gathers data so it passes a minimum bar for amount and quality of content that we extract from the kernel's perf support.
--- .../shell/coresight/memcpy_thread_16k_10.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 tools/perf/tests/shell/coresight/memcpy_thread_16k_10.sh
tools/perf/tests/shell/coresight/memcpy_thread_16k_10.sh new file +18 -0
@@ -0,0 +1,18 @@ +#!/bin/sh -e +# CoreSight / Memcpy 16k 10 Threads + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <[email protected]>, 2021 + +TEST="memcpy_thread" +. $(dirname $0)/../lib/coresight.sh +ARGS="16 10 1" +DATV="16k_10" +DATA="$DATD/perf-$TEST-$DATV.data" + +perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS + +perf_dump_aux_verify "$DATA" 10 10 10 + +err=$? +exit $err
Signature · 1 line
2.32.0
Re: [PATCH v5 08/14] perf test: Add memcpy thread test shell script
Quoted 7 lines · On Thu, Jul 28, 2022 at 03:52:50PM +0100, [email protected] wrote:
From: "Carsten Haitzler (Rasterman)" <[email protected]>
Add a script to drive the threaded memcpy test that gathers data so it passes a minimum bar for amount and quality of content that we extract from the kernel's perf support.
Signed-off-by Carsten Haitzler <[email protected]>
PATCH v5 9/14 perf test: Add thread loop test tool
In reply to [email protected]From: "Carsten Haitzler (Rasterman)" <[email protected]>
Add test tool to be driven by further test scripts. This is a simple C based loop with threads test to drive from scripts that can output TIDs for tracking/checking.
--- tools/perf/tests/shell/coresight/Makefile | 3 +- .../shell/coresight/thread_loop/.gitignore | 1 + .../shell/coresight/thread_loop/Makefile | 33 +++++++ .../shell/coresight/thread_loop/thread_loop.c | 86 +++++++++++++++++++ 4 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 tools/perf/tests/shell/coresight/thread_loop/.gitignore create mode 100644 tools/perf/tests/shell/coresight/thread_loop/Makefile create mode 100644 tools/perf/tests/shell/coresight/thread_loop/thread_loop.c
tools/perf/tests/shell/coresight/Makefile +2 -1
@@ -6,7 +6,8 @@ include ../../../../../tools/scripts/utilities.mak SUBDIRS = \ asm_pure_loop \ - memcpy_thread + memcpy_thread \ + thread_loop all: $(SUBDIRS) $(SUBDIRS):
tools/perf/tests/shell/coresight/thread_loop/.gitignore new file +1 -0
@@ -0,0 +1 @@ +thread_loop
tools/perf/tests/shell/coresight/thread_loop/Makefile new file +33 -0
@@ -0,0 +1,33 @@ +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <[email protected]>, 2021 +include ../Makefile.miniconfig + +# Binary to produce +BIN=thread_loop +# Any linking/libraries needed for the binary - empty if none needed +LIB=-pthread + +all: $(BIN) + +$(BIN): $(BIN).c +ifdef CORESIGHT +ifeq ($(ARCH),arm64) +# Build line + $(Q)$(CC) $(BIN).c -o $(BIN) $(LIB) +endif +endif + +install-tests: all +ifdef CORESIGHT +ifeq ($(ARCH),arm64) +# Install the test tool in the right place + $(call QUIET_INSTALL, tests) \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/$(INSTDIR_SUB)/$(BIN)'; \ + $(INSTALL) $(BIN) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/$(INSTDIR_SUB)/$(BIN)/$(BIN)' +endif +endif + +clean: + $(Q)$(RM) -f $(BIN) + +.PHONY: all clean install-tests
tools/perf/tests/shell/coresight/thread_loop/thread_loop.c new file +86 -0
86 lines not on this page · raw message
Signature · 1 line
2.32.0
Re: [PATCH v5 09/14] perf test: Add thread loop test tool
Quoted 7 lines · On Thu, Jul 28, 2022 at 03:52:51PM +0100, [email protected] wrote:
From: "Carsten Haitzler (Rasterman)" <[email protected]>
Add test tool to be driven by further test scripts. This is a simple C based loop with threads test to drive from scripts that can output TIDs for tracking/checking.
Signed-off-by Carsten Haitzler <[email protected]>
PATCH v5 10/14 perf test: Add thread loop test shell scripts
In reply to [email protected]From: "Carsten Haitzler (Rasterman)" <[email protected]>
Add a script to drive the thread loop test that gathers data so it passes a minimum bar (in this case do we get any perf context data for every thread).
--- .../coresight/thread_loop_check_tid_10.sh | 19 +++++++++++++++++++ .../coresight/thread_loop_check_tid_2.sh | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100755 tools/perf/tests/shell/coresight/thread_loop_check_tid_10.sh create mode 100755 tools/perf/tests/shell/coresight/thread_loop_check_tid_2.sh
tools/perf/tests/shell/coresight/thread_loop_check_tid_10.sh new file +19 -0
@@ -0,0 +1,19 @@ +#!/bin/sh -e +# CoreSight / Thread Loop 10 Threads - Check TID + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <[email protected]>, 2021 + +TEST="thread_loop" +. $(dirname $0)/../lib/coresight.sh +ARGS="10 1" +DATV="check-tid-10th" +DATA="$DATD/perf-$TEST-$DATV.data" +STDO="$DATD/perf-$TEST-$DATV.stdout" + +SHOW_TID=1 perf record -s $PERFRECOPT -o "$DATA" "$BIN" $ARGS > $STDO + +perf_dump_aux_tid_verify "$DATA" "$STDO" + +err=$? +exit $err
tools/perf/tests/shell/coresight/thread_loop_check_tid_2.sh new file +19 -0
@@ -0,0 +1,19 @@ +#!/bin/sh -e +# CoreSight / Thread Loop 2 Threads - Check TID + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <[email protected]>, 2021 + +TEST="thread_loop" +. $(dirname $0)/../lib/coresight.sh +ARGS="2 20" +DATV="check-tid-2th" +DATA="$DATD/perf-$TEST-$DATV.data" +STDO="$DATD/perf-$TEST-$DATV.stdout" + +SHOW_TID=1 perf record -s $PERFRECOPT -o "$DATA" "$BIN" $ARGS > $STDO + +perf_dump_aux_tid_verify "$DATA" "$STDO" + +err=$? +exit $err
Signature · 1 line
2.32.0
Re: [PATCH v5 10/14] perf test: Add thread loop test shell scripts
Quoted 7 lines · On Thu, Jul 28, 2022 at 03:52:52PM +0100, [email protected] wrote:
From: "Carsten Haitzler (Rasterman)" <[email protected]>
Add a script to drive the thread loop test that gathers data so it passes a minimum bar (in this case do we get any perf context data for every thread).
Signed-off-by Carsten Haitzler <[email protected]>
PATCH v5 11/14 perf test: Add unroll thread test tool
In reply to [email protected]From: "Carsten Haitzler (Rasterman)" <[email protected]>
Add test tool to be driven by further test scripts. This is a simple C based test that is for arm64 with some inline ASM to manually unroll a lot of code to have a very long sequence of commands.
--- tools/perf/tests/shell/coresight/Makefile | 3 +- .../coresight/unroll_loop_thread/.gitignore | 1 + .../coresight/unroll_loop_thread/Makefile | 33 +++++++++ .../unroll_loop_thread/unroll_loop_thread.c | 74 +++++++++++++++++++ 4 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 tools/perf/tests/shell/coresight/unroll_loop_thread/.gitignore create mode 100644 tools/perf/tests/shell/coresight/unroll_loop_thread/Makefile create mode 100644 tools/perf/tests/shell/coresight/unroll_loop_thread/unroll_loop_thread.c
tools/perf/tests/shell/coresight/Makefile +2 -1
@@ -7,7 +7,8 @@ include ../../../../../tools/scripts/utilities.mak SUBDIRS = \ asm_pure_loop \ memcpy_thread \ - thread_loop + thread_loop \ + unroll_loop_thread all: $(SUBDIRS) $(SUBDIRS):
tools/perf/tests/shell/coresight/unroll_loop_thread/.gitignore new file +1 -0
@@ -0,0 +1 @@ +unroll_loop_thread
tools/perf/tests/shell/coresight/unroll_loop_thread/Makefile new file +33 -0
@@ -0,0 +1,33 @@ +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <[email protected]>, 2021 +include ../Makefile.miniconfig + +# Binary to produce +BIN=unroll_loop_thread +# Any linking/libraries needed for the binary - empty if none needed +LIB=-pthread + +all: $(BIN) + +$(BIN): $(BIN).c +ifdef CORESIGHT +ifeq ($(ARCH),arm64) +# Build line + $(Q)$(CC) $(BIN).c -o $(BIN) $(LIB) +endif +endif + +install-tests: all +ifdef CORESIGHT +ifeq ($(ARCH),arm64) +# Install the test tool in the right place + $(call QUIET_INSTALL, tests) \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/$(INSTDIR_SUB)/$(BIN)'; \ + $(INSTALL) $(BIN) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/$(INSTDIR_SUB)/$(BIN)/$(BIN)' +endif +endif + +clean: + $(Q)$(RM) -f $(BIN) + +.PHONY: all clean install-tests
tools/perf/tests/shell/coresight/unroll_loop_thread/unroll_loop_thread.c new file +74 -0
74 lines not on this page · raw message
Signature · 1 line
2.32.0
Re: [PATCH v5 11/14] perf test: Add unroll thread test tool
Quoted 84 lines · On Thu, Jul 28, 2022 at 03:52:53PM +0100, [email protected] wrote:
From: "Carsten Haitzler (Rasterman)" <[email protected]>
Add test tool to be driven by further test scripts. This is a simple C based test that is for arm64 with some inline ASM to manually unroll a lot of code to have a very long sequence of commands.
Signed-off-by Carsten Haitzler <[email protected]>--- tools/perf/tests/shell/coresight/Makefile | 3 +- .../coresight/unroll_loop_thread/.gitignore | 1 + .../coresight/unroll_loop_thread/Makefile | 33 +++++++++ .../unroll_loop_thread/unroll_loop_thread.c | 74 +++++++++++++++++++ 4 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 tools/perf/tests/shell/coresight/unroll_loop_thread/.gitignore create mode 100644 tools/perf/tests/shell/coresight/unroll_loop_thread/Makefile create mode 100644 tools/perf/tests/shell/coresight/unroll_loop_thread/unroll_loop_thread.ctools/perf/tests/shell/coresight/Makefile +2
-1@@ -7,7 +7,8 @@ include ../../../../../tools/scripts/utilities.mak SUBDIRS = \ asm_pure_loop \ memcpy_thread \ - thread_loop + thread_loop \ + unroll_loop_thread all: $(SUBDIRS) $(SUBDIRS):tools/perf/tests/shell/coresight/unroll_loop_thread/.gitignore new file +1
-0@@ -0,0 +1 @@ +unroll_loop_threadtools/perf/tests/shell/coresight/unroll_loop_thread/Makefile new file +33
-0@@ -0,0 +1,33 @@ +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <[email protected]>, 2021 +include ../Makefile.miniconfig + +# Binary to produce +BIN=unroll_loop_thread +# Any linking/libraries needed for the binary - empty if none needed +LIB=-pthread + +all: $(BIN) + +$(BIN): $(BIN).c +ifdef CORESIGHT +ifeq ($(ARCH),arm64) +# Build line + $(Q)$(CC) $(BIN).c -o $(BIN) $(LIB) +endif +endif + +install-tests: all +ifdef CORESIGHT +ifeq ($(ARCH),arm64) +# Install the test tool in the right place + $(call QUIET_INSTALL, tests) \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/$(INSTDIR_SUB)/$(BIN)'; \ + $(INSTALL) $(BIN) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/$(INSTDIR_SUB)/$(BIN)/$(BIN)' +endif +endif + +clean: + $(Q)$(RM) -f $(BIN) + +.PHONY: all clean install-teststools/perf/tests/shell/coresight/unroll_loop_thread/unroll_loop_thread.c new file +1
-0@@ -0,0 +1,74 @@ +// SPDX-License-Identifier: GPL-2.0
tools/perf/tests/shell/coresight/unroll_loop_thread/unroll_loop_thread.c line 11
Quoted 10 lines
tools/perf/tests/shell/coresight/unroll_loop_thread/unroll_loop_thread.c new file +10
-0+// Carsten Haitzler <[email protected]>, 2021 +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <pthread.h> + +struct args { +pthread_t th; +unsigned int in, out;
nitpick: "out" field is not used, drop it?
With this minor fixing, the patch LGTM:
Quoted 66 lines
tools/perf/tests/shell/coresight/unroll_loop_thread/unroll_loop_thread.c new file +63
-0+void *ret; +}; + +static void *thrfn (void *arg) +{ +struct args *a = arg; +unsigned int i, in = a->in; + +for (i =0 ; i <10000 ; i++) { + asmvolatile ( +// force an unroll of thia add instruction so we can test long runs of code +#define SNIP1 "add %[in], %[in], #1\n" +// 10 +#define SNIP2 SNIP1 SNIP1 SNIP1 SNIP1 SNIP1 SNIP1 SNIP1 SNIP1 SNIP1 SNIP1 +// 100 +#define SNIP3 SNIP2 SNIP2 SNIP2 SNIP2 SNIP2 SNIP2 SNIP2 SNIP2 SNIP2 SNIP2 +// 1000 +#define SNIP4 SNIP3 SNIP3 SNIP3 SNIP3 SNIP3 SNIP3 SNIP3 SNIP3 SNIP3 SNIP3 +// 10000 +#define SNIP5 SNIP4 SNIP4 SNIP4 SNIP4 SNIP4 SNIP4 SNIP4 SNIP4 SNIP4 SNIP4 +// 100000 +SNIP5 SNIP5 SNIP5 SNIP5 SNIP5 SNIP5 SNIP5 SNIP5 SNIP5 SNIP5 + :/* out */ + :/* in */ [in]"r" (in) + :/* clobber */ + ); + } +} + +static pthread_t new_thr (void *(*fn) (void *arg),void *arg) +{ +pthread_t t; +pthread_attr_t attr; + +pthread_attr_init (&attr); +pthread_create (&t, &attr, fn, arg); +return t; +} + +int main (int argc,char **argv) +{ +unsigned int i, thr; +pthread_t threads[256 ]; +struct args args[256 ]; + +if (argc <2 ) { +printf ("ERR: %s [numthreads]\n" , argv[0 ]); +exit (1 ); + } + + thr =atoi (argv[1 ]); +if ((thr >256 ) || (thr <1 )) { +printf ("ERR: threads 1-256\n" ); +exit (1 ); + } +for (i =0 ; i < thr; i++) { + args[i].in =rand (); + args[i].th =new_thr (thrfn, &(args[i])); + } +for (i =0 ; i < thr; i++) +pthread_join (args[i].th, &(args[i].ret)); +return 0 ; +}Signature · 1 line
2.32.0
PATCH v5 12/14 perf test: Add unroll thread test shell script
In reply to [email protected]From: "Carsten Haitzler (Rasterman)" <[email protected]>
This adds scripts to drive the unroll thread tests to compare perf output against a minimum bar of content/quality.
--- .../shell/coresight/unroll_loop_thread_10.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 tools/perf/tests/shell/coresight/unroll_loop_thread_10.sh
tools/perf/tests/shell/coresight/unroll_loop_thread_10.sh new file +18 -0
@@ -0,0 +1,18 @@ +#!/bin/sh -e +# CoreSight / Unroll Loop Thread 10 + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <[email protected]>, 2021 + +TEST="unroll_loop_thread" +. $(dirname $0)/../lib/coresight.sh +ARGS="10" +DATV="10" +DATA="$DATD/perf-$TEST-$DATV.data" + +perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS + +perf_dump_aux_verify "$DATA" 10 10 10 + +err=$? +exit $err
Signature · 1 line
2.32.0
Re: [PATCH v5 12/14] perf test: Add unroll thread test shell script
Quoted 22 lines · On Thu, Jul 28, 2022 at 03:52:54PM +0100, [email protected] wrote:
From: "Carsten Haitzler (Rasterman)" <[email protected]>
This adds scripts to drive the unroll thread tests to compare perf output against a minimum bar of content/quality.
Signed-off-by Carsten Haitzler <[email protected]>--- .../shell/coresight/unroll_loop_thread_10.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 tools/perf/tests/shell/coresight/unroll_loop_thread_10.shtools/perf/tests/shell/coresight/unroll_loop_thread_10.sh new file +5
-0@@ -0,0 +1,18 @@ +#!/bin/sh -e +# CoreSight / Unroll Loop Thread 10 + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <[email protected]>, 2021
tools/perf/tests/shell/coresight/unroll_loop_thread_10.sh line 15
Quoted 10 lines
tools/perf/tests/shell/coresight/unroll_loop_thread_10.sh new file +10
-0+ +TEST="unroll_loop_thread" +. $(dirname $0)/../lib/coresight.sh +ARGS="10" +DATV="10" +DATA="$DATD/perf-$TEST-$DATV.data" + +perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS + +perf_dump_aux_verify "$DATA" 10 10 10
Just minor comments for checking the trace data quality:
The unroll program loops for 10000 times per thread, and this test creates 10 threads; so if we pass the parameter "10 10 10" for perf_dump_aux_verify, seems to me this is very conservative?
I would like hear Mike's opinion for these quality metrics; the patch itself is fine for me, you could add my review tag:
P.s. it's off-topic, just want to remind to use the "b4" tool when you spin for next version's patch set, e.g. you could use below commands:
$ b4 am [email protected] ^ ` I get the message ID from the page: https://lore.kernel.org/lkml/[email protected]/ $ git am ./v5_20220728_carsten_haitzler_a_patch_series_improving_data_quality_of_perf_test_for_coresight.mbx
We can benefit from this due "b4" can automatically append tags in patches; this can help us to track which patches have been reviewed and tested in previous versions.
Thanks,
Leo
Quoted 6 lines
tools/perf/tests/shell/coresight/unroll_loop_thread_10.sh new file +3
-0+ +err=$? +exit $errSignature · 1 line
2.32.0
Re: [PATCH v5 12/14] perf test: Add unroll thread test shell script
Quoted 36 lines · Leo Yan
Quoted 22 lines · On Thu, Jul 28, 2022 at 03:52:54PM +0100, [email protected] wrote:
From: "Carsten Haitzler (Rasterman)" <[email protected]>
This adds scripts to drive the unroll thread tests to compare perf output against a minimum bar of content/quality.
Signed-off-by Carsten Haitzler <[email protected]>--- .../shell/coresight/unroll_loop_thread_10.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)create mode 100755
tools/perf/tests/shell/coresight/unroll_loop_thread_10.shtools/perf/tests/shell/coresight/unroll_loop_thread_10.sh new file +5
-0@@ -0,0 +1,18 @@ +#!/bin/sh -e +# CoreSight / Unroll Loop Thread 10 + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <[email protected]>, 2021tools/perf/tests/shell/coresight/unroll_loop_thread_10.sh line 15
Quoted 10 lines
tools/perf/tests/shell/coresight/unroll_loop_thread_10.sh new file +10
-0+ +TEST="unroll_loop_thread" +. $(dirname $0)/../lib/coresight.sh +ARGS="10" +DATV="10" +DATA="$DATD/perf-$TEST-$DATV.data" + +perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS + +perf_dump_aux_verify "$DATA" 10 10 10Just minor comments for checking the trace data quality:
Quoted 3 lines
The unroll program loops for 10000 times per thread, and this test creates 10 threads; so if we pass the parameter "10 10 10" for
perf_dump_aux_verify, seems to me this is very conservative?
Correct. It's very conservative. It's essentially saying "i need just SOME data... something minimal to say it caught something executing". It SHOULD catch it, but the more I raise these numbers, the more likely it is sometimes you get failures. At the start My numbers were chosen at about 20% of the minimum run of the code empirically. It's not 100%^ pure ASM so some is compiler generated code thus some may vary per binary produced by different compilers and options, so there has to be some leeway.
So I did lower the bar to "some data - just some" as opposed to "a reasonable amount of data" which would be larger numbers. The csv files still store this side-bad data anyway.
Quoted 15 lines
I would like hear Mike's opinion for these quality metrics; the patch itself is fine for me, you could add my review tag:
Reviewed-by Leo Yan <[email protected]>P.s. it's off-topic, just want to remind to use the "b4" tool when you spin for next version's patch set, e.g. you could use below commands:
$ b4 am [email protected] ^ ` I get the message ID from the page: https://lore.kernel.org/lkml/[email protected]/ $ git am ./v5_20220728_carsten_haitzler_a_patch_series_improving_data_quality_of_perf_test_for_coresight.mbx
Quoted 3 lines
We can benefit from this due "b4" can automatically append tags in patches; this can help us to track which patches have been reviewed and tested in previous versions.
OK - that's news to me. I'll look into it.
Quoted 9 lines
Thanks,
LeoQuoted 6 lines
tools/perf/tests/shell/coresight/unroll_loop_thread_10.sh new file +3
-0+ +err=$? +exit $errSignature · 1 line
2.32.0
PATCH v5 13/14 perf test: Add git ignore for tmp and output files of CoreSight tests
In reply to [email protected]From: "Carsten Haitzler (Rasterman)" <[email protected]>
Ignore other output files of the new CoreSight tests so they don't fill git status with noise we don't need or want.
--- tools/perf/.gitignore | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/.gitignore +2 -0
@@ -22,6 +22,7 @@ perf-archive perf-iostat tags TAGS +stats-*.csv cscope* config.mak config.mak.autogen
@@ -29,6 +30,7 @@ config.mak.autogen *-flex.* *.pyc *.pyo +*.stdout .config-detected util/intel-pt-decoder/inat-tables.c arch/*/include/generated/
Signature · 1 line
2.32.0
Re: [PATCH v5 13/14] perf test: Add git ignore for tmp and output files of CoreSight tests
Quoted 6 lines · On Thu, Jul 28, 2022 at 03:52:55PM +0100, [email protected] wrote:
From: "Carsten Haitzler (Rasterman)" <[email protected]>
Ignore other output files of the new CoreSight tests so they don't fill git status with noise we don't need or want.
Signed-off-by Carsten Haitzler <[email protected]>
Quoted 27 lines
--- tools/perf/.gitignore | 2 ++ 1 file changed, 2 insertions(+)tools/perf/.gitignore +2
-0@@ -22,6 +22,7 @@ perf-archive perf-iostat tags TAGS +stats-*.csv cscope* config.mak config.mak.autogen@@ -29,6 +30,7 @@ config.mak.autogen *-flex.* *.pyc *.pyo +*.stdout .config-detected util/intel-pt-decoder/inat-tables.c arch/*/include/generated/Signature · 1 line
2.32.0
PATCH v5 14/14 perf test: Add relevant documentation about CoreSight testing
In reply to [email protected]From: "Carsten Haitzler (Rasterman)" <[email protected]>
Add/improve documentation helping people get started with CoreSight and perf as well as describe the testing and how it works.
--- .../trace/coresight/coresight-perf.rst | 160 ++++++++++++++++++ tools/perf/Documentation/arm-coresight.txt | 5 + 2 files changed, 165 insertions(+) create mode 100644 Documentation/trace/coresight/coresight-perf.rst create mode 100644 tools/perf/Documentation/arm-coresight.txt
Documentation/trace/coresight/coresight-perf.rst new file +160 -0
@@ -0,0 +1,160 @@ +.. SPDX-License-Identifier: GPL-2.0 + +================ +CoreSight - Perf +================ + + :Author: Carsten Haitzler <[email protected]> + :Date: June 29th, 2022 + +Perf is able to locally access CoreSight trace data and store it to the +output perf data files. This data can then be later decoded to give the +instructions that were traced for debugging or profiling purposes. You +can log such data with a perf record command like:: + + perf record -e cs_etm//u testbinary + +This would run some test binary (testbinary) until it exits and record +a perf.data trace file. That file would have AUX sections if CoreSight +is working correctly. You can dump the content of this file as +readable text with a command like:: + + perf report --stdio --dump -i perf.data + +You should find some sections of this file have AUX data blocks like:: + + 0x1e78 [0x30]: PERF_RECORD_AUXTRACE size: 0x11dd0 offset: 0 ref: 0x1b614fc1061b0ad1 idx: 0 tid: 531230 cpu: -1 + + . ... CoreSight ETM Trace data: size 73168 bytes + Idx:0; ID:10; I_ASYNC : Alignment Synchronisation. + Idx:12; ID:10; I_TRACE_INFO : Trace Info.; INFO=0x0 { CC.0 } + Idx:17; ID:10; I_ADDR_L_64IS0 : Address, Long, 64 bit, IS0.; Addr=0x0000000000000000; + Idx:26; ID:10; I_TRACE_ON : Trace On. + Idx:27; ID:10; I_ADDR_CTXT_L_64IS0 : Address & Context, Long, 64 bit, IS0.; Addr=0x0000FFFFB6069140; Ctxt: AArch64,EL0, NS; + Idx:38; ID:10; I_ATOM_F6 : Atom format 6.; EEEEEEEEEEEEEEEEEEEEEEEE + Idx:39; ID:10; I_ATOM_F6 : Atom format 6.; EEEEEEEEEEEEEEEEEEEEEEEE + Idx:40; ID:10; I_ATOM_F6 : Atom format 6.; EEEEEEEEEEEEEEEEEEEEEEEE + Idx:41; ID:10; I_ATOM_F6 : Atom format 6.; EEEEEEEEEEEN + ... + +If you see these above, then your system is tracing CoreSight data +correctly. + +To compile perf with CoreSight support in the tools/perf directory do:: + + make CORESIGHT=1 + +This requires OpenCSD to build. You may install distribution packages +for the support such as libopencsd and libopencsd-dev or download it +and build yourself. Upstream OpenCSD is located at: + + https://github.com/Linaro/OpenCSD + +For complete information on building perf with CoreSight support and +more extensive usage look at: + + https://github.com/Linaro/OpenCSD/blob/master/HOWTO.md + + +Kernel CoreSight Support +------------------------ + +You will also want CoreSight support enabled in your kernel config. +Ensure it is enabled with:: + + CONFIG_CORESIGHT=y + +There are various other CoreSight options you probably also want +enabled like:: + + CONFIG_CORESIGHT_LINKS_AND_SINKS=y + CONFIG_CORESIGHT_LINK_AND_SINK_TMC=y + CONFIG_CORESIGHT_CATU=y + CONFIG_CORESIGHT_SINK_TPIU=y + CONFIG_CORESIGHT_SINK_ETBV10=y + CONFIG_CORESIGHT_SOURCE_ETM4X=y + CONFIG_CORESIGHT_STM=y + CONFIG_CORESIGHT_CPU_DEBUG=y + CONFIG_CORESIGHT_CTI=y + CONFIG_CORESIGHT_CTI_INTEGRATION_REGS=y + +Please refer to the kernel configuration help for more information. + +Perf test - Verify kernel and userspace perf CoreSight work +----------------------------------------------------------- + +When you run perf test, it will do a lot of self tests. Some of those +tests will cover CoreSight (only if enabled and on ARM64). You +generally would run perf test from the tools/perf directory in the +kernel tree. Some tests will check some internal perf support like: + + Check Arm CoreSight trace data recording and synthesized samples + Check Arm SPE trace data recording and synthesized samples + +Some others will actually use perf record and some test binaries that +are in tests/shell/coresight and will collect traces to ensure a +minimum level of functionality is met. The scripts that launch these +tests are in the same directory. These will all look like: + + CoreSight / ASM Pure Loop + CoreSight / Memcpy 16k 10 Threads + CoreSight / Thread Loop 10 Threads - Check TID + etc. + +These perf record tests will not run if the tool binaries do not exist +in tests/shell/coresight/*/ and will be skipped. If you do not have +CoreSight support in hardware then either do not build perf with +CoreSight support or remove these binaries in order to not have these +tests fail and have them skip instead. + +These tests will log historical results in the current working +directory (e.g. tools/perf) and will be named stats-\*.csv like: + + stats-asm_pure_loop-out.csv + stats-memcpy_thread-16k_10.csv + ... + +These statistic files log some aspects of the AUX data sections in +the perf data output counting some numbers of certain encodings (a +good way to know that it's working in a very simple way). One problem +with CoreSight is that given a large enough amount of data needing to +be logged, some of it can be lost due to the processor not waking up +in time to read out all the data from buffers etc.. You will notice +that the amount of data collected can vary a lot per run of perf test. +If you wish to see how this changes over time, simply run perf test +multiple times and all these csv files will have more and more data +appended to it that you can later examine, graph and otherwise use to +figure out if things have become worse or better. + +This means sometimes these tests fail as they don't capture all the +data needed. This is about tracking quality and amount of data +produced over time and to see when changes to the Linux kernel improve +quality of traces. + +Be aware that some of these tests take quite a while to run, specifically +in processing the perf data file and dumping contents to then examine what +is inside. + +You can change where these csv logs are stored by setting the +PERF_TEST_CORESIGHT_STATDIR environment variable before running perf +test like:: + + export PERF_TEST_CORESIGHT_STATDIR=/var/tmp + perf test + +They will also store resulting perf output data in the current +directory for later inspection like:: + + perf-asm_pure_loop-out.data + perf-memcpy_thread-16k_10.data + ... + +You can alter where the perf data files are stored by setting the +PERF_TEST_CORESIGHT_DATADIR environment variable such as:: + + PERF_TEST_CORESIGHT_DATADIR=/var/tmp + perf test + +You may wish to set these above environment variables if you whish to +keep the output of tests outside of the current working directory for +longer term storage and examination.
tools/perf/Documentation/arm-coresight.txt new file +5 -0
@@ -0,0 +1,5 @@ +Arm CoreSight Support +===================== + +For full documentation, see Documentation/trace/coresight/coresight-perf.rst +in the kernel tree.
Signature · 1 line
2.32.0
Re: [PATCH v5 14/14] perf test: Add relevant documentation about CoreSight testing
Quoted 87 lines · On Thu, Jul 28, 2022 at 03:52:56PM +0100, [email protected] wrote:
From: "Carsten Haitzler (Rasterman)" <[email protected]>
Add/improve documentation helping people get started with CoreSight and perf as well as describe the testing and how it works.
Signed-off-by Carsten Haitzler <[email protected]>--- .../trace/coresight/coresight-perf.rst | 160 ++++++++++++++++++ tools/perf/Documentation/arm-coresight.txt | 5 + 2 files changed, 165 insertions(+) create mode 100644 Documentation/trace/coresight/coresight-perf.rst create mode 100644 tools/perf/Documentation/arm-coresight.txtDocumentation/trace/coresight/coresight-perf.rst new file +67
-0@@ -0,0 +1,160 @@ +.. SPDX-License-Identifier: GPL-2.0 + +================ +CoreSight - Perf +================ + + :Author: Carsten Haitzler <[email protected]> + :Date: June 29th, 2022 + +Perf is able to locally access CoreSight trace data and store it to the +output perf data files. This data can then be later decoded to give the +instructions that were traced for debugging or profiling purposes. You +can log such data with a perf record command like:: + + perf record -e cs_etm//u testbinary + +This would run some test binary (testbinary) until it exits and record +a perf.data trace file. That file would have AUX sections if CoreSight +is working correctly. You can dump the content of this file as +readable text with a command like:: + + perf report --stdio --dump -i perf.data + +You should find some sections of this file have AUX data blocks like:: + + 0x1e78 [0x30]: PERF_RECORD_AUXTRACE size: 0x11dd0 offset: 0 ref: 0x1b614fc1061b0ad1 idx: 0 tid: 531230 cpu: -1 + + . ... CoreSight ETM Trace data: size 73168 bytes + Idx:0; ID:10; I_ASYNC : Alignment Synchronisation. + Idx:12; ID:10; I_TRACE_INFO : Trace Info.; INFO=0x0 { CC.0 } + Idx:17; ID:10; I_ADDR_L_64IS0 : Address, Long, 64 bit, IS0.; Addr=0x0000000000000000; + Idx:26; ID:10; I_TRACE_ON : Trace On. + Idx:27; ID:10; I_ADDR_CTXT_L_64IS0 : Address & Context, Long, 64 bit, IS0.; Addr=0x0000FFFFB6069140; Ctxt: AArch64,EL0, NS; + Idx:38; ID:10; I_ATOM_F6 : Atom format 6.; EEEEEEEEEEEEEEEEEEEEEEEE + Idx:39; ID:10; I_ATOM_F6 : Atom format 6.; EEEEEEEEEEEEEEEEEEEEEEEE + Idx:40; ID:10; I_ATOM_F6 : Atom format 6.; EEEEEEEEEEEEEEEEEEEEEEEE + Idx:41; ID:10; I_ATOM_F6 : Atom format 6.; EEEEEEEEEEEN + ... + +If you see these above, then your system is tracing CoreSight data +correctly. + +To compile perf with CoreSight support in the tools/perf directory do:: + + make CORESIGHT=1 + +This requires OpenCSD to build. You may install distribution packages +for the support such as libopencsd and libopencsd-dev or download it +and build yourself. Upstream OpenCSD is located at: + + https://github.com/Linaro/OpenCSD + +For complete information on building perf with CoreSight support and +more extensive usage look at: + + https://github.com/Linaro/OpenCSD/blob/master/HOWTO.md + + +Kernel CoreSight Support +------------------------ + +You will also want CoreSight support enabled in your kernel config. +Ensure it is enabled with:: + + CONFIG_CORESIGHT=y + +There are various other CoreSight options you probably also want
Documentation/trace/coresight/coresight-perf.rst line 77
Quoted 10 lines
Documentation/trace/coresight/coresight-perf.rst new file +10
-0+enabled like:: + + CONFIG_CORESIGHT_LINKS_AND_SINKS=y + CONFIG_CORESIGHT_LINK_AND_SINK_TMC=y + CONFIG_CORESIGHT_CATU=y + CONFIG_CORESIGHT_SINK_TPIU=y + CONFIG_CORESIGHT_SINK_ETBV10=y + CONFIG_CORESIGHT_SOURCE_ETM4X=y + CONFIG_CORESIGHT_STM=y + CONFIG_CORESIGHT_CPU_DEBUG=y
So far CORESIGHT_STM and CORESIGHT_CPU_DEBUG are irrelevant with perf recording. Perf only creates path from source (ETM) to sink (TMC-ETR or TMC-ETF), so it's good to drop them.
Quoted 71 lines
Documentation/trace/coresight/coresight-perf.rst new file +71
-0+ CONFIG_CORESIGHT_CTI=y + CONFIG_CORESIGHT_CTI_INTEGRATION_REGS=y + +Please refer to the kernel configuration help for more information. + +Perf test - Verify kernel and userspace perf CoreSight work +----------------------------------------------------------- + +When you run perf test, it will do a lot of self tests. Some of those +tests will cover CoreSight (only if enabled and on ARM64). You +generally would run perf test from the tools/perf directory in the +kernel tree. Some tests will check some internal perf support like: + + Check Arm CoreSight trace data recording and synthesized samples + Check Arm SPE trace data recording and synthesized samples + +Some others will actually use perf record and some test binaries that +are in tests/shell/coresight and will collect traces to ensure a +minimum level of functionality is met. The scripts that launch these +tests are in the same directory. These will all look like: + + CoreSight / ASM Pure Loop + CoreSight / Memcpy 16k 10 Threads + CoreSight / Thread Loop 10 Threads - Check TID + etc. + +These perf record tests will not run if the tool binaries do not exist +in tests/shell/coresight/*/ and will be skipped. If you do not have +CoreSight support in hardware then either do not build perf with +CoreSight support or remove these binaries in order to not have these +tests fail and have them skip instead. + +These tests will log historical results in the current working +directory (e.g. tools/perf) and will be named stats-\*.csv like: + + stats-asm_pure_loop-out.csv + stats-memcpy_thread-16k_10.csv + ... + +These statistic files log some aspects of the AUX data sections in +the perf data output counting some numbers of certain encodings (a +good way to know that it's working in a very simple way). One problem +with CoreSight is that given a large enough amount of data needing to +be logged, some of it can be lost due to the processor not waking up +in time to read out all the data from buffers etc.. You will notice +that the amount of data collected can vary a lot per run of perf test. +If you wish to see how this changes over time, simply run perf test +multiple times and all these csv files will have more and more data +appended to it that you can later examine, graph and otherwise use to +figure out if things have become worse or better. + +This means sometimes these tests fail as they don't capture all the +data needed. This is about tracking quality and amount of data +produced over time and to see when changes to the Linux kernel improve +quality of traces. + +Be aware that some of these tests take quite a while to run, specifically +in processing the perf data file and dumping contents to then examine what +is inside. + +You can change where these csv logs are stored by setting the +PERF_TEST_CORESIGHT_STATDIR environment variable before running perf +test like:: + + export PERF_TEST_CORESIGHT_STATDIR=/var/tmp + perf test + +They will also store resulting perf output data in the current +directory for later inspection like:: + + perf-asm_pure_loop-out.data
Documentation/trace/coresight/coresight-perf.rst line 158
Quoted 10 lines
Documentation/trace/coresight/coresight-perf.rst new file +10
-0+ perf-memcpy_thread-16k_10.data + ... + +You can alter where the perf data files are stored by setting the +PERF_TEST_CORESIGHT_DATADIR environment variable such as:: + + PERF_TEST_CORESIGHT_DATADIR=/var/tmp + perf test + +You may wish to set these above environment variables if you whish to
s/whish/wish/
tools/perf/Documentation/arm-coresight.txt
Quoted 7 lines
Documentation/trace/coresight/coresight-perf.rst new file +2
-0+keep the output of tests outside of the current working directory for +longer term storage and examination.tools/perf/Documentation/arm-coresight.txt new file +0
-0
You could see we have a document perf-arm-spe.txt, for alignment it's good to rename this file as perf-arm-coresight.txt.
The rest of this patch is good for me, with addressing the above minor comments:
Quoted 9 lines
tools/perf/Documentation/arm-coresight.txt new file +5
-0@@ -0,0 +1,5 @@ +Arm CoreSight Support +===================== + +For full documentation, see Documentation/trace/coresight/coresight-perf.rst +in the kernel tree.Signature · 1 line
2.32.0
Re: [PATCH v5 14/14] perf test: Add relevant documentation about CoreSight testing
Quoted 94 lines · Leo Yan
Quoted 93 lines · On Thu, Jul 28, 2022 at 03:52:56PM +0100, [email protected] wrote:
From: "Carsten Haitzler (Rasterman)" <[email protected]>
Add/improve documentation helping people get started with CoreSight and perf as well as describe the testing and how it works.
Signed-off-by Carsten Haitzler <[email protected]>--- .../trace/coresight/coresight-perf.rst | 160 ++++++++++++++++++ tools/perf/Documentation/arm-coresight.txt | 5 + 2 files changed, 165 insertions(+)create mode 100644
Documentation/trace/coresight/coresight-perf.rstcreate mode 100644tools/perf/Documentation/arm-coresight.txtDocumentation/trace/coresight/coresight-perf.rst new file +73
-0@@ -0,0 +1,160 @@ +.. SPDX-License-Identifier: GPL-2.0 + +================ +CoreSight - Perf +================ + + :Author: Carsten Haitzler <[email protected]> + :Date: June 29th, 2022 + +Perf is able to locally access CoreSight trace data and store it to the +output perf data files. This data can then be later decoded to give the +instructions that were traced for debugging or profiling purposes. You +can log such data with a perf record command like:: + + perf record -e cs_etm//u testbinary + +This would run some test binary (testbinary) until it exits and record +a perf.data trace file. That file would have AUX sections if CoreSight +is working correctly. You can dump the content of this file as +readable text with a command like:: + + perf report --stdio --dump -i perf.data + +You should find some sections of this file have AUX data blocks like:: + + 0x1e78 [0x30]: PERF_RECORD_AUXTRACE size: 0x11dd0 offset: 0 ref: 0x1b614fc1061b0ad1 idx: 0 tid: 531230 cpu: -1 + + . ... CoreSight ETM Trace data: size 73168 bytes + Idx:0; ID:10; I_ASYNC : Alignment Synchronisation. + Idx:12; ID:10; I_TRACE_INFO : Trace Info.; INFO=0x0 { CC.0 } + Idx:17; ID:10; I_ADDR_L_64IS0 : Address, Long, 64 bit, IS0.; Addr=0x0000000000000000; + Idx:26; ID:10; I_TRACE_ON : Trace On. + Idx:27; ID:10; I_ADDR_CTXT_L_64IS0 : Address & Context, Long, 64 bit, IS0.; Addr=0x0000FFFFB6069140; Ctxt: AArch64,EL0, NS; + Idx:38; ID:10; I_ATOM_F6 : Atom format 6.; EEEEEEEEEEEEEEEEEEEEEEEE + Idx:39; ID:10; I_ATOM_F6 : Atom format 6.; EEEEEEEEEEEEEEEEEEEEEEEE + Idx:40; ID:10; I_ATOM_F6 : Atom format 6.; EEEEEEEEEEEEEEEEEEEEEEEE + Idx:41; ID:10; I_ATOM_F6 : Atom format 6.; EEEEEEEEEEEN + ... + +If you see these above, then your system is tracing CoreSight data +correctly. + +To compile perf with CoreSight support in the tools/perf directory do:: + + make CORESIGHT=1 + +This requires OpenCSD to build. You may install distribution packages +for the support such as libopencsd and libopencsd-dev or download it +and build yourself. Upstream OpenCSD is located at: + + https://github.com/Linaro/OpenCSD + +For complete information on building perf with CoreSight support and +more extensive usage look at: + + https://github.com/Linaro/OpenCSD/blob/master/HOWTO.md + + +Kernel CoreSight Support +------------------------ + +You will also want CoreSight support enabled in your kernel config. +Ensure it is enabled with:: + + CONFIG_CORESIGHT=y + +There are various other CoreSight options you probably also want +enabled like:: + + CONFIG_CORESIGHT_LINKS_AND_SINKS=y + CONFIG_CORESIGHT_LINK_AND_SINK_TMC=y + CONFIG_CORESIGHT_CATU=y + CONFIG_CORESIGHT_SINK_TPIU=y
Quoted 8 lines
Documentation/trace/coresight/coresight-perf.rst line 77
Quoted 4 lines
Documentation/trace/coresight/coresight-perf.rst new file +4
-0+ CONFIG_CORESIGHT_SINK_ETBV10=y + CONFIG_CORESIGHT_SOURCE_ETM4X=y + CONFIG_CORESIGHT_STM=y + CONFIG_CORESIGHT_CPU_DEBUG=ySo far
CORESIGHT_STMandCORESIGHT_CPU_DEBUGare irrelevant with perf recording. Perf only creates path from source (ETM) to sink (TMC-ETR or TMC-ETF), so it's good to drop them.
will do.
Quoted 75 lines
Quoted 75 lines
Documentation/trace/coresight/coresight-perf.rst new file +75
-0+ CONFIG_CORESIGHT_CTI=y + CONFIG_CORESIGHT_CTI_INTEGRATION_REGS=y + +Please refer to the kernel configuration help for more information. + +Perf test - Verify kernel and userspace perf CoreSight work +----------------------------------------------------------- + +When you run perf test, it will do a lot of self tests. Some of those +tests will cover CoreSight (only if enabled and on ARM64). You +generally would run perf test from the tools/perf directory in the +kernel tree. Some tests will check some internal perf support like: + + Check Arm CoreSight trace data recording and synthesized samples + Check Arm SPE trace data recording and synthesized samples + +Some others will actually use perf record and some test binaries that +are in tests/shell/coresight and will collect traces to ensure a +minimum level of functionality is met. The scripts that launch these +tests are in the same directory. These will all look like: + + CoreSight / ASM Pure Loop + CoreSight / Memcpy 16k 10 Threads + CoreSight / Thread Loop 10 Threads - Check TID + etc. + +These perf record tests will not run if the tool binaries do not exist +in tests/shell/coresight/*/ and will be skipped. If you do not have +CoreSight support in hardware then either do not build perf with +CoreSight support or remove these binaries in order to not have these +tests fail and have them skip instead. + +These tests will log historical results in the current working +directory (e.g. tools/perf) and will be named stats-\*.csv like: + + stats-asm_pure_loop-out.csv + stats-memcpy_thread-16k_10.csv + ... + +These statistic files log some aspects of the AUX data sections in +the perf data output counting some numbers of certain encodings (a +good way to know that it's working in a very simple way). One problem +with CoreSight is that given a large enough amount of data needing to +be logged, some of it can be lost due to the processor not waking up +in time to read out all the data from buffers etc.. You will notice +that the amount of data collected can vary a lot per run of perf test. +If you wish to see how this changes over time, simply run perf test +multiple times and all these csv files will have more and more data +appended to it that you can later examine, graph and otherwise use to +figure out if things have become worse or better. + +This means sometimes these tests fail as they don't capture all the +data needed. This is about tracking quality and amount of data +produced over time and to see when changes to the Linux kernel improve +quality of traces. + +Be aware that some of these tests take quite a while to run, specifically +in processing the perf data file and dumping contents to then examine what +is inside. + +You can change where these csv logs are stored by setting the +PERF_TEST_CORESIGHT_STATDIR environment variable before running perf +test like:: + + export PERF_TEST_CORESIGHT_STATDIR=/var/tmp + perf test + +They will also store resulting perf output data in the current +directory for later inspection like:: + + perf-asm_pure_loop-out.data + perf-memcpy_thread-16k_10.data + ... + +You can alter where the perf data files are stored by setting the
Quoted 8 lines
Documentation/trace/coresight/coresight-perf.rst line 158
Quoted 6 lines
Documentation/trace/coresight/coresight-perf.rst new file +6
-0+PERF_TEST_CORESIGHT_DATADIR environment variable such as:: + + PERF_TEST_CORESIGHT_DATADIR=/var/tmp + perf test + +You may wish to set these above environment variables if you whish tos/whish/wish/
good catch. :)
Quoted 11 lines
tools/perf/Documentation/arm-coresight.txt
Quoted 7 lines
Documentation/trace/coresight/coresight-perf.rst new file +2
-0+keep the output of tests outside of the current working directory for +longer term storage and examination.tools/perf/Documentation/arm-coresight.txt new file +0
-0You could see we have a document perf-arm-spe.txt, for alignment it's good to rename this file as perf-arm-coresight.txt.
Quoted 2 lines
The rest of this patch is good for me, with addressing the above minor comments:
will do.
Quoted 12 lines
Reviewed-by Leo Yan <[email protected]>Quoted 9 lines
tools/perf/Documentation/arm-coresight.txt new file +5
-0@@ -0,0 +1,5 @@ +Arm CoreSight Support +===================== + +For full documentation, see Documentation/trace/coresight/coresight-perf.rst +in the kernel tree.Signature · 1 line
2.32.0
Mike Leach
Reviewed-byRe: [PATCH v5 14/14] perf test: Add relevant documentation about CoreSight testing
Quoted 214 lines · Carsten Haitzler
Quoted 94 lines · Leo Yan
Quoted 93 lines · On Thu, Jul 28, 2022 at 03:52:56PM +0100, [email protected] wrote:
From: "Carsten Haitzler (Rasterman)" <[email protected]>
Add/improve documentation helping people get started with CoreSight and perf as well as describe the testing and how it works.
Signed-off-by Carsten Haitzler <[email protected]>--- .../trace/coresight/coresight-perf.rst | 160 ++++++++++++++++++ tools/perf/Documentation/arm-coresight.txt | 5 + 2 files changed, 165 insertions(+)create mode 100644
Documentation/trace/coresight/coresight-perf.rstcreate mode 100644tools/perf/Documentation/arm-coresight.txtDocumentation/trace/coresight/coresight-perf.rst new file +73
-0@@ -0,0 +1,160 @@ +.. SPDX-License-Identifier: GPL-2.0 + +================ +CoreSight - Perf +================ + + :Author: Carsten Haitzler <[email protected]> + :Date: June 29th, 2022 + +Perf is able to locally access CoreSight trace data and store it to the +output perf data files. This data can then be later decoded to give the +instructions that were traced for debugging or profiling purposes. You +can log such data with a perf record command like:: + + perf record -e cs_etm//u testbinary + +This would run some test binary (testbinary) until it exits and record +a perf.data trace file. That file would have AUX sections if CoreSight +is working correctly. You can dump the content of this file as +readable text with a command like:: + + perf report --stdio --dump -i perf.data + +You should find some sections of this file have AUX data blocks like:: + + 0x1e78 [0x30]: PERF_RECORD_AUXTRACE size: 0x11dd0 offset: 0 ref: 0x1b614fc1061b0ad1 idx: 0 tid: 531230 cpu: -1 + + . ... CoreSight ETM Trace data: size 73168 bytes + Idx:0; ID:10; I_ASYNC : Alignment Synchronisation. + Idx:12; ID:10; I_TRACE_INFO : Trace Info.; INFO=0x0 { CC.0 } + Idx:17; ID:10; I_ADDR_L_64IS0 : Address, Long, 64 bit, IS0.; Addr=0x0000000000000000; + Idx:26; ID:10; I_TRACE_ON : Trace On. + Idx:27; ID:10; I_ADDR_CTXT_L_64IS0 : Address & Context, Long, 64 bit, IS0.; Addr=0x0000FFFFB6069140; Ctxt: AArch64,EL0, NS; + Idx:38; ID:10; I_ATOM_F6 : Atom format 6.; EEEEEEEEEEEEEEEEEEEEEEEE + Idx:39; ID:10; I_ATOM_F6 : Atom format 6.; EEEEEEEEEEEEEEEEEEEEEEEE + Idx:40; ID:10; I_ATOM_F6 : Atom format 6.; EEEEEEEEEEEEEEEEEEEEEEEE + Idx:41; ID:10; I_ATOM_F6 : Atom format 6.; EEEEEEEEEEEN + ... + +If you see these above, then your system is tracing CoreSight data +correctly. + +To compile perf with CoreSight support in the tools/perf directory do:: + + make CORESIGHT=1 + +This requires OpenCSD to build. You may install distribution packages +for the support such as libopencsd and libopencsd-dev or download it +and build yourself. Upstream OpenCSD is located at: + + https://github.com/Linaro/OpenCSD + +For complete information on building perf with CoreSight support and +more extensive usage look at: + + https://github.com/Linaro/OpenCSD/blob/master/HOWTO.md + + +Kernel CoreSight Support +------------------------ + +You will also want CoreSight support enabled in your kernel config. +Ensure it is enabled with:: + + CONFIG_CORESIGHT=y + +There are various other CoreSight options you probably also want +enabled like:: + + CONFIG_CORESIGHT_LINKS_AND_SINKS=y + CONFIG_CORESIGHT_LINK_AND_SINK_TMC=y + CONFIG_CORESIGHT_CATU=y + CONFIG_CORESIGHT_SINK_TPIU=yQuoted 8 lines
Documentation/trace/coresight/coresight-perf.rst line 77
Quoted 4 lines
Documentation/trace/coresight/coresight-perf.rst new file +4
-0+ CONFIG_CORESIGHT_SINK_ETBV10=y + CONFIG_CORESIGHT_SOURCE_ETM4X=y + CONFIG_CORESIGHT_STM=y + CONFIG_CORESIGHT_CPU_DEBUG=ySo far
CORESIGHT_STMandCORESIGHT_CPU_DEBUGare irrelevant with perf recording. Perf only creates path from source (ETM) to sink (TMC-ETR or TMC-ETF), so it's good to drop them.will do.
Quoted 75 lines
Quoted 75 lines
Documentation/trace/coresight/coresight-perf.rst new file +75
-0+ CONFIG_CORESIGHT_CTI=y + CONFIG_CORESIGHT_CTI_INTEGRATION_REGS=y + +Please refer to the kernel configuration help for more information. + +Perf test - Verify kernel and userspace perf CoreSight work +----------------------------------------------------------- + +When you run perf test, it will do a lot of self tests. Some of those +tests will cover CoreSight (only if enabled and on ARM64). You +generally would run perf test from the tools/perf directory in the +kernel tree. Some tests will check some internal perf support like: + + Check Arm CoreSight trace data recording and synthesized samples + Check Arm SPE trace data recording and synthesized samples + +Some others will actually use perf record and some test binaries that +are in tests/shell/coresight and will collect traces to ensure a +minimum level of functionality is met. The scripts that launch these +tests are in the same directory. These will all look like: + + CoreSight / ASM Pure Loop + CoreSight / Memcpy 16k 10 Threads + CoreSight / Thread Loop 10 Threads - Check TID + etc. + +These perf record tests will not run if the tool binaries do not exist +in tests/shell/coresight/*/ and will be skipped. If you do not have +CoreSight support in hardware then either do not build perf with +CoreSight support or remove these binaries in order to not have these +tests fail and have them skip instead. + +These tests will log historical results in the current working +directory (e.g. tools/perf) and will be named stats-\*.csv like: + + stats-asm_pure_loop-out.csv + stats-memcpy_thread-16k_10.csv + ... + +These statistic files log some aspects of the AUX data sections in +the perf data output counting some numbers of certain encodings (a +good way to know that it's working in a very simple way). One problem +with CoreSight is that given a large enough amount of data needing to +be logged, some of it can be lost due to the processor not waking up +in time to read out all the data from buffers etc.. You will notice +that the amount of data collected can vary a lot per run of perf test. +If you wish to see how this changes over time, simply run perf test +multiple times and all these csv files will have more and more data +appended to it that you can later examine, graph and otherwise use to +figure out if things have become worse or better. + +This means sometimes these tests fail as they don't capture all the +data needed. This is about tracking quality and amount of data +produced over time and to see when changes to the Linux kernel improve +quality of traces. + +Be aware that some of these tests take quite a while to run, specifically +in processing the perf data file and dumping contents to then examine what +is inside. + +You can change where these csv logs are stored by setting the +PERF_TEST_CORESIGHT_STATDIR environment variable before running perf +test like:: + + export PERF_TEST_CORESIGHT_STATDIR=/var/tmp + perf test + +They will also store resulting perf output data in the current +directory for later inspection like:: + + perf-asm_pure_loop-out.data + perf-memcpy_thread-16k_10.data + ... + +You can alter where the perf data files are stored by setting theQuoted 8 lines
Documentation/trace/coresight/coresight-perf.rst line 158
Quoted 6 lines
Documentation/trace/coresight/coresight-perf.rst new file +6
-0+PERF_TEST_CORESIGHT_DATADIR environment variable such as:: + + PERF_TEST_CORESIGHT_DATADIR=/var/tmp + perf test + +You may wish to set these above environment variables if you whish tos/whish/wish/
good catch. :)
Quoted 11 lines
tools/perf/Documentation/arm-coresight.txt
Quoted 7 lines
Documentation/trace/coresight/coresight-perf.rst new file +2
-0+keep the output of tests outside of the current working directory for +longer term storage and examination.tools/perf/Documentation/arm-coresight.txt new file +0
-0You could see we have a document perf-arm-spe.txt, for alignment it's good to rename this file as perf-arm-coresight.txt.
Quoted 2 lines
The rest of this patch is good for me, with addressing the above minor comments:
will do.
Quoted 3 lines
Reviewed-by Leo Yan <[email protected]>
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
tools/perf/Documentation/arm-coresight.txt new file +5
-1@@ -0,0 +1,5 @@ +Arm CoreSight Support +===================== + +For full documentation, see Documentation/trace/coresight/coresight-perf.rst +in the kernel tree. --2.32.0
Signature · 3 lines
Mike Leach Principal Engineer, ARM Ltd. Manchester Design Centre. UK
Hi Carsten,
Been running the tests on my Dragonboard DB410 and see the following:-
1) for every test I get a warning of the form:-
[ 4167.796633] cma: cma_alloc: reserved: alloc failed, req-size: 4096
pages, ret: -12
meaning the initial allocation for teh perf buffer has failed. is the allocation size for the perf buffer mmap fixed or can it be set for the individual target?
Not sure if this is a worry - as far as I recall, if the ETR driver cannot set a buffer size it reduces till it can.
2) A couple of the TID tests fail in my case, but the interesting output I get if I use -v is=>
77: CoreSight / Thread Loop 10 Threads - Check TID :
--- start ---
test child forked, pid 4646
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 2.005 MB ./perf-thread_loop-check-tid-10th.data ]
Warning:
Please install libunwind or libdw development packages during the perf build. Warning:
AUX data lost 2 times out of 2!
Thread IDs 4662 4662 4662 4662 4662 4662 4662 4662 not found in perf AUX data test child finished with -1
---- end ----
CoreSight / Thread Loop 10 Threads - Check TID: FAILED!
78: CoreSight / Thread Loop 2 Threads - Check TID :
--- start ---
test child forked, pid 4693
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.005 MB ./perf-thread_loop-check-tid-2th.data ]
Warning:
Please install libunwind or libdw development packages during the perf build. Thread IDs 4699 4699 not found in perf AUX data
test child finished with -1
---- end ----
Are we expecting the same TID to be repeated in that way?
Regards
Mike
Quoted 96 lines · On Thu, 28 Jul 2022 at 15:53, <[email protected]> wrote:
From: "Carsten Haitzler (Rasterman)" <[email protected]>
This is a prelude to adding more tests to shell tests and in order to support putting those tests into subdirectories, I need to change the test code that scans/finds and runs them.
To support subdirs I have to recurse so it's time to refactor the code to allow this and centralize the shell script finding into one location and only one single scan that builds a list of all the found tests in memory instead of it being duplicated in 3 places.
This code also optimizes things like knowing the max width of desciption strings (as we can do that while we scan instead of a whole new pass of opening files). It also more cleanly filters scripts to see only *.sh files thus skipping random other files in directories like *~ backup files, other random junk/data files that may appear and the scripts must be executable to make the cut (this ensures the script lib dir is not seen as scripts to run). This avoids perf test running previous older versions of test scripts that are editor backup files as well as skipping perf.data files that may appear and so on.
Signed-off-by Carsten Haitzler <[email protected]>Carsten Haitzler (Rasterman) (14):
perf test: Refactor shell tests allowing subdirs
perf test: Add CoreSight shell lib shared code for future tests perf test: Add build infra for perf test tools for CoreSight tests perf test: Add asm pureloop test tool
perf test: Add asm pureloop test shell script
perf test: Add git ignore for perf data generated by the CoreSight
tests
perf test: Add memcpy thread test tool
perf test: Add memcpy thread test shell script
perf test: Add thread loop test tool
perf test: Add thread loop test shell scripts
perf test: Add unroll thread test tool
perf test: Add unroll thread test shell script
perf test: Add git ignore for tmp and output files of CoreSight tests perf test: Add relevant documentation about CoreSight testing.../trace/coresight/coresight-perf.rst | 160 ++++++++++++++ MAINTAINERS | 1 + tools/perf/.gitignore | 6 +- tools/perf/Documentation/arm-coresight.txt | 5 + tools/perf/Makefile.perf | 18 +- tools/perf/tests/Build | 1 + tools/perf/tests/builtin-test-list.c | 207 ++++++++++++++++++ tools/perf/tests/builtin-test-list.h | 12 + tools/perf/tests/builtin-test.c | 152 ++----------- tools/perf/tests/shell/coresight/Makefile | 30 +++ .../tests/shell/coresight/Makefile.miniconfig | 24 ++ .../tests/shell/coresight/asm_pure_loop.sh | 18 ++ .../shell/coresight/asm_pure_loop/.gitignore | 1 + .../shell/coresight/asm_pure_loop/Makefile | 34 +++ .../coresight/asm_pure_loop/asm_pure_loop.S | 28 +++ .../shell/coresight/memcpy_thread/.gitignore | 1 + .../shell/coresight/memcpy_thread/Makefile | 33 +++ .../coresight/memcpy_thread/memcpy_thread.c | 79 +++++++ .../shell/coresight/memcpy_thread_16k_10.sh | 18 ++ .../shell/coresight/thread_loop/.gitignore | 1 + .../shell/coresight/thread_loop/Makefile | 33 +++ .../shell/coresight/thread_loop/thread_loop.c | 86 ++++++++ .../coresight/thread_loop_check_tid_10.sh | 19 ++ .../coresight/thread_loop_check_tid_2.sh | 19 ++ .../coresight/unroll_loop_thread/.gitignore | 1 + .../coresight/unroll_loop_thread/Makefile | 33 +++ .../unroll_loop_thread/unroll_loop_thread.c | 74 +++++++ .../shell/coresight/unroll_loop_thread_10.sh | 18 ++ tools/perf/tests/shell/lib/coresight.sh | 132 +++++++++++ 29 files changed, 1105 insertions(+), 139 deletions(-) create mode 100644 Documentation/trace/coresight/coresight-perf.rst create mode 100644 tools/perf/Documentation/arm-coresight.txt create mode 100644 tools/perf/tests/builtin-test-list.c create mode 100644 tools/perf/tests/builtin-test-list.h create mode 100644 tools/perf/tests/shell/coresight/Makefile create mode 100644 tools/perf/tests/shell/coresight/Makefile.miniconfig create mode 100755 tools/perf/tests/shell/coresight/asm_pure_loop.sh create mode 100644 tools/perf/tests/shell/coresight/asm_pure_loop/.gitignore create mode 100644 tools/perf/tests/shell/coresight/asm_pure_loop/Makefile create mode 100644 tools/perf/tests/shell/coresight/asm_pure_loop/asm_pure_loop.S create mode 100644 tools/perf/tests/shell/coresight/memcpy_thread/.gitignore create mode 100644 tools/perf/tests/shell/coresight/memcpy_thread/Makefile create mode 100644 tools/perf/tests/shell/coresight/memcpy_thread/memcpy_thread.c create mode 100755 tools/perf/tests/shell/coresight/memcpy_thread_16k_10.sh create mode 100644 tools/perf/tests/shell/coresight/thread_loop/.gitignore create mode 100644 tools/perf/tests/shell/coresight/thread_loop/Makefile create mode 100644 tools/perf/tests/shell/coresight/thread_loop/thread_loop.c create mode 100755 tools/perf/tests/shell/coresight/thread_loop_check_tid_10.sh create mode 100755 tools/perf/tests/shell/coresight/thread_loop_check_tid_2.sh create mode 100644 tools/perf/tests/shell/coresight/unroll_loop_thread/.gitignore create mode 100644 tools/perf/tests/shell/coresight/unroll_loop_thread/Makefile create mode 100644 tools/perf/tests/shell/coresight/unroll_loop_thread/unroll_loop_thread.c create mode 100755 tools/perf/tests/shell/coresight/unroll_loop_thread_10.sh create mode 100644 tools/perf/tests/shell/lib/coresight.sh
Quoted 3 lines
--
2.32.0
--
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK