perf: Make tsc testing as a common testing case
v5 cover perf: Make tsc testing as a common testing case
This patch set is to follow up the building failure which was found by Arnaldo:
CC /tmp/build/perf/tests/llvm-src-prologue.o
CC /tmp/build/perf/tests/llvm-src-relocation.o
tests/perf-time-to-tsc.c:24:10: fatal error: arch-tests.h: No such file or directory
24 | #include "arch-tests.h"
| ^~~~~~~~~~~~~~
compilation terminated.
Patch 01 has removed the header "arch-tests.h" from the testing code, so that this can fix the reported building failure.
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 69f48c7040d3 ("perf script: Add min, max to futex-contention output, in addition to avg").
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
PATCH v5 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
@@ -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
@@ -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
@@ -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
@@ -61,6 +61,7 @@ perf-y += demangle-java-test.o perf-y += pfm.o perf-y += parse-metric.o perf-y += pe-file-parsing.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
@@ -345,6 +345,10 @@ static struct test generic_tests[] = { .desc = "PE file support", .func = test__pe_file_parsing, }, + { + .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
@@ -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
@@ -123,6 +123,7 @@ const char *test__pfm_subtest_get_desc(int subtest);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__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
PATCH v5 2/2 perf tests tsc: Add checking helper is_supported()
In reply to Leo YanSo 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
@@ -348,6 +348,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
@@ -169,3 +169,16 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybeevlist__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
@@ -128,6 +128,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