Skip to contentSkip to conversation

perf test: Shell - Limit to only run executable scripts in tests

PATCH In review [email protected] 2 participants 14 messages Dec 15, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/12 perf test: Shell - Limit to only run executable scripts in tests

From: Carsten Haitzler <[email protected]>

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.

---
 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(-)
tools/perf/tests/builtin-test.c +1 -1
index c4b888f18e9c..1a7e21e5acf1 100644
@@ -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)
 {
tools/perf/util/path.c +12 -0
index caed0336429f..7dde8c230ae8 100644
@@ -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);
+}
tools/perf/util/path.h +1 -0
index 083429b7efa3..d94902c22222 100644
@@ -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 */
Signature · 1 line
2.32.0
#1 lore raw

PATCH 2/12 perf test: Shell - only run .sh shell files to skip other files

From: Carsten Haitzler <[email protected]>

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.

---
 tools/perf/tests/builtin-test.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
tools/perf/tests/builtin-test.c +16 -1
index 1a7e21e5acf1..2f6a74d9f0bc 100644
@@ -512,7 +512,22 @@ 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) && is_executable_file(base, ent) && ent->d_name[0] != '.')
+		if (!is_directory(base, ent) && \
+		    is_executable_file(base, ent) && \
+		    (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)
 {
Signature · 1 line
2.32.0
#2 lore raw

PATCH 3/12 perf test: Use 3 digits for test numbering now we can have more tests

In reply to [email protected]

From: Carsten Haitzler <[email protected]>

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.

---
 tools/perf/tests/builtin-test.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
tools/perf/tests/builtin-test.c +7 -7
index 2f6a74d9f0bc..9091f7c74f8e 100644
@@ -634,7 +634,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.desc);
+		pr_info("%3d: %-*s:", i, width, test.desc);
 		test_and_print(&test, false, -1);
 	}
 
@@ -679,11 +679,11 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
 		}
 
 		if (t->is_supported && !t->is_supported()) {
-			pr_debug("%2d: %-*s: Disabled\n", i, width, t->desc);
+			pr_debug("%3d: %-*s: Disabled\n", i, width, t->desc);
 			continue;
 		}
 
-		pr_info("%2d: %-*s:", i, width, t->desc);
+		pr_info("%3d: %-*s:", i, width, t->desc);
 
 		if (intlist__find(skiplist, i)) {
 			color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (user override)\n");
@@ -723,7 +723,7 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
 				if (!perf_test__matches(t->subtest.get_desc(subi), curr, argc, argv))
 					continue;
 
-				pr_info("%2d.%1d: %-*s:", i, subi + 1, subw,
+				pr_info("%3d.%1d: %-*s:", i, subi + 1, subw,
 					t->subtest.get_desc(subi));
 				err = test_and_print(t, skip, subi);
 				if (err != TEST_OK && t->subtest.skip_if_fail)
@@ -759,7 +759,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);
 	}
 
 	closedir(dir);
@@ -779,14 +779,14 @@ static int perf_test__list(int argc, const char **argv)
 		    (t->is_supported && !t->is_supported()))
 			continue;
 
-		pr_info("%2d: %s\n", i, t->desc);
+		pr_info("%3d: %s\n", i, t->desc);
 
 		if (t->subtest.get_nr) {
 			int subn = t->subtest.get_nr();
 			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,
 					t->subtest.get_desc(subi));
 		}
 	}
Signature · 1 line
2.32.0
#3 lore raw

PATCH 4/12 perf test: Add beginning of test infra + test to exercise coresight

In reply to [email protected]

From: Carsten Haitzler <[email protected]>

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.

---
 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
MAINTAINERS +3 -0
index 0510e4d03058..c2d7db515c70 100644
@@ -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.*
 
tools/perf/Makefile.perf +12 -2
index e47f04e5b51e..94b48393b438 100644
@@ -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
tools/perf/tests/shell/coresight_asm_pure_loop.sh new file +18 -0
new file mode 100755
index 000000000000..542d4a37e349
@@ -0,0 +1,18 @@
+#!/bin/sh -e
+# Coresight / ASM Pure Loop
+
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 2021
+
+TEST="asm_pure_loop"
+. $(dirname $0)/lib/coresight.sh
+ARGS=""
+DATV="out"
+DATA="$DATD/perf-$TEST-$DATV.data"
+
+perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS
+
+perf_dump_aux_verify "$DATA" 2601 334 334
+
+err=$?
+exit $err
tools/perf/tests/shell/lib/coresight.sh new file +130 -0

130 lines not on this page · raw message

tools/perf/tests/shell/tools/Makefile new file +26 -0
new file mode 100644
index 000000000000..c7ada20922fd
@@ -0,0 +1,26 @@
+# SPDX-License-Identifier: GPL-2.0-only
+# Carsten Haitzler <[email protected]>, 2021
+include ../../../../../tools/scripts/Makefile.include
+include ../../../../../tools/scripts/Makefile.arch
+include ../../../../../tools/scripts/utilities.mak
+
+SUBDIRS = \
+	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)
tools/perf/tests/shell/tools/coresight/Makefile new file +27 -0
new file mode 100644
index 000000000000..723006ea827c
@@ -0,0 +1,27 @@
+# SPDX-License-Identifier: GPL-2.0-only
+# Carsten Haitzler <[email protected]>, 2021
+include ../../../../../../tools/scripts/Makefile.include
+include ../../../../../../tools/scripts/Makefile.arch
+include ../../../../../../tools/scripts/utilities.mak
+
+SUBDIRS = \
+	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)
+
tools/perf/tests/shell/tools/coresight/Makefile.miniconfig new file +23 -0
new file mode 100644
index 000000000000..cedd26c6a0eb
@@ -0,0 +1,23 @@
+# SPDX-License-Identifier: GPL-2.0-only
+# Carsten Haitzler <[email protected]>, 2021
+
+ifndef DESTDIR
+prefix ?= $(HOME)
+endif
+
+DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
+perfexecdir = libexec/perf-core
+perfexec_instdir = $(perfexecdir)
+
+ifneq ($(filter /%,$(firstword $(perfexecdir))),)
+perfexec_instdir = $(perfexecdir)
+else
+perfexec_instdir = $(prefix)/$(perfexecdir)
+endif
+
+perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir))
+INSTALL = install
+
+include ../../../../../../scripts/Makefile.include
+include ../../../../../../scripts/Makefile.arch
+include ../../../../../../scripts/utilities.mak
tools/perf/tests/shell/tools/coresight/asm_pure_loop/Makefile new file +30 -0
new file mode 100644
index 000000000000..10c5a60cb71c
@@ -0,0 +1,30 @@
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 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
tools/perf/tests/shell/tools/coresight/asm_pure_loop/asm_pure_loop.S new file +28 -0
new file mode 100644
index 000000000000..262876451021
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Tamas Zsoldos <[email protected]>, 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
Signature · 1 line
2.32.0
#4 lore raw

PATCH 5/12 perf test: Add coresight test to check all threads get some data logged

In reply to [email protected]

From: Carsten Haitzler <[email protected]>

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.

---
 .../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
tools/perf/tests/shell/coresight_thread_loop_check_tid_10.sh new file +19 -0
new file mode 100755
index 000000000000..283ad9facdee
@@ -0,0 +1,19 @@
+#!/bin/sh -e
+# Coresight / Thread Loop 10 Threads - Check TID
+
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 2021
+
+TEST="thread_loop"
+. $(dirname $0)/lib/coresight.sh
+ARGS="10 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
tools/perf/tests/shell/coresight_thread_loop_check_tid_2.sh new file +19 -0
new file mode 100755
index 000000000000..ce8ba534bba2
@@ -0,0 +1,19 @@
+#!/bin/sh -e
+# Coresight / Thread Loop 2 Threads - Check TID
+
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 2021
+
+TEST="thread_loop"
+. $(dirname $0)/lib/coresight.sh
+ARGS="2 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
tools/perf/tests/shell/coresight_thread_loop_check_tid_250.sh new file +19 -0
new file mode 100755
index 000000000000..cb14581c1e68
@@ -0,0 +1,19 @@
+#!/bin/sh -e
+# Coresight / Thread Loop 250 Threads - Check TID
+
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 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
tools/perf/tests/shell/tools/coresight/Makefile +2 -1
index 723006ea827c..1edab729db76 100644
@@ -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):
tools/perf/tests/shell/tools/coresight/thread_loop/Makefile new file +29 -0
new file mode 100644
index 000000000000..424df4e8b0e6
@@ -0,0 +1,29 @@
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 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
tools/perf/tests/shell/tools/coresight/thread_loop/thread_loop.c new file +86 -0

86 lines not on this page · raw message

Signature · 1 line
2.32.0
#5 lore raw

PATCH 6/12 perf test: Add tests to re-use the thread loop test to check aux data

In reply to [email protected]

From: Carsten Haitzler <[email protected]>

This checks to see that the thread_loop tests produces sensible amounts of aux coresight data.

---
 .../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
tools/perf/tests/shell/coresight_thread_loop_2.sh new file +18 -0
new file mode 100755
index 000000000000..6d790b870a67
@@ -0,0 +1,18 @@
+#!/bin/sh -e
+# Coresight / Thread Loop 2 Threads
+
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 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
tools/perf/tests/shell/coresight_thread_loop_25.sh new file +18 -0
new file mode 100755
index 000000000000..cce74202e4db
@@ -0,0 +1,18 @@
+#!/bin/sh -e
+# Coresight / Thread Loop 25 Threads
+
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 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
tools/perf/tests/shell/coresight_thread_loop_250.sh new file +18 -0
new file mode 100755
index 000000000000..55f271462a4d
@@ -0,0 +1,18 @@
+#!/bin/sh -e
+# Coresight / Thread Loop 250 Threads
+
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 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
Signature · 1 line
2.32.0
#6 lore raw

PATCH 7/12 perf test: Add simple bubblesort test for coresight aux data

In reply to [email protected]

From: Carsten Haitzler <[email protected]>

This adds a simple bubblesort test that sorts small and large data sets to see if a sufficient mount of aux data is produced.

---
 .../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
tools/perf/tests/shell/coresight_bubble_sort_random.sh new file +20 -0
new file mode 100755
index 000000000000..63567f8c4f8b
@@ -0,0 +1,20 @@
+#!/bin/sh -e
+# Coresight / Bubblesort Random Array
+
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 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
tools/perf/tests/shell/coresight_bubble_sort_small.sh new file +20 -0
new file mode 100755
index 000000000000..ac86d9973fba
@@ -0,0 +1,20 @@
+#!/bin/sh -e
+# Coresight / Bubblesort Small Array
+
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 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
tools/perf/tests/shell/tools/coresight/Makefile +2 -1
index 1edab729db76..49fa80d28df4 100644
@@ -6,7 +6,8 @@ include ../../../../../../tools/scripts/utilities.mak
 
 SUBDIRS = \
 	asm_pure_loop \
-	thread_loop
+	thread_loop \
+	bubble_sort
 
 all: $(SUBDIRS)
 $(SUBDIRS):
tools/perf/tests/shell/tools/coresight/bubble_sort/Makefile new file +31 -0
new file mode 100644
index 000000000000..6b82854f9f2b
@@ -0,0 +1,31 @@
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 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
tools/perf/tests/shell/tools/coresight/bubble_sort/bubble_sort.c new file +89 -0

89 lines not on this page · raw message

tools/perf/tests/shell/tools/coresight/bubble_sort/random_array.txt new file +1855 -0

1,855 lines not on this page · raw message

tools/perf/tests/shell/tools/coresight/bubble_sort/small_array.txt new file +10 -0
new file mode 100644
index 000000000000..d351c8437d0a
@@ -0,0 +1,10 @@
+11637
+3799
+23116
+15091
+13022
+15840
+27029
+27563
+25641
+28703
Signature · 1 line
2.32.0
#7 lore raw

PATCH 8/12 perf test: Add threaded bubblesort tests for coresight

In reply to [email protected]

From: Carsten Haitzler <[email protected]>

This adds threaded versions of the bubblesort test to check perf produces sane/sufficient coresight aux data.

---
 .../coresight_bubble_sort_thread_random.sh    |    20 +
 .../coresight_bubble_sort_thread_small.sh     |    20 +
 .../perf/tests/shell/tools/coresight/Makefile |     3 +-
 .../coresight/bubble_sort_thread/Makefile     |    31 +
 .../bubble_sort_thread/bubble_sort_thread.c   |   136 +
 .../bubble_sort_thread/random_array.txt       | 30000 ++++++++++++++++
 .../bubble_sort_thread/small_array.txt        |    10 +
 7 files changed, 30219 insertions(+), 1 deletion(-)
 create mode 100755 tools/perf/tests/shell/coresight_bubble_sort_thread_random.sh
 create mode 100755 tools/perf/tests/shell/coresight_bubble_sort_thread_small.sh
 create mode 100644 tools/perf/tests/shell/tools/coresight/bubble_sort_thread/Makefile
 create mode 100644 tools/perf/tests/shell/tools/coresight/bubble_sort_thread/bubble_sort_thread.c
 create mode 100644 tools/perf/tests/shell/tools/coresight/bubble_sort_thread/random_array.txt
 create mode 100644 tools/perf/tests/shell/tools/coresight/bubble_sort_thread/small_array.txt
tools/perf/tests/shell/coresight_bubble_sort_thread_random.sh new file +20 -0
new file mode 100755
index 000000000000..09f2e62aece1
@@ -0,0 +1,20 @@
+#!/bin/sh -e
+# Coresight / Bubblesort Thread Random Array
+
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 2021
+
+TEST="bubble_sort_thread"
+. $(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" 2 7392 7392
+
+err=$?
+exit $err
tools/perf/tests/shell/coresight_bubble_sort_thread_small.sh new file +20 -0
new file mode 100755
index 000000000000..6d4f0413be94
@@ -0,0 +1,20 @@
+#!/bin/sh -e
+# Coresight / Bubblesort Thread Small Array
+
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 2021
+
+TEST="bubble_sort_thread"
+. $(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" 90 7 7
+
+err=$?
+exit $err
tools/perf/tests/shell/tools/coresight/Makefile +2 -1
index 49fa80d28df4..a1a752f45c46 100644
@@ -7,7 +7,8 @@ include ../../../../../../tools/scripts/utilities.mak
 SUBDIRS = \
 	asm_pure_loop \
 	thread_loop \
-	bubble_sort
+	bubble_sort \
+	bubble_sort_thread
 
 all: $(SUBDIRS)
 $(SUBDIRS):
tools/perf/tests/shell/tools/coresight/bubble_sort_thread/Makefile new file +31 -0
new file mode 100644
index 000000000000..a7468e201ca2
@@ -0,0 +1,31 @@
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 2021
+include ../Makefile.miniconfig
+
+BIN=bubble_sort_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)'; \
+		$(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
tools/perf/tests/shell/tools/coresight/bubble_sort_thread/bubble_sort_thread.c new file +136 -0

136 lines not on this page · raw message

tools/perf/tests/shell/tools/coresight/bubble_sort_thread/random_array.txt new file +30000 -0

2,784 lines not on this page · raw message

tools/perf/tests/shell/tools/coresight/bubble_sort_thread/small_array.txt new file +10 -0
new file mode 100644
index 000000000000..d351c8437d0a

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.32.0

Part of the diff is not shown here. View the raw message.

#8 lore raw

PATCH 9/12 perf test: Add add memcpy test for coresight quality checking

In reply to [email protected]

From: Carsten Haitzler <[email protected]>

This adds memory bound tests for quality checking perf's aux data recording.

---
 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
tools/perf/tests/shell/coresight_memcpy_1m.sh new file +18 -0
new file mode 100755
index 000000000000..fa1c28d73b66
@@ -0,0 +1,18 @@
+#!/bin/sh -e
+# Coresight / Memcpy 1M
+
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 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
tools/perf/tests/shell/coresight_memcpy_32m.sh new file +18 -0
new file mode 100755
index 000000000000..4ab5459e3824
@@ -0,0 +1,18 @@
+#!/bin/sh -e
+# Coresight / Memcpy 32M
+
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 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
tools/perf/tests/shell/coresight_memcpy_64k.sh new file +18 -0
new file mode 100755
index 000000000000..5b6ba2a6d394
@@ -0,0 +1,18 @@
+#!/bin/sh -e
+# Coresight / Memcpy 64K
+
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 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
tools/perf/tests/shell/tools/coresight/Makefile +2 -1
index a1a752f45c46..99030c889b04 100644
@@ -8,7 +8,8 @@ SUBDIRS = \
 	asm_pure_loop \
 	thread_loop \
 	bubble_sort \
-	bubble_sort_thread
+	bubble_sort_thread \
+        memcpy
 
 all: $(SUBDIRS)
 $(SUBDIRS):
tools/perf/tests/shell/tools/coresight/memcpy/Makefile new file +29 -0
new file mode 100644
index 000000000000..7c31fe4ec399
@@ -0,0 +1,29 @@
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 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
tools/perf/tests/shell/tools/coresight/memcpy/memcpy.c new file +40 -0
new file mode 100644
index 000000000000..1aa0617448ad
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-2.0
+// Carsten Haitzler <[email protected]>, 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;
+}
Signature · 1 line
2.32.0
#9 lore raw

PATCH 10/12 perf test: Add threaded memcpy tests to check coresight aux data

In reply to [email protected]

From: Carsten Haitzler <[email protected]>

This adds threaded memcpy test looking at coresight aux data quality.

---
 .../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
tools/perf/tests/shell/coresight_memcpy_thread_1m_2.sh new file +18 -0
new file mode 100755
index 000000000000..32d5ee94343a
@@ -0,0 +1,18 @@
+#!/bin/sh -e
+# Coresight / Memcpy 1M 2 Threads
+
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 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
tools/perf/tests/shell/coresight_memcpy_thread_1m_25.sh new file +18 -0
new file mode 100755
index 000000000000..6510f8c7df99
@@ -0,0 +1,18 @@
+#!/bin/sh -e
+# Coresight / Memcpy 1M 25 Threads
+
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 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
tools/perf/tests/shell/coresight_memcpy_thread_32m_10.sh new file +18 -0
new file mode 100755
index 000000000000..3715ed4b612e
@@ -0,0 +1,18 @@
+#!/bin/sh -e
+# Coresight / Memcpy 32M 10 Threads
+
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 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
tools/perf/tests/shell/coresight_memcpy_thread_32m_2.sh new file +18 -0
new file mode 100755
index 000000000000..ad57bf4d9c0c
@@ -0,0 +1,18 @@
+#!/bin/sh -e
+# Coresight / Memcpy 32M 2 Threads
+
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 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
tools/perf/tests/shell/coresight_memcpy_thread_64k_2.sh new file +18 -0
new file mode 100755
index 000000000000..282cc8922641
@@ -0,0 +1,18 @@
+#!/bin/sh -e
+# Coresight / Memcpy 64k 2 Threads
+
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 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
tools/perf/tests/shell/coresight_memcpy_thread_64k_25.sh new file +18 -0
new file mode 100755
index 000000000000..05bc6c23f4a1
@@ -0,0 +1,18 @@
+#!/bin/sh -e
+# Coresight / Memcpy 64k 25 Threads
+
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 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
tools/perf/tests/shell/coresight_memcpy_thread_64k_250.sh new file +18 -0
new file mode 100755
index 000000000000..aaf35e32f610
@@ -0,0 +1,18 @@
+#!/bin/sh -e
+# Coresight / Memcpy 64k 250 Threads
+
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 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
tools/perf/tests/shell/tools/coresight/Makefile +2 -1
index 99030c889b04..be671aac06b8 100644
@@ -9,7 +9,8 @@ SUBDIRS = \
 	thread_loop \
 	bubble_sort \
 	bubble_sort_thread \
-        memcpy
+        memcpy \
+        memcpy_thread
 
 all: $(SUBDIRS)
 $(SUBDIRS):
tools/perf/tests/shell/tools/coresight/memcpy_thread/Makefile new file +29 -0
new file mode 100644
index 000000000000..e2604cfae74b
@@ -0,0 +1,29 @@
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 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
tools/perf/tests/shell/tools/coresight/memcpy_thread/memcpy_thread.c new file +79 -0

79 lines not on this page · raw message

Signature · 1 line
2.32.0
#10 lore raw

PATCH 11/12 perf test: Add unrolled loop tests for coresight aux data

In reply to [email protected]

From: Carsten Haitzler <[email protected]>

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.

---
 .../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
tools/perf/tests/shell/coresight_unroll_loop_thread_1.sh new file +18 -0
new file mode 100755
index 000000000000..9175ec532bd8
@@ -0,0 +1,18 @@
+#!/bin/sh -e
+# Coresight / Unroll Loop Thread 1
+
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 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
tools/perf/tests/shell/coresight_unroll_loop_thread_10.sh new file +18 -0
new file mode 100755
index 000000000000..66cf0245294e
@@ -0,0 +1,18 @@
+#!/bin/sh -e
+# Coresight / Unroll Loop Thread 10
+
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 2021
+
+TEST="unroll_loop_thread"
+. $(dirname $0)/lib/coresight.sh
+ARGS="10"
+DATV="10"
+DATA="$DATD/perf-$TEST-$DATV.data"
+
+perf record $PERFRECOPT -o "$DATA" "$BIN" $ARGS
+
+perf_dump_aux_verify "$DATA" 127 17 17
+
+err=$?
+exit $err
tools/perf/tests/shell/coresight_unroll_loop_thread_2.sh new file +18 -0
new file mode 100755
index 000000000000..ff2e293699b0
@@ -0,0 +1,18 @@
+#!/bin/sh -e
+# Coresight / Unroll Loop Thread 2
+
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 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
tools/perf/tests/shell/coresight_unroll_loop_thread_25.sh new file +18 -0
new file mode 100755
index 000000000000..7d7669a797ab
@@ -0,0 +1,18 @@
+#!/bin/sh -e
+# Coresight / Unroll Loop Thread 25
+
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 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
tools/perf/tests/shell/coresight_unroll_loop_thread_250.sh new file +18 -0
new file mode 100755
index 000000000000..7a0e23aff0dc
@@ -0,0 +1,18 @@
+#!/bin/sh -e
+# Coresight / Unroll Loop Thread 250
+
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 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
tools/perf/tests/shell/tools/coresight/Makefile +2 -1
index be671aac06b8..b9cdeff1149b 100644
@@ -10,7 +10,8 @@ SUBDIRS = \
 	bubble_sort \
 	bubble_sort_thread \
         memcpy \
-        memcpy_thread
+        memcpy_thread \
+        unroll_loop_thread
 
 all: $(SUBDIRS)
 $(SUBDIRS):
tools/perf/tests/shell/tools/coresight/unroll_loop_thread/Makefile new file +29 -0
new file mode 100644
index 000000000000..45ab2be8be92
@@ -0,0 +1,29 @@
+# SPDX-License-Identifier: GPL-2.0
+# Carsten Haitzler <[email protected]>, 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
tools/perf/tests/shell/tools/coresight/unroll_loop_thread/unroll_loop_thread.c new file +74 -0

74 lines not on this page · raw message

Signature · 1 line
2.32.0
#11 lore raw

PATCH 12/12 perf test: Add docs for coresight and related tests

In reply to [email protected]

From: Carsten Haitzler <[email protected]>

This adds documentation about the coresight specific tests as part of perf test

---
 MAINTAINERS                                |   1 +
 tools/perf/Documentation/arm-coresight.txt | 140 +++++++++++++++++++++
 2 files changed, 141 insertions(+)
 create mode 100644 tools/perf/Documentation/arm-coresight.txt
MAINTAINERS +1 -0
index c2d7db515c70..a6e31d32f1ae 100644
@@ -1789,6 +1789,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
tools/perf/Documentation/arm-coresight.txt new file +140 -0

140 lines not on this page · raw message

Signature · 1 line
2.32.0
#12 lore raw
In reply to [email protected]
Quoted 10 lines · On 15/12/2021 12:53, [email protected] wrote:

From: Carsten Haitzler <[email protected]>

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.

Hi Carsten,

Because these apply to tools/perf files rather than the coresight drivers they will need to apply to Arnaldo's perf/core branch. At the moment I'm getting merge conflicts so I can't test and review them.

I also think you would have to do to: [email protected] and [email protected]

James

Quoted 52 lines
---
 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(-)
tools/perf/tests/builtin-test.c +1 -1
index c4b888f18e9c..1a7e21e5acf1 100644
@@ -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)
 {
tools/perf/util/path.c +12 -0
index caed0336429f..7dde8c230ae8 100644
@@ -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);
+}
tools/perf/util/path.h +1 -0
index 083429b7efa3..d94902c22222 100644
@@ -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 */
#13 lore raw
Quoted 14 lines · James Clark
Quoted 10 lines · On 15/12/2021 12:53, [email protected] wrote:

From: Carsten Haitzler <[email protected]>

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.

Quoted 7 lines

Hi Carsten,

Because these apply to tools/perf files rather than the coresight drivers they will need to apply to Arnaldo's perf/core branch. At the moment I'm getting merge conflicts so I can't test and review them.

I also think you would have to do to: [email protected] and [email protected]

I will send updated versions of the series and include the above - though perf-users does describe itself for users and not development, thus I skipped it. I should get the full list then of everyone

Quoted 54 lines

James

Quoted 52 lines
---
  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(-)
tools/perf/tests/builtin-test.c +1 -1
index c4b888f18e9c..1a7e21e5acf1 100644
@@ -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)
  {
tools/perf/util/path.c +12 -0
index caed0336429f..7dde8c230ae8 100644
@@ -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);
+}
tools/perf/util/path.h +1 -0
index 083429b7efa3..d94902c22222 100644
@@ -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 */