Perf tool: Support TSC for Arm64
Subsystems (2)
v4 cover Perf tool: Support TSC for Arm64
This patch set is to refactor TSC implementation and move TSC code from x86 folder to util/tsc.c, this allows all archs to reuse the code. And alse move the TSC testing from x86 folder to tests so can work as a common testing.
So far, for x86 it needs to support cap_user_time_zero and for Arm64 it needs to support cap_user_time_short. For architecture specific code, every arch only needs to implement its own rdtsc() to read out timer's counter.
This patch set has been rebased on the perf/core branch with latest commit b1f815c479c1 ("perf vendor events power9: Add hv_24x7 core level metric events") and tested on Arm64 DB410c.
$ perf test list
[...]
68: Convert perf time to TSC
[...] $ perf test 68 -v
68: Convert perf time to TSC
--- start ---
test child forked, pid 10961
mmap size 528384B
1st event perf time 35715036563417 tsc 686221770989
rdtsc time 35715036649719 tsc 686221772647
2nd event perf time 35715036660448 tsc 686221772852
test child finished with 0
---- end ----
Convert perf time to TSC: OkChanges from v3:
* Added comments for Arm64's rdtsc() for short counter (PeterZ);
* Rebased on latest acme/perf/core branch.
Changes from v2:
* Refactored patch set to move TSC common code to util/tsc.c (Wei/Al);
* Moved TSC testing to perf/tests (Wei);
* Dropped Arm SPE timestamp patch so can have clear purpose and easier reviewing; will send Arm SPE timestamp as separate patch.
Leo Yan (6):
perf tsc: Move out common functions from x86 perf tsc: Add rdtsc() for Arm64
perf tsc: Calculate timestamp with cap_user_time_short perf tsc: Support cap_user_time_short for event TIME_CONV perf tests tsc: Make tsc testing as a common testing perf tests tsc: Add checking helper is_supported()
tools/lib/perf/include/perf/event.h | 4 +
tools/perf/arch/arm64/util/Build | 1 +
tools/perf/arch/arm64/util/tsc.c | 21 +++++
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/arch/x86/util/tsc.c | 73 +----------------
tools/perf/tests/Build | 1 +
tools/perf/tests/builtin-test.c | 5 ++
.../{arch/x86 => }/tests/perf-time-to-tsc.c | 13 +++
tools/perf/tests/tests.h | 2 +
tools/perf/util/jitdump.c | 14 ++--
tools/perf/util/synthetic-events.c | 8 --
tools/perf/util/tsc.c | 81 +++++++++++++++++++
tools/perf/util/tsc.h | 5 ++
15 files changed, 143 insertions(+), 91 deletions(-)
create mode 100644 tools/perf/arch/arm64/util/tsc.c
rename tools/perf/{arch/x86 => }/tests/perf-time-to-tsc.c (93%)Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v4 1/6 perf tsc: Move out common functions from x86
Functions perf_read_tsc_conversion() and perf_event__synth_time_conv() should work as common functions rather than x86 specific, so move these two functions out from arch/x86 folder and place them into util/tsc.c.
Since the function perf_event__synth_time_conv() will be linked in util/tsc.c, remove its weak version.
--- tools/perf/arch/x86/util/tsc.c | 73 +----------------------------- tools/perf/util/synthetic-events.c | 8 ---- tools/perf/util/tsc.c | 71 +++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 80 deletions(-)
tools/perf/arch/x86/util/tsc.c +1 -72
@@ -1,45 +1,7 @@// SPDX-License-Identifier: GPL-2.0 -#include <stdbool.h> -#include <errno.h> - -#include <linux/stddef.h> -#include <linux/perf_event.h> -#include <linux/types.h> -#include <asm/barrier.h> -#include "../../../util/debug.h" -#include "../../../util/event.h" -#include "../../../util/synthetic-events.h" -#include "../../../util/tsc.h" - -int perf_read_tsc_conversion (const struct perf_event_mmap_page *pc, -struct perf_tsc_conversion *tc) -{ -bool cap_user_time_zero; -u32 seq; -int i =0 ; - -while (1 ) { - seq = pc->lock; -rmb (); - tc->time_mult = pc->time_mult; - tc->time_shift = pc->time_shift; - tc->time_zero = pc->time_zero; - cap_user_time_zero = pc->cap_user_time_zero; -rmb (); -if (pc->lock == seq && !(seq &1 )) -break ; -if (++i >10000 ) { -pr_debug ("failed to get perf_event_mmap_page lock\n" ); -return -EINVAL ; - } - } -if (!cap_user_time_zero) -return -EOPNOTSUPP ; - -return 0 ; -} +#include "../../../util/tsc.h" u64 rdtsc (void ) {
@@ -49,36 +11,3 @@ u64 rdtsc(void)return low | ((u64 )high) <<32 ; } - -int perf_event__synth_time_conv (const struct perf_event_mmap_page *pc, -struct perf_tool *tool, -perf_event__handler_t process, -struct machine *machine) -{ -union perf_event event = { - .time_conv = { - .header = { - .type =PERF_RECORD_TIME_CONV , - .size =sizeof (struct perf_record_time_conv ), - }, - }, - }; -struct perf_tsc_conversion tc; -int err; - -if (!pc) -return 0 ; - err =perf_read_tsc_conversion (pc, &tc); -if (err == -EOPNOTSUPP ) -return 0 ; -if (err) -return err; - -pr_debug2 ("Synthesizing TSC conversion information\n" ); - - event.time_conv.time_mult = tc.time_mult; - event.time_conv.time_shift = tc.time_shift; - event.time_conv.time_zero = tc.time_zero; - -return process (tool, &event,NULL , machine); -}
tools/perf/util/synthetic-events.c +0 -8
@@ -2006,14 +2006,6 @@ int perf_event__synthesize_stat_events(struct perf_stat_config *config, struct preturn 0 ; } -int __weak perf_event__synth_time_conv (const struct perf_event_mmap_page *pc__maybe_unused , -struct perf_tool *tool__maybe_unused , -perf_event__handler_t process__maybe_unused , -struct machine *machine__maybe_unused ) -{ -return 0 ; -} -extern const struct perf_header_feature_ops feat_ops[HEADER_LAST_FEATURE ]; int perf_event__synthesize_features(struct perf_tool *tool, struct perf_session *session,
tools/perf/util/tsc.c +71 -0
84 lines not on this page · raw message
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v4 2/6 perf tsc: Add rdtsc() for Arm64
In reply to Leo YanThe system register CNTVCT_EL0 can be used to retrieve the counter from user space. Add rdtsc() for Arm64.
--- tools/perf/arch/arm64/util/Build | 1 + tools/perf/arch/arm64/util/tsc.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 tools/perf/arch/arm64/util/tsc.c
tools/perf/arch/arm64/util/Build +1 -0
@@ -1,6 +1,7 @@ perf-y += header.o perf-y += machine.o perf-y += perf_regs.o +perf-y += tsc.o perf-$(CONFIG_DWARF) += dwarf-regs.o perf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
tools/perf/arch/arm64/util/tsc.c new file +21 -0
@@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/types.h> + +#include "../../../util/tsc.h" + +u64 rdtsc (void ) +{ +u64 val; + +/* +* According to ARM DDI 0487F.c, from Armv8.0 to Armv8.5 inclusive, the +* system counter is at least 56 bits wide; from Armv8.6, the counter +* must be 64 bits wide. So the system counter could be less than 64 +* bits wide and it is attributed with the flag 'cap_user_time_short' +* is true. +*/ + asmvolatile ("mrs %0, cntvct_el0" :"=r" (val)); + +return val; +}
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v4 3/6 perf tsc: Calculate timestamp with cap_user_time_short
In reply to Leo YanThe perf mmap'ed buffer contains the flag 'cap_user_time_short' and two extra fields 'time_cycles' and 'time_mask', perf tool needs to know them for handling the counter wrapping case.
This patch is to reads out the relevant parameters from the head of the first mmap'ed page and stores into the structure 'perf_tsc_conversion', if the flag 'cap_user_time_short' has been set, it will firstly calibrate cycle value for timestamp calculation.
--- tools/perf/util/tsc.c | 12 +++++++++--- tools/perf/util/tsc.h | 5 +++++ 2 files changed, 14 insertions(+), 3 deletions(-)
tools/perf/util/tsc.c +9 -3
@@ -28,6 +28,10 @@ u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc) {u64 quot, rem; +if (tc->cap_user_time_short) + cyc = tc->time_cycles + + ((cyc - tc->time_cycles) & tc->time_mask); + quot = cyc >> tc->time_shift; rem = cyc & (((u64 )1 << tc->time_shift) -1 ); return tc->time_zero + quot * tc->time_mult +
@@ -37,7 +41,6 @@ u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc)int perf_read_tsc_conversion (const struct perf_event_mmap_page *pc,struct perf_tsc_conversion *tc) { -bool cap_user_time_zero;u32 seq;int i =0 ;
@@ -47,7 +50,10 @@ int perf_read_tsc_conversion(const struct perf_event_mmap_page *pc, tc->time_mult = pc->time_mult; tc->time_shift = pc->time_shift; tc->time_zero = pc->time_zero; - cap_user_time_zero = pc->cap_user_time_zero; + tc->time_cycles = pc->time_cycles; + tc->time_mask = pc->time_mask; + tc->cap_user_time_zero = pc->cap_user_time_zero; + tc->cap_user_time_short = pc->cap_user_time_short;rmb ();if (pc->lock == seq && !(seq &1 ))break ;
@@ -57,7 +63,7 @@ int perf_read_tsc_conversion(const struct perf_event_mmap_page *pc, } } -if (!cap_user_time_zero) +if (!tc->cap_user_time_zero)return -EOPNOTSUPP ;return 0 ;
tools/perf/util/tsc.h +5 -0
@@ -8,6 +8,11 @@ struct perf_tsc_conversion {u16 time_shift;u32 time_mult;u64 time_zero; +u64 time_cycles; +u64 time_mask; + +bool cap_user_time_zero; +bool cap_user_time_short; };struct perf_event_mmap_page ;
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v4 4/6 perf tsc: Support cap_user_time_short for event TIME_CONV
In reply to Leo YanThe synthesized event TIME_CONV doesn't contain the complete parameters for counters, this will lead to wrong conversion between counter cycles and timestamp.
This patch extends event TIME_CONV to record flags 'cap_user_time_zero' which is used to indicate the counter parameters are valid or not, if not will directly return 0 for timestamp calculation. And record the flag 'cap_user_time_short' and its relevant fields 'time_cycles' and 'time_mask' for cycle calibration.
--- tools/lib/perf/include/perf/event.h | 4 ++++ tools/perf/util/jitdump.c | 14 +++++++++----- tools/perf/util/tsc.c | 4 ++++ 3 files changed, 17 insertions(+), 5 deletions(-)
tools/lib/perf/include/perf/event.h +4 -0
@@ -324,6 +324,10 @@ struct perf_record_time_conv {__u64 time_shift;__u64 time_mult;__u64 time_zero; +__u64 time_cycles; +__u64 time_mask; +bool cap_user_time_zero; +bool cap_user_time_short; };struct perf_record_header_feature {
tools/perf/util/jitdump.c +9 -5
@@ -374,11 +374,15 @@ static uint64_t convert_timestamp(struct jit_buf_desc *jd, uint64_t timestamp)if (!jd->use_arch_timestamp)return timestamp; - tc.time_shift = jd->session->time_conv.time_shift; - tc.time_mult = jd->session->time_conv.time_mult; - tc.time_zero = jd->session->time_conv.time_zero; - -if (!tc.time_mult) + tc.time_shift = jd->session->time_conv.time_shift; + tc.time_mult = jd->session->time_conv.time_mult; + tc.time_zero = jd->session->time_conv.time_zero; + tc.time_cycles = jd->session->time_conv.time_cycles; + tc.time_mask = jd->session->time_conv.time_mask; + tc.cap_user_time_zero = jd->session->time_conv.cap_user_time_zero; + tc.cap_user_time_short = jd->session->time_conv.cap_user_time_short; + +if (!tc.cap_user_time_zero)return 0 ;return tsc_to_perf_time (timestamp, &tc);
tools/perf/util/tsc.c +4 -0
@@ -98,6 +98,10 @@ int perf_event__synth_time_conv(const struct perf_event_mmap_page *pc, event.time_conv.time_mult = tc.time_mult; event.time_conv.time_shift = tc.time_shift; event.time_conv.time_zero = tc.time_zero; + event.time_conv.time_cycles = tc.time_cycles; + event.time_conv.time_mask = tc.time_mask; + event.time_conv.cap_user_time_zero = tc.cap_user_time_zero; + event.time_conv.cap_user_time_short = tc.cap_user_time_short;return process (tool, &event,NULL , machine); }
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v4 5/6 perf tests tsc: Make tsc testing as a common testing
In reply to Leo Yanx86 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).
---
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 | 0
tools/perf/tests/tests.h | 1 +
7 files changed, 6 insertions(+), 6 deletions(-)
rename tools/perf/{arch/x86 => }/tests/perf-time-to-tsc.c (100%)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 +0 -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 · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v4 6/6 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
@@ -171,3 +171,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 · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi Arnaldo,
Quoted 5 lines · Leo Yan
This patch set is to refactor TSC implementation and move TSC code from x86 folder to
util/tsc.c, this allows all archs to reuse the code. And alse move the TSC testing from x86 folder to tests so can work as a common testing.
Quoted 8 lines
So far, for x86 it needs to support
cap_user_time_zeroand for Arm64 it needs to supportcap_user_time_short. For architecture specific code, every arch only needs to implement its ownrdtsc()to read out timer's counter.This patch set has been rebased on the perf/core branch with latest commit
b1f815c479c1("perf vendor events power9: Addhv_24x7core level metric events") and tested on Arm64 DB410c.
Could you pick up this patch set? Thanks!
Leo
Quoted 58 lines
$ perf test list [...] 68: Convert perf time to TSC [...]$ perf test 68 -v 68: Convert perf time to TSC --- start --- test child forked, pid 10961 mmap size 528384B 1st event perf time 35715036563417 tsc 686221770989 rdtsc time 35715036649719 tsc 686221772647 2nd event perf time 35715036660448 tsc 686221772852 test child finished with 0 ---- end ---- Convert perf time to TSC: OkChanges from v3:
* Added comments for Arm64'srdtsc()for short counter (PeterZ);
* Rebased on latest acme/perf/core branch.Changes from v2:
* Refactored patch set to move TSC common code toutil/tsc.c(Wei/Al);
* Moved TSC testing to perf/tests (Wei);
* Dropped Arm SPE timestamp patch so can have clear purpose and easier reviewing; will send Arm SPE timestamp as separate patch.Leo Yan (6):
perf tsc: Move out common functions from x86 perf tsc: Addrdtsc()for Arm64
perf tsc: Calculate timestamp withcap_user_time_shortperf tsc: Supportcap_user_time_shortfor eventTIME_CONVperf tests tsc: Make tsc testing as a common testing perf tests tsc: Add checking helperis_supported()tools/lib/perf/include/perf/event.h | 4 + tools/perf/arch/arm64/util/Build | 1 + tools/perf/arch/arm64/util/tsc.c | 21 +++++ 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/arch/x86/util/tsc.c | 73 +---------------- tools/perf/tests/Build | 1 + tools/perf/tests/builtin-test.c | 5 ++ .../{arch/x86 => }/tests/perf-time-to-tsc.c | 13 +++ tools/perf/tests/tests.h | 2 + tools/perf/util/jitdump.c | 14 ++-- tools/perf/util/synthetic-events.c | 8 -- tools/perf/util/tsc.c | 81 +++++++++++++++++++ tools/perf/util/tsc.h | 5 ++ 15 files changed, 143 insertions(+), 91 deletions(-) create mode 100644 tools/perf/arch/arm64/util/tsc.c rename tools/perf/{arch/x86 => }/tests/perf-time-to-tsc.c (93%)Signature · 1 line
2.17.1
Arnaldo Carvalho de Melo
maintainerEm Tue, Sep 22, 2020 at 08:07:32PM +0800, Leo Yan escreveu:
Quoted 13 lines
Hi Arnaldo,
Quoted 10 lines · Leo Yan
This patch set is to refactor TSC implementation and move TSC code from x86 folder to
util/tsc.c, this allows all archs to reuse the code. And alse move the TSC testing from x86 folder to tests so can work as a common testing.So far, for x86 it needs to support
cap_user_time_zeroand for Arm64 it needs to supportcap_user_time_short. For architecture specific code, every arch only needs to implement its ownrdtsc()to read out timer's counter.
Quoted 5 lines
Quoted 3 lines
This patch set has been rebased on the perf/core branch with latest commit
b1f815c479c1("perf vendor events power9: Addhv_24x7core level metric events") and tested on Arm64 DB410c.Could you pick up this patch set? Thanks!
Yeah, I picked it up now, its a pity nobody provided Acks :-\
Or have a missed them somehow?
- Arnaldo
Quoted 60 lines
Leo
Quoted 58 lines
$ perf test list [...] 68: Convert perf time to TSC [...]$ perf test 68 -v 68: Convert perf time to TSC --- start --- test child forked, pid 10961 mmap size 528384B 1st event perf time 35715036563417 tsc 686221770989 rdtsc time 35715036649719 tsc 686221772647 2nd event perf time 35715036660448 tsc 686221772852 test child finished with 0 ---- end ---- Convert perf time to TSC: OkChanges from v3:
* Added comments for Arm64'srdtsc()for short counter (PeterZ);
* Rebased on latest acme/perf/core branch.Changes from v2:
* Refactored patch set to move TSC common code toutil/tsc.c(Wei/Al);
* Moved TSC testing to perf/tests (Wei);
* Dropped Arm SPE timestamp patch so can have clear purpose and easier reviewing; will send Arm SPE timestamp as separate patch.Leo Yan (6):
perf tsc: Move out common functions from x86 perf tsc: Addrdtsc()for Arm64
perf tsc: Calculate timestamp withcap_user_time_shortperf tsc: Supportcap_user_time_shortfor eventTIME_CONVperf tests tsc: Make tsc testing as a common testing perf tests tsc: Add checking helperis_supported()tools/lib/perf/include/perf/event.h | 4 + tools/perf/arch/arm64/util/Build | 1 + tools/perf/arch/arm64/util/tsc.c | 21 +++++ 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/arch/x86/util/tsc.c | 73 +---------------- tools/perf/tests/Build | 1 + tools/perf/tests/builtin-test.c | 5 ++ .../{arch/x86 => }/tests/perf-time-to-tsc.c | 13 +++ tools/perf/tests/tests.h | 2 + tools/perf/util/jitdump.c | 14 ++-- tools/perf/util/synthetic-events.c | 8 -- tools/perf/util/tsc.c | 81 +++++++++++++++++++ tools/perf/util/tsc.h | 5 ++ 15 files changed, 143 insertions(+), 91 deletions(-) create mode 100644 tools/perf/arch/arm64/util/tsc.c rename tools/perf/{arch/x86 => }/tests/perf-time-to-tsc.c (93%)Signature · 1 line
2.17.1
Signature · 1 line
- Arnaldo
Quoted 14 lines · Arnaldo Carvalho de Melo
Em Tue, Sep 22, 2020 at 08:07:32PM +0800, Leo Yan escreveu:
Quoted 13 lines
Hi Arnaldo,
Quoted 10 lines · Leo Yan
This patch set is to refactor TSC implementation and move TSC code from x86 folder to
util/tsc.c, this allows all archs to reuse the code. And alse move the TSC testing from x86 folder to tests so can work as a common testing.So far, for x86 it needs to support
cap_user_time_zeroand for Arm64 it needs to supportcap_user_time_short. For architecture specific code, every arch only needs to implement its ownrdtsc()to read out timer's counter.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
This patch set has been rebased on the perf/core branch with latest commit
b1f815c479c1("perf vendor events power9: Addhv_24x7core level metric events") and tested on Arm64 DB410c.Could you pick up this patch set? Thanks!
Yeah, I picked it up now, its a pity nobody provided Acks :-\
Thanks, Arnaldo!
Quoted 1 line
Or have a missed them somehow?
No, you didn't miss anything. I should actively chase Ack tags (e.g. Peter or Will's acknowledge) before ask merging. Will note for this later.
Thanks,
Leo
Arnaldo Carvalho de Melo
maintainerEm Tue, Sep 22, 2020 at 01:49:06PM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 18 lines
Em Tue, Sep 22, 2020 at 08:07:32PM +0800, Leo Yan escreveu:
Quoted 17 lines
Hi Arnaldo,
Quoted 13 lines · Leo Yan
This patch set is to refactor TSC implementation and move TSC code from x86 folder to
util/tsc.c, this allows all archs to reuse the code. And alse move the TSC testing from x86 folder to tests so can work as a common testing.So far, for x86 it needs to support
cap_user_time_zeroand for Arm64 it needs to supportcap_user_time_short. For architecture specific code, every arch only needs to implement its ownrdtsc()to read out timer's counter.This patch set has been rebased on the perf/core branch with latest commit
b1f815c479c1("perf vendor events power9: Addhv_24x7core level metric events") and tested on Arm64 DB410c.
Quoted 5 lines
Quoted 1 line
Could you pick up this patch set? Thanks!
Yeah, I picked it up now, its a pity nobody provided Acks :-\
Or have a missed them somehow?
Also:
$ cat dm.log/debian:experimental-x-mips64
CC /tmp/build/perf/tests/llvm-src-prologue.o
CC /tmp/build/perf/tests/llvm-src-relocation.otests/perf-time-to-tsc.c:24:10: fatal error: arch-tests.h: No such file or directory
24 | #include "arch-tests.h"
| ^~~~~~~~~~~~~~
compilation terminated.
make[4]: *** [/git/linux/tools/build/Makefile.build:96: /tmp/build/perf/tests/perf-time-to-tsc.o] Error 1 make[4]: *** Waiting for unfinished jobs....
[perfbuilder@five ~]$ cat dm.log/debian:experimental-x-mipsel | grep "fatal error" -A5 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.
make[4]: *** [/git/linux/tools/build/Makefile.build:96: /tmp/build/perf/tests/perf-time-to-tsc.o] Error 1 make[4]: *** Waiting for unfinished jobs....
[perfbuilder@five ~]$
[perfbuilder@five ~]$ cat dm.log/fedora:30-x-ARC-uClibc | grep "fatal error" -A5 tests/perf-time-to-tsc.c:24:10: fatal error: arch-tests.h: No such file or directory
#include "arch-tests.h"
^~~~~~~~~~~~~~compilation terminated.
make[4]: *** [/git/linux/tools/build/Makefile.build:97: /tmp/build/perf/tests/perf-time-to-tsc.o] Error 1 make[4]: *** Waiting for unfinished jobs....
[perfbuilder@five ~]$
[perfbuilder@five ~]$ cat dm.log/ubuntu:18.04-x-s390 | grep "fatal error" -A5 tests/perf-time-to-tsc.c:24:10: fatal error: arch-tests.h: No such file or directory
#include "arch-tests.h"
^~~~~~~~~~~~~~compilation terminated.
/git/linux/tools/build/Makefile.build:96: recipe for target '/tmp/build/perf/tests/perf-time-to-tsc.o' failed make[4]: *** [/tmp/build/perf/tests/perf-time-to-tsc.o] Error 1
[perfbuilder@five ~]$
Oh, it works for arm64 and powerpc
69 25.93 ubuntu:18.04-x-arm : Ok arm-linux-gnueabihf-gcc (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) 7.5.0 70 25.69 ubuntu:18.04-x-arm64 : Ok aarch64-linux-gnu-gcc (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) 7.5.0
68 79.84 ubuntu:18.04 : Ok gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0, clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final) 69 25.93 ubuntu:18.04-x-arm : Ok arm-linux-gnueabihf-gcc (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) 7.5.0 70 25.69 ubuntu:18.04-x-arm64 : Ok aarch64-linux-gnu-gcc (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) 7.5.0 71 11.75 ubuntu:18.04-x-m68k : FAIL m68k-linux-gnu-gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 72 25.72 ubuntu:18.04-x-powerpc : Ok powerpc-linux-gnu-gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 73 28.10 ubuntu:18.04-x-powerpc64 : Ok powerpc64-linux-gnu-gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 74 27.84 ubuntu:18.04-x-powerpc64el : Ok powerpc64le-linux-gnu-gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 75 12.11 ubuntu:18.04-x-riscv64 : FAIL riscv64-linux-gnu-gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 76 11.85 ubuntu:18.04-x-s390 : FAIL s390x-linux-gnu-gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 77 12.55 ubuntu:18.04-x-sh4 : FAIL sh4-linux-gnu-gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 78 11.42 ubuntu:18.04-x-sparc64 : FAIL sparc64-linux-gnu-gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
[perfbuilder@five ~]$ grep tsc dm.log/ubuntu\:18.04-x-powerpc64
CC /tmp/build/perf/tests/perf-time-to-tsc.o CC /tmp/build/perf/util/tsc.o CC /tmp/build/perf/tests/perf-time-to-tsc.o CC /tmp/build/perf/util/tsc.o CC /tmp/build/perf/tests/perf-time-to-tsc.o CC /tmp/build/perf/util/tsc.o
[perfbuilder@five ~]$
Can you please take a look and resubmit? I'm removing the series from my local branch.
- Arnaldo
Arnaldo Carvalho de Melo
maintainerEm Wed, Sep 23, 2020 at 12:27:53PM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 19 lines
Em Tue, Sep 22, 2020 at 01:49:06PM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 18 lines
Em Tue, Sep 22, 2020 at 08:07:32PM +0800, Leo Yan escreveu:
Quoted 17 lines
Hi Arnaldo,
Quoted 13 lines · Leo Yan
This patch set is to refactor TSC implementation and move TSC code from x86 folder to
util/tsc.c, this allows all archs to reuse the code. And alse move the TSC testing from x86 folder to tests so can work as a common testing.So far, for x86 it needs to support
cap_user_time_zeroand for Arm64 it needs to supportcap_user_time_short. For architecture specific code, every arch only needs to implement its ownrdtsc()to read out timer's counter.This patch set has been rebased on the perf/core branch with latest commit
b1f815c479c1("perf vendor events power9: Addhv_24x7core level metric events") and tested on Arm64 DB410c.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Could you pick up this patch set? Thanks!
Yeah, I picked it up now, its a pity nobody provided Acks :-\
Or have a missed them somehow?
Also:
So, this is the first:
commit 0ab58c405dd7c143a1482cb9414eb0eb9b31d42a (HEAD)
Author: Leo Yan <[email protected]> Date: Mon Sep 14 19:53:10 2020 +0800
perf tests tsc: Make tsc testing as a common testing
I'll remove it and the ones after that, so the main feature is kept.
I'll retest, and then push to perf/core you can then continue from there.
Thanks,
- Arnaldo
Hi Arnaldo,
Quoted 34 lines · Arnaldo Carvalho de Melo
Em Wed, Sep 23, 2020 at 12:27:53PM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 19 lines
Em Tue, Sep 22, 2020 at 01:49:06PM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 18 lines
Em Tue, Sep 22, 2020 at 08:07:32PM +0800, Leo Yan escreveu:
Quoted 17 lines
Hi Arnaldo,
Quoted 13 lines · Leo Yan
This patch set is to refactor TSC implementation and move TSC code from x86 folder to
util/tsc.c, this allows all archs to reuse the code. And alse move the TSC testing from x86 folder to tests so can work as a common testing.So far, for x86 it needs to support
cap_user_time_zeroand for Arm64 it needs to supportcap_user_time_short. For architecture specific code, every arch only needs to implement its ownrdtsc()to read out timer's counter.This patch set has been rebased on the perf/core branch with latest commit
b1f815c479c1("perf vendor events power9: Addhv_24x7core level metric events") and tested on Arm64 DB410c.Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Could you pick up this patch set? Thanks!
Yeah, I picked it up now, its a pity nobody provided Acks :-\
Or have a missed them somehow?
Also:
So, this is the first:
commit
0ab58c405dd7c143a1482cb9414eb0eb9b31d42a(HEAD)Author: Leo Yan <[email protected]> Date: Mon Sep 14 19:53:10 2020 +0800
Quoted 6 lines
perf tests tsc: Make tsc testing as a common testing
I'll remove it and the ones after that, so the main feature is kept.
I'll retest, and then push to perf/core you can then continue from there.
Will monitor perf/core branch and after you push onto it, I will fix
the issue ASAP. Sorry for inconvenience.
Thanks,
Leo