* [PATCH 01/12] perf test: Shell - Limit to only run executable scripts in tests @ 2021-12-15 16:22 carsten.haitzler 2021-12-15 16:22 ` [PATCH 02/12] perf test: Shell - only run .sh shell files to skip other files carsten.haitzler ` (9 more replies) 0 siblings, 10 replies; 19+ messages in thread From: carsten.haitzler @ 2021-12-15 16:22 UTC (permalink / raw) To: linux-perf-users From: Carsten Haitzler <carsten.haitzler@arm.com> Perf test's shell runner will just run everything in the tests directory (as long as it's not another directory or does not begin with a dot), but sometimes you find files in there that are not shell scripts - perf.data output for example if you do some testing and then the next time you run perf test it tries to run these. Check the files are executable so they are actually intended to be test scripts and not just some "random junk" files there. Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com> --- tools/perf/tests/builtin-test.c | 4 +++- tools/perf/util/path.c | 12 ++++++++++++ tools/perf/util/path.h | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 8cb5a1c3489e..ece272b55587 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -295,7 +295,9 @@ static const char *shell_test__description(char *description, size_t size, #define for_each_shell_test(entlist, nr, base, ent) \ for (int __i = 0; __i < nr && (ent = entlist[__i]); __i++) \ - if (!is_directory(base, ent) && ent->d_name[0] != '.') + if (!is_directory(base, ent) && \ + is_executable_file(base, ent) && \ + ent->d_name[0] != '.') static const char *shell_tests__dir(char *path, size_t size) { diff --git a/tools/perf/util/path.c b/tools/perf/util/path.c index caed0336429f..7dde8c230ae8 100644 --- a/tools/perf/util/path.c +++ b/tools/perf/util/path.c @@ -92,3 +92,15 @@ bool is_directory(const char *base_path, const struct dirent *dent) return S_ISDIR(st.st_mode); } + +bool is_executable_file(const char *base_path, const struct dirent *dent) +{ + char path[PATH_MAX]; + struct stat st; + + sprintf(path, "%s/%s", base_path, dent->d_name); + if (stat(path, &st)) + return false; + + return !S_ISDIR(st.st_mode) && (st.st_mode & S_IXUSR); +} diff --git a/tools/perf/util/path.h b/tools/perf/util/path.h index 083429b7efa3..d94902c22222 100644 --- a/tools/perf/util/path.h +++ b/tools/perf/util/path.h @@ -12,5 +12,6 @@ int path__join3(char *bf, size_t size, const char *path1, const char *path2, con bool is_regular_file(const char *file); bool is_directory(const char *base_path, const struct dirent *dent); +bool is_executable_file(const char *base_path, const struct dirent *dent); #endif /* _PERF_PATH_H */ -- 2.32.0 ^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 02/12] perf test: Shell - only run .sh shell files to skip other files 2021-12-15 16:22 [PATCH 01/12] perf test: Shell - Limit to only run executable scripts in tests carsten.haitzler @ 2021-12-15 16:22 ` carsten.haitzler 2021-12-15 16:22 ` [PATCH 03/12] perf test: Use 3 digits for test numbering now we can have more tests carsten.haitzler ` (8 subsequent siblings) 9 siblings, 0 replies; 19+ messages in thread From: carsten.haitzler @ 2021-12-15 16:22 UTC (permalink / raw) To: linux-perf-users From: Carsten Haitzler <carsten.haitzler@arm.com> You edit your scripts in the tests and end up with your usual shell backup files with ~ or .bak or something else at the end, but then your next perf test run wants to run the backups too. You might also have perf .data files in the directory or something else undesireable as well. You end up chasing which test is the one you edited and the backup and have to keep removing all the backup files, so automatically skip any files that are not plain *.sh scripts to limit the time wasted in chasing ghosts. Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com> --- tools/perf/tests/builtin-test.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index ece272b55587..849737ead9fd 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -297,7 +297,20 @@ static const char *shell_test__description(char *description, size_t size, for (int __i = 0; __i < nr && (ent = entlist[__i]); __i++) \ if (!is_directory(base, ent) && \ is_executable_file(base, ent) && \ - ent->d_name[0] != '.') + ent->d_name[0] != '.' && \ + (shell_file_is_sh(ent->d_name) == 0)) + +static int shell_file_is_sh(const char *file) +{ + const char *ext; + + ext = strchr(file, '.'); + if (!ext) + return -1; + if (!strcmp(ext, ".sh")) + return 0; + return -1; +} static const char *shell_tests__dir(char *path, size_t size) { -- 2.32.0 ^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 03/12] perf test: Use 3 digits for test numbering now we can have more tests 2021-12-15 16:22 [PATCH 01/12] perf test: Shell - Limit to only run executable scripts in tests carsten.haitzler 2021-12-15 16:22 ` [PATCH 02/12] perf test: Shell - only run .sh shell files to skip other files carsten.haitzler @ 2021-12-15 16:22 ` carsten.haitzler 2021-12-15 16:22 ` [PATCH 04/12] perf test: Add beginning of test infra + test to exercise coresight carsten.haitzler ` (7 subsequent siblings) 9 siblings, 0 replies; 19+ messages in thread From: carsten.haitzler @ 2021-12-15 16:22 UTC (permalink / raw) To: linux-perf-users From: Carsten Haitzler <carsten.haitzler@arm.com> This is in preparation for adding more tests that will need the test number to be 3 digts so they align nicely in the output. Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com> --- tools/perf/tests/builtin-test.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 849737ead9fd..8652dcc4912c 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -435,7 +435,7 @@ static int run_shell_tests(int argc, const char *argv[], int i, int width, continue; st.file = ent->d_name; - pr_info("%2d: %-*s:", i, width, test_suite.desc); + pr_info("%3d: %-*s:", i, width, test_suite.desc); if (intlist__find(skiplist, i)) { color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (user override)\n"); @@ -485,7 +485,7 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) continue; } - pr_info("%2d: %-*s:", i, width, test_description(t, -1)); + pr_info("%3d: %-*s:", i, width, test_description(t, -1)); if (intlist__find(skiplist, i)) { color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (user override)\n"); @@ -525,7 +525,7 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) curr, argc, argv)) continue; - pr_info("%2d.%1d: %-*s:", i, subi + 1, subw, + pr_info("%3d.%1d: %-*s:", i, subi + 1, subw, test_description(t, subi)); test_and_print(t, subi); } @@ -560,7 +560,7 @@ static int perf_test__list_shell(int argc, const char **argv, int i) if (!perf_test__matches(t.desc, curr, argc, argv)) continue; - pr_info("%2d: %s\n", i, t.desc); + pr_info("%3d: %s\n", i, t.desc); } @@ -582,14 +582,14 @@ static int perf_test__list(int argc, const char **argv) if (!perf_test__matches(test_description(t, -1), curr, argc, argv)) continue; - pr_info("%2d: %s\n", i, test_description(t, -1)); + pr_info("%3d: %s\n", i, test_description(t, -1)); if (has_subtests(t)) { int subn = num_subtests(t); int subi; for (subi = 0; subi < subn; subi++) - pr_info("%2d:%1d: %s\n", i, subi + 1, + pr_info("%3d:%1d: %s\n", i, subi + 1, test_description(t, subi)); } } -- 2.32.0 ^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 04/12] perf test: Add beginning of test infra + test to exercise coresight 2021-12-15 16:22 [PATCH 01/12] perf test: Shell - Limit to only run executable scripts in tests carsten.haitzler 2021-12-15 16:22 ` [PATCH 02/12] perf test: Shell - only run .sh shell files to skip other files carsten.haitzler 2021-12-15 16:22 ` [PATCH 03/12] perf test: Use 3 digits for test numbering now we can have more tests carsten.haitzler @ 2021-12-15 16:22 ` carsten.haitzler 2021-12-15 16:22 ` [PATCH 05/12] perf test: Add coresight test to check all threads get some data logged carsten.haitzler ` (6 subsequent siblings) 9 siblings, 0 replies; 19+ messages in thread From: carsten.haitzler @ 2021-12-15 16:22 UTC (permalink / raw) To: linux-perf-users From: Carsten Haitzler <carsten.haitzler@arm.com> This adds the initial test harness to run perf record and examine the resuling output when coresight is enabled on arm64 and check the resulting quality of the output as part of perf test. Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com> --- MAINTAINERS | 3 + tools/perf/Makefile.perf | 14 +- .../tests/shell/coresight_asm_pure_loop.sh | 18 +++ tools/perf/tests/shell/lib/coresight.sh | 130 ++++++++++++++++++ tools/perf/tests/shell/tools/Makefile | 26 ++++ .../perf/tests/shell/tools/coresight/Makefile | 27 ++++ .../shell/tools/coresight/Makefile.miniconfig | 23 ++++ .../tools/coresight/asm_pure_loop/Makefile | 30 ++++ .../coresight/asm_pure_loop/asm_pure_loop.S | 28 ++++ 9 files changed, 297 insertions(+), 2 deletions(-) create mode 100755 tools/perf/tests/shell/coresight_asm_pure_loop.sh create mode 100644 tools/perf/tests/shell/lib/coresight.sh create mode 100644 tools/perf/tests/shell/tools/Makefile create mode 100644 tools/perf/tests/shell/tools/coresight/Makefile create mode 100644 tools/perf/tests/shell/tools/coresight/Makefile.miniconfig create mode 100644 tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile create mode 100644 tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S diff --git a/MAINTAINERS b/MAINTAINERS index 13f9a84a617e..d46e8469c467 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1894,6 +1894,9 @@ 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 F: tools/perf/arch/arm/util/pmu.c +F: tools/perf/tests/shell/coresight_* +F: tools/perf/tests/shell/tools/Makefile +F: tools/perf/tests/shell/tools/coresight/* F: tools/perf/util/cs-etm-decoder/* F: tools/perf/util/cs-etm.* diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 80522bcfafe0..26467a2c71f4 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -630,7 +630,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_TOOLS_DIR := $(srctree)/tools/perf/tests/shell/tools + +tests-tools-targets: FORCE + $(Q)$(MAKE) -C $(TESTS_TOOLS_DIR) + +tests-tools-targets-clean: + $(Q)$(MAKE) -C $(TESTS_TOOLS_DIR) clean + +all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS) tests-tools-targets # Create python binding output directory if not already present _dummy := $(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python') @@ -1020,6 +1028,7 @@ install-tests: all install-gtk $(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' + $(Q)$(MAKE) -C tests/shell/tools install-tests install-bin: install-tools install-tests install-traceevent-plugins @@ -1088,7 +1097,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-tools-targets-clean $(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(OUTPUT)perf-iostat $(LANG_BINDINGS) $(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete $(Q)$(RM) $(OUTPUT).config-detected @@ -1155,5 +1164,6 @@ FORCE: .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell .PHONY: $(GIT-HEAD-PHONY) TAGS tags cscope FORCE prepare .PHONY: libtraceevent_plugins archheaders +.PHONY: $(TESTS_TOOLS_TARGETS) endif # force_fixdep diff --git a/tools/perf/tests/shell/coresight_asm_pure_loop.sh b/tools/perf/tests/shell/coresight_asm_pure_loop.sh new file mode 100755 index 000000000000..542d4a37e349 --- /dev/null +++ b/tools/perf/tests/shell/coresight_asm_pure_loop.sh @@ -0,0 +1,18 @@ +#!/bin/sh -e +# Coresight / ASM Pure Loop + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 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" 2601 334 334 + +err=$? +exit $err diff --git a/tools/perf/tests/shell/lib/coresight.sh b/tools/perf/tests/shell/lib/coresight.sh new file mode 100644 index 000000000000..cd6c1283e6f5 --- /dev/null +++ b/tools/perf/tests/shell/lib/coresight.sh @@ -0,0 +1,130 @@ +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 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. + +# perf record options for the perf tests to use +PERFRECMEM="-m ,128M" +PERFRECOPT="$PERFRECMEM -e cs_etm//u" + +# These tests need to be run as root or coresight won't allow large buffers +# and will not collect proper data +UID=`id -u` +if test "$UID" -ne 0; then + echo "Not running as root... skip" + exit 2 +fi + +TOOLS=$(dirname $0)/tools +DIR="$TOOLS/coresight/$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 2 +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 F3 atoms in just about + # anything but certainly we will see some trace info and async atom + # chunks. + DUMP="$DATD/perf-tmp-aux-dump.txt" + perf report --stdio --dump -i "$1" | \ + grep -o -e I_ATOM_F3 -e I_ASYNC -e I_TRACE_INFO > "$DUMP" + # Simply count how many of these atoms 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_F3_NUM=`grep I_ATOM_F3 "$DUMP" | wc -l` + ATOM_ASYNC_NUM=`grep I_ASYNC "$DUMP" | wc -l` + ATOM_TRACE_INFO_NUM=`grep I_TRACE_INFO "$DUMP" | wc -l` + rm -f "$DUMP" + + # Arguments provide minimums for a pass + CHECK_F3_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 F3 Count, Minimum, ATOM ASYNC Count, Minimum, TRACE INFO Count, Minimum" > "$STATF" + fi + echo -n "$ATOM_F3_NUM, $CHECK_F3_MIN, $ATOM_ASYNC_NUM, $CHECK_ASYNC_MIN, $ATOM_TRACE_INFO_NUM, $CHECK_TRACE_INFO_MIN" >> "$STATF" + + # Actually check to see if we passed or failed. + check_val_min "ATOM_F3" "$ATOM_F3_NUM" "$CHECK_F3_MIN" "$STATF" + check_val_min "ASYNC" "$ATOM_ASYNC_NUM" "$CHECK_ASYNC_MIN" "$STATF" + check_val_min "TRACE_INFO" "$ATOM_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` + + # 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 +} diff --git a/tools/perf/tests/shell/tools/Makefile b/tools/perf/tests/shell/tools/Makefile new file mode 100644 index 000000000000..c7ada20922fd --- /dev/null +++ b/tools/perf/tests/shell/tools/Makefile @@ -0,0 +1,26 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 +include ../../../../../tools/scripts/Makefile.include +include ../../../../../tools/scripts/Makefile.arch +include ../../../../../tools/scripts/utilities.mak + +SUBDIRS = \ + coresight + +all: $(SUBDIRS) +$(SUBDIRS): + $(Q)$(MAKE) -C $@ + +INSTALLDIRS = $(SUBDIRS:%=install-%) + +install-tests: all $(INSTALLDIRS) +$(INSTALLDIRS): + $(Q)$(MAKE) -C $(@:install-%=%) install-tests + +CLEANDIRS = $(SUBDIRS:%=clean-%) + +clean: $(CLEANDIRS) +$(CLEANDIRS): + $(Q)$(MAKE) -C $(@:clean-%=%) O=$(OUTPUT) clean >/dev/null + +.PHONY: all clean install-tests $(SUBDIRS) $(CLEANDIRS) $(INSTALLDIRS) diff --git a/tools/perf/tests/shell/tools/coresight/Makefile b/tools/perf/tests/shell/tools/coresight/Makefile new file mode 100644 index 000000000000..723006ea827c --- /dev/null +++ b/tools/perf/tests/shell/tools/coresight/Makefile @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 +include ../../../../../../tools/scripts/Makefile.include +include ../../../../../../tools/scripts/Makefile.arch +include ../../../../../../tools/scripts/utilities.mak + +SUBDIRS = \ + asm_pure_loop + +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) + diff --git a/tools/perf/tests/shell/tools/coresight/Makefile.miniconfig b/tools/perf/tests/shell/tools/coresight/Makefile.miniconfig new file mode 100644 index 000000000000..cedd26c6a0eb --- /dev/null +++ b/tools/perf/tests/shell/tools/coresight/Makefile.miniconfig @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Carsten Haitzler <carsten.haitzler@arm.com>, 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 + +include ../../../../../../scripts/Makefile.include +include ../../../../../../scripts/Makefile.arch +include ../../../../../../scripts/utilities.mak diff --git a/tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile new file mode 100644 index 000000000000..10c5a60cb71c --- /dev/null +++ b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 + +include ../Makefile.miniconfig + +BIN=asm_pure_loop +LIB= + +all: $(BIN) + +$(BIN): $(BIN).S +ifdef CORESIGHT +ifeq ($(ARCH),arm64) + $(Q)$(CC) $(BIN).S -nostdlib -static -o $(BIN) $(LIB) +endif +endif + +install-tests: all +ifdef CORESIGHT +ifeq ($(ARCH),arm64) + $(call QUIET_INSTALL, tests) \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)'; \ + $(INSTALL) $(BIN) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)/$(BIN)' +endif +endif + +clean: + $(Q)$(RM) -f $(BIN) + +.PHONY: all clean install-tests diff --git a/tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S new file mode 100644 index 000000000000..262876451021 --- /dev/null +++ b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Tamas Zsoldos <tamas.zsoldos@arm.com>, 2021 */ + +.globl _start +_start: + mov x0, 0x000fffff + 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 -- 2.32.0 ^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 05/12] perf test: Add coresight test to check all threads get some data logged 2021-12-15 16:22 [PATCH 01/12] perf test: Shell - Limit to only run executable scripts in tests carsten.haitzler ` (2 preceding siblings ...) 2021-12-15 16:22 ` [PATCH 04/12] perf test: Add beginning of test infra + test to exercise coresight carsten.haitzler @ 2021-12-15 16:22 ` carsten.haitzler 2021-12-15 16:22 ` [PATCH 06/12] perf test: Add tests to re-use the thread loop test to check aux data carsten.haitzler ` (5 subsequent siblings) 9 siblings, 0 replies; 19+ messages in thread From: carsten.haitzler @ 2021-12-15 16:22 UTC (permalink / raw) To: linux-perf-users From: Carsten Haitzler <carsten.haitzler@arm.com> This adds a test and test scripts to check that all threads in the target binary end up logging some kind of coresight aux data and that they are not missing. Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com> --- .../coresight_thread_loop_check_tid_10.sh | 19 ++++ .../coresight_thread_loop_check_tid_2.sh | 19 ++++ .../coresight_thread_loop_check_tid_250.sh | 19 ++++ .../perf/tests/shell/tools/coresight/Makefile | 3 +- .../tools/coresight/thread_loop/Makefile | 29 +++++++ .../tools/coresight/thread_loop/thread_loop.c | 86 +++++++++++++++++++ 6 files changed, 174 insertions(+), 1 deletion(-) 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 100755 tools/perf/tests/shell/coresight_thread_loop_check_tid_250.sh create mode 100644 tools/perf/tests/shell/tools/coresight/thread_loop/Makefile create mode 100644 tools/perf/tests/shell/tools/coresight/thread_loop/thread_loop.c diff --git a/tools/perf/tests/shell/coresight_thread_loop_check_tid_10.sh b/tools/perf/tests/shell/coresight_thread_loop_check_tid_10.sh new file mode 100755 index 000000000000..283ad9facdee --- /dev/null +++ b/tools/perf/tests/shell/coresight_thread_loop_check_tid_10.sh @@ -0,0 +1,19 @@ +#!/bin/sh -e +# Coresight / Thread Loop 10 Threads - Check TID + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 + +TEST="thread_loop" +. $(dirname $0)/lib/coresight.sh +ARGS="10 2000" +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 diff --git a/tools/perf/tests/shell/coresight_thread_loop_check_tid_2.sh b/tools/perf/tests/shell/coresight_thread_loop_check_tid_2.sh new file mode 100755 index 000000000000..ce8ba534bba2 --- /dev/null +++ b/tools/perf/tests/shell/coresight_thread_loop_check_tid_2.sh @@ -0,0 +1,19 @@ +#!/bin/sh -e +# Coresight / Thread Loop 2 Threads - Check TID + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 + +TEST="thread_loop" +. $(dirname $0)/lib/coresight.sh +ARGS="2 4000" +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 diff --git a/tools/perf/tests/shell/coresight_thread_loop_check_tid_250.sh b/tools/perf/tests/shell/coresight_thread_loop_check_tid_250.sh new file mode 100755 index 000000000000..cb14581c1e68 --- /dev/null +++ b/tools/perf/tests/shell/coresight_thread_loop_check_tid_250.sh @@ -0,0 +1,19 @@ +#!/bin/sh -e +# Coresight / Thread Loop 250 Threads - Check TID + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 + +TEST="thread_loop" +. $(dirname $0)/lib/coresight.sh +ARGS="250 100" +DATV="check-tid-250th" +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 diff --git a/tools/perf/tests/shell/tools/coresight/Makefile b/tools/perf/tests/shell/tools/coresight/Makefile index 723006ea827c..1edab729db76 100644 --- a/tools/perf/tests/shell/tools/coresight/Makefile +++ b/tools/perf/tests/shell/tools/coresight/Makefile @@ -5,7 +5,8 @@ include ../../../../../../tools/scripts/Makefile.arch include ../../../../../../tools/scripts/utilities.mak SUBDIRS = \ - asm_pure_loop + asm_pure_loop \ + thread_loop all: $(SUBDIRS) $(SUBDIRS): diff --git a/tools/perf/tests/shell/tools/coresight/thread_loop/Makefile b/tools/perf/tests/shell/tools/coresight/thread_loop/Makefile new file mode 100644 index 000000000000..424df4e8b0e6 --- /dev/null +++ b/tools/perf/tests/shell/tools/coresight/thread_loop/Makefile @@ -0,0 +1,29 @@ +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 +include ../Makefile.miniconfig + +BIN=thread_loop +LIB=-pthread + +all: $(BIN) + +$(BIN): $(BIN).c +ifdef CORESIGHT +ifeq ($(ARCH),arm64) + $(Q)$(CC) $(BIN).c -o $(BIN) $(LIB) +endif +endif + +install-tests: all +ifdef CORESIGHT +ifeq ($(ARCH),arm64) + $(call QUIET_INSTALL, tests) \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)'; \ + $(INSTALL) $(BIN) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)/$(BIN)' +endif +endif + +clean: + $(Q)$(RM) -f $(BIN) + +.PHONY: all clean install-tests diff --git a/tools/perf/tests/shell/tools/coresight/thread_loop/thread_loop.c b/tools/perf/tests/shell/tools/coresight/thread_loop/thread_loop.c new file mode 100644 index 000000000000..c0158fac7d0b --- /dev/null +++ b/tools/perf/tests/shell/tools/coresight/thread_loop/thread_loop.c @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0 +// Carsten Haitzler <carsten.haitzler@arm.com>, 2021 + +// define this for gettid() +#define _GNU_SOURCE + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <pthread.h> +#include <sys/syscall.h> +#ifndef SYS_gettid +// gettid is 178 on arm64 +# define SYS_gettid 178 +#endif +#define gettid() syscall(SYS_gettid) + +struct args { + unsigned int loops; + pthread_t th; + void *ret; +}; + +static void *thrfn(void *arg) +{ + struct args *a = arg; + int i = 0, len = a->loops; + + if (getenv("SHOW_TID")) { + unsigned long long tid = gettid(); + + printf("%llu\n", tid); + } + asm volatile( + "loop:\n" + "add %[i], %[i], #1\n" + "cmp %[i], %[len]\n" + "blt loop\n" + : /* out */ + : /* in */ [i] "r" (i), [len] "r" (len) + : /* clobber */ + ); + return (void *)(long)i; +} + +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, len, thr; + pthread_t threads[256]; + struct args args[256]; + + if (argc < 3) { + printf("ERR: %s [numthreads] [numloops (millions)]\n", argv[0]); + exit(1); + } + + thr = atoi(argv[1]); + if ((thr < 1) || (thr > 256)) { + printf("ERR: threads 1-256\n"); + exit(1); + } + len = atoi(argv[2]); + if ((len < 1) || (len > 4000)) { + printf("ERR: max loops 4000 (millions)\n"); + exit(1); + } + len *= 1000000; + for (i = 0; i < thr; i++) { + args[i].loops = len; + args[i].th = new_thr(thrfn, &(args[i])); + } + for (i = 0; i < thr; i++) + pthread_join(args[i].th, &(args[i].ret)); + return 0; +} -- 2.32.0 ^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 06/12] perf test: Add tests to re-use the thread loop test to check aux data 2021-12-15 16:22 [PATCH 01/12] perf test: Shell - Limit to only run executable scripts in tests carsten.haitzler ` (3 preceding siblings ...) 2021-12-15 16:22 ` [PATCH 05/12] perf test: Add coresight test to check all threads get some data logged carsten.haitzler @ 2021-12-15 16:22 ` carsten.haitzler 2021-12-15 16:22 ` [PATCH 07/12] perf test: Add simple bubblesort test for coresight " carsten.haitzler ` (4 subsequent siblings) 9 siblings, 0 replies; 19+ messages in thread From: carsten.haitzler @ 2021-12-15 16:22 UTC (permalink / raw) To: linux-perf-users From: Carsten Haitzler <carsten.haitzler@arm.com> This checks to see that the thread_loop tests produces sensible amounts of aux coresight data. Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com> --- .../tests/shell/coresight_thread_loop_2.sh | 18 ++++++++++++++++++ .../tests/shell/coresight_thread_loop_25.sh | 18 ++++++++++++++++++ .../tests/shell/coresight_thread_loop_250.sh | 18 ++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100755 tools/perf/tests/shell/coresight_thread_loop_2.sh create mode 100755 tools/perf/tests/shell/coresight_thread_loop_25.sh create mode 100755 tools/perf/tests/shell/coresight_thread_loop_250.sh diff --git a/tools/perf/tests/shell/coresight_thread_loop_2.sh b/tools/perf/tests/shell/coresight_thread_loop_2.sh new file mode 100755 index 000000000000..6d790b870a67 --- /dev/null +++ b/tools/perf/tests/shell/coresight_thread_loop_2.sh @@ -0,0 +1,18 @@ +#!/bin/sh -e +# Coresight / Thread Loop 2 Threads + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 + +TEST="thread_loop" +. $(dirname $0)/lib/coresight.sh +ARGS="2 20" +DATV="2th" +DATA="$DATD/perf-$TEST-$DATV.data" + +perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS + +perf_dump_aux_verify "$DATA" 724 11 11 + +err=$? +exit $err diff --git a/tools/perf/tests/shell/coresight_thread_loop_25.sh b/tools/perf/tests/shell/coresight_thread_loop_25.sh new file mode 100755 index 000000000000..cce74202e4db --- /dev/null +++ b/tools/perf/tests/shell/coresight_thread_loop_25.sh @@ -0,0 +1,18 @@ +#!/bin/sh -e +# Coresight / Thread Loop 25 Threads + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 + +TEST="thread_loop" +. $(dirname $0)/lib/coresight.sh +ARGS="25 2" +DATV="25th" +DATA="$DATD/perf-$TEST-$DATV.data" + +perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS + +perf_dump_aux_verify "$DATA" 388121 1255 1255 + +err=$? +exit $err diff --git a/tools/perf/tests/shell/coresight_thread_loop_250.sh b/tools/perf/tests/shell/coresight_thread_loop_250.sh new file mode 100755 index 000000000000..55f271462a4d --- /dev/null +++ b/tools/perf/tests/shell/coresight_thread_loop_250.sh @@ -0,0 +1,18 @@ +#!/bin/sh -e +# Coresight / Thread Loop 250 Threads + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 + +TEST="thread_loop" +. $(dirname $0)/lib/coresight.sh +ARGS="250 1" +DATV="250th" +DATA="$DATD/perf-$TEST-$DATV.data" + +perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS + +perf_dump_aux_verify "$DATA" 724 11 11 + +err=$? +exit $err -- 2.32.0 ^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 07/12] perf test: Add simple bubblesort test for coresight aux data 2021-12-15 16:22 [PATCH 01/12] perf test: Shell - Limit to only run executable scripts in tests carsten.haitzler ` (4 preceding siblings ...) 2021-12-15 16:22 ` [PATCH 06/12] perf test: Add tests to re-use the thread loop test to check aux data carsten.haitzler @ 2021-12-15 16:22 ` carsten.haitzler 2021-12-15 16:22 ` [PATCH 09/12] perf test: Add add memcpy test for coresight quality checking carsten.haitzler ` (3 subsequent siblings) 9 siblings, 0 replies; 19+ messages in thread From: carsten.haitzler @ 2021-12-15 16:22 UTC (permalink / raw) To: linux-perf-users From: Carsten Haitzler <carsten.haitzler@arm.com> This adds a simple bubblesort test that sorts small and large data sets to see if a sufficient mount of aux data is produced. Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com> --- .../shell/coresight_bubble_sort_random.sh | 20 + .../shell/coresight_bubble_sort_small.sh | 20 + .../perf/tests/shell/tools/coresight/Makefile | 3 +- .../tools/coresight/bubble_sort/Makefile | 31 + .../tools/coresight/bubble_sort/bubble_sort.c | 89 + .../coresight/bubble_sort/random_array.txt | 1855 +++++++++++++++++ .../coresight/bubble_sort/small_array.txt | 10 + 7 files changed, 2027 insertions(+), 1 deletion(-) create mode 100755 tools/perf/tests/shell/coresight_bubble_sort_random.sh create mode 100755 tools/perf/tests/shell/coresight_bubble_sort_small.sh create mode 100644 tools/perf/tests/shell/tools/coresight/bubble_sort/Makefile create mode 100644 tools/perf/tests/shell/tools/coresight/bubble_sort/bubble_sort.c create mode 100644 tools/perf/tests/shell/tools/coresight/bubble_sort/random_array.txt create mode 100644 tools/perf/tests/shell/tools/coresight/bubble_sort/small_array.txt diff --git a/tools/perf/tests/shell/coresight_bubble_sort_random.sh b/tools/perf/tests/shell/coresight_bubble_sort_random.sh new file mode 100755 index 000000000000..63567f8c4f8b --- /dev/null +++ b/tools/perf/tests/shell/coresight_bubble_sort_random.sh @@ -0,0 +1,20 @@ +#!/bin/sh -e +# Coresight / Bubblesort Random Array + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 + +TEST="bubble_sort" +. $(dirname $0)/lib/coresight.sh +ARGS="$DIR/random_array.txt" +DATV="random" +DATA="$DATD/perf-$TEST-$DATV.data" + +echo $ARGS + +perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS + +perf_dump_aux_verify "$DATA" 4188 1630 1630 + +err=$? +exit $err diff --git a/tools/perf/tests/shell/coresight_bubble_sort_small.sh b/tools/perf/tests/shell/coresight_bubble_sort_small.sh new file mode 100755 index 000000000000..ac86d9973fba --- /dev/null +++ b/tools/perf/tests/shell/coresight_bubble_sort_small.sh @@ -0,0 +1,20 @@ +#!/bin/sh -e +# Coresight / Bubblesort Small Array + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 + +TEST="bubble_sort" +. $(dirname $0)/lib/coresight.sh +ARGS="$DIR/small_array.txt" +DATV="small" +DATA="$DATD/perf-$TEST-$DATV.data" + +echo $ARGS + +perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS + +perf_dump_aux_verify "$DATA" 66 6 6 + +err=$? +exit $err diff --git a/tools/perf/tests/shell/tools/coresight/Makefile b/tools/perf/tests/shell/tools/coresight/Makefile index 1edab729db76..49fa80d28df4 100644 --- a/tools/perf/tests/shell/tools/coresight/Makefile +++ b/tools/perf/tests/shell/tools/coresight/Makefile @@ -6,7 +6,8 @@ include ../../../../../../tools/scripts/utilities.mak SUBDIRS = \ asm_pure_loop \ - thread_loop + thread_loop \ + bubble_sort all: $(SUBDIRS) $(SUBDIRS): diff --git a/tools/perf/tests/shell/tools/coresight/bubble_sort/Makefile b/tools/perf/tests/shell/tools/coresight/bubble_sort/Makefile new file mode 100644 index 000000000000..6b82854f9f2b --- /dev/null +++ b/tools/perf/tests/shell/tools/coresight/bubble_sort/Makefile @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 +include ../Makefile.miniconfig + +BIN=bubble_sort +LIB= + +all: $(BIN) + +$(BIN): $(BIN).c +ifdef CORESIGHT +ifeq ($(ARCH),arm64) + $(Q)$(CC) $(BIN).c -o $(BIN) $(LIB) +endif +endif + +install-tests: all +ifdef CORESIGHT +ifeq ($(ARCH),arm64) + $(call QUIET_INSTALL, tests) \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)'; \ + $(INSTALL) $(BIN) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)/$(BIN)'; \ + $(INSTALL) random_array.txt '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)/random_array.txt'; \ + $(INSTALL) small_array.txt '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)/small_array.txt' +endif +endif + +clean: + $(Q)$(RM) -f $(BIN) + +.PHONY: all clean install-tests diff --git a/tools/perf/tests/shell/tools/coresight/bubble_sort/bubble_sort.c b/tools/perf/tests/shell/tools/coresight/bubble_sort/bubble_sort.c new file mode 100644 index 000000000000..07169e03a803 --- /dev/null +++ b/tools/perf/tests/shell/tools/coresight/bubble_sort/bubble_sort.c @@ -0,0 +1,89 @@ +// SPDX-License-Identifier: GPL-2.0 +// Andrea Brunato <andrea.brunato@arm.com>, 2021 +// Example taken from: https://gcc.gnu.org/wiki/AutoFDO/Tutorial + +#include <stdlib.h> +#include <stdio.h> +#include <assert.h> + +int count_lines(FILE *fp) +{ + int lines_n = 0; + char c; + + for (c = getc(fp); !feof(fp); c = getc(fp)) { + if (c == '\n') + lines_n = lines_n + 1; + } + fseek(fp, 0, SEEK_SET); +#ifdef DEBUG + printf("Number of lines: %d\n", lines_n); +#endif + return lines_n; +} + +#ifdef DEBUG +void print_array(int *arr, int size) +{ + int i; + + assert(arr != NULL); + for (i = 0; i < size; i++) + printf("%d\n", arr[i]); +} +#endif + +void bubble_sort(int *a, int n) +{ + int i, t, s = 1; + + while (s) { + s = 0; + for (i = 1; i < n; i++) { + if (a[i] < a[i - 1]) { + t = a[i]; + a[i] = a[i - 1]; + a[i - 1] = t; + s = 1; + } + } + } +} + +void init_array(int *arr, int size, FILE *fp) +{ + int i; + + for (i = 0; i < size; i++) + fscanf(fp, "%d", &arr[i]); +} + +int main(int argc, char **argv) +{ + int lines_n = 0, *arr = NULL; + FILE *fp; + + assert((argc == 2) && "Please specify an input file\n"); + + fp = fopen(argv[1], "r"); + assert((fp != NULL) && "ERROR: Couldn't open the specified file\n"); + + // Input file expected formar: one number per line + lines_n = count_lines(fp); + + arr = malloc(sizeof(int) * lines_n); + init_array(arr, lines_n, fp); + + bubble_sort(arr, lines_n); + +#ifdef DEBUG + print_array(arr, lines_n); +#endif + + free(arr); + fclose(fp); + + return 0; +} + + diff --git a/tools/perf/tests/shell/tools/coresight/bubble_sort/random_array.txt b/tools/perf/tests/shell/tools/coresight/bubble_sort/random_array.txt new file mode 100644 index 000000000000..d041cfb7a649 --- /dev/null +++ b/tools/perf/tests/shell/tools/coresight/bubble_sort/random_array.txt @@ -0,0 +1,1855 @@ +11637 +3799 +23116 +15091 +13022 +15840 +27029 +27563 +25641 +28703 +3017 +29923 +26998 +18230 +26864 +9139 +28431 +18283 +21315 +28167 +7700 +14798 +15512 +20470 +9237 +29921 +28395 +15057 +29819 +26831 +5926 +26653 +390 +2976 +21651 +410 +11429 +1828 +3534 +31091 +9141 +30892 +29619 +5033 +20585 +15413 +28673 +32517 +8875 +7509 +22159 +1482 +28926 +2748 +25246 +23677 +2712 +20332 +23615 +2481 +28581 +29728 +13726 +26364 +28074 +23534 +12120 +4130 +1307 +20009 +15225 +17469 +12076 +11899 +22886 +2854 +4667 +11494 +25057 +18590 +15010 +9295 +6603 +12891 +14441 +5499 +26880 +21390 +15932 +3975 +11242 +19063 +27555 +28538 +30148 +14592 +3360 +21049 +24923 +29681 +5157 +15595 +8863 +19992 +12588 +32711 +3077 +22132 +10031 +21685 +1634 +22046 +7323 +17925 +20453 +3694 +4502 +13543 +1959 +9365 +25814 +29540 +30414 +551 +32722 +23697 +32501 +9890 +13134 +2408 +21814 +1692 +8219 +27175 +19880 +1971 +17913 +10985 +75 +6275 +29139 +7104 +3241 +24809 +13310 +17897 +32684 +7199 +2015 +31825 +20985 +30466 +25403 +28839 +3939 +30171 +9223 +27181 +1302 +7945 +18902 +22094 +28959 +28100 +1874 +29613 +4804 +23941 +31981 +1874 +25476 +10176 +2004 +16080 +32404 +24472 +14217 +9647 +24917 +15001 +15559 +23867 +32520 +2545 +2233 +28869 +13685 +26640 +6548 +27395 +13590 +2851 +1008 +10772 +10417 +17257 +19706 +21757 +27627 +13514 +4631 +19162 +1138 +6325 +22136 +12944 +16124 +12359 +25197 +13024 +13459 +31896 +4661 +12648 +24619 +29975 +2417 +30526 +9880 +32733 +19252 +25646 +12851 +25535 +22792 +21622 +25256 +9785 +11252 +23999 +22965 +10221 +32537 +754 +6831 +11892 +4420 +12472 +20903 +18420 +14968 +17626 +25366 +27811 +6781 +15767 +19341 +28487 +28252 +1225 +31467 +10531 +29736 +12770 +11237 +26065 +9298 +9389 +4413 +25708 +4222 +206 +1952 +16927 +17411 +19671 +23966 +21346 +5232 +26240 +11465 +24782 +20600 +18201 +4713 +32313 +4899 +14371 +11307 +5277 +2022 +14443 +14631 +28140 +23499 +3955 +7565 +18082 +28583 +26049 +11652 +27835 +5415 +29742 +8307 +8380 +20582 +5376 +28696 +762 +6860 +8829 +3579 +2620 +14623 +26606 +31027 +8334 +5654 +15247 +25230 +8096 +1998 +11131 +25257 +31275 +18099 +22294 +9458 +17779 +22216 +4149 +22198 +172 +23793 +30710 +4351 +9939 +13985 +11652 +59 +26587 +9059 +26071 +20826 +3493 +32165 +10983 +29045 +28704 +29635 +19259 +15806 +15124 +18009 +20333 +17020 +1086 +13690 +32368 +14632 +15249 +31064 +18941 +9348 +9006 +31486 +4229 +26282 +24749 +11214 +12670 +5822 +23520 +7971 +28458 +28781 +15391 +28848 +1629 +30060 +19100 +27055 +6999 +7166 +31382 +12066 +15730 +23622 +17211 +30853 +15946 +7092 +5278 +14151 +29985 +2197 +3038 +17757 +14821 +11374 +16227 +7657 +29476 +7761 +6718 +5380 +3255 +28899 +507 +21354 +8942 +21928 +17282 +15106 +8035 +17251 +28354 +14675 +16033 +23012 +10270 +3609 +12387 +4083 +22608 +18438 +10363 +31842 +25456 +2993 +12567 +12285 +10847 +4036 +25889 +2263 +7521 +8246 +27332 +6281 +5934 +2057 +24322 +22014 +18625 +17420 +11120 +4933 +18486 +9201 +22355 +20027 +14665 +6106 +16764 +1955 +2674 +24517 +23913 +20392 +16961 +25273 +5622 +29187 +20339 +11895 +10335 +9094 +20758 +14115 +44 +29610 +29161 +14578 +30088 +22551 +9064 +19533 +428 +27047 +210 +7836 +24192 +18636 +32533 +4747 +1086 +23230 +6341 +31606 +8201 +29138 +28172 +11305 +1387 +25794 +23095 +2600 +1452 +8294 +15374 +31146 +18513 +11 +7897 +30819 +31 +11752 +32591 +27803 +26885 +7667 +31592 +10244 +24349 +17836 +25237 +21489 +9578 +6322 +5457 +15157 +15541 +19222 +12621 +21554 +22651 +12729 +10582 +10290 +10887 +23746 +26686 +1585 +10165 +31947 +19779 +15980 +20878 +28201 +26455 +10696 +19505 +29741 +1935 +2223 +28124 +17789 +24280 +25012 +11103 +6445 +10182 +22947 +31249 +12870 +25620 +9034 +28337 +17508 +12857 +32045 +23453 +18922 +29958 +13095 +27482 +1809 +13962 +15407 +23537 +28052 +24819 +7332 +29319 +11951 +7396 +0 +24126 +1573 +15203 +1194 +31509 +19366 +23180 +21698 +24946 +14946 +8384 +30229 +10099 +5060 +23938 +12575 +7220 +29396 +25422 +22865 +3935 +31126 +14275 +9741 +25019 +26108 +8997 +29459 +5595 +14307 +22680 +13453 +23456 +1218 +889 +11412 +22111 +15488 +16512 +24954 +25449 +14049 +10795 +6430 +7939 +23312 +8849 +4246 +3910 +3920 +8279 +29146 +23176 +29495 +22478 +22801 +15464 +1404 +24320 +9644 +24047 +6372 +25831 +10546 +25452 +162 +12526 +10816 +2805 +12098 +18199 +22284 +2588 +632 +23869 +9515 +18597 +5439 +11016 +19721 +14495 +5671 +3879 +9479 +13968 +25634 +12409 +8940 +1133 +25751 +6666 +19636 +3114 +18339 +27366 +24370 +31234 +24247 +27662 +16433 +9814 +13447 +20513 +18877 +26999 +18659 +27305 +15751 +17192 +11982 +31198 +11367 +20537 +6868 +9125 +26707 +28962 +4645 +22880 +29957 +21981 +29763 +10879 +15307 +21373 +652 +471 +6426 +15176 +11717 +8774 +21421 +22152 +11363 +21204 +8266 +30627 +3237 +17767 +9548 +31154 +26199 +11867 +2590 +508 +5685 +9562 +4680 +3527 +21332 +29853 +4331 +26626 +5804 +8806 +30680 +11836 +2053 +13250 +18750 +12811 +3459 +18921 +14531 +11448 +4381 +19024 +7032 +10599 +19932 +23346 +21110 +31736 +5792 +10309 +407 +6914 +19374 +11265 +15050 +30440 +14511 +16243 +19207 +25865 +3421 +8436 +17959 +30839 +28976 +22855 +1350 +5242 +4582 +19248 +4215 +10734 +29691 +1157 +5396 +5088 +30686 +24674 +29795 +20935 +12005 +1845 +20897 +25337 +27343 +27057 +11172 +23295 +28899 +2790 +15386 +30010 +3736 +22563 +13654 +32418 +3320 +9260 +4893 +1352 +897 +24116 +27410 +7866 +32310 +19354 +2760 +3243 +30622 +26854 +1810 +28332 +6230 +2049 +10362 +12110 +19718 +1304 +17994 +19655 +16923 +9017 +17840 +19894 +9328 +22423 +11185 +18453 +985 +14984 +31486 +2702 +7584 +20132 +5354 +22683 +27453 +15499 +8065 +9823 +29909 +31059 +23496 +32412 +31828 +3667 +13160 +5790 +11816 +31151 +6194 +16912 +20180 +32485 +10858 +28523 +9886 +10689 +1200 +26441 +2446 +10208 +4201 +649 +19694 +21476 +30880 +8900 +9817 +19507 +27582 +16013 +27193 +4177 +29851 +5791 +22262 +28816 +8540 +23328 +26992 +28046 +19652 +2195 +2694 +5634 +7430 +6356 +25759 +17606 +25591 +9758 +17330 +7393 +20057 +31341 +24765 +29760 +20556 +31406 +24439 +16953 +30044 +8448 +19044 +15593 +11764 +10639 +10535 +7469 +13865 +1039 +11436 +1319 +4999 +17500 +13796 +24842 +29723 +24282 +27361 +30792 +32410 +23984 +1667 +8323 +8491 +13317 +388 +9755 +28091 +19517 +29286 +23245 +4345 +9550 +18217 +31425 +17815 +6570 +7935 +6310 +550 +11700 +23011 +25532 +6854 +103 +6814 +15256 +6215 +122 +32352 +10646 +641 +4857 +16185 +26396 +6434 +14595 +6690 +29538 +25092 +16330 +15523 +5603 +8869 +19911 +4792 +12133 +27733 +23723 +32383 +1051 +10146 +8913 +6907 +4710 +6920 +27069 +15176 +17705 +13502 +17262 +7841 +12984 +29694 +21297 +2230 +10199 +24639 +9762 +9313 +5847 +18081 +9873 +14930 +5548 +953 +4307 +24255 +3720 +22293 +18312 +21097 +15784 +60 +4343 +2003 +26727 +26292 +24345 +6251 +28117 +25523 +15836 +31525 +32079 +8277 +31309 +8216 +15472 +9717 +10462 +10504 +27278 +12602 +13757 +11568 +26986 +22193 +18985 +334 +11 +675 +23098 +13090 +10232 +24131 +24210 +32671 +23747 +9766 +13959 +30837 +8515 +31295 +2313 +24877 +10020 +30433 +22083 +3478 +7941 +18436 +14792 +17040 +12004 +13669 +15490 +16678 +23356 +28066 +26871 +25077 +23461 +21786 +27509 +27367 +14961 +2380 +1662 +32487 +19835 +6455 +15376 +614 +9477 +10695 +28054 +28624 +31433 +17214 +30103 +22748 +32392 +26740 +20452 +19781 +17204 +18886 +2597 +16593 +833 +32064 +17379 +17717 +25184 +19581 +19423 +26962 +23824 +25178 +12322 +15802 +17619 +10654 +32343 +17037 +25858 +17284 +20361 +31406 +28206 +17839 +8121 +29850 +28389 +17970 +11480 +16044 +27103 +32676 +9884 +7189 +18612 +27375 +13011 +25248 +8624 +27167 +16913 +17033 +28474 +8431 +28770 +32216 +18027 +25686 +1292 +5509 +6894 +12620 +21287 +24917 +26323 +28448 +23047 +12968 +24616 +3809 +29518 +9663 +24553 +29202 +14835 +21220 +6785 +12761 +21624 +19053 +25295 +15607 +15236 +30405 +13704 +5130 +29608 +26410 +15114 +19041 +21133 +467 +24536 +10935 +2035 +14883 +8947 +22955 +13146 +9581 +29738 +19553 +7607 +125 +25092 +5985 +7843 +1713 +10628 +25470 +10901 +19348 +14538 +29719 +15625 +18293 +1742 +4258 +18738 +16429 +3453 +21625 +30091 +18119 +32643 +4672 +27135 +2571 +3211 +9096 +24942 +14666 +21660 +28962 +8376 +27399 +15822 +31049 +24155 +20515 +1979 +16109 +4627 +21804 +30092 +334 +18524 +11833 +20560 +28614 +29904 +21991 +23488 +20411 +11622 +15031 +2605 +21713 +7213 +7527 +11539 +27664 +26088 +569 +4311 +20104 +28409 +20140 +19522 +9077 +10930 +18157 +16787 +25216 +31867 +15602 +23801 +7375 +126 +9909 +32501 +19906 +19960 +7843 +8081 +9047 +22998 +5138 +21896 +32155 +32038 +291 +26500 +17796 +3376 +5274 +17693 +16263 +1929 +27670 +17073 +4405 +31778 +14877 +27450 +32036 +32068 +18642 +30320 +25415 +9179 +13420 +22419 +11277 +9943 +11543 +2342 +18245 +21913 +28469 +14693 +27338 +15644 +18322 +2936 +12075 +26487 +32264 +7399 +14240 +15771 +24509 +18825 +24192 +31505 +26939 +30511 +461 +1128 +112 +24820 +1294 +11189 +20272 +8069 +12934 +9509 +19741 +29200 +15054 +28557 +25545 +16865 +27595 +9225 +28484 +31668 +5411 +23119 +10962 +27218 +25619 +29940 +3622 +1066 +11964 +31472 +20788 +23492 +24322 +8570 +11716 +22958 +29473 +16120 +23711 +6619 +19457 +29281 +27719 +244 +23114 +28056 +26593 +9480 +27710 +31837 +32069 +4026 +9879 +9042 +32608 +6795 +27340 +6852 +883 +20682 +18656 +7122 +15695 +13991 +16284 +29566 +6121 +6020 +31946 +29874 +31744 +1946 +22451 +25898 +23162 +9393 +3941 +3448 +32753 +22040 +29576 +14181 +5697 +22569 +11246 +21344 +2891 +13406 +24146 +390 +10703 +8579 +25655 +2793 +4943 +30009 +9639 +18977 +24143 +18134 +19731 +14156 +1232 +8084 +383 +30027 +15069 +9746 +1381 +778 +25038 +28997 +11532 +13229 +23991 +28602 +28324 +28633 +21528 +13926 +7710 +4674 +28146 +31878 +30140 +24761 +26088 +10278 +9298 +19222 +26857 +23429 +19972 +14196 +27217 +12954 +30148 +17750 +19522 +21466 +21660 +11011 +32207 +22585 +14840 +3521 +10587 +22146 +4859 +17064 +31390 +28883 +23549 +28312 +116 +5260 +19196 +6555 +22381 +29286 +19461 +9586 +10974 +5676 +32061 +26244 +1874 +19439 +5705 +20417 +25687 +23385 +29016 +3201 +5790 +15781 +21509 +19756 +23127 +23924 +10464 +22550 +26144 +29604 +20089 +11870 +16496 +20640 +27227 +22890 +23413 +7918 +22186 +30532 +23574 +1646 +25828 +315 +31698 +13637 +31893 +25564 +13690 +14596 +32347 +23953 +1829 +19971 +23093 +5300 +29371 +10063 +1129 +21488 +22779 +8333 +24487 +27310 +30552 +21547 +723 +10370 +13546 +4082 +8682 +13208 +5546 +31993 +27919 +16801 +20501 +20527 +4578 +20495 +23257 +5340 +21509 +26646 +19661 +26958 +13559 +419 +11644 +26349 +32524 +11124 +31548 +26106 +15439 +13550 +17329 +17758 +19741 +1020 +17659 +29331 +18736 +6154 +26313 +28267 +2627 +29486 +29044 +5708 +5702 +31775 +7941 +9466 +30057 +7336 +2555 +28935 +12294 +4047 +13739 +15228 +30671 +25563 +4206 +21361 +22280 +475 +6302 +20412 +26433 +952 +26151 +20481 +19452 +18371 +8940 +20951 +17110 +13156 +4703 +31059 +25482 +7312 +3673 +17124 +18114 +4580 +17464 +1390 +20398 +31910 +10008 +26001 +27332 +16160 +4857 +24098 +13238 +13060 +3120 +24159 +29069 +10728 +28482 +5384 +3942 +7447 +6547 +19071 +3039 +13274 +20428 +9912 +18337 +19645 +22585 +24266 +16901 +2802 +14553 +30885 +30400 +32399 +6435 +29473 +20710 +28030 +8862 +1808 +27159 +18300 +31619 +11378 +7340 +338 +27066 +27540 +24851 +23453 +30335 +11332 +27409 +25216 +6464 +3600 +31313 +6494 +17896 +19375 +2169 +30255 +10571 +22434 +1402 +12939 +6410 +1089 +1078 +14455 +23491 +3051 +4024 +6072 +28925 +19218 +11802 +23003 +4122 +23330 +21650 +1085 +1812 +31021 +11195 +17798 +11999 +23012 +15104 +10956 +890 +24979 +9399 +16561 +432 +7010 +5096 +5997 +20666 +10967 +11989 +24193 +14253 +28125 +1741 +11372 +14820 +1120 +31350 +11628 +25363 +17657 +3996 +2792 +22729 +7050 +10487 +10522 +13410 +17034 +5294 +26133 +5995 +20262 +1747 +18778 +26293 +17222 +23151 +28805 +28665 +4636 +14509 +11355 +12011 +7781 +21985 +29915 +29324 +6290 +15154 +29132 +11290 +522 +5120 +20375 +25145 +11202 +29750 +15947 +26516 +22990 +7319 +20231 +10644 +27608 +21434 +32345 +18927 +6568 +9749 +31987 +23632 +21696 +9666 +2040 +2134 +2242 +5559 +27430 +20952 +192 +31554 +18837 +11816 +30277 +25451 +21547 +2541 +25816 +29475 +16232 +1700 +19817 +21906 +14691 +12591 +18044 +8909 +25202 +27953 +23172 +22914 +6804 +14234 +12636 +20760 +21866 +31846 +17844 +20014 +21902 +15389 +24169 +29553 +14032 +16076 +5035 +25992 +25029 +4317 +16615 +20427 +24495 +11357 +12509 +8751 +24526 +11103 +6514 +27064 +23387 +25860 +7862 +29519 +32038 +5185 +30944 +24886 +17154 +31396 +30740 +8150 +27337 +28106 +8701 +16534 +32519 +25090 diff --git a/tools/perf/tests/shell/tools/coresight/bubble_sort/small_array.txt b/tools/perf/tests/shell/tools/coresight/bubble_sort/small_array.txt new file mode 100644 index 000000000000..d351c8437d0a --- /dev/null +++ b/tools/perf/tests/shell/tools/coresight/bubble_sort/small_array.txt @@ -0,0 +1,10 @@ +11637 +3799 +23116 +15091 +13022 +15840 +27029 +27563 +25641 +28703 -- 2.32.0 ^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 09/12] perf test: Add add memcpy test for coresight quality checking 2021-12-15 16:22 [PATCH 01/12] perf test: Shell - Limit to only run executable scripts in tests carsten.haitzler ` (5 preceding siblings ...) 2021-12-15 16:22 ` [PATCH 07/12] perf test: Add simple bubblesort test for coresight " carsten.haitzler @ 2021-12-15 16:22 ` carsten.haitzler 2021-12-15 16:22 ` [PATCH 10/12] perf test: Add threaded memcpy tests to check coresight aux data carsten.haitzler ` (2 subsequent siblings) 9 siblings, 0 replies; 19+ messages in thread From: carsten.haitzler @ 2021-12-15 16:22 UTC (permalink / raw) To: linux-perf-users From: Carsten Haitzler <carsten.haitzler@arm.com> This adds memory bound tests for quality checking perf's aux data recording. Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com> --- tools/perf/tests/shell/coresight_memcpy_1m.sh | 18 +++++++++ .../perf/tests/shell/coresight_memcpy_32m.sh | 18 +++++++++ .../perf/tests/shell/coresight_memcpy_64k.sh | 18 +++++++++ .../perf/tests/shell/tools/coresight/Makefile | 3 +- .../shell/tools/coresight/memcpy/Makefile | 29 ++++++++++++++ .../shell/tools/coresight/memcpy/memcpy.c | 40 +++++++++++++++++++ 6 files changed, 125 insertions(+), 1 deletion(-) create mode 100755 tools/perf/tests/shell/coresight_memcpy_1m.sh create mode 100755 tools/perf/tests/shell/coresight_memcpy_32m.sh create mode 100755 tools/perf/tests/shell/coresight_memcpy_64k.sh create mode 100644 tools/perf/tests/shell/tools/coresight/memcpy/Makefile create mode 100644 tools/perf/tests/shell/tools/coresight/memcpy/memcpy.c diff --git a/tools/perf/tests/shell/coresight_memcpy_1m.sh b/tools/perf/tests/shell/coresight_memcpy_1m.sh new file mode 100755 index 000000000000..fa1c28d73b66 --- /dev/null +++ b/tools/perf/tests/shell/coresight_memcpy_1m.sh @@ -0,0 +1,18 @@ +#!/bin/sh -e +# Coresight / Memcpy 1M + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 + +TEST="memcpy" +. $(dirname $0)/lib/coresight.sh +ARGS="1024 2" +DATV="1m" +DATA="$DATD/perf-$TEST-$DATV.data" + +perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS + +perf_dump_aux_verify "$DATA" 39 766 766 + +err=$? +exit $err diff --git a/tools/perf/tests/shell/coresight_memcpy_32m.sh b/tools/perf/tests/shell/coresight_memcpy_32m.sh new file mode 100755 index 000000000000..4ab5459e3824 --- /dev/null +++ b/tools/perf/tests/shell/coresight_memcpy_32m.sh @@ -0,0 +1,18 @@ +#!/bin/sh -e +# Coresight / Memcpy 32M + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 + +TEST="memcpy" +. $(dirname $0)/lib/coresight.sh +ARGS="32768 1" +DATV="32m" +DATA="$DATD/perf-$TEST-$DATV.data" + +perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS + +perf_dump_aux_verify "$DATA" 39 7804 7804 + +err=$? +exit $err diff --git a/tools/perf/tests/shell/coresight_memcpy_64k.sh b/tools/perf/tests/shell/coresight_memcpy_64k.sh new file mode 100755 index 000000000000..5b6ba2a6d394 --- /dev/null +++ b/tools/perf/tests/shell/coresight_memcpy_64k.sh @@ -0,0 +1,18 @@ +#!/bin/sh -e +# Coresight / Memcpy 64K + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 + +TEST="memcpy" +. $(dirname $0)/lib/coresight.sh +ARGS="64 40" +DATV="64k" +DATA="$DATD/perf-$TEST-$DATV.data" + +perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS + +perf_dump_aux_verify "$DATA" 40 934 934 + +err=$? +exit $err diff --git a/tools/perf/tests/shell/tools/coresight/Makefile b/tools/perf/tests/shell/tools/coresight/Makefile index a1a752f45c46..99030c889b04 100644 --- a/tools/perf/tests/shell/tools/coresight/Makefile +++ b/tools/perf/tests/shell/tools/coresight/Makefile @@ -8,7 +8,8 @@ SUBDIRS = \ asm_pure_loop \ thread_loop \ bubble_sort \ - bubble_sort_thread + bubble_sort_thread \ + memcpy all: $(SUBDIRS) $(SUBDIRS): diff --git a/tools/perf/tests/shell/tools/coresight/memcpy/Makefile b/tools/perf/tests/shell/tools/coresight/memcpy/Makefile new file mode 100644 index 000000000000..7c31fe4ec399 --- /dev/null +++ b/tools/perf/tests/shell/tools/coresight/memcpy/Makefile @@ -0,0 +1,29 @@ +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 +include ../Makefile.miniconfig + +BIN=memcpy +LIB= + +all: $(BIN) + +$(BIN): $(BIN).c +ifdef CORESIGHT +ifeq ($(ARCH),arm64) + $(Q)$(CC) $(BIN).c -o $(BIN) $(LIB) +endif +endif + +install-tests: all +ifdef CORESIGHT +ifeq ($(ARCH),arm64) + $(call QUIET_INSTALL, tests) \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)'; \ + $(INSTALL) $(BIN) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)/$(BIN)' +endif +endif + +clean: + $(Q)$(RM) -f $(BIN) + +.PHONY: all clean install-tests diff --git a/tools/perf/tests/shell/tools/coresight/memcpy/memcpy.c b/tools/perf/tests/shell/tools/coresight/memcpy/memcpy.c new file mode 100644 index 000000000000..1aa0617448ad --- /dev/null +++ b/tools/perf/tests/shell/tools/coresight/memcpy/memcpy.c @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0 +// Carsten Haitzler <carsten.haitzler@arm.com>, 2021 +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> + +int main(int argc, char **argv) +{ + unsigned long i, len, size; + unsigned char *src, *dst; + long long v; + + if (argc < 3) { + printf("ERR: %s [copysize Kb] [numloops (hundreds)]\n", argv[0]); + exit(1); + } + + v = atoll(argv[1]); + if ((v < 1) || (v > (1024 * 1024))) { + printf("ERR: max memory 1GB (1048576 KB)\n"); + exit(1); + } + size = v; + v = atoll(argv[2]); + if ((v < 1) || (v > 40000000000ll)) { + printf("ERR: loops 1-40000000000 (hundreds)\n"); + exit(1); + } + len = v * 100; + src = malloc(size * 1024); + dst = malloc(size * 1024); + if ((!src) || (!dst)) { + printf("ERR: Can't allocate memory\n"); + exit(1); + } + for (i = 0; i < len; i++) + memcpy(dst, src, size * 1024); + return 0; +} -- 2.32.0 ^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 10/12] perf test: Add threaded memcpy tests to check coresight aux data 2021-12-15 16:22 [PATCH 01/12] perf test: Shell - Limit to only run executable scripts in tests carsten.haitzler ` (6 preceding siblings ...) 2021-12-15 16:22 ` [PATCH 09/12] perf test: Add add memcpy test for coresight quality checking carsten.haitzler @ 2021-12-15 16:22 ` carsten.haitzler 2021-12-15 16:22 ` [PATCH 11/12] perf test: Add unrolled loop tests for " carsten.haitzler 2021-12-15 16:22 ` [PATCH 12/12] perf test: Add docs for coresight and related tests carsten.haitzler 9 siblings, 0 replies; 19+ messages in thread From: carsten.haitzler @ 2021-12-15 16:22 UTC (permalink / raw) To: linux-perf-users From: Carsten Haitzler <carsten.haitzler@arm.com> This adds threaded memcpy test looking at coresight aux data quality. Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com> --- .../shell/coresight_memcpy_thread_1m_2.sh | 18 +++++ .../shell/coresight_memcpy_thread_1m_25.sh | 18 +++++ .../shell/coresight_memcpy_thread_32m_10.sh | 18 +++++ .../shell/coresight_memcpy_thread_32m_2.sh | 18 +++++ .../shell/coresight_memcpy_thread_64k_2.sh | 18 +++++ .../shell/coresight_memcpy_thread_64k_25.sh | 18 +++++ .../shell/coresight_memcpy_thread_64k_250.sh | 18 +++++ .../perf/tests/shell/tools/coresight/Makefile | 3 +- .../tools/coresight/memcpy_thread/Makefile | 29 +++++++ .../coresight/memcpy_thread/memcpy_thread.c | 79 +++++++++++++++++++ 10 files changed, 236 insertions(+), 1 deletion(-) create mode 100755 tools/perf/tests/shell/coresight_memcpy_thread_1m_2.sh create mode 100755 tools/perf/tests/shell/coresight_memcpy_thread_1m_25.sh create mode 100755 tools/perf/tests/shell/coresight_memcpy_thread_32m_10.sh create mode 100755 tools/perf/tests/shell/coresight_memcpy_thread_32m_2.sh create mode 100755 tools/perf/tests/shell/coresight_memcpy_thread_64k_2.sh create mode 100755 tools/perf/tests/shell/coresight_memcpy_thread_64k_25.sh create mode 100755 tools/perf/tests/shell/coresight_memcpy_thread_64k_250.sh create mode 100644 tools/perf/tests/shell/tools/coresight/memcpy_thread/Makefile create mode 100644 tools/perf/tests/shell/tools/coresight/memcpy_thread/memcpy_thread.c diff --git a/tools/perf/tests/shell/coresight_memcpy_thread_1m_2.sh b/tools/perf/tests/shell/coresight_memcpy_thread_1m_2.sh new file mode 100755 index 000000000000..32d5ee94343a --- /dev/null +++ b/tools/perf/tests/shell/coresight_memcpy_thread_1m_2.sh @@ -0,0 +1,18 @@ +#!/bin/sh -e +# Coresight / Memcpy 1M 2 Threads + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 + +TEST="memcpy_thread" +. $(dirname $0)/lib/coresight.sh +ARGS="1024 2 400" +DATV="1m_2" +DATA="$DATD/perf-$TEST-$DATV.data" + +perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS + +perf_dump_aux_verify "$DATA" 125 26 26 + +err=$? +exit $err diff --git a/tools/perf/tests/shell/coresight_memcpy_thread_1m_25.sh b/tools/perf/tests/shell/coresight_memcpy_thread_1m_25.sh new file mode 100755 index 000000000000..6510f8c7df99 --- /dev/null +++ b/tools/perf/tests/shell/coresight_memcpy_thread_1m_25.sh @@ -0,0 +1,18 @@ +#!/bin/sh -e +# Coresight / Memcpy 1M 25 Threads + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 + +TEST="memcpy_thread" +. $(dirname $0)/lib/coresight.sh +ARGS="1024 25 1" +DATV="1m_25" +DATA="$DATD/perf-$TEST-$DATV.data" + +perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS + +perf_dump_aux_verify "$DATA" 1 44 43 + +err=$? +exit $err diff --git a/tools/perf/tests/shell/coresight_memcpy_thread_32m_10.sh b/tools/perf/tests/shell/coresight_memcpy_thread_32m_10.sh new file mode 100755 index 000000000000..3715ed4b612e --- /dev/null +++ b/tools/perf/tests/shell/coresight_memcpy_thread_32m_10.sh @@ -0,0 +1,18 @@ +#!/bin/sh -e +# Coresight / Memcpy 32M 10 Threads + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 + +TEST="memcpy_thread" +. $(dirname $0)/lib/coresight.sh +ARGS="32768 10 1" +DATV="32m_10" +DATA="$DATD/perf-$TEST-$DATV.data" + +perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS + +perf_dump_aux_verify "$DATA" 6 36 36 + +err=$? +exit $err diff --git a/tools/perf/tests/shell/coresight_memcpy_thread_32m_2.sh b/tools/perf/tests/shell/coresight_memcpy_thread_32m_2.sh new file mode 100755 index 000000000000..ad57bf4d9c0c --- /dev/null +++ b/tools/perf/tests/shell/coresight_memcpy_thread_32m_2.sh @@ -0,0 +1,18 @@ +#!/bin/sh -e +# Coresight / Memcpy 32M 2 Threads + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 + +TEST="memcpy_thread" +. $(dirname $0)/lib/coresight.sh +ARGS="32768 2 1" +DATV="32m_2" +DATA="$DATD/perf-$TEST-$DATV.data" + +perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS + +perf_dump_aux_verify "$DATA" 3 12 12 + +err=$? +exit $err diff --git a/tools/perf/tests/shell/coresight_memcpy_thread_64k_2.sh b/tools/perf/tests/shell/coresight_memcpy_thread_64k_2.sh new file mode 100755 index 000000000000..282cc8922641 --- /dev/null +++ b/tools/perf/tests/shell/coresight_memcpy_thread_64k_2.sh @@ -0,0 +1,18 @@ +#!/bin/sh -e +# Coresight / Memcpy 64k 2 Threads + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 + +TEST="memcpy_thread" +. $(dirname $0)/lib/coresight.sh +ARGS="64 2 100" +DATV="64k_2" +DATA="$DATD/perf-$TEST-$DATV.data" + +perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS + +perf_dump_aux_verify "$DATA" 66 11 11 + +err=$? +exit $err diff --git a/tools/perf/tests/shell/coresight_memcpy_thread_64k_25.sh b/tools/perf/tests/shell/coresight_memcpy_thread_64k_25.sh new file mode 100755 index 000000000000..05bc6c23f4a1 --- /dev/null +++ b/tools/perf/tests/shell/coresight_memcpy_thread_64k_25.sh @@ -0,0 +1,18 @@ +#!/bin/sh -e +# Coresight / Memcpy 64k 25 Threads + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 + +TEST="memcpy_thread" +. $(dirname $0)/lib/coresight.sh +ARGS="64 25 2" +DATV="64k_25" +DATA="$DATD/perf-$TEST-$DATV.data" + +perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS + +perf_dump_aux_verify "$DATA" 118 31 31 + +err=$? +exit $err diff --git a/tools/perf/tests/shell/coresight_memcpy_thread_64k_250.sh b/tools/perf/tests/shell/coresight_memcpy_thread_64k_250.sh new file mode 100755 index 000000000000..aaf35e32f610 --- /dev/null +++ b/tools/perf/tests/shell/coresight_memcpy_thread_64k_250.sh @@ -0,0 +1,18 @@ +#!/bin/sh -e +# Coresight / Memcpy 64k 250 Threads + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 + +TEST="memcpy_thread" +. $(dirname $0)/lib/coresight.sh +ARGS="64 250 1" +DATV="64k_250" +DATA="$DATD/perf-$TEST-$DATV.data" + +perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS + +perf_dump_aux_verify "$DATA" 340 1878 1878 + +err=$? +exit $err diff --git a/tools/perf/tests/shell/tools/coresight/Makefile b/tools/perf/tests/shell/tools/coresight/Makefile index 99030c889b04..be671aac06b8 100644 --- a/tools/perf/tests/shell/tools/coresight/Makefile +++ b/tools/perf/tests/shell/tools/coresight/Makefile @@ -9,7 +9,8 @@ SUBDIRS = \ thread_loop \ bubble_sort \ bubble_sort_thread \ - memcpy + memcpy \ + memcpy_thread all: $(SUBDIRS) $(SUBDIRS): diff --git a/tools/perf/tests/shell/tools/coresight/memcpy_thread/Makefile b/tools/perf/tests/shell/tools/coresight/memcpy_thread/Makefile new file mode 100644 index 000000000000..e2604cfae74b --- /dev/null +++ b/tools/perf/tests/shell/tools/coresight/memcpy_thread/Makefile @@ -0,0 +1,29 @@ +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 +include ../Makefile.miniconfig + +BIN=memcpy_thread +LIB=-pthread + +all: $(BIN) + +$(BIN): $(BIN).c +ifdef CORESIGHT +ifeq ($(ARCH),arm64) + $(Q)$(CC) $(BIN).c -o $(BIN) $(LIB) +endif +endif + +install-tests: all +ifdef CORESIGHT +ifeq ($(ARCH),arm64) + $(call QUIET_INSTALL, tests) \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)'; \ + $(INSTALL) $(BIN) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)/$(BIN)' +endif +endif + +clean: + $(Q)$(RM) -f $(BIN) + +.PHONY: all clean install-tests diff --git a/tools/perf/tests/shell/tools/coresight/memcpy_thread/memcpy_thread.c b/tools/perf/tests/shell/tools/coresight/memcpy_thread/memcpy_thread.c new file mode 100644 index 000000000000..a7e169d1bf64 --- /dev/null +++ b/tools/perf/tests/shell/tools/coresight/memcpy_thread/memcpy_thread.c @@ -0,0 +1,79 @@ +// SPDX-License-Identifier: GPL-2.0 +// Carsten Haitzler <carsten.haitzler@arm.com>, 2021 +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <pthread.h> + +struct args { + unsigned long loops; + unsigned long size; + pthread_t th; + void *ret; +}; + +static void *thrfn(void *arg) +{ + struct args *a = arg; + unsigned long i, len = a->loops; + unsigned char *src, *dst; + + src = malloc(a->size * 1024); + dst = malloc(a->size * 1024); + if ((!src) || (!dst)) { + printf("ERR: Can't allocate memory\n"); + exit(1); + } + for (i = 0; i < len; i++) + memcpy(dst, src, a->size * 1024); +} + +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 long i, len, size, thr; + pthread_t threads[256]; + struct args args[256]; + long long v; + + if (argc < 4) { + printf("ERR: %s [copysize Kb] [numthreads] [numloops (hundreds)]\n", argv[0]); + exit(1); + } + + v = atoll(argv[1]); + if ((v < 1) || (v > (1024 * 1024))) { + printf("ERR: max memory 1GB (1048576 KB)\n"); + exit(1); + } + size = v; + thr = atol(argv[2]); + if ((thr < 1) || (thr > 256)) { + printf("ERR: threads 1-256\n"); + exit(1); + } + v = atoll(argv[3]); + if ((v < 1) || (v > 40000000000ll)) { + printf("ERR: loops 1-40000000000 (hundreds)\n"); + exit(1); + } + len = v * 100; + for (i = 0; i < thr; i++) { + args[i].loops = len; + args[i].size = size; + args[i].th = new_thr(thrfn, &(args[i])); + } + for (i = 0; i < thr; i++) + pthread_join(args[i].th, &(args[i].ret)); + return 0; +} -- 2.32.0 ^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 11/12] perf test: Add unrolled loop tests for coresight aux data 2021-12-15 16:22 [PATCH 01/12] perf test: Shell - Limit to only run executable scripts in tests carsten.haitzler ` (7 preceding siblings ...) 2021-12-15 16:22 ` [PATCH 10/12] perf test: Add threaded memcpy tests to check coresight aux data carsten.haitzler @ 2021-12-15 16:22 ` carsten.haitzler 2021-12-15 16:22 ` [PATCH 12/12] perf test: Add docs for coresight and related tests carsten.haitzler 9 siblings, 0 replies; 19+ messages in thread From: carsten.haitzler @ 2021-12-15 16:22 UTC (permalink / raw) To: linux-perf-users From: Carsten Haitzler <carsten.haitzler@arm.com> These tests have large batches of code manually unrolled with macros to ensure that the processor has to walk through a lot of instructions and memory for those instructions to generate the coresight aux data. Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com> --- .../shell/coresight_unroll_loop_thread_1.sh | 18 +++++ .../shell/coresight_unroll_loop_thread_10.sh | 18 +++++ .../shell/coresight_unroll_loop_thread_2.sh | 18 +++++ .../shell/coresight_unroll_loop_thread_25.sh | 18 +++++ .../shell/coresight_unroll_loop_thread_250.sh | 18 +++++ .../perf/tests/shell/tools/coresight/Makefile | 3 +- .../coresight/unroll_loop_thread/Makefile | 29 ++++++++ .../unroll_loop_thread/unroll_loop_thread.c | 74 +++++++++++++++++++ 8 files changed, 195 insertions(+), 1 deletion(-) create mode 100755 tools/perf/tests/shell/coresight_unroll_loop_thread_1.sh create mode 100755 tools/perf/tests/shell/coresight_unroll_loop_thread_10.sh create mode 100755 tools/perf/tests/shell/coresight_unroll_loop_thread_2.sh create mode 100755 tools/perf/tests/shell/coresight_unroll_loop_thread_25.sh create mode 100755 tools/perf/tests/shell/coresight_unroll_loop_thread_250.sh create mode 100644 tools/perf/tests/shell/tools/coresight/unroll_loop_thread/Makefile create mode 100644 tools/perf/tests/shell/tools/coresight/unroll_loop_thread/unroll_loop_thread.c diff --git a/tools/perf/tests/shell/coresight_unroll_loop_thread_1.sh b/tools/perf/tests/shell/coresight_unroll_loop_thread_1.sh new file mode 100755 index 000000000000..9175ec532bd8 --- /dev/null +++ b/tools/perf/tests/shell/coresight_unroll_loop_thread_1.sh @@ -0,0 +1,18 @@ +#!/bin/sh -e +# Coresight / Unroll Loop Thread 1 + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 + +TEST="unroll_loop_thread" +. $(dirname $0)/lib/coresight.sh +ARGS="1" +DATV="1" +DATA="$DATD/perf-$TEST-$DATV.data" + +perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS + +perf_dump_aux_verify "$DATA" 118 14 14 + +err=$? +exit $err diff --git a/tools/perf/tests/shell/coresight_unroll_loop_thread_10.sh b/tools/perf/tests/shell/coresight_unroll_loop_thread_10.sh new file mode 100755 index 000000000000..66cf0245294e --- /dev/null +++ b/tools/perf/tests/shell/coresight_unroll_loop_thread_10.sh @@ -0,0 +1,18 @@ +#!/bin/sh -e +# Coresight / Unroll Loop Thread 10 + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 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" 127 17 17 + +err=$? +exit $err diff --git a/tools/perf/tests/shell/coresight_unroll_loop_thread_2.sh b/tools/perf/tests/shell/coresight_unroll_loop_thread_2.sh new file mode 100755 index 000000000000..ff2e293699b0 --- /dev/null +++ b/tools/perf/tests/shell/coresight_unroll_loop_thread_2.sh @@ -0,0 +1,18 @@ +#!/bin/sh -e +# Coresight / Unroll Loop Thread 2 + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 + +TEST="unroll_loop_thread" +. $(dirname $0)/lib/coresight.sh +ARGS="2" +DATV="2" +DATA="$DATD/perf-$TEST-$DATV.data" + +perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS + +perf_dump_aux_verify "$DATA" 65 6 6 + +err=$? +exit $err diff --git a/tools/perf/tests/shell/coresight_unroll_loop_thread_25.sh b/tools/perf/tests/shell/coresight_unroll_loop_thread_25.sh new file mode 100755 index 000000000000..7d7669a797ab --- /dev/null +++ b/tools/perf/tests/shell/coresight_unroll_loop_thread_25.sh @@ -0,0 +1,18 @@ +#!/bin/sh -e +# Coresight / Unroll Loop Thread 25 + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 + +TEST="unroll_loop_thread" +. $(dirname $0)/lib/coresight.sh +ARGS="25" +DATV="25" +DATA="$DATD/perf-$TEST-$DATV.data" + +perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS + +perf_dump_aux_verify "$DATA" 72 26 25 + +err=$? +exit $err diff --git a/tools/perf/tests/shell/coresight_unroll_loop_thread_250.sh b/tools/perf/tests/shell/coresight_unroll_loop_thread_250.sh new file mode 100755 index 000000000000..7a0e23aff0dc --- /dev/null +++ b/tools/perf/tests/shell/coresight_unroll_loop_thread_250.sh @@ -0,0 +1,18 @@ +#!/bin/sh -e +# Coresight / Unroll Loop Thread 250 + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 + +TEST="unroll_loop_thread" +. $(dirname $0)/lib/coresight.sh +ARGS="250" +DATV="250" +DATA="$DATD/perf-$TEST-$DATV.data" + +perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS + +perf_dump_aux_verify "$DATA" 544 2417 2417 + +err=$? +exit $err diff --git a/tools/perf/tests/shell/tools/coresight/Makefile b/tools/perf/tests/shell/tools/coresight/Makefile index be671aac06b8..b9cdeff1149b 100644 --- a/tools/perf/tests/shell/tools/coresight/Makefile +++ b/tools/perf/tests/shell/tools/coresight/Makefile @@ -10,7 +10,8 @@ SUBDIRS = \ bubble_sort \ bubble_sort_thread \ memcpy \ - memcpy_thread + memcpy_thread \ + unroll_loop_thread all: $(SUBDIRS) $(SUBDIRS): diff --git a/tools/perf/tests/shell/tools/coresight/unroll_loop_thread/Makefile b/tools/perf/tests/shell/tools/coresight/unroll_loop_thread/Makefile new file mode 100644 index 000000000000..45ab2be8be92 --- /dev/null +++ b/tools/perf/tests/shell/tools/coresight/unroll_loop_thread/Makefile @@ -0,0 +1,29 @@ +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 +include ../Makefile.miniconfig + +BIN=unroll_loop_thread +LIB=-pthread + +all: $(BIN) + +$(BIN): $(BIN).c +ifdef CORESIGHT +ifeq ($(ARCH),arm64) + $(Q)$(CC) $(BIN).c -o $(BIN) $(LIB) +endif +endif + +install-tests: all +ifdef CORESIGHT +ifeq ($(ARCH),arm64) + $(call QUIET_INSTALL, tests) \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)'; \ + $(INSTALL) $(BIN) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)/$(BIN)' +endif +endif + +clean: + $(Q)$(RM) -f $(BIN) + +.PHONY: all clean install-tests diff --git a/tools/perf/tests/shell/tools/coresight/unroll_loop_thread/unroll_loop_thread.c b/tools/perf/tests/shell/tools/coresight/unroll_loop_thread/unroll_loop_thread.c new file mode 100644 index 000000000000..cb9d22c7dfb9 --- /dev/null +++ b/tools/perf/tests/shell/tools/coresight/unroll_loop_thread/unroll_loop_thread.c @@ -0,0 +1,74 @@ +// SPDX-License-Identifier: GPL-2.0 +// Carsten Haitzler <carsten.haitzler@arm.com>, 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; + void *ret; +}; + +static void *thrfn(void *arg) +{ + struct args *a = arg; + unsigned int i, in = a->in; + + for (i = 0; i < 10000; i++) { + asm volatile ( +// 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; +} -- 2.32.0 ^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 12/12] perf test: Add docs for coresight and related tests 2021-12-15 16:22 [PATCH 01/12] perf test: Shell - Limit to only run executable scripts in tests carsten.haitzler ` (8 preceding siblings ...) 2021-12-15 16:22 ` [PATCH 11/12] perf test: Add unrolled loop tests for " carsten.haitzler @ 2021-12-15 16:22 ` carsten.haitzler 9 siblings, 0 replies; 19+ messages in thread From: carsten.haitzler @ 2021-12-15 16:22 UTC (permalink / raw) To: linux-perf-users From: Carsten Haitzler <carsten.haitzler@arm.com> This adds documentation about the coresight specific tests as part of perf test Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com> --- MAINTAINERS | 1 + tools/perf/Documentation/arm-coresight.txt | 140 +++++++++++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 tools/perf/Documentation/arm-coresight.txt diff --git a/MAINTAINERS b/MAINTAINERS index d46e8469c467..1a93977a0132 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1890,6 +1890,7 @@ F: Documentation/trace/coresight/* F: drivers/hwtracing/coresight/* F: include/dt-bindings/arm/coresight-cti-dt.h F: include/linux/coresight* +F: tools/perf/Documentation/arm-coresight.txt 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 diff --git a/tools/perf/Documentation/arm-coresight.txt b/tools/perf/Documentation/arm-coresight.txt new file mode 100644 index 000000000000..3a9e6c573c58 --- /dev/null +++ b/tools/perf/Documentation/arm-coresight.txt @@ -0,0 +1,140 @@ +Arm Coresight Support +===================== + +Coresight is a feature of some Arm based processors that allows for +debugging. One of the things it can do is trace every instruction +executed and remotely expose that information in a hardware compressed +stream. Perf is able to locally access that stream and store it to the +output perf data files. This stream 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 perf directory do + + make CORESIGHT=1 + +This will compile the perf tool with coresight support as well as +build some small test binaries for perf test. This requires you also +be compiling for 64bit Arm (ARM64/aarch64). The tools run as part of +perf coresight tracing are in tests/shell/tools/coresight. + +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 + +Some others will actually use perf record and some test binaries that +are in tests/shell/tools/coresight and will collect traces to ensure a +minimum level of functionality is met. The scripts that launch these +tests are in tests/shell. These will all look like: + + Coresight / Memcpy 1M 25 Threads + Coresight / Unroll Loop Thread 2 + ... + +These perf record tests will not run if the tool binaries do not exist +in tests/shell/tools/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-bubble_sort-random.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. + +Be aware that amny 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-memcpy-1m.data + perf-thread_loop-2th.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 which to +keep the output of tests outside of the current working directory for +longer term storage and examination. -- 2.32.0 ^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 01/12] perf test: Shell - Limit to only run executable scripts in tests @ 2021-12-15 16:03 carsten.haitzler 2021-12-15 16:03 ` [PATCH 04/12] perf test: Add beginning of test infra + test to exercise coresight carsten.haitzler 0 siblings, 1 reply; 19+ messages in thread From: carsten.haitzler @ 2021-12-15 16:03 UTC (permalink / raw) To: linux-kernel Cc: coresight, suzuki.poulose, mathieu.poirier, mike.leach, leo.yan, inux-perf-users, acme From: Carsten Haitzler <carsten.haitzler@arm.com> Perf test's shell runner will just run everything in the tests directory (as long as it's not another directory or does not begin with a dot), but sometimes you find files in there that are not shell scripts - perf.data output for example if you do some testing and then the next time you run perf test it tries to run these. Check the files are executable so they are actually intended to be test scripts and not just some "random junk" files there. Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com> --- tools/perf/tests/builtin-test.c | 4 +++- tools/perf/util/path.c | 12 ++++++++++++ tools/perf/util/path.h | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 8cb5a1c3489e..ece272b55587 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -295,7 +295,9 @@ static const char *shell_test__description(char *description, size_t size, #define for_each_shell_test(entlist, nr, base, ent) \ for (int __i = 0; __i < nr && (ent = entlist[__i]); __i++) \ - if (!is_directory(base, ent) && ent->d_name[0] != '.') + if (!is_directory(base, ent) && \ + is_executable_file(base, ent) && \ + ent->d_name[0] != '.') static const char *shell_tests__dir(char *path, size_t size) { diff --git a/tools/perf/util/path.c b/tools/perf/util/path.c index caed0336429f..7dde8c230ae8 100644 --- a/tools/perf/util/path.c +++ b/tools/perf/util/path.c @@ -92,3 +92,15 @@ bool is_directory(const char *base_path, const struct dirent *dent) return S_ISDIR(st.st_mode); } + +bool is_executable_file(const char *base_path, const struct dirent *dent) +{ + char path[PATH_MAX]; + struct stat st; + + sprintf(path, "%s/%s", base_path, dent->d_name); + if (stat(path, &st)) + return false; + + return !S_ISDIR(st.st_mode) && (st.st_mode & S_IXUSR); +} diff --git a/tools/perf/util/path.h b/tools/perf/util/path.h index 083429b7efa3..d94902c22222 100644 --- a/tools/perf/util/path.h +++ b/tools/perf/util/path.h @@ -12,5 +12,6 @@ int path__join3(char *bf, size_t size, const char *path1, const char *path2, con bool is_regular_file(const char *file); bool is_directory(const char *base_path, const struct dirent *dent); +bool is_executable_file(const char *base_path, const struct dirent *dent); #endif /* _PERF_PATH_H */ -- 2.32.0 ^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 04/12] perf test: Add beginning of test infra + test to exercise coresight 2021-12-15 16:03 [PATCH 01/12] perf test: Shell - Limit to only run executable scripts in tests carsten.haitzler @ 2021-12-15 16:03 ` carsten.haitzler 2021-12-21 15:03 ` Leo Yan ` (2 more replies) 0 siblings, 3 replies; 19+ messages in thread From: carsten.haitzler @ 2021-12-15 16:03 UTC (permalink / raw) To: linux-kernel Cc: coresight, suzuki.poulose, mathieu.poirier, mike.leach, leo.yan, inux-perf-users, acme From: Carsten Haitzler <carsten.haitzler@arm.com> This adds the initial test harness to run perf record and examine the resuling output when coresight is enabled on arm64 and check the resulting quality of the output as part of perf test. Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com> --- MAINTAINERS | 3 + tools/perf/Makefile.perf | 14 +- .../tests/shell/coresight_asm_pure_loop.sh | 18 +++ tools/perf/tests/shell/lib/coresight.sh | 130 ++++++++++++++++++ tools/perf/tests/shell/tools/Makefile | 26 ++++ .../perf/tests/shell/tools/coresight/Makefile | 27 ++++ .../shell/tools/coresight/Makefile.miniconfig | 23 ++++ .../tools/coresight/asm_pure_loop/Makefile | 30 ++++ .../coresight/asm_pure_loop/asm_pure_loop.S | 28 ++++ 9 files changed, 297 insertions(+), 2 deletions(-) create mode 100755 tools/perf/tests/shell/coresight_asm_pure_loop.sh create mode 100644 tools/perf/tests/shell/lib/coresight.sh create mode 100644 tools/perf/tests/shell/tools/Makefile create mode 100644 tools/perf/tests/shell/tools/coresight/Makefile create mode 100644 tools/perf/tests/shell/tools/coresight/Makefile.miniconfig create mode 100644 tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile create mode 100644 tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S diff --git a/MAINTAINERS b/MAINTAINERS index 13f9a84a617e..d46e8469c467 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1894,6 +1894,9 @@ 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 F: tools/perf/arch/arm/util/pmu.c +F: tools/perf/tests/shell/coresight_* +F: tools/perf/tests/shell/tools/Makefile +F: tools/perf/tests/shell/tools/coresight/* F: tools/perf/util/cs-etm-decoder/* F: tools/perf/util/cs-etm.* diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 80522bcfafe0..26467a2c71f4 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -630,7 +630,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_TOOLS_DIR := $(srctree)/tools/perf/tests/shell/tools + +tests-tools-targets: FORCE + $(Q)$(MAKE) -C $(TESTS_TOOLS_DIR) + +tests-tools-targets-clean: + $(Q)$(MAKE) -C $(TESTS_TOOLS_DIR) clean + +all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS) tests-tools-targets # Create python binding output directory if not already present _dummy := $(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python') @@ -1020,6 +1028,7 @@ install-tests: all install-gtk $(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' + $(Q)$(MAKE) -C tests/shell/tools install-tests install-bin: install-tools install-tests install-traceevent-plugins @@ -1088,7 +1097,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-tools-targets-clean $(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(OUTPUT)perf-iostat $(LANG_BINDINGS) $(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete $(Q)$(RM) $(OUTPUT).config-detected @@ -1155,5 +1164,6 @@ FORCE: .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell .PHONY: $(GIT-HEAD-PHONY) TAGS tags cscope FORCE prepare .PHONY: libtraceevent_plugins archheaders +.PHONY: $(TESTS_TOOLS_TARGETS) endif # force_fixdep diff --git a/tools/perf/tests/shell/coresight_asm_pure_loop.sh b/tools/perf/tests/shell/coresight_asm_pure_loop.sh new file mode 100755 index 000000000000..542d4a37e349 --- /dev/null +++ b/tools/perf/tests/shell/coresight_asm_pure_loop.sh @@ -0,0 +1,18 @@ +#!/bin/sh -e +# Coresight / ASM Pure Loop + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 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" 2601 334 334 + +err=$? +exit $err diff --git a/tools/perf/tests/shell/lib/coresight.sh b/tools/perf/tests/shell/lib/coresight.sh new file mode 100644 index 000000000000..cd6c1283e6f5 --- /dev/null +++ b/tools/perf/tests/shell/lib/coresight.sh @@ -0,0 +1,130 @@ +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 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. + +# perf record options for the perf tests to use +PERFRECMEM="-m ,128M" +PERFRECOPT="$PERFRECMEM -e cs_etm//u" + +# These tests need to be run as root or coresight won't allow large buffers +# and will not collect proper data +UID=`id -u` +if test "$UID" -ne 0; then + echo "Not running as root... skip" + exit 2 +fi + +TOOLS=$(dirname $0)/tools +DIR="$TOOLS/coresight/$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 2 +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 F3 atoms in just about + # anything but certainly we will see some trace info and async atom + # chunks. + DUMP="$DATD/perf-tmp-aux-dump.txt" + perf report --stdio --dump -i "$1" | \ + grep -o -e I_ATOM_F3 -e I_ASYNC -e I_TRACE_INFO > "$DUMP" + # Simply count how many of these atoms 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_F3_NUM=`grep I_ATOM_F3 "$DUMP" | wc -l` + ATOM_ASYNC_NUM=`grep I_ASYNC "$DUMP" | wc -l` + ATOM_TRACE_INFO_NUM=`grep I_TRACE_INFO "$DUMP" | wc -l` + rm -f "$DUMP" + + # Arguments provide minimums for a pass + CHECK_F3_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 F3 Count, Minimum, ATOM ASYNC Count, Minimum, TRACE INFO Count, Minimum" > "$STATF" + fi + echo -n "$ATOM_F3_NUM, $CHECK_F3_MIN, $ATOM_ASYNC_NUM, $CHECK_ASYNC_MIN, $ATOM_TRACE_INFO_NUM, $CHECK_TRACE_INFO_MIN" >> "$STATF" + + # Actually check to see if we passed or failed. + check_val_min "ATOM_F3" "$ATOM_F3_NUM" "$CHECK_F3_MIN" "$STATF" + check_val_min "ASYNC" "$ATOM_ASYNC_NUM" "$CHECK_ASYNC_MIN" "$STATF" + check_val_min "TRACE_INFO" "$ATOM_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` + + # 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 +} diff --git a/tools/perf/tests/shell/tools/Makefile b/tools/perf/tests/shell/tools/Makefile new file mode 100644 index 000000000000..c7ada20922fd --- /dev/null +++ b/tools/perf/tests/shell/tools/Makefile @@ -0,0 +1,26 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 +include ../../../../../tools/scripts/Makefile.include +include ../../../../../tools/scripts/Makefile.arch +include ../../../../../tools/scripts/utilities.mak + +SUBDIRS = \ + coresight + +all: $(SUBDIRS) +$(SUBDIRS): + $(Q)$(MAKE) -C $@ + +INSTALLDIRS = $(SUBDIRS:%=install-%) + +install-tests: all $(INSTALLDIRS) +$(INSTALLDIRS): + $(Q)$(MAKE) -C $(@:install-%=%) install-tests + +CLEANDIRS = $(SUBDIRS:%=clean-%) + +clean: $(CLEANDIRS) +$(CLEANDIRS): + $(Q)$(MAKE) -C $(@:clean-%=%) O=$(OUTPUT) clean >/dev/null + +.PHONY: all clean install-tests $(SUBDIRS) $(CLEANDIRS) $(INSTALLDIRS) diff --git a/tools/perf/tests/shell/tools/coresight/Makefile b/tools/perf/tests/shell/tools/coresight/Makefile new file mode 100644 index 000000000000..723006ea827c --- /dev/null +++ b/tools/perf/tests/shell/tools/coresight/Makefile @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 +include ../../../../../../tools/scripts/Makefile.include +include ../../../../../../tools/scripts/Makefile.arch +include ../../../../../../tools/scripts/utilities.mak + +SUBDIRS = \ + asm_pure_loop + +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) + diff --git a/tools/perf/tests/shell/tools/coresight/Makefile.miniconfig b/tools/perf/tests/shell/tools/coresight/Makefile.miniconfig new file mode 100644 index 000000000000..cedd26c6a0eb --- /dev/null +++ b/tools/perf/tests/shell/tools/coresight/Makefile.miniconfig @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Carsten Haitzler <carsten.haitzler@arm.com>, 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 + +include ../../../../../../scripts/Makefile.include +include ../../../../../../scripts/Makefile.arch +include ../../../../../../scripts/utilities.mak diff --git a/tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile new file mode 100644 index 000000000000..10c5a60cb71c --- /dev/null +++ b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 + +include ../Makefile.miniconfig + +BIN=asm_pure_loop +LIB= + +all: $(BIN) + +$(BIN): $(BIN).S +ifdef CORESIGHT +ifeq ($(ARCH),arm64) + $(Q)$(CC) $(BIN).S -nostdlib -static -o $(BIN) $(LIB) +endif +endif + +install-tests: all +ifdef CORESIGHT +ifeq ($(ARCH),arm64) + $(call QUIET_INSTALL, tests) \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)'; \ + $(INSTALL) $(BIN) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)/$(BIN)' +endif +endif + +clean: + $(Q)$(RM) -f $(BIN) + +.PHONY: all clean install-tests diff --git a/tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S new file mode 100644 index 000000000000..262876451021 --- /dev/null +++ b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Tamas Zsoldos <tamas.zsoldos@arm.com>, 2021 */ + +.globl _start +_start: + mov x0, 0x000fffff + 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 -- 2.32.0 ^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH 04/12] perf test: Add beginning of test infra + test to exercise coresight 2021-12-15 16:03 ` [PATCH 04/12] perf test: Add beginning of test infra + test to exercise coresight carsten.haitzler @ 2021-12-21 15:03 ` Leo Yan 2021-12-21 20:40 ` Arnaldo Carvalho de Melo 2022-01-04 15:14 ` Carsten Haitzler 2022-01-19 16:58 ` James Clark 2022-02-04 10:21 ` Mike Leach 2 siblings, 2 replies; 19+ messages in thread From: Leo Yan @ 2021-12-21 15:03 UTC (permalink / raw) To: carsten.haitzler Cc: linux-kernel, coresight, suzuki.poulose, mathieu.poirier, mike.leach, inux-perf-users, acme Hi Carsten, On Wed, Dec 15, 2021 at 04:03:55PM +0000, carsten.haitzler@foss.arm.com wrote: > From: Carsten Haitzler <carsten.haitzler@arm.com> > > This adds the initial test harness to run perf record and examine the > resuling output when coresight is enabled on arm64 and check the > resulting quality of the output as part of perf test. > > Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com> > --- > MAINTAINERS | 3 + > tools/perf/Makefile.perf | 14 +- > .../tests/shell/coresight_asm_pure_loop.sh | 18 +++ > tools/perf/tests/shell/lib/coresight.sh | 130 ++++++++++++++++++ > tools/perf/tests/shell/tools/Makefile | 26 ++++ > .../perf/tests/shell/tools/coresight/Makefile | 27 ++++ > .../shell/tools/coresight/Makefile.miniconfig | 23 ++++ > .../tools/coresight/asm_pure_loop/Makefile | 30 ++++ > .../coresight/asm_pure_loop/asm_pure_loop.S | 28 ++++ > 9 files changed, 297 insertions(+), 2 deletions(-) > create mode 100755 tools/perf/tests/shell/coresight_asm_pure_loop.sh > create mode 100644 tools/perf/tests/shell/lib/coresight.sh > create mode 100644 tools/perf/tests/shell/tools/Makefile > create mode 100644 tools/perf/tests/shell/tools/coresight/Makefile > create mode 100644 tools/perf/tests/shell/tools/coresight/Makefile.miniconfig > create mode 100644 tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile > create mode 100644 tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S The folder naming is okay for me, but it is cyclic with the format: "tools/.../tools/". So I am wandering if below two pathes are better? tools/perf/tests/shell/prog/coresight/ or tools/perf/tests/shell/coresight/ I'd like to leave this question for Arnaldo / Jiri for the folder layout. > diff --git a/MAINTAINERS b/MAINTAINERS > index 13f9a84a617e..d46e8469c467 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -1894,6 +1894,9 @@ 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 > F: tools/perf/arch/arm/util/pmu.c > +F: tools/perf/tests/shell/coresight_* > +F: tools/perf/tests/shell/tools/Makefile > +F: tools/perf/tests/shell/tools/coresight/* > F: tools/perf/util/cs-etm-decoder/* > F: tools/perf/util/cs-etm.* > > diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf > index 80522bcfafe0..26467a2c71f4 100644 > --- a/tools/perf/Makefile.perf > +++ b/tools/perf/Makefile.perf > @@ -630,7 +630,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_TOOLS_DIR := $(srctree)/tools/perf/tests/shell/tools > + > +tests-tools-targets: FORCE > + $(Q)$(MAKE) -C $(TESTS_TOOLS_DIR) > + > +tests-tools-targets-clean: > + $(Q)$(MAKE) -C $(TESTS_TOOLS_DIR) clean > + > +all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS) tests-tools-targets > > # Create python binding output directory if not already present > _dummy := $(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python') > @@ -1020,6 +1028,7 @@ install-tests: all install-gtk > $(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' > + $(Q)$(MAKE) -C tests/shell/tools install-tests > > install-bin: install-tools install-tests install-traceevent-plugins > > @@ -1088,7 +1097,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-tools-targets-clean > $(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(OUTPUT)perf-iostat $(LANG_BINDINGS) > $(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete > $(Q)$(RM) $(OUTPUT).config-detected > @@ -1155,5 +1164,6 @@ FORCE: > .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell > .PHONY: $(GIT-HEAD-PHONY) TAGS tags cscope FORCE prepare > .PHONY: libtraceevent_plugins archheaders > +.PHONY: $(TESTS_TOOLS_TARGETS) > > endif # force_fixdep > diff --git a/tools/perf/tests/shell/coresight_asm_pure_loop.sh b/tools/perf/tests/shell/coresight_asm_pure_loop.sh > new file mode 100755 > index 000000000000..542d4a37e349 > --- /dev/null > +++ b/tools/perf/tests/shell/coresight_asm_pure_loop.sh > @@ -0,0 +1,18 @@ > +#!/bin/sh -e > +# Coresight / ASM Pure Loop > + > +# SPDX-License-Identifier: GPL-2.0 > +# Carsten Haitzler <carsten.haitzler@arm.com>, 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 Is $ARGS redundant and can be removed? > +perf_dump_aux_verify "$DATA" 2601 334 334 These three magic numbers "2601 334 334" would be hard to understand. One way is the code can dynamically calculate these values based on the loop times (the loop is is predefined in asm_pure_loop.S), or it's good to give explanation in comments for these values. > + > +err=$? > +exit $err > diff --git a/tools/perf/tests/shell/lib/coresight.sh b/tools/perf/tests/shell/lib/coresight.sh > new file mode 100644 > index 000000000000..cd6c1283e6f5 > --- /dev/null > +++ b/tools/perf/tests/shell/lib/coresight.sh > @@ -0,0 +1,130 @@ > +# SPDX-License-Identifier: GPL-2.0 > +# Carsten Haitzler <carsten.haitzler@arm.com>, 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. > + > +# perf record options for the perf tests to use > +PERFRECMEM="-m ,128M" We must use 128Mb for the AUX trace buffer? The big buffer size is not friendly for embedded system. > +PERFRECOPT="$PERFRECMEM -e cs_etm//u" > + > +# These tests need to be run as root or coresight won't allow large buffers > +# and will not collect proper data > +UID=`id -u` > +if test "$UID" -ne 0; then > + echo "Not running as root... skip" > + exit 2 > +fi > + > +TOOLS=$(dirname $0)/tools > +DIR="$TOOLS/coresight/$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="." It's blur to set DATD and STATD to ".". If the user doesn't specify the envs, it's not clear it will point to which folder. > +# 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 2 > +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 F3 atoms in just about > + # anything but certainly we will see some trace info and async atom > + # chunks. > + DUMP="$DATD/perf-tmp-aux-dump.txt" > + perf report --stdio --dump -i "$1" | \ > + grep -o -e I_ATOM_F3 -e I_ASYNC -e I_TRACE_INFO > "$DUMP" > + # Simply count how many of these atoms 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_F3_NUM=`grep I_ATOM_F3 "$DUMP" | wc -l` > + ATOM_ASYNC_NUM=`grep I_ASYNC "$DUMP" | wc -l` > + ATOM_TRACE_INFO_NUM=`grep I_TRACE_INFO "$DUMP" | wc -l` > + rm -f "$DUMP" > + > + # Arguments provide minimums for a pass > + CHECK_F3_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 F3 Count, Minimum, ATOM ASYNC Count, Minimum, TRACE INFO Count, Minimum" > "$STATF" > + fi > + echo -n "$ATOM_F3_NUM, $CHECK_F3_MIN, $ATOM_ASYNC_NUM, $CHECK_ASYNC_MIN, $ATOM_TRACE_INFO_NUM, $CHECK_TRACE_INFO_MIN" >> "$STATF" > + > + # Actually check to see if we passed or failed. > + check_val_min "ATOM_F3" "$ATOM_F3_NUM" "$CHECK_F3_MIN" "$STATF" > + check_val_min "ASYNC" "$ATOM_ASYNC_NUM" "$CHECK_ASYNC_MIN" "$STATF" > + check_val_min "TRACE_INFO" "$ATOM_TRACE_INFO_NUM" "$CHECK_TRACE_INFO_MIN" "$STATF" > + echo ", Ok" >> "$STATF" > +} > + > +perf_dump_aux_tid_verify() { This function is not used in the test contained in this patch. > + # 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` > + > + # 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 > +} > diff --git a/tools/perf/tests/shell/tools/Makefile b/tools/perf/tests/shell/tools/Makefile > new file mode 100644 > index 000000000000..c7ada20922fd > --- /dev/null > +++ b/tools/perf/tests/shell/tools/Makefile > @@ -0,0 +1,26 @@ > +# SPDX-License-Identifier: GPL-2.0-only > +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 > +include ../../../../../tools/scripts/Makefile.include > +include ../../../../../tools/scripts/Makefile.arch > +include ../../../../../tools/scripts/utilities.mak To be honest, I don't understand well for perf's build and config system. Seems to me, a good example for building program is jevents. Please take a look for the code: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/Makefile.perf#n667 If follow the same method with jevents for building test programs, I can see one benefit is we don't need to create a Makefile, on the other hand, we can reuse the perf's build system and simply create a Build file under the folder tools/perf/tests/shell/.../coresight/. > + > +SUBDIRS = \ > + coresight > + > +all: $(SUBDIRS) > +$(SUBDIRS): > + $(Q)$(MAKE) -C $@ > + > +INSTALLDIRS = $(SUBDIRS:%=install-%) > + > +install-tests: all $(INSTALLDIRS) > +$(INSTALLDIRS): > + $(Q)$(MAKE) -C $(@:install-%=%) install-tests > + > +CLEANDIRS = $(SUBDIRS:%=clean-%) > + > +clean: $(CLEANDIRS) > +$(CLEANDIRS): > + $(Q)$(MAKE) -C $(@:clean-%=%) O=$(OUTPUT) clean >/dev/null > + > +.PHONY: all clean install-tests $(SUBDIRS) $(CLEANDIRS) $(INSTALLDIRS) > diff --git a/tools/perf/tests/shell/tools/coresight/Makefile b/tools/perf/tests/shell/tools/coresight/Makefile > new file mode 100644 > index 000000000000..723006ea827c > --- /dev/null > +++ b/tools/perf/tests/shell/tools/coresight/Makefile > @@ -0,0 +1,27 @@ > +# SPDX-License-Identifier: GPL-2.0-only > +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 > +include ../../../../../../tools/scripts/Makefile.include > +include ../../../../../../tools/scripts/Makefile.arch > +include ../../../../../../tools/scripts/utilities.mak > + > +SUBDIRS = \ > + asm_pure_loop > + > +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) > + > diff --git a/tools/perf/tests/shell/tools/coresight/Makefile.miniconfig b/tools/perf/tests/shell/tools/coresight/Makefile.miniconfig > new file mode 100644 > index 000000000000..cedd26c6a0eb > --- /dev/null > +++ b/tools/perf/tests/shell/tools/coresight/Makefile.miniconfig > @@ -0,0 +1,23 @@ > +# SPDX-License-Identifier: GPL-2.0-only > +# Carsten Haitzler <carsten.haitzler@arm.com>, 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 > + > +include ../../../../../../scripts/Makefile.include > +include ../../../../../../scripts/Makefile.arch > +include ../../../../../../scripts/utilities.mak As suggested above, if we refer the building method of jevent, I think this Makefile.miniconfig is not needed anymore. > diff --git a/tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile > new file mode 100644 > index 000000000000..10c5a60cb71c > --- /dev/null > +++ b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile > @@ -0,0 +1,30 @@ > +# SPDX-License-Identifier: GPL-2.0 > +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 > + > +include ../Makefile.miniconfig > + > +BIN=asm_pure_loop > +LIB= > + > +all: $(BIN) > + > +$(BIN): $(BIN).S > +ifdef CORESIGHT > +ifeq ($(ARCH),arm64) > + $(Q)$(CC) $(BIN).S -nostdlib -static -o $(BIN) $(LIB) > +endif > +endif > + > +install-tests: all > +ifdef CORESIGHT > +ifeq ($(ARCH),arm64) > + $(call QUIET_INSTALL, tests) \ > + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)'; \ > + $(INSTALL) $(BIN) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)/$(BIN)' > +endif > +endif > + > +clean: > + $(Q)$(RM) -f $(BIN) > + > +.PHONY: all clean install-tests > diff --git a/tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S > new file mode 100644 > index 000000000000..262876451021 > --- /dev/null > +++ b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S > @@ -0,0 +1,28 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* Tamas Zsoldos <tamas.zsoldos@arm.com>, 2021 */ > + > +.globl _start > +_start: > + mov x0, 0x000fffff > + 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 I verified this code on Arm64 machine and it works! I am a bit worry about the code for using the hard code number for system call. Another option is to use the inline assembly in C code, I think you have considered for this approach, this might introduce noise for extra branch instructions during the testing, but it can allow us to program standard C program (and don't worry about the program exiting). If you think using assembly code is better than inline assembly, it would be fine for me. Eventually, the system call number is very seldomly to be changed. Thanks, Leo ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 04/12] perf test: Add beginning of test infra + test to exercise coresight 2021-12-21 15:03 ` Leo Yan @ 2021-12-21 20:40 ` Arnaldo Carvalho de Melo 2022-01-04 15:15 ` Carsten Haitzler 2022-01-04 15:14 ` Carsten Haitzler 1 sibling, 1 reply; 19+ messages in thread From: Arnaldo Carvalho de Melo @ 2021-12-21 20:40 UTC (permalink / raw) To: Leo Yan Cc: carsten.haitzler, linux-kernel, coresight, suzuki.poulose, mathieu.poirier, mike.leach, inux-perf-users Em Tue, Dec 21, 2021 at 11:03:49PM +0800, Leo Yan escreveu: > Hi Carsten, > > On Wed, Dec 15, 2021 at 04:03:55PM +0000, carsten.haitzler@foss.arm.com wrote: > > From: Carsten Haitzler <carsten.haitzler@arm.com> > > > > This adds the initial test harness to run perf record and examine the > > resuling output when coresight is enabled on arm64 and check the > > resulting quality of the output as part of perf test. > > > > Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com> > > --- > > MAINTAINERS | 3 + > > tools/perf/Makefile.perf | 14 +- > > .../tests/shell/coresight_asm_pure_loop.sh | 18 +++ > > tools/perf/tests/shell/lib/coresight.sh | 130 ++++++++++++++++++ > > tools/perf/tests/shell/tools/Makefile | 26 ++++ > > .../perf/tests/shell/tools/coresight/Makefile | 27 ++++ > > .../shell/tools/coresight/Makefile.miniconfig | 23 ++++ > > .../tools/coresight/asm_pure_loop/Makefile | 30 ++++ > > .../coresight/asm_pure_loop/asm_pure_loop.S | 28 ++++ > > 9 files changed, 297 insertions(+), 2 deletions(-) > > create mode 100755 tools/perf/tests/shell/coresight_asm_pure_loop.sh > > create mode 100644 tools/perf/tests/shell/lib/coresight.sh > > create mode 100644 tools/perf/tests/shell/tools/Makefile > > create mode 100644 tools/perf/tests/shell/tools/coresight/Makefile > > create mode 100644 tools/perf/tests/shell/tools/coresight/Makefile.miniconfig > > create mode 100644 tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile > > create mode 100644 tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S > > The folder naming is okay for me, but it is cyclic with the format: > "tools/.../tools/". So I am wandering if below two pathes are better? > > tools/perf/tests/shell/prog/coresight/ > or > tools/perf/tests/shell/coresight/ The later, its descriptive enough, I think, and the shortest variant so far. - Arnaldo > I'd like to leave this question for Arnaldo / Jiri for the folder > layout. > > > diff --git a/MAINTAINERS b/MAINTAINERS > > index 13f9a84a617e..d46e8469c467 100644 > > --- a/MAINTAINERS > > +++ b/MAINTAINERS > > @@ -1894,6 +1894,9 @@ 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 > > F: tools/perf/arch/arm/util/pmu.c > > +F: tools/perf/tests/shell/coresight_* > > +F: tools/perf/tests/shell/tools/Makefile > > +F: tools/perf/tests/shell/tools/coresight/* > > F: tools/perf/util/cs-etm-decoder/* > > F: tools/perf/util/cs-etm.* > > > > diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf > > index 80522bcfafe0..26467a2c71f4 100644 > > --- a/tools/perf/Makefile.perf > > +++ b/tools/perf/Makefile.perf > > @@ -630,7 +630,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_TOOLS_DIR := $(srctree)/tools/perf/tests/shell/tools > > + > > +tests-tools-targets: FORCE > > + $(Q)$(MAKE) -C $(TESTS_TOOLS_DIR) > > + > > +tests-tools-targets-clean: > > + $(Q)$(MAKE) -C $(TESTS_TOOLS_DIR) clean > > + > > +all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS) tests-tools-targets > > > > # Create python binding output directory if not already present > > _dummy := $(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python') > > @@ -1020,6 +1028,7 @@ install-tests: all install-gtk > > $(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' > > + $(Q)$(MAKE) -C tests/shell/tools install-tests > > > > install-bin: install-tools install-tests install-traceevent-plugins > > > > @@ -1088,7 +1097,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-tools-targets-clean > > $(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(OUTPUT)perf-iostat $(LANG_BINDINGS) > > $(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete > > $(Q)$(RM) $(OUTPUT).config-detected > > @@ -1155,5 +1164,6 @@ FORCE: > > .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell > > .PHONY: $(GIT-HEAD-PHONY) TAGS tags cscope FORCE prepare > > .PHONY: libtraceevent_plugins archheaders > > +.PHONY: $(TESTS_TOOLS_TARGETS) > > > > endif # force_fixdep > > diff --git a/tools/perf/tests/shell/coresight_asm_pure_loop.sh b/tools/perf/tests/shell/coresight_asm_pure_loop.sh > > new file mode 100755 > > index 000000000000..542d4a37e349 > > --- /dev/null > > +++ b/tools/perf/tests/shell/coresight_asm_pure_loop.sh > > @@ -0,0 +1,18 @@ > > +#!/bin/sh -e > > +# Coresight / ASM Pure Loop > > + > > +# SPDX-License-Identifier: GPL-2.0 > > +# Carsten Haitzler <carsten.haitzler@arm.com>, 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 > > Is $ARGS redundant and can be removed? > > > +perf_dump_aux_verify "$DATA" 2601 334 334 > > These three magic numbers "2601 334 334" would be hard to understand. > One way is the code can dynamically calculate these values based on the > loop times (the loop is is predefined in asm_pure_loop.S), or it's > good to give explanation in comments for these values. > > > + > > +err=$? > > +exit $err > > diff --git a/tools/perf/tests/shell/lib/coresight.sh b/tools/perf/tests/shell/lib/coresight.sh > > new file mode 100644 > > index 000000000000..cd6c1283e6f5 > > --- /dev/null > > +++ b/tools/perf/tests/shell/lib/coresight.sh > > @@ -0,0 +1,130 @@ > > +# SPDX-License-Identifier: GPL-2.0 > > +# Carsten Haitzler <carsten.haitzler@arm.com>, 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. > > + > > +# perf record options for the perf tests to use > > +PERFRECMEM="-m ,128M" > > We must use 128Mb for the AUX trace buffer? The big buffer size is > not friendly for embedded system. > > > +PERFRECOPT="$PERFRECMEM -e cs_etm//u" > > + > > +# These tests need to be run as root or coresight won't allow large buffers > > +# and will not collect proper data > > +UID=`id -u` > > +if test "$UID" -ne 0; then > > + echo "Not running as root... skip" > > + exit 2 > > +fi > > + > > +TOOLS=$(dirname $0)/tools > > +DIR="$TOOLS/coresight/$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="." > > It's blur to set DATD and STATD to ".". If the user doesn't specify > the envs, it's not clear it will point to which folder. > > > +# 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 2 > > +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 F3 atoms in just about > > + # anything but certainly we will see some trace info and async atom > > + # chunks. > > + DUMP="$DATD/perf-tmp-aux-dump.txt" > > + perf report --stdio --dump -i "$1" | \ > > + grep -o -e I_ATOM_F3 -e I_ASYNC -e I_TRACE_INFO > "$DUMP" > > + # Simply count how many of these atoms 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_F3_NUM=`grep I_ATOM_F3 "$DUMP" | wc -l` > > + ATOM_ASYNC_NUM=`grep I_ASYNC "$DUMP" | wc -l` > > + ATOM_TRACE_INFO_NUM=`grep I_TRACE_INFO "$DUMP" | wc -l` > > + rm -f "$DUMP" > > + > > + # Arguments provide minimums for a pass > > + CHECK_F3_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 F3 Count, Minimum, ATOM ASYNC Count, Minimum, TRACE INFO Count, Minimum" > "$STATF" > > + fi > > + echo -n "$ATOM_F3_NUM, $CHECK_F3_MIN, $ATOM_ASYNC_NUM, $CHECK_ASYNC_MIN, $ATOM_TRACE_INFO_NUM, $CHECK_TRACE_INFO_MIN" >> "$STATF" > > + > > + # Actually check to see if we passed or failed. > > + check_val_min "ATOM_F3" "$ATOM_F3_NUM" "$CHECK_F3_MIN" "$STATF" > > + check_val_min "ASYNC" "$ATOM_ASYNC_NUM" "$CHECK_ASYNC_MIN" "$STATF" > > + check_val_min "TRACE_INFO" "$ATOM_TRACE_INFO_NUM" "$CHECK_TRACE_INFO_MIN" "$STATF" > > + echo ", Ok" >> "$STATF" > > +} > > + > > +perf_dump_aux_tid_verify() { > > This function is not used in the test contained in this patch. > > > + # 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` > > + > > + # 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 > > +} > > diff --git a/tools/perf/tests/shell/tools/Makefile b/tools/perf/tests/shell/tools/Makefile > > new file mode 100644 > > index 000000000000..c7ada20922fd > > --- /dev/null > > +++ b/tools/perf/tests/shell/tools/Makefile > > @@ -0,0 +1,26 @@ > > +# SPDX-License-Identifier: GPL-2.0-only > > +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 > > +include ../../../../../tools/scripts/Makefile.include > > +include ../../../../../tools/scripts/Makefile.arch > > +include ../../../../../tools/scripts/utilities.mak > > To be honest, I don't understand well for perf's build and config > system. Seems to me, a good example for building program is jevents. > > Please take a look for the code: > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/Makefile.perf#n667 > > If follow the same method with jevents for building test programs, > I can see one benefit is we don't need to create a Makefile, on the > other hand, we can reuse the perf's build system and simply create a > Build file under the folder tools/perf/tests/shell/.../coresight/. > > > + > > +SUBDIRS = \ > > + coresight > > + > > +all: $(SUBDIRS) > > +$(SUBDIRS): > > + $(Q)$(MAKE) -C $@ > > + > > +INSTALLDIRS = $(SUBDIRS:%=install-%) > > + > > +install-tests: all $(INSTALLDIRS) > > +$(INSTALLDIRS): > > + $(Q)$(MAKE) -C $(@:install-%=%) install-tests > > + > > +CLEANDIRS = $(SUBDIRS:%=clean-%) > > + > > +clean: $(CLEANDIRS) > > +$(CLEANDIRS): > > + $(Q)$(MAKE) -C $(@:clean-%=%) O=$(OUTPUT) clean >/dev/null > > + > > +.PHONY: all clean install-tests $(SUBDIRS) $(CLEANDIRS) $(INSTALLDIRS) > > diff --git a/tools/perf/tests/shell/tools/coresight/Makefile b/tools/perf/tests/shell/tools/coresight/Makefile > > new file mode 100644 > > index 000000000000..723006ea827c > > --- /dev/null > > +++ b/tools/perf/tests/shell/tools/coresight/Makefile > > @@ -0,0 +1,27 @@ > > +# SPDX-License-Identifier: GPL-2.0-only > > +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 > > +include ../../../../../../tools/scripts/Makefile.include > > +include ../../../../../../tools/scripts/Makefile.arch > > +include ../../../../../../tools/scripts/utilities.mak > > + > > +SUBDIRS = \ > > + asm_pure_loop > > + > > +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) > > + > > diff --git a/tools/perf/tests/shell/tools/coresight/Makefile.miniconfig b/tools/perf/tests/shell/tools/coresight/Makefile.miniconfig > > new file mode 100644 > > index 000000000000..cedd26c6a0eb > > --- /dev/null > > +++ b/tools/perf/tests/shell/tools/coresight/Makefile.miniconfig > > @@ -0,0 +1,23 @@ > > +# SPDX-License-Identifier: GPL-2.0-only > > +# Carsten Haitzler <carsten.haitzler@arm.com>, 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 > > + > > +include ../../../../../../scripts/Makefile.include > > +include ../../../../../../scripts/Makefile.arch > > +include ../../../../../../scripts/utilities.mak > > As suggested above, if we refer the building method of jevent, I think > this Makefile.miniconfig is not needed anymore. > > > diff --git a/tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile > > new file mode 100644 > > index 000000000000..10c5a60cb71c > > --- /dev/null > > +++ b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile > > @@ -0,0 +1,30 @@ > > +# SPDX-License-Identifier: GPL-2.0 > > +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 > > + > > +include ../Makefile.miniconfig > > + > > +BIN=asm_pure_loop > > +LIB= > > + > > +all: $(BIN) > > + > > +$(BIN): $(BIN).S > > +ifdef CORESIGHT > > +ifeq ($(ARCH),arm64) > > + $(Q)$(CC) $(BIN).S -nostdlib -static -o $(BIN) $(LIB) > > +endif > > +endif > > + > > +install-tests: all > > +ifdef CORESIGHT > > +ifeq ($(ARCH),arm64) > > + $(call QUIET_INSTALL, tests) \ > > + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)'; \ > > + $(INSTALL) $(BIN) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)/$(BIN)' > > +endif > > +endif > > + > > +clean: > > + $(Q)$(RM) -f $(BIN) > > + > > +.PHONY: all clean install-tests > > diff --git a/tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S > > new file mode 100644 > > index 000000000000..262876451021 > > --- /dev/null > > +++ b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S > > @@ -0,0 +1,28 @@ > > +/* SPDX-License-Identifier: GPL-2.0 */ > > +/* Tamas Zsoldos <tamas.zsoldos@arm.com>, 2021 */ > > + > > +.globl _start > > +_start: > > + mov x0, 0x000fffff > > + 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 > > I verified this code on Arm64 machine and it works! > > I am a bit worry about the code for using the hard code number for > system call. Another option is to use the inline assembly > in C code, I think you have considered for this approach, this might > introduce noise for extra branch instructions during the testing, > but it can allow us to program standard C program (and don't worry > about the program exiting). > > If you think using assembly code is better than inline assembly, it > would be fine for me. Eventually, the system call number is very > seldomly to be changed. > > Thanks, > Leo -- - Arnaldo ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 04/12] perf test: Add beginning of test infra + test to exercise coresight 2021-12-21 20:40 ` Arnaldo Carvalho de Melo @ 2022-01-04 15:15 ` Carsten Haitzler 0 siblings, 0 replies; 19+ messages in thread From: Carsten Haitzler @ 2022-01-04 15:15 UTC (permalink / raw) To: Arnaldo Carvalho de Melo, Leo Yan Cc: linux-kernel, coresight, suzuki.poulose, mathieu.poirier, mike.leach, inux-perf-users On 12/21/21 20:40, Arnaldo Carvalho de Melo wrote: > Em Tue, Dec 21, 2021 at 11:03:49PM +0800, Leo Yan escreveu: >> Hi Carsten, >> >> On Wed, Dec 15, 2021 at 04:03:55PM +0000, carsten.haitzler@foss.arm.com wrote: >>> From: Carsten Haitzler <carsten.haitzler@arm.com> >>> >>> This adds the initial test harness to run perf record and examine the >>> resuling output when coresight is enabled on arm64 and check the >>> resulting quality of the output as part of perf test. >>> >>> Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com> >>> --- >>> MAINTAINERS | 3 + >>> tools/perf/Makefile.perf | 14 +- >>> .../tests/shell/coresight_asm_pure_loop.sh | 18 +++ >>> tools/perf/tests/shell/lib/coresight.sh | 130 ++++++++++++++++++ >>> tools/perf/tests/shell/tools/Makefile | 26 ++++ >>> .../perf/tests/shell/tools/coresight/Makefile | 27 ++++ >>> .../shell/tools/coresight/Makefile.miniconfig | 23 ++++ >>> .../tools/coresight/asm_pure_loop/Makefile | 30 ++++ >>> .../coresight/asm_pure_loop/asm_pure_loop.S | 28 ++++ >>> 9 files changed, 297 insertions(+), 2 deletions(-) >>> create mode 100755 tools/perf/tests/shell/coresight_asm_pure_loop.sh >>> create mode 100644 tools/perf/tests/shell/lib/coresight.sh >>> create mode 100644 tools/perf/tests/shell/tools/Makefile >>> create mode 100644 tools/perf/tests/shell/tools/coresight/Makefile >>> create mode 100644 tools/perf/tests/shell/tools/coresight/Makefile.miniconfig >>> create mode 100644 tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile >>> create mode 100644 tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S >> >> The folder naming is okay for me, but it is cyclic with the format: >> "tools/.../tools/". So I am wandering if below two pathes are better? >> >> tools/perf/tests/shell/prog/coresight/ >> or >> tools/perf/tests/shell/coresight/ > > The later, its descriptive enough, I think, and the shortest variant so > far. Sure - no problem. I can change that. Once no one has any more comments and a few of the pending thnigs I've marked to resolve are solved, I'll submit a new patch set. > - Arnaldo > >> I'd like to leave this question for Arnaldo / Jiri for the folder >> layout. >> >>> diff --git a/MAINTAINERS b/MAINTAINERS >>> index 13f9a84a617e..d46e8469c467 100644 >>> --- a/MAINTAINERS >>> +++ b/MAINTAINERS >>> @@ -1894,6 +1894,9 @@ 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 >>> F: tools/perf/arch/arm/util/pmu.c >>> +F: tools/perf/tests/shell/coresight_* >>> +F: tools/perf/tests/shell/tools/Makefile >>> +F: tools/perf/tests/shell/tools/coresight/* >>> F: tools/perf/util/cs-etm-decoder/* >>> F: tools/perf/util/cs-etm.* >>> >>> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf >>> index 80522bcfafe0..26467a2c71f4 100644 >>> --- a/tools/perf/Makefile.perf >>> +++ b/tools/perf/Makefile.perf >>> @@ -630,7 +630,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_TOOLS_DIR := $(srctree)/tools/perf/tests/shell/tools >>> + >>> +tests-tools-targets: FORCE >>> + $(Q)$(MAKE) -C $(TESTS_TOOLS_DIR) >>> + >>> +tests-tools-targets-clean: >>> + $(Q)$(MAKE) -C $(TESTS_TOOLS_DIR) clean >>> + >>> +all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS) tests-tools-targets >>> >>> # Create python binding output directory if not already present >>> _dummy := $(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python') >>> @@ -1020,6 +1028,7 @@ install-tests: all install-gtk >>> $(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' >>> + $(Q)$(MAKE) -C tests/shell/tools install-tests >>> >>> install-bin: install-tools install-tests install-traceevent-plugins >>> >>> @@ -1088,7 +1097,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-tools-targets-clean >>> $(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(OUTPUT)perf-iostat $(LANG_BINDINGS) >>> $(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete >>> $(Q)$(RM) $(OUTPUT).config-detected >>> @@ -1155,5 +1164,6 @@ FORCE: >>> .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell >>> .PHONY: $(GIT-HEAD-PHONY) TAGS tags cscope FORCE prepare >>> .PHONY: libtraceevent_plugins archheaders >>> +.PHONY: $(TESTS_TOOLS_TARGETS) >>> >>> endif # force_fixdep >>> diff --git a/tools/perf/tests/shell/coresight_asm_pure_loop.sh b/tools/perf/tests/shell/coresight_asm_pure_loop.sh >>> new file mode 100755 >>> index 000000000000..542d4a37e349 >>> --- /dev/null >>> +++ b/tools/perf/tests/shell/coresight_asm_pure_loop.sh >>> @@ -0,0 +1,18 @@ >>> +#!/bin/sh -e >>> +# Coresight / ASM Pure Loop >>> + >>> +# SPDX-License-Identifier: GPL-2.0 >>> +# Carsten Haitzler <carsten.haitzler@arm.com>, 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 >> >> Is $ARGS redundant and can be removed? >> >>> +perf_dump_aux_verify "$DATA" 2601 334 334 >> >> These three magic numbers "2601 334 334" would be hard to understand. >> One way is the code can dynamically calculate these values based on the >> loop times (the loop is is predefined in asm_pure_loop.S), or it's >> good to give explanation in comments for these values. >> >>> + >>> +err=$? >>> +exit $err >>> diff --git a/tools/perf/tests/shell/lib/coresight.sh b/tools/perf/tests/shell/lib/coresight.sh >>> new file mode 100644 >>> index 000000000000..cd6c1283e6f5 >>> --- /dev/null >>> +++ b/tools/perf/tests/shell/lib/coresight.sh >>> @@ -0,0 +1,130 @@ >>> +# SPDX-License-Identifier: GPL-2.0 >>> +# Carsten Haitzler <carsten.haitzler@arm.com>, 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. >>> + >>> +# perf record options for the perf tests to use >>> +PERFRECMEM="-m ,128M" >> >> We must use 128Mb for the AUX trace buffer? The big buffer size is >> not friendly for embedded system. >> >>> +PERFRECOPT="$PERFRECMEM -e cs_etm//u" >>> + >>> +# These tests need to be run as root or coresight won't allow large buffers >>> +# and will not collect proper data >>> +UID=`id -u` >>> +if test "$UID" -ne 0; then >>> + echo "Not running as root... skip" >>> + exit 2 >>> +fi >>> + >>> +TOOLS=$(dirname $0)/tools >>> +DIR="$TOOLS/coresight/$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="." >> >> It's blur to set DATD and STATD to ".". If the user doesn't specify >> the envs, it's not clear it will point to which folder. >> >>> +# 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 2 >>> +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 F3 atoms in just about >>> + # anything but certainly we will see some trace info and async atom >>> + # chunks. >>> + DUMP="$DATD/perf-tmp-aux-dump.txt" >>> + perf report --stdio --dump -i "$1" | \ >>> + grep -o -e I_ATOM_F3 -e I_ASYNC -e I_TRACE_INFO > "$DUMP" >>> + # Simply count how many of these atoms 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_F3_NUM=`grep I_ATOM_F3 "$DUMP" | wc -l` >>> + ATOM_ASYNC_NUM=`grep I_ASYNC "$DUMP" | wc -l` >>> + ATOM_TRACE_INFO_NUM=`grep I_TRACE_INFO "$DUMP" | wc -l` >>> + rm -f "$DUMP" >>> + >>> + # Arguments provide minimums for a pass >>> + CHECK_F3_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 F3 Count, Minimum, ATOM ASYNC Count, Minimum, TRACE INFO Count, Minimum" > "$STATF" >>> + fi >>> + echo -n "$ATOM_F3_NUM, $CHECK_F3_MIN, $ATOM_ASYNC_NUM, $CHECK_ASYNC_MIN, $ATOM_TRACE_INFO_NUM, $CHECK_TRACE_INFO_MIN" >> "$STATF" >>> + >>> + # Actually check to see if we passed or failed. >>> + check_val_min "ATOM_F3" "$ATOM_F3_NUM" "$CHECK_F3_MIN" "$STATF" >>> + check_val_min "ASYNC" "$ATOM_ASYNC_NUM" "$CHECK_ASYNC_MIN" "$STATF" >>> + check_val_min "TRACE_INFO" "$ATOM_TRACE_INFO_NUM" "$CHECK_TRACE_INFO_MIN" "$STATF" >>> + echo ", Ok" >> "$STATF" >>> +} >>> + >>> +perf_dump_aux_tid_verify() { >> >> This function is not used in the test contained in this patch. >> >>> + # 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` >>> + >>> + # 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 >>> +} >>> diff --git a/tools/perf/tests/shell/tools/Makefile b/tools/perf/tests/shell/tools/Makefile >>> new file mode 100644 >>> index 000000000000..c7ada20922fd >>> --- /dev/null >>> +++ b/tools/perf/tests/shell/tools/Makefile >>> @@ -0,0 +1,26 @@ >>> +# SPDX-License-Identifier: GPL-2.0-only >>> +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 >>> +include ../../../../../tools/scripts/Makefile.include >>> +include ../../../../../tools/scripts/Makefile.arch >>> +include ../../../../../tools/scripts/utilities.mak >> >> To be honest, I don't understand well for perf's build and config >> system. Seems to me, a good example for building program is jevents. >> >> Please take a look for the code: >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/Makefile.perf#n667 >> >> If follow the same method with jevents for building test programs, >> I can see one benefit is we don't need to create a Makefile, on the >> other hand, we can reuse the perf's build system and simply create a >> Build file under the folder tools/perf/tests/shell/.../coresight/. >> >>> + >>> +SUBDIRS = \ >>> + coresight >>> + >>> +all: $(SUBDIRS) >>> +$(SUBDIRS): >>> + $(Q)$(MAKE) -C $@ >>> + >>> +INSTALLDIRS = $(SUBDIRS:%=install-%) >>> + >>> +install-tests: all $(INSTALLDIRS) >>> +$(INSTALLDIRS): >>> + $(Q)$(MAKE) -C $(@:install-%=%) install-tests >>> + >>> +CLEANDIRS = $(SUBDIRS:%=clean-%) >>> + >>> +clean: $(CLEANDIRS) >>> +$(CLEANDIRS): >>> + $(Q)$(MAKE) -C $(@:clean-%=%) O=$(OUTPUT) clean >/dev/null >>> + >>> +.PHONY: all clean install-tests $(SUBDIRS) $(CLEANDIRS) $(INSTALLDIRS) >>> diff --git a/tools/perf/tests/shell/tools/coresight/Makefile b/tools/perf/tests/shell/tools/coresight/Makefile >>> new file mode 100644 >>> index 000000000000..723006ea827c >>> --- /dev/null >>> +++ b/tools/perf/tests/shell/tools/coresight/Makefile >>> @@ -0,0 +1,27 @@ >>> +# SPDX-License-Identifier: GPL-2.0-only >>> +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 >>> +include ../../../../../../tools/scripts/Makefile.include >>> +include ../../../../../../tools/scripts/Makefile.arch >>> +include ../../../../../../tools/scripts/utilities.mak >>> + >>> +SUBDIRS = \ >>> + asm_pure_loop >>> + >>> +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) >>> + >>> diff --git a/tools/perf/tests/shell/tools/coresight/Makefile.miniconfig b/tools/perf/tests/shell/tools/coresight/Makefile.miniconfig >>> new file mode 100644 >>> index 000000000000..cedd26c6a0eb >>> --- /dev/null >>> +++ b/tools/perf/tests/shell/tools/coresight/Makefile.miniconfig >>> @@ -0,0 +1,23 @@ >>> +# SPDX-License-Identifier: GPL-2.0-only >>> +# Carsten Haitzler <carsten.haitzler@arm.com>, 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 >>> + >>> +include ../../../../../../scripts/Makefile.include >>> +include ../../../../../../scripts/Makefile.arch >>> +include ../../../../../../scripts/utilities.mak >> >> As suggested above, if we refer the building method of jevent, I think >> this Makefile.miniconfig is not needed anymore. >> >>> diff --git a/tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile >>> new file mode 100644 >>> index 000000000000..10c5a60cb71c >>> --- /dev/null >>> +++ b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile >>> @@ -0,0 +1,30 @@ >>> +# SPDX-License-Identifier: GPL-2.0 >>> +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 >>> + >>> +include ../Makefile.miniconfig >>> + >>> +BIN=asm_pure_loop >>> +LIB= >>> + >>> +all: $(BIN) >>> + >>> +$(BIN): $(BIN).S >>> +ifdef CORESIGHT >>> +ifeq ($(ARCH),arm64) >>> + $(Q)$(CC) $(BIN).S -nostdlib -static -o $(BIN) $(LIB) >>> +endif >>> +endif >>> + >>> +install-tests: all >>> +ifdef CORESIGHT >>> +ifeq ($(ARCH),arm64) >>> + $(call QUIET_INSTALL, tests) \ >>> + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)'; \ >>> + $(INSTALL) $(BIN) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)/$(BIN)' >>> +endif >>> +endif >>> + >>> +clean: >>> + $(Q)$(RM) -f $(BIN) >>> + >>> +.PHONY: all clean install-tests >>> diff --git a/tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S >>> new file mode 100644 >>> index 000000000000..262876451021 >>> --- /dev/null >>> +++ b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S >>> @@ -0,0 +1,28 @@ >>> +/* SPDX-License-Identifier: GPL-2.0 */ >>> +/* Tamas Zsoldos <tamas.zsoldos@arm.com>, 2021 */ >>> + >>> +.globl _start >>> +_start: >>> + mov x0, 0x000fffff >>> + 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 >> >> I verified this code on Arm64 machine and it works! >> >> I am a bit worry about the code for using the hard code number for >> system call. Another option is to use the inline assembly >> in C code, I think you have considered for this approach, this might >> introduce noise for extra branch instructions during the testing, >> but it can allow us to program standard C program (and don't worry >> about the program exiting). >> >> If you think using assembly code is better than inline assembly, it >> would be fine for me. Eventually, the system call number is very >> seldomly to be changed. >> >> Thanks, >> Leo > ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 04/12] perf test: Add beginning of test infra + test to exercise coresight 2021-12-21 15:03 ` Leo Yan 2021-12-21 20:40 ` Arnaldo Carvalho de Melo @ 2022-01-04 15:14 ` Carsten Haitzler 1 sibling, 0 replies; 19+ messages in thread From: Carsten Haitzler @ 2022-01-04 15:14 UTC (permalink / raw) To: Leo Yan Cc: linux-kernel, coresight, suzuki.poulose, mathieu.poirier, mike.leach, inux-perf-users, acme On 12/21/21 15:03, Leo Yan wrote: > Hi Carsten, > > On Wed, Dec 15, 2021 at 04:03:55PM +0000, carsten.haitzler@foss.arm.com wrote: >> From: Carsten Haitzler <carsten.haitzler@arm.com> >> >> This adds the initial test harness to run perf record and examine the >> resuling output when coresight is enabled on arm64 and check the >> resulting quality of the output as part of perf test. >> >> Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com> >> --- >> MAINTAINERS | 3 + >> tools/perf/Makefile.perf | 14 +- >> .../tests/shell/coresight_asm_pure_loop.sh | 18 +++ >> tools/perf/tests/shell/lib/coresight.sh | 130 ++++++++++++++++++ >> tools/perf/tests/shell/tools/Makefile | 26 ++++ >> .../perf/tests/shell/tools/coresight/Makefile | 27 ++++ >> .../shell/tools/coresight/Makefile.miniconfig | 23 ++++ >> .../tools/coresight/asm_pure_loop/Makefile | 30 ++++ >> .../coresight/asm_pure_loop/asm_pure_loop.S | 28 ++++ >> 9 files changed, 297 insertions(+), 2 deletions(-) >> create mode 100755 tools/perf/tests/shell/coresight_asm_pure_loop.sh >> create mode 100644 tools/perf/tests/shell/lib/coresight.sh >> create mode 100644 tools/perf/tests/shell/tools/Makefile >> create mode 100644 tools/perf/tests/shell/tools/coresight/Makefile >> create mode 100644 tools/perf/tests/shell/tools/coresight/Makefile.miniconfig >> create mode 100644 tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile >> create mode 100644 tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S > > The folder naming is okay for me, but it is cyclic with the format: > "tools/.../tools/". So I am wandering if below two pathes are better? > > tools/perf/tests/shell/prog/coresight/ > or > tools/perf/tests/shell/coresight/ > > I'd like to leave this question for Arnaldo / Jiri for the folder > layout. Personally - I'm not fussed. :) So whatever you think is best. >> diff --git a/MAINTAINERS b/MAINTAINERS >> index 13f9a84a617e..d46e8469c467 100644 >> --- a/MAINTAINERS >> +++ b/MAINTAINERS >> @@ -1894,6 +1894,9 @@ 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 >> F: tools/perf/arch/arm/util/pmu.c >> +F: tools/perf/tests/shell/coresight_* >> +F: tools/perf/tests/shell/tools/Makefile >> +F: tools/perf/tests/shell/tools/coresight/* >> F: tools/perf/util/cs-etm-decoder/* >> F: tools/perf/util/cs-etm.* >> >> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf >> index 80522bcfafe0..26467a2c71f4 100644 >> --- a/tools/perf/Makefile.perf >> +++ b/tools/perf/Makefile.perf >> @@ -630,7 +630,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_TOOLS_DIR := $(srctree)/tools/perf/tests/shell/tools >> + >> +tests-tools-targets: FORCE >> + $(Q)$(MAKE) -C $(TESTS_TOOLS_DIR) >> + >> +tests-tools-targets-clean: >> + $(Q)$(MAKE) -C $(TESTS_TOOLS_DIR) clean >> + >> +all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS) tests-tools-targets >> >> # Create python binding output directory if not already present >> _dummy := $(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python') >> @@ -1020,6 +1028,7 @@ install-tests: all install-gtk >> $(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' >> + $(Q)$(MAKE) -C tests/shell/tools install-tests >> >> install-bin: install-tools install-tests install-traceevent-plugins >> >> @@ -1088,7 +1097,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-tools-targets-clean >> $(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(OUTPUT)perf-iostat $(LANG_BINDINGS) >> $(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete >> $(Q)$(RM) $(OUTPUT).config-detected >> @@ -1155,5 +1164,6 @@ FORCE: >> .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell >> .PHONY: $(GIT-HEAD-PHONY) TAGS tags cscope FORCE prepare >> .PHONY: libtraceevent_plugins archheaders >> +.PHONY: $(TESTS_TOOLS_TARGETS) >> >> endif # force_fixdep >> diff --git a/tools/perf/tests/shell/coresight_asm_pure_loop.sh b/tools/perf/tests/shell/coresight_asm_pure_loop.sh >> new file mode 100755 >> index 000000000000..542d4a37e349 >> --- /dev/null >> +++ b/tools/perf/tests/shell/coresight_asm_pure_loop.sh >> @@ -0,0 +1,18 @@ >> +#!/bin/sh -e >> +# Coresight / ASM Pure Loop >> + >> +# SPDX-License-Identifier: GPL-2.0 >> +# Carsten Haitzler <carsten.haitzler@arm.com>, 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 > > Is $ARGS redundant and can be removed? > >> +perf_dump_aux_verify "$DATA" 2601 334 334 > > These three magic numbers "2601 334 334" would be hard to understand. > One way is the code can dynamically calculate these values based on the > loop times (the loop is is predefined in asm_pure_loop.S), or it's > good to give explanation in comments for these values. > >> + >> +err=$? >> +exit $err >> diff --git a/tools/perf/tests/shell/lib/coresight.sh b/tools/perf/tests/shell/lib/coresight.sh >> new file mode 100644 >> index 000000000000..cd6c1283e6f5 >> --- /dev/null >> +++ b/tools/perf/tests/shell/lib/coresight.sh >> @@ -0,0 +1,130 @@ >> +# SPDX-License-Identifier: GPL-2.0 >> +# Carsten Haitzler <carsten.haitzler@arm.com>, 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. >> + >> +# perf record options for the perf tests to use >> +PERFRECMEM="-m ,128M" > > We must use 128Mb for the AUX trace buffer? The big buffer size is > not friendly for embedded system. > >> +PERFRECOPT="$PERFRECMEM -e cs_etm//u" >> + >> +# These tests need to be run as root or coresight won't allow large buffers >> +# and will not collect proper data >> +UID=`id -u` >> +if test "$UID" -ne 0; then >> + echo "Not running as root... skip" >> + exit 2 >> +fi >> + >> +TOOLS=$(dirname $0)/tools >> +DIR="$TOOLS/coresight/$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="." > > It's blur to set DATD and STATD to ".". If the user doesn't specify > the envs, it's not clear it will point to which folder. > >> +# 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 2 >> +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 F3 atoms in just about >> + # anything but certainly we will see some trace info and async atom >> + # chunks. >> + DUMP="$DATD/perf-tmp-aux-dump.txt" >> + perf report --stdio --dump -i "$1" | \ >> + grep -o -e I_ATOM_F3 -e I_ASYNC -e I_TRACE_INFO > "$DUMP" >> + # Simply count how many of these atoms 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_F3_NUM=`grep I_ATOM_F3 "$DUMP" | wc -l` >> + ATOM_ASYNC_NUM=`grep I_ASYNC "$DUMP" | wc -l` >> + ATOM_TRACE_INFO_NUM=`grep I_TRACE_INFO "$DUMP" | wc -l` >> + rm -f "$DUMP" >> + >> + # Arguments provide minimums for a pass >> + CHECK_F3_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 F3 Count, Minimum, ATOM ASYNC Count, Minimum, TRACE INFO Count, Minimum" > "$STATF" >> + fi >> + echo -n "$ATOM_F3_NUM, $CHECK_F3_MIN, $ATOM_ASYNC_NUM, $CHECK_ASYNC_MIN, $ATOM_TRACE_INFO_NUM, $CHECK_TRACE_INFO_MIN" >> "$STATF" >> + >> + # Actually check to see if we passed or failed. >> + check_val_min "ATOM_F3" "$ATOM_F3_NUM" "$CHECK_F3_MIN" "$STATF" >> + check_val_min "ASYNC" "$ATOM_ASYNC_NUM" "$CHECK_ASYNC_MIN" "$STATF" >> + check_val_min "TRACE_INFO" "$ATOM_TRACE_INFO_NUM" "$CHECK_TRACE_INFO_MIN" "$STATF" >> + echo ", Ok" >> "$STATF" >> +} >> + >> +perf_dump_aux_tid_verify() { > > This function is not used in the test contained in this patch. > >> + # 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` >> + >> + # 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 >> +} >> diff --git a/tools/perf/tests/shell/tools/Makefile b/tools/perf/tests/shell/tools/Makefile >> new file mode 100644 >> index 000000000000..c7ada20922fd >> --- /dev/null >> +++ b/tools/perf/tests/shell/tools/Makefile >> @@ -0,0 +1,26 @@ >> +# SPDX-License-Identifier: GPL-2.0-only >> +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 >> +include ../../../../../tools/scripts/Makefile.include >> +include ../../../../../tools/scripts/Makefile.arch >> +include ../../../../../tools/scripts/utilities.mak > > To be honest, I don't understand well for perf's build and config > system. Seems to me, a good example for building program is jevents. > > Please take a look for the code: > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/Makefile.perf#n667 > > If follow the same method with jevents for building test programs, > I can see one benefit is we don't need to create a Makefile, on the > other hand, we can reuse the perf's build system and simply create a > Build file under the folder tools/perf/tests/shell/.../coresight/. > >> + >> +SUBDIRS = \ >> + coresight >> + >> +all: $(SUBDIRS) >> +$(SUBDIRS): >> + $(Q)$(MAKE) -C $@ >> + >> +INSTALLDIRS = $(SUBDIRS:%=install-%) >> + >> +install-tests: all $(INSTALLDIRS) >> +$(INSTALLDIRS): >> + $(Q)$(MAKE) -C $(@:install-%=%) install-tests >> + >> +CLEANDIRS = $(SUBDIRS:%=clean-%) >> + >> +clean: $(CLEANDIRS) >> +$(CLEANDIRS): >> + $(Q)$(MAKE) -C $(@:clean-%=%) O=$(OUTPUT) clean >/dev/null >> + >> +.PHONY: all clean install-tests $(SUBDIRS) $(CLEANDIRS) $(INSTALLDIRS) >> diff --git a/tools/perf/tests/shell/tools/coresight/Makefile b/tools/perf/tests/shell/tools/coresight/Makefile >> new file mode 100644 >> index 000000000000..723006ea827c >> --- /dev/null >> +++ b/tools/perf/tests/shell/tools/coresight/Makefile >> @@ -0,0 +1,27 @@ >> +# SPDX-License-Identifier: GPL-2.0-only >> +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 >> +include ../../../../../../tools/scripts/Makefile.include >> +include ../../../../../../tools/scripts/Makefile.arch >> +include ../../../../../../tools/scripts/utilities.mak >> + >> +SUBDIRS = \ >> + asm_pure_loop >> + >> +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) >> + >> diff --git a/tools/perf/tests/shell/tools/coresight/Makefile.miniconfig b/tools/perf/tests/shell/tools/coresight/Makefile.miniconfig >> new file mode 100644 >> index 000000000000..cedd26c6a0eb >> --- /dev/null >> +++ b/tools/perf/tests/shell/tools/coresight/Makefile.miniconfig >> @@ -0,0 +1,23 @@ >> +# SPDX-License-Identifier: GPL-2.0-only >> +# Carsten Haitzler <carsten.haitzler@arm.com>, 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 >> + >> +include ../../../../../../scripts/Makefile.include >> +include ../../../../../../scripts/Makefile.arch >> +include ../../../../../../scripts/utilities.mak > > As suggested above, if we refer the building method of jevent, I think > this Makefile.miniconfig is not needed anymore. > >> diff --git a/tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile >> new file mode 100644 >> index 000000000000..10c5a60cb71c >> --- /dev/null >> +++ b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile >> @@ -0,0 +1,30 @@ >> +# SPDX-License-Identifier: GPL-2.0 >> +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 >> + >> +include ../Makefile.miniconfig >> + >> +BIN=asm_pure_loop >> +LIB= >> + >> +all: $(BIN) >> + >> +$(BIN): $(BIN).S >> +ifdef CORESIGHT >> +ifeq ($(ARCH),arm64) >> + $(Q)$(CC) $(BIN).S -nostdlib -static -o $(BIN) $(LIB) >> +endif >> +endif >> + >> +install-tests: all >> +ifdef CORESIGHT >> +ifeq ($(ARCH),arm64) >> + $(call QUIET_INSTALL, tests) \ >> + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)'; \ >> + $(INSTALL) $(BIN) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)/$(BIN)' >> +endif >> +endif >> + >> +clean: >> + $(Q)$(RM) -f $(BIN) >> + >> +.PHONY: all clean install-tests >> diff --git a/tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S >> new file mode 100644 >> index 000000000000..262876451021 >> --- /dev/null >> +++ b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S >> @@ -0,0 +1,28 @@ >> +/* SPDX-License-Identifier: GPL-2.0 */ >> +/* Tamas Zsoldos <tamas.zsoldos@arm.com>, 2021 */ >> + >> +.globl _start >> +_start: >> + mov x0, 0x000fffff >> + 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 > > I verified this code on Arm64 machine and it works! > > I am a bit worry about the code for using the hard code number for > system call. Another option is to use the inline assembly > in C code, I think you have considered for this approach, this might > introduce noise for extra branch instructions during the testing, > but it can allow us to program standard C program (and don't worry > about the program exiting). > > If you think using assembly code is better than inline assembly, it > would be fine for me. Eventually, the system call number is very > seldomly to be changed. > > Thanks, > Leo ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 04/12] perf test: Add beginning of test infra + test to exercise coresight 2021-12-15 16:03 ` [PATCH 04/12] perf test: Add beginning of test infra + test to exercise coresight carsten.haitzler 2021-12-21 15:03 ` Leo Yan @ 2022-01-19 16:58 ` James Clark 2022-02-04 10:21 ` Mike Leach 2 siblings, 0 replies; 19+ messages in thread From: James Clark @ 2022-01-19 16:58 UTC (permalink / raw) To: carsten.haitzler, linux-kernel Cc: coresight, inux-perf-users, acme, mike.leach, suzuki K Poulose, Leo Yan, Mathieu Poirier, Anshuman Khandual On 15/12/2021 16:03, carsten.haitzler@foss.arm.com wrote: > From: Carsten Haitzler <carsten.haitzler@arm.com> > > This adds the initial test harness to run perf record and examine the > resuling output when coresight is enabled on arm64 and check the > resulting quality of the output as part of perf test. > > Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com> > --- [...] > diff --git a/tools/perf/tests/shell/coresight_asm_pure_loop.sh b/tools/perf/tests/shell/coresight_asm_pure_loop.sh > new file mode 100755 > index 000000000000..542d4a37e349 > --- /dev/null > +++ b/tools/perf/tests/shell/coresight_asm_pure_loop.sh > @@ -0,0 +1,18 @@ > +#!/bin/sh -e > +# Coresight / ASM Pure Loop > + > +# SPDX-License-Identifier: GPL-2.0 > +# Carsten Haitzler <carsten.haitzler@arm.com>, 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" 2601 334 334 > + > +err=$? > +exit $err > diff --git a/tools/perf/tests/shell/lib/coresight.sh b/tools/perf/tests/shell/lib/coresight.sh > new file mode 100644 > index 000000000000..cd6c1283e6f5 > --- /dev/null > +++ b/tools/perf/tests/shell/lib/coresight.sh > @@ -0,0 +1,130 @@ > +# SPDX-License-Identifier: GPL-2.0 > +# Carsten Haitzler <carsten.haitzler@arm.com>, 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. > + > +# perf record options for the perf tests to use > +PERFRECMEM="-m ,128M" > +PERFRECOPT="$PERFRECMEM -e cs_etm//u" > + > +# These tests need to be run as root or coresight won't allow large buffers > +# and will not collect proper data I've somewhat fixed this with the change 7cc9680c4be. Can you re-test that it works without sudo? I think it's best to avoid it unless necessary and the cs_etm//u seems to suggest that it's not necessary. If 'proper data' can't be collected without root then it seems more like the tests have found a real issue to fix rather than something to be worked around. James ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 04/12] perf test: Add beginning of test infra + test to exercise coresight 2021-12-15 16:03 ` [PATCH 04/12] perf test: Add beginning of test infra + test to exercise coresight carsten.haitzler 2021-12-21 15:03 ` Leo Yan 2022-01-19 16:58 ` James Clark @ 2022-02-04 10:21 ` Mike Leach 2 siblings, 0 replies; 19+ messages in thread From: Mike Leach @ 2022-02-04 10:21 UTC (permalink / raw) To: carsten.haitzler Cc: linux-kernel, coresight, suzuki.poulose, mathieu.poirier, leo.yan, inux-perf-users, acme Hi Carsten I've been looking at these tests from a trace decode perspective and have a few comments to make. On Wed, 15 Dec 2021 at 16:04, <carsten.haitzler@foss.arm.com> wrote: > > From: Carsten Haitzler <carsten.haitzler@arm.com> > > This adds the initial test harness to run perf record and examine the > resuling output when coresight is enabled on arm64 and check the > resulting quality of the output as part of perf test. > > Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com> > --- > MAINTAINERS | 3 + > tools/perf/Makefile.perf | 14 +- > .../tests/shell/coresight_asm_pure_loop.sh | 18 +++ > tools/perf/tests/shell/lib/coresight.sh | 130 ++++++++++++++++++ > tools/perf/tests/shell/tools/Makefile | 26 ++++ > .../perf/tests/shell/tools/coresight/Makefile | 27 ++++ > .../shell/tools/coresight/Makefile.miniconfig | 23 ++++ > .../tools/coresight/asm_pure_loop/Makefile | 30 ++++ > .../coresight/asm_pure_loop/asm_pure_loop.S | 28 ++++ > 9 files changed, 297 insertions(+), 2 deletions(-) > create mode 100755 tools/perf/tests/shell/coresight_asm_pure_loop.sh > create mode 100644 tools/perf/tests/shell/lib/coresight.sh > create mode 100644 tools/perf/tests/shell/tools/Makefile > create mode 100644 tools/perf/tests/shell/tools/coresight/Makefile > create mode 100644 tools/perf/tests/shell/tools/coresight/Makefile.miniconfig > create mode 100644 tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile > create mode 100644 tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S > > diff --git a/MAINTAINERS b/MAINTAINERS > index 13f9a84a617e..d46e8469c467 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -1894,6 +1894,9 @@ 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 > F: tools/perf/arch/arm/util/pmu.c > +F: tools/perf/tests/shell/coresight_* > +F: tools/perf/tests/shell/tools/Makefile > +F: tools/perf/tests/shell/tools/coresight/* > F: tools/perf/util/cs-etm-decoder/* > F: tools/perf/util/cs-etm.* > > diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf > index 80522bcfafe0..26467a2c71f4 100644 > --- a/tools/perf/Makefile.perf > +++ b/tools/perf/Makefile.perf > @@ -630,7 +630,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_TOOLS_DIR := $(srctree)/tools/perf/tests/shell/tools > + > +tests-tools-targets: FORCE > + $(Q)$(MAKE) -C $(TESTS_TOOLS_DIR) > + > +tests-tools-targets-clean: > + $(Q)$(MAKE) -C $(TESTS_TOOLS_DIR) clean > + > +all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS) tests-tools-targets > > # Create python binding output directory if not already present > _dummy := $(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python') > @@ -1020,6 +1028,7 @@ install-tests: all install-gtk > $(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' > + $(Q)$(MAKE) -C tests/shell/tools install-tests > > install-bin: install-tools install-tests install-traceevent-plugins > > @@ -1088,7 +1097,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-tools-targets-clean > $(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(OUTPUT)perf-iostat $(LANG_BINDINGS) > $(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete > $(Q)$(RM) $(OUTPUT).config-detected > @@ -1155,5 +1164,6 @@ FORCE: > .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell > .PHONY: $(GIT-HEAD-PHONY) TAGS tags cscope FORCE prepare > .PHONY: libtraceevent_plugins archheaders > +.PHONY: $(TESTS_TOOLS_TARGETS) > > endif # force_fixdep > diff --git a/tools/perf/tests/shell/coresight_asm_pure_loop.sh b/tools/perf/tests/shell/coresight_asm_pure_loop.sh > new file mode 100755 > index 000000000000..542d4a37e349 > --- /dev/null > +++ b/tools/perf/tests/shell/coresight_asm_pure_loop.sh > @@ -0,0 +1,18 @@ > +#!/bin/sh -e > +# Coresight / ASM Pure Loop > + > +# SPDX-License-Identifier: GPL-2.0 > +# Carsten Haitzler <carsten.haitzler@arm.com>, 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" 2601 334 334 > + > +err=$? > +exit $err > diff --git a/tools/perf/tests/shell/lib/coresight.sh b/tools/perf/tests/shell/lib/coresight.sh > new file mode 100644 > index 000000000000..cd6c1283e6f5 > --- /dev/null > +++ b/tools/perf/tests/shell/lib/coresight.sh > @@ -0,0 +1,130 @@ > +# SPDX-License-Identifier: GPL-2.0 > +# Carsten Haitzler <carsten.haitzler@arm.com>, 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. > + > +# perf record options for the perf tests to use > +PERFRECMEM="-m ,128M" > +PERFRECOPT="$PERFRECMEM -e cs_etm//u" > + > +# These tests need to be run as root or coresight won't allow large buffers > +# and will not collect proper data > +UID=`id -u` > +if test "$UID" -ne 0; then > + echo "Not running as root... skip" > + exit 2 > +fi > + > +TOOLS=$(dirname $0)/tools > +DIR="$TOOLS/coresight/$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 2 > +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 F3 atoms in just about > + # anything but certainly we will see some trace info and async atom > + # chunks. > + DUMP="$DATD/perf-tmp-aux-dump.txt" > + perf report --stdio --dump -i "$1" | \ > + grep -o -e I_ATOM_F3 -e I_ASYNC -e I_TRACE_INFO > "$DUMP" > + # Simply count how many of these atoms 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_F3_NUM=`grep I_ATOM_F3 "$DUMP" | wc -l` > + ATOM_ASYNC_NUM=`grep I_ASYNC "$DUMP" | wc -l` > + ATOM_TRACE_INFO_NUM=`grep I_TRACE_INFO "$DUMP" | wc -l` > + rm -f "$DUMP" > + Terminology - an ATOM packet is one that contains branch taken / not take atoms - E / N. These come in 6 different formats F1 .. F6. So here we shoud drop the ATOM_ prefix from TRACE_INFO and ASYNC > + # Arguments provide minimums for a pass > + CHECK_F3_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 F3 Count, Minimum, ATOM ASYNC Count, Minimum, TRACE INFO Count, Minimum" > "$STATF" > + fi > + echo -n "$ATOM_F3_NUM, $CHECK_F3_MIN, $ATOM_ASYNC_NUM, $CHECK_ASYNC_MIN, $ATOM_TRACE_INFO_NUM, $CHECK_TRACE_INFO_MIN" >> "$STATF" > + > + # Actually check to see if we passed or failed. > + check_val_min "ATOM_F3" "$ATOM_F3_NUM" "$CHECK_F3_MIN" "$STATF" > + check_val_min "ASYNC" "$ATOM_ASYNC_NUM" "$CHECK_ASYNC_MIN" "$STATF" > + check_val_min "TRACE_INFO" "$ATOM_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` > + > + # 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 > +} > diff --git a/tools/perf/tests/shell/tools/Makefile b/tools/perf/tests/shell/tools/Makefile > new file mode 100644 > index 000000000000..c7ada20922fd > --- /dev/null > +++ b/tools/perf/tests/shell/tools/Makefile > @@ -0,0 +1,26 @@ > +# SPDX-License-Identifier: GPL-2.0-only > +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 > +include ../../../../../tools/scripts/Makefile.include > +include ../../../../../tools/scripts/Makefile.arch > +include ../../../../../tools/scripts/utilities.mak > + > +SUBDIRS = \ > + coresight > + > +all: $(SUBDIRS) > +$(SUBDIRS): > + $(Q)$(MAKE) -C $@ > + > +INSTALLDIRS = $(SUBDIRS:%=install-%) > + > +install-tests: all $(INSTALLDIRS) > +$(INSTALLDIRS): > + $(Q)$(MAKE) -C $(@:install-%=%) install-tests > + > +CLEANDIRS = $(SUBDIRS:%=clean-%) > + > +clean: $(CLEANDIRS) > +$(CLEANDIRS): > + $(Q)$(MAKE) -C $(@:clean-%=%) O=$(OUTPUT) clean >/dev/null > + > +.PHONY: all clean install-tests $(SUBDIRS) $(CLEANDIRS) $(INSTALLDIRS) > diff --git a/tools/perf/tests/shell/tools/coresight/Makefile b/tools/perf/tests/shell/tools/coresight/Makefile > new file mode 100644 > index 000000000000..723006ea827c > --- /dev/null > +++ b/tools/perf/tests/shell/tools/coresight/Makefile > @@ -0,0 +1,27 @@ > +# SPDX-License-Identifier: GPL-2.0-only > +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 > +include ../../../../../../tools/scripts/Makefile.include > +include ../../../../../../tools/scripts/Makefile.arch > +include ../../../../../../tools/scripts/utilities.mak > + > +SUBDIRS = \ > + asm_pure_loop > + > +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) > + > diff --git a/tools/perf/tests/shell/tools/coresight/Makefile.miniconfig b/tools/perf/tests/shell/tools/coresight/Makefile.miniconfig > new file mode 100644 > index 000000000000..cedd26c6a0eb > --- /dev/null > +++ b/tools/perf/tests/shell/tools/coresight/Makefile.miniconfig > @@ -0,0 +1,23 @@ > +# SPDX-License-Identifier: GPL-2.0-only > +# Carsten Haitzler <carsten.haitzler@arm.com>, 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 > + > +include ../../../../../../scripts/Makefile.include > +include ../../../../../../scripts/Makefile.arch > +include ../../../../../../scripts/utilities.mak > diff --git a/tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile > new file mode 100644 > index 000000000000..10c5a60cb71c > --- /dev/null > +++ b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile > @@ -0,0 +1,30 @@ > +# SPDX-License-Identifier: GPL-2.0 > +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 > + > +include ../Makefile.miniconfig > + > +BIN=asm_pure_loop > +LIB= > + > +all: $(BIN) > + > +$(BIN): $(BIN).S > +ifdef CORESIGHT > +ifeq ($(ARCH),arm64) > + $(Q)$(CC) $(BIN).S -nostdlib -static -o $(BIN) $(LIB) > +endif > +endif > + > +install-tests: all > +ifdef CORESIGHT > +ifeq ($(ARCH),arm64) > + $(call QUIET_INSTALL, tests) \ > + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)'; \ > + $(INSTALL) $(BIN) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)/$(BIN)' > +endif > +endif > + > +clean: > + $(Q)$(RM) -f $(BIN) > + > +.PHONY: all clean install-tests > diff --git a/tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S > new file mode 100644 > index 000000000000..262876451021 > --- /dev/null > +++ b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S > @@ -0,0 +1,28 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* Tamas Zsoldos <tamas.zsoldos@arm.com>, 2021 */ > + > +.globl _start > +_start: > + mov x0, 0x000fffff > + 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 > -- > 2.32.0 > Bear in mind too that the general principle of ETM4 trace is to trace "waypoint" instructions - these are typically branches - which could potentially cause a change in program flow. The rest are deduced from the program image. The test program above is a good start - there are three waypoint instructions - looking at the code, each iteration of the look will generate a NEE atom element pattern. (cbnz x1 is never taken as x1 is always 0, br x2 is unconditional and always taken, cbnz x0, loop is always taken - except for the final time on loop exit). Which fits nicely into the ATOM_F3 packet you are counting. However - there is nothing in the ETM architecture that says an implementation has to use this packet. Depending on timings and implementation details the same trace on a different platform could be output as consecutive ATOM_F2 packets NE EN EE etc, etc. Both cases will decode correctly. Counting a particular ATOM packet type is therefore not a portable test. For a given bounded trace run*, you shoul always see the same number of atom elements. Helpfully ATOM_F1 packets contain 1 atom, _F2 2 atoms. up to F5 with 5 atoms. Less helpfully F6 contains between 4 and 24 atoms. For ASYNC / TRACE INFO these are programmed to appear at every 4k bytes of trace. This allows synchronisation to be established if the hardware buffer has wrapped. They will also appear at start of trace and other locations defined in the ETM4 architecture spec. However, both are emitted as a pair due to a synchronisation request - the ASYNC allows the packet processor to start interpreting the bytes stream into a set of packets. TRACEINFO is used by the trace decoder to turn the set of packets into decoded trace. For the purposes of the perf report --dump you are using, it is only necessary to count the ASYNCs. TRACEINFO does not add a great deal. One additional caveat here - while most implementations provide the register that allows the programming of ASYNC frequency, it is possible for an implementation to set this register as RO and use a single fixed frequency - which might not be 4k bytes. Regards Mike *by bounded trace run - I mean one that has completed without the buffer wrapping - i.e. where perf does not report loss of trace. -- Mike Leach Principal Engineer, ARM Ltd. Manchester Design Centre. UK ^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 01/12] perf test: Shell - Limit to only run executable scripts in tests @ 2021-12-15 12:53 carsten.haitzler 2021-12-15 12:54 ` [PATCH 04/12] perf test: Add beginning of test infra + test to exercise coresight carsten.haitzler 0 siblings, 1 reply; 19+ messages in thread From: carsten.haitzler @ 2021-12-15 12:53 UTC (permalink / raw) To: linux-kernel Cc: coresight, suzuki.poulose, mathieu.poirier, mike.leach, leo.yan From: Carsten Haitzler <carsten.haitzler@arm.com> Perf test's shell runner will just run everything in the tests directory (as long as it's not another directory or does not begin with a dot), but sometimes you find files in there that are not shell scripts - perf.data output for example if you do some testing and then the next time you run perf test it tries to run these. Check the files are executable so they are actually intended to be test scripts and not just some "random junk" files there. Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com> --- tools/perf/tests/builtin-test.c | 2 +- tools/perf/util/path.c | 12 ++++++++++++ tools/perf/util/path.h | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index c4b888f18e9c..1a7e21e5acf1 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -512,7 +512,7 @@ static const char *shell_test__description(char *description, size_t size, #define for_each_shell_test(dir, base, ent) \ while ((ent = readdir(dir)) != NULL) \ - if (!is_directory(base, ent) && ent->d_name[0] != '.') + if (!is_directory(base, ent) && is_executable_file(base, ent) && ent->d_name[0] != '.') static const char *shell_tests__dir(char *path, size_t size) { diff --git a/tools/perf/util/path.c b/tools/perf/util/path.c index caed0336429f..7dde8c230ae8 100644 --- a/tools/perf/util/path.c +++ b/tools/perf/util/path.c @@ -92,3 +92,15 @@ bool is_directory(const char *base_path, const struct dirent *dent) return S_ISDIR(st.st_mode); } + +bool is_executable_file(const char *base_path, const struct dirent *dent) +{ + char path[PATH_MAX]; + struct stat st; + + sprintf(path, "%s/%s", base_path, dent->d_name); + if (stat(path, &st)) + return false; + + return !S_ISDIR(st.st_mode) && (st.st_mode & S_IXUSR); +} diff --git a/tools/perf/util/path.h b/tools/perf/util/path.h index 083429b7efa3..d94902c22222 100644 --- a/tools/perf/util/path.h +++ b/tools/perf/util/path.h @@ -12,5 +12,6 @@ int path__join3(char *bf, size_t size, const char *path1, const char *path2, con bool is_regular_file(const char *file); bool is_directory(const char *base_path, const struct dirent *dent); +bool is_executable_file(const char *base_path, const struct dirent *dent); #endif /* _PERF_PATH_H */ -- 2.32.0 ^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 04/12] perf test: Add beginning of test infra + test to exercise coresight 2021-12-15 12:53 [PATCH 01/12] perf test: Shell - Limit to only run executable scripts in tests carsten.haitzler @ 2021-12-15 12:54 ` carsten.haitzler 0 siblings, 0 replies; 19+ messages in thread From: carsten.haitzler @ 2021-12-15 12:54 UTC (permalink / raw) To: linux-kernel Cc: coresight, suzuki.poulose, mathieu.poirier, mike.leach, leo.yan From: Carsten Haitzler <carsten.haitzler@arm.com> This adds the initial test harness to run perf record and examine the resuling output when coresight is enabled on arm64 and check the resulting quality of the output as part of perf test. Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com> --- MAINTAINERS | 3 + tools/perf/Makefile.perf | 14 +- .../tests/shell/coresight_asm_pure_loop.sh | 18 +++ tools/perf/tests/shell/lib/coresight.sh | 130 ++++++++++++++++++ tools/perf/tests/shell/tools/Makefile | 26 ++++ .../perf/tests/shell/tools/coresight/Makefile | 27 ++++ .../shell/tools/coresight/Makefile.miniconfig | 23 ++++ .../tools/coresight/asm_pure_loop/Makefile | 30 ++++ .../coresight/asm_pure_loop/asm_pure_loop.S | 28 ++++ 9 files changed, 297 insertions(+), 2 deletions(-) create mode 100755 tools/perf/tests/shell/coresight_asm_pure_loop.sh create mode 100644 tools/perf/tests/shell/lib/coresight.sh create mode 100644 tools/perf/tests/shell/tools/Makefile create mode 100644 tools/perf/tests/shell/tools/coresight/Makefile create mode 100644 tools/perf/tests/shell/tools/coresight/Makefile.miniconfig create mode 100644 tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile create mode 100644 tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S diff --git a/MAINTAINERS b/MAINTAINERS index 0510e4d03058..c2d7db515c70 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1793,6 +1793,9 @@ 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 F: tools/perf/arch/arm/util/pmu.c +F: tools/perf/tests/shell/coresight_* +F: tools/perf/tests/shell/tools/Makefile +F: tools/perf/tests/shell/tools/coresight/* F: tools/perf/util/cs-etm-decoder/* F: tools/perf/util/cs-etm.* diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index e47f04e5b51e..94b48393b438 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -620,7 +620,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_TOOLS_DIR := $(srctree)/tools/perf/tests/shell/tools + +tests-tools-targets: FORCE + $(Q)$(MAKE) -C $(TESTS_TOOLS_DIR) + +tests-tools-targets-clean: + $(Q)$(MAKE) -C $(TESTS_TOOLS_DIR) clean + +all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS) tests-tools-targets # Create python binding output directory if not already present _dummy := $(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python') @@ -994,6 +1002,7 @@ install-tests: all install-gtk $(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' + $(Q)$(MAKE) -C tests/shell/tools install-tests install-bin: install-tools install-tests install-traceevent-plugins @@ -1048,7 +1057,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-tools-targets-clean $(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(OUTPUT)perf-iostat $(LANG_BINDINGS) $(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete $(Q)$(RM) $(OUTPUT).config-detected @@ -1115,5 +1124,6 @@ FORCE: .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell .PHONY: $(GIT-HEAD-PHONY) TAGS tags cscope FORCE prepare .PHONY: libtraceevent_plugins archheaders +.PHONY: $(TESTS_TOOLS_TARGETS) endif # force_fixdep diff --git a/tools/perf/tests/shell/coresight_asm_pure_loop.sh b/tools/perf/tests/shell/coresight_asm_pure_loop.sh new file mode 100755 index 000000000000..542d4a37e349 --- /dev/null +++ b/tools/perf/tests/shell/coresight_asm_pure_loop.sh @@ -0,0 +1,18 @@ +#!/bin/sh -e +# Coresight / ASM Pure Loop + +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 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" 2601 334 334 + +err=$? +exit $err diff --git a/tools/perf/tests/shell/lib/coresight.sh b/tools/perf/tests/shell/lib/coresight.sh new file mode 100644 index 000000000000..cd6c1283e6f5 --- /dev/null +++ b/tools/perf/tests/shell/lib/coresight.sh @@ -0,0 +1,130 @@ +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 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. + +# perf record options for the perf tests to use +PERFRECMEM="-m ,128M" +PERFRECOPT="$PERFRECMEM -e cs_etm//u" + +# These tests need to be run as root or coresight won't allow large buffers +# and will not collect proper data +UID=`id -u` +if test "$UID" -ne 0; then + echo "Not running as root... skip" + exit 2 +fi + +TOOLS=$(dirname $0)/tools +DIR="$TOOLS/coresight/$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 2 +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 F3 atoms in just about + # anything but certainly we will see some trace info and async atom + # chunks. + DUMP="$DATD/perf-tmp-aux-dump.txt" + perf report --stdio --dump -i "$1" | \ + grep -o -e I_ATOM_F3 -e I_ASYNC -e I_TRACE_INFO > "$DUMP" + # Simply count how many of these atoms 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_F3_NUM=`grep I_ATOM_F3 "$DUMP" | wc -l` + ATOM_ASYNC_NUM=`grep I_ASYNC "$DUMP" | wc -l` + ATOM_TRACE_INFO_NUM=`grep I_TRACE_INFO "$DUMP" | wc -l` + rm -f "$DUMP" + + # Arguments provide minimums for a pass + CHECK_F3_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 F3 Count, Minimum, ATOM ASYNC Count, Minimum, TRACE INFO Count, Minimum" > "$STATF" + fi + echo -n "$ATOM_F3_NUM, $CHECK_F3_MIN, $ATOM_ASYNC_NUM, $CHECK_ASYNC_MIN, $ATOM_TRACE_INFO_NUM, $CHECK_TRACE_INFO_MIN" >> "$STATF" + + # Actually check to see if we passed or failed. + check_val_min "ATOM_F3" "$ATOM_F3_NUM" "$CHECK_F3_MIN" "$STATF" + check_val_min "ASYNC" "$ATOM_ASYNC_NUM" "$CHECK_ASYNC_MIN" "$STATF" + check_val_min "TRACE_INFO" "$ATOM_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` + + # 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 +} diff --git a/tools/perf/tests/shell/tools/Makefile b/tools/perf/tests/shell/tools/Makefile new file mode 100644 index 000000000000..c7ada20922fd --- /dev/null +++ b/tools/perf/tests/shell/tools/Makefile @@ -0,0 +1,26 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 +include ../../../../../tools/scripts/Makefile.include +include ../../../../../tools/scripts/Makefile.arch +include ../../../../../tools/scripts/utilities.mak + +SUBDIRS = \ + coresight + +all: $(SUBDIRS) +$(SUBDIRS): + $(Q)$(MAKE) -C $@ + +INSTALLDIRS = $(SUBDIRS:%=install-%) + +install-tests: all $(INSTALLDIRS) +$(INSTALLDIRS): + $(Q)$(MAKE) -C $(@:install-%=%) install-tests + +CLEANDIRS = $(SUBDIRS:%=clean-%) + +clean: $(CLEANDIRS) +$(CLEANDIRS): + $(Q)$(MAKE) -C $(@:clean-%=%) O=$(OUTPUT) clean >/dev/null + +.PHONY: all clean install-tests $(SUBDIRS) $(CLEANDIRS) $(INSTALLDIRS) diff --git a/tools/perf/tests/shell/tools/coresight/Makefile b/tools/perf/tests/shell/tools/coresight/Makefile new file mode 100644 index 000000000000..723006ea827c --- /dev/null +++ b/tools/perf/tests/shell/tools/coresight/Makefile @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 +include ../../../../../../tools/scripts/Makefile.include +include ../../../../../../tools/scripts/Makefile.arch +include ../../../../../../tools/scripts/utilities.mak + +SUBDIRS = \ + asm_pure_loop + +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) + diff --git a/tools/perf/tests/shell/tools/coresight/Makefile.miniconfig b/tools/perf/tests/shell/tools/coresight/Makefile.miniconfig new file mode 100644 index 000000000000..cedd26c6a0eb --- /dev/null +++ b/tools/perf/tests/shell/tools/coresight/Makefile.miniconfig @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Carsten Haitzler <carsten.haitzler@arm.com>, 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 + +include ../../../../../../scripts/Makefile.include +include ../../../../../../scripts/Makefile.arch +include ../../../../../../scripts/utilities.mak diff --git a/tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile new file mode 100644 index 000000000000..10c5a60cb71c --- /dev/null +++ b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: GPL-2.0 +# Carsten Haitzler <carsten.haitzler@arm.com>, 2021 + +include ../Makefile.miniconfig + +BIN=asm_pure_loop +LIB= + +all: $(BIN) + +$(BIN): $(BIN).S +ifdef CORESIGHT +ifeq ($(ARCH),arm64) + $(Q)$(CC) $(BIN).S -nostdlib -static -o $(BIN) $(LIB) +endif +endif + +install-tests: all +ifdef CORESIGHT +ifeq ($(ARCH),arm64) + $(call QUIET_INSTALL, tests) \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)'; \ + $(INSTALL) $(BIN) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/tools/$(BIN)/$(BIN)' +endif +endif + +clean: + $(Q)$(RM) -f $(BIN) + +.PHONY: all clean install-tests diff --git a/tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S new file mode 100644 index 000000000000..262876451021 --- /dev/null +++ b/tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Tamas Zsoldos <tamas.zsoldos@arm.com>, 2021 */ + +.globl _start +_start: + mov x0, 0x000fffff + 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 -- 2.32.0 ^ permalink raw reply related [flat|nested] 19+ messages in thread
end of thread, other threads:[~2022-02-04 10:21 UTC | newest] Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-12-15 16:22 [PATCH 01/12] perf test: Shell - Limit to only run executable scripts in tests carsten.haitzler 2021-12-15 16:22 ` [PATCH 02/12] perf test: Shell - only run .sh shell files to skip other files carsten.haitzler 2021-12-15 16:22 ` [PATCH 03/12] perf test: Use 3 digits for test numbering now we can have more tests carsten.haitzler 2021-12-15 16:22 ` [PATCH 04/12] perf test: Add beginning of test infra + test to exercise coresight carsten.haitzler 2021-12-15 16:22 ` [PATCH 05/12] perf test: Add coresight test to check all threads get some data logged carsten.haitzler 2021-12-15 16:22 ` [PATCH 06/12] perf test: Add tests to re-use the thread loop test to check aux data carsten.haitzler 2021-12-15 16:22 ` [PATCH 07/12] perf test: Add simple bubblesort test for coresight " carsten.haitzler 2021-12-15 16:22 ` [PATCH 09/12] perf test: Add add memcpy test for coresight quality checking carsten.haitzler 2021-12-15 16:22 ` [PATCH 10/12] perf test: Add threaded memcpy tests to check coresight aux data carsten.haitzler 2021-12-15 16:22 ` [PATCH 11/12] perf test: Add unrolled loop tests for " carsten.haitzler 2021-12-15 16:22 ` [PATCH 12/12] perf test: Add docs for coresight and related tests carsten.haitzler -- strict thread matches above, loose matches on Subject: below -- 2021-12-15 16:03 [PATCH 01/12] perf test: Shell - Limit to only run executable scripts in tests carsten.haitzler 2021-12-15 16:03 ` [PATCH 04/12] perf test: Add beginning of test infra + test to exercise coresight carsten.haitzler 2021-12-21 15:03 ` Leo Yan 2021-12-21 20:40 ` Arnaldo Carvalho de Melo 2022-01-04 15:15 ` Carsten Haitzler 2022-01-04 15:14 ` Carsten Haitzler 2022-01-19 16:58 ` James Clark 2022-02-04 10:21 ` Mike Leach 2021-12-15 12:53 [PATCH 01/12] perf test: Shell - Limit to only run executable scripts in tests carsten.haitzler 2021-12-15 12:54 ` [PATCH 04/12] perf test: Add beginning of test infra + test to exercise coresight carsten.haitzler
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.