Skip to contentSkip to conversation

perf: Make tsc testing as a common testing case

PATCH Applied Leo Yan 3 participants 5 messages Oct 19, 2020 – Oct 20, 2020 perf events

lore
Share & tools
lore

Leo Yan

author
#0 lore raw

v6 cover perf: Make tsc testing as a common testing case

This patch set is to move tsc testing from x86 specific to common testing case. Since Arnaldo found the building failure for patch set v4 [1], the first four patches have been merged but the last two patches were left out; this patch set is to resend the last two patches with fixed the building failure (by removing the header "arch-tests.h" from the testing code).

These two patches have been tested on x86_64 and Arm64. Though I don't test them on archs MIPS, PowerPC, etc, I tried to search every header so ensure included headers are supported for all archs.

These two patches have been rebased on the perf/core branch with its latest commit 744aec4df2c5 ("perf c2c: Update documentation for metrics reorganization").

Changes from v5:
* Found the merging confliction on latest perf/core, so rebased it.

[1] https://lore.kernel.org/patchwork/cover/1305382/#1505752

Leo Yan (2):
perf tests tsc: Make tsc testing as a common testing perf tests tsc: Add checking helper is_supported()

 tools/perf/arch/x86/include/arch-tests.h      |  1 -
 tools/perf/arch/x86/tests/Build               |  1 -
 tools/perf/arch/x86/tests/arch-tests.c        |  4 ----
 tools/perf/tests/Build                        |  1 +
 tools/perf/tests/builtin-test.c               |  5 +++++
 .../{arch/x86 => }/tests/perf-time-to-tsc.c   | 19 +++++++++++++++----
 tools/perf/tests/tests.h                      |  2 ++
 7 files changed, 23 insertions(+), 10 deletions(-)
 rename tools/perf/{arch/x86 => }/tests/perf-time-to-tsc.c (92%)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v6 1/2 perf tests tsc: Make tsc testing as a common testing

x86 arch provides the testing for conversion between tsc and perf time, the testing is located in x86 arch folder. Move this testing out from x86 arch folder and place it into the common testing folder, so allows to execute tsc testing on other architectures (e.g. Arm64).

This patch removes the inclusion of "arch-tests.h" from the testing code, this can avoid building failure if any arch has no this header file.

---
 tools/perf/arch/x86/include/arch-tests.h           | 1 -
 tools/perf/arch/x86/tests/Build                    | 1 -
 tools/perf/arch/x86/tests/arch-tests.c             | 4 ----
 tools/perf/tests/Build                             | 1 +
 tools/perf/tests/builtin-test.c                    | 4 ++++
 tools/perf/{arch/x86 => }/tests/perf-time-to-tsc.c | 6 ++----
 tools/perf/tests/tests.h                           | 1 +
 7 files changed, 8 insertions(+), 10 deletions(-)
 rename tools/perf/{arch/x86 => }/tests/perf-time-to-tsc.c (98%)
tools/perf/arch/x86/include/arch-tests.h +0 -1
index c41c5affe4be..6a54b94f1c25 100644
@@ -7,7 +7,6 @@ struct test;
 
 /* Tests */
 int test__rdpmc(struct test *test __maybe_unused, int subtest);
-int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest);
 int test__insn_x86(struct test *test __maybe_unused, int subtest);
 int test__intel_pt_pkt_decoder(struct test *test, int subtest);
 int test__bp_modify(struct test *test, int subtest);
tools/perf/arch/x86/tests/Build +0 -1
index 2997c506550c..36d4f248b51d 100644
@@ -3,6 +3,5 @@ perf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o
 
 perf-y += arch-tests.o
 perf-y += rdpmc.o
-perf-y += perf-time-to-tsc.o
 perf-$(CONFIG_AUXTRACE) += insn-x86.o intel-pt-pkt-decoder-test.o
 perf-$(CONFIG_X86_64) += bp-modify.o
tools/perf/arch/x86/tests/arch-tests.c +0 -4
index 6763135aec17..bc25d727b4e9 100644
@@ -8,10 +8,6 @@ struct test arch_tests[] = {
 		.desc = "x86 rdpmc",
 		.func = test__rdpmc,
 	},
-	{
-		.desc = "Convert perf time to TSC",
-		.func = test__perf_time_to_tsc,
-	},
 #ifdef HAVE_DWARF_UNWIND_SUPPORT
 	{
 		.desc = "DWARF unwind",
tools/perf/tests/Build +1 -0
index 4d15bf6041fb..aa4dc4f5abde 100644
@@ -62,6 +62,7 @@ perf-y += pfm.o
 perf-y += parse-metric.o
 perf-y += pe-file-parsing.o
 perf-y += expand-cgroup.o
+perf-y += perf-time-to-tsc.o
 
 $(OUTPUT)tests/llvm-src-base.c: tests/bpf-script-example.c tests/Build
 	$(call rule_mkdir)
tools/perf/tests/builtin-test.c +4 -0
index 132bdb3e6c31..02e7bbf70419 100644
@@ -349,6 +349,10 @@ static struct test generic_tests[] = {
 		.desc = "Event expansion for cgroups",
 		.func = test__expand_cgroup_events,
 	},
+	{
+		.desc = "Convert perf time to TSC",
+		.func = test__perf_time_to_tsc,
+	},
 	{
 		.func = NULL,
 	},
tools/perf/tests/perf-time-to-tsc.c renamed from tools/perf/arch/x86/tests/perf-time-to-tsc.c +2 -4
similarity index 98%
rename from tools/perf/arch/x86/tests/perf-time-to-tsc.c
rename to tools/perf/tests/perf-time-to-tsc.c
index 026d32ed078e..aee97c16c0d9 100644
@@ -18,10 +18,8 @@
 #include "thread_map.h"
 #include "record.h"
 #include "tsc.h"
-#include "util/mmap.h"
-#include "tests/tests.h"
-
-#include "arch-tests.h"
+#include "mmap.h"
+#include "tests.h"
 
 #define CHECK__(x) {				\
 	while ((x) < 0) {			\
tools/perf/tests/tests.h +1 -0
index c85a2c08e407..c9b180e640e5 100644
@@ -124,6 +124,7 @@ int test__pfm_subtest_get_nr(void);
 int test__parse_metric(struct test *test, int subtest);
 int test__pe_file_parsing(struct test *test, int subtest);
 int test__expand_cgroup_events(struct test *test, int subtest);
+int test__perf_time_to_tsc(struct test *test, int subtest);
 
 bool test__bp_signal_is_supported(void);
 bool test__bp_account_is_supported(void);
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH v6 2/2 perf tests tsc: Add checking helper is_supported()

In reply to Leo Yan

So far tsc is enabled on x86_64, i386 and Arm64 architectures, add checking helper to skip this testing for other architectures.

---
 tools/perf/tests/builtin-test.c     |  1 +
 tools/perf/tests/perf-time-to-tsc.c | 13 +++++++++++++
 tools/perf/tests/tests.h            |  1 +
 3 files changed, 15 insertions(+)
tools/perf/tests/builtin-test.c +1 -0
index 02e7bbf70419..a185904c47f3 100644
@@ -352,6 +352,7 @@ static struct test generic_tests[] = {
 	{
 		.desc = "Convert perf time to TSC",
 		.func = test__perf_time_to_tsc,
+		.is_supported = test__tsc_is_supported,
 	},
 	{
 		.func = NULL,
tools/perf/tests/perf-time-to-tsc.c +13 -0
index aee97c16c0d9..a9560e0f6360 100644
@@ -169,3 +169,16 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe
 	evlist__delete(evlist);
 	return err;
 }
+
+bool test__tsc_is_supported(void)
+{
+	/*
+	 * Except x86_64/i386 and Arm64, other archs don't support TSC in perf.
+	 * Just enable the test for x86_64/i386 and Arm64 archs.
+	 */
+#if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__)
+	return true;
+#else
+	return false;
+#endif
+}
tools/perf/tests/tests.h +1 -0
index c9b180e640e5..b1f2aac93b33 100644
@@ -129,6 +129,7 @@ int test__perf_time_to_tsc(struct test *test, int subtest);
 bool test__bp_signal_is_supported(void);
 bool test__bp_account_is_supported(void);
 bool test__wp_is_supported(void);
+bool test__tsc_is_supported(void);
 
 #if defined(__arm__) || defined(__aarch64__)
 #ifdef HAVE_DWARF_UNWIND_SUPPORT
Signature · 1 line
2.17.1
Acked-by on the v6 series
#3 lore raw
In reply to Leo Yan
Quoted 18 lines · Leo Yan

This patch set is to move tsc testing from x86 specific to common testing case. Since Arnaldo found the building failure for patch set v4 [1], the first four patches have been merged but the last two patches were left out; this patch set is to resend the last two patches with fixed the building failure (by removing the header "arch-tests.h" from the testing code).

These two patches have been tested on x86_64 and Arm64. Though I don't test them on archs MIPS, PowerPC, etc, I tried to search every header so ensure included headers are supported for all archs.

These two patches have been rebased on the perf/core branch with its latest commit 744aec4df2c5 ("perf c2c: Update documentation for metrics reorganization").

Changes from v5:
* Found the merging confliction on latest perf/core, so rebased it.

Quoted 6 lines

[1] https://lore.kernel.org/patchwork/cover/1305382/#1505752

Leo Yan (2):
perf tests tsc: Make tsc testing as a common testing perf tests tsc: Add checking helper is_supported()

thanks,
jirka

Quoted 14 lines
 tools/perf/arch/x86/include/arch-tests.h      |  1 -
 tools/perf/arch/x86/tests/Build               |  1 -
 tools/perf/arch/x86/tests/arch-tests.c        |  4 ----
 tools/perf/tests/Build                        |  1 +
 tools/perf/tests/builtin-test.c               |  5 +++++
 .../{arch/x86 => }/tests/perf-time-to-tsc.c   | 19 +++++++++++++++----
 tools/perf/tests/tests.h                      |  2 ++
 7 files changed, 23 insertions(+), 10 deletions(-)
 rename tools/perf/{arch/x86 => }/tests/perf-time-to-tsc.c (92%)
Signature · 1 line
2.17.1
maintainer Applied
#4 lore raw

Em Tue, Oct 20, 2020 at 08:11:59AM +0200, Jiri Olsa escreveu:

Quoted 19 lines · Leo Yan
Quoted 18 lines

This patch set is to move tsc testing from x86 specific to common testing case. Since Arnaldo found the building failure for patch set v4 [1], the first four patches have been merged but the last two patches were left out; this patch set is to resend the last two patches with fixed the building failure (by removing the header "arch-tests.h" from the testing code).

These two patches have been tested on x86_64 and Arm64. Though I don't test them on archs MIPS, PowerPC, etc, I tried to search every header so ensure included headers are supported for all archs.

These two patches have been rebased on the perf/core branch with its latest commit 744aec4df2c5 ("perf c2c: Update documentation for metrics reorganization").

Changes from v5:
* Found the merging confliction on latest perf/core, so rebased it.

Quoted 8 lines
Quoted 6 lines

[1] https://lore.kernel.org/patchwork/cover/1305382/#1505752

Leo Yan (2):
perf tests tsc: Make tsc testing as a common testing perf tests tsc: Add checking helper is_supported()

Thanks, applied.

- Arnaldo