Skip to contentSkip to conversation

Perf tool: Enable Arm arch timer counter and arm-spe's timestamp

PATCH In review Leo Yan 6 participants 16 messages Aug 7, 2020 – Aug 21, 2020

Subsystems (2)
lore
Share & tools
lore

Leo Yan

author
#0 lore raw

v2 cover Perf tool: Enable Arm arch timer counter and arm-spe's timestamp

This patch set is to enable Arm arch timer counter and Arm SPE is the first customer to use arch timer counter for its timestamp.

Patches 01 ~ 03 enables Arm arch timer counter in Perf tool; patch 01 is to retrieve arch timer's parameters from mmaped page; patch 02 provides APIs for the conversion between arch timer's counter and time; patch 03 adds a test for patches 01 and 02.

As the first customer to use Arm arch timer counter in perf tool, patch 04 is to generate sample's timestamp for ARM SPE AUX trace data.

This patch set has been rebased on perf/core branch with the latest commit c4735d990268 ("perf evsel: Don't set sample_regs_intr/sample_regs_user for dummy event").

After changes:

  # perf test 67 -v
    67: Convert perf time to arch timer counter
    --- start ---
    test child forked, pid 5463
    mmap size 528384B
    1st event perf time 2231755083020 arch timer cnt 113097053477
    test time           2231755087460 arch timer cnt 113097053699
    2nd event perf time 2231755090680 arch timer cnt 113097053860
    test child finished with 0
    ---- end ----

Reports the SPE sample with timestamp:

  $ perf script -F,+time
    dd  6799 [034] 25496.733475:          1              l1d-access:      ffff87f37b88 _dl_start+0x288 (/usr/lib/aarch64-linux-gnu/ld-2.28.so)
    dd  6799 [034] 25496.733475:          1              tlb-access:      ffff87f37b88 _dl_start+0x288 (/usr/lib/aarch64-linux-gnu/ld-2.28.so)
    dd  6799 [034] 25496.733479:          1              l1d-access:      ffff87f37c74 _dl_start+0x374 (/usr/lib/aarch64-linux-gnu/ld-2.28.so)
    dd  6799 [034] 25496.733479:          1              tlb-access:      ffff87f37c74 _dl_start+0x374 (/usr/lib/aarch64-linux-gnu/ld-2.28.so)
    dd  6799 [034] 25496.733485:          1              l1d-access:      ffff87f49af4 __GI___tunables_init+0x3c (/usr/lib/aarch64-linux-gnu/ld-2.28.so)
    dd  6799 [034] 25496.733485:          1              tlb-access:      ffff87f49af4 __GI___tunables_init+0x3c (/usr/lib/aarch64-linux-gnu/ld-2.28.so)

Changes from v1:
* Rebased on the latest perf/core branch;
* Added a testing for Arm timer counter conversion (Ian Rogers).

Leo Yan (4):
perf tools: Support Arm arch timer counter
perf arm_arch_timer: Convert between counter and timestamp perf arm_arch_timer: Test conversion between counter and timestamp perf arm-spe: Enable timestamp with arch timer counter

 tools/perf/arch/arm64/include/arch-tests.h    |   6 +
 tools/perf/arch/arm64/tests/Build             |   1 +
 tools/perf/arch/arm64/tests/arch-tests.c      |   4 +
 .../tests/perf-time-to-arch-timer-counter.c   | 189 ++++++++++++++++++
 tools/perf/arch/arm64/util/Build              |   1 +
 tools/perf/arch/arm64/util/arch_timer.c       |  50 +++++
 tools/perf/arch/arm64/util/arm-spe.c          |  17 ++
 tools/perf/util/Build                         |   1 +
 tools/perf/util/arm-spe.c                     |  16 +-
 tools/perf/util/arm-spe.h                     |   5 +
 tools/perf/util/arm_arch_timer.c              |  28 +++
 tools/perf/util/arm_arch_timer.h              |  23 +++
 12 files changed, 339 insertions(+), 2 deletions(-)
 create mode 100644 tools/perf/arch/arm64/tests/perf-time-to-arch-timer-counter.c
 create mode 100644 tools/perf/arch/arm64/util/arch_timer.c
 create mode 100644 tools/perf/util/arm_arch_timer.c
 create mode 100644 tools/perf/util/arm_arch_timer.h
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v2 1/4 perf tools: Support Arm arch timer counter

The Arm arch timer can be used to calculate timestamp, the basic idea is the arch timer's counter value can be recorded in the hardware tracing data, e.g. the arch timer's counter value can be used for Arm CoreSight (not now but might be implemented later) and Arm SPE. So we need a way to convert the arch timer's counter to the system time, the conversion is dependent on some related parameters, e.g. 'time_shift', 'time_mult', 'time_offset', etc; furthermore, to handle the counter wrapping issue, perf tool needs to know 'time_cycles' and 'time_mask' for correction.

This patch is to support Arm arch timer by reading out the relevant parameters from the head of first mmaped page. And these parameters will be stored into the structure 'perf_arch_timer_conversion' for later calculation timestamp.

---
 tools/perf/arch/arm64/util/Build        |  1 +
 tools/perf/arch/arm64/util/arch_timer.c | 50 +++++++++++++++++++++++++
 tools/perf/util/arm_arch_timer.h        | 20 ++++++++++
 3 files changed, 71 insertions(+)
 create mode 100644 tools/perf/arch/arm64/util/arch_timer.c
 create mode 100644 tools/perf/util/arm_arch_timer.h
tools/perf/arch/arm64/util/Build +1 -0
index 5c13438c7bd4..77f4d7b30932 100644
@@ -1,3 +1,4 @@
+perf-y += arch_timer.o
 perf-y += header.o
 perf-y += machine.o
 perf-y += perf_regs.o
tools/perf/arch/arm64/util/arch_timer.c new file +50 -0

50 lines not on this page · raw message

tools/perf/util/arm_arch_timer.h new file +20 -0
new file mode 100644
index 000000000000..a3263cc4e5cf
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __PERF_ARM_ARCH_TIMER_H
+#define __PERF_ARM_ARCH_TIMER_H
+
+#include <linux/types.h>
+
+struct perf_arch_timer_conversion {
+	u16 time_shift;
+	u32 time_mult;
+	u64 time_zero;
+	u64 time_cycles;
+	u64 time_mask;
+};
+
+struct perf_event_mmap_page;
+
+int perf_read_arch_timer_conversion(const struct perf_event_mmap_page *pc,
+				    struct perf_arch_timer_conversion *tc);
+
+#endif // __PERF_ARM_ARCH_TIMER_H
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH v2 1/4] perf tools: Support Arm arch timer counter

Hi Leo

Quoted 78 lines · Leo Yan

The Arm arch timer can be used to calculate timestamp, the basic idea is the arch timer's counter value can be recorded in the hardware tracing data, e.g. the arch timer's counter value can be used for Arm CoreSight (not now but might be implemented later) and Arm SPE. So we need a way to convert the arch timer's counter to the system time, the conversion is dependent on some related parameters, e.g. 'time_shift', 'time_mult', 'time_offset', etc; furthermore, to handle the counter wrapping issue, perf tool needs to know 'time_cycles' and 'time_mask' for correction.

This patch is to support Arm arch timer by reading out the relevant parameters from the head of first mmaped page. And these parameters will be stored into the structure 'perf_arch_timer_conversion' for later calculation timestamp.

---
 tools/perf/arch/arm64/util/Build        |  1 +
 tools/perf/arch/arm64/util/arch_timer.c | 50 +++++++++++++++++++++++++
 tools/perf/util/arm_arch_timer.h        | 20 ++++++++++
 3 files changed, 71 insertions(+)
 create mode 100644 tools/perf/arch/arm64/util/arch_timer.c
 create mode 100644 tools/perf/util/arm_arch_timer.h
tools/perf/arch/arm64/util/Build +1 -0
index 5c13438c7bd4..77f4d7b30932 100644
@@ -1,3 +1,4 @@
+perf-y += arch_timer.o
 perf-y += header.o
 perf-y += machine.o
 perf-y += perf_regs.o
tools/perf/arch/arm64/util/arch_timer.c new file +40 -0
new file mode 100644
index 000000000000..dcc217c294fc
@@ -0,0 +1,50 @@
+// 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/arm_arch_timer.h"
+
+int perf_read_arch_timer_conversion(const struct perf_event_mmap_page *pc,
+				    struct perf_arch_timer_conversion *tc)
+{
+	bool cap_user_time_zero, cap_user_time_short;
+	u32 seq;
+	int i = 0;
+
+	while (1) {
+		seq = pc->lock;
+		/* Add barrier between the sequence lock and data accessing */
+		rmb();
+
+		tc->time_mult = pc->time_mult;
+		tc->time_shift = pc->time_shift;
+		tc->time_zero = pc->time_zero;
+		tc->time_cycles = pc->time_cycles;
+		tc->time_mask = pc->time_mask;
+		cap_user_time_zero = pc->cap_user_time_zero;
+		cap_user_time_short = pc->cap_user_time_short;
+
+		/* Add barrier between the data accessing and sequence lock */
+		rmb();
+		if (pc->lock == seq && !(seq & 1))
+			break;
+		if (++i > 10000) {
+			pr_debug("%s: failed to get perf_event_mmap_page lock\n",

tools/perf/arch/arm64/util/arch_timer.c line 50

Quoted 10 lines
tools/perf/arch/arm64/util/arch_timer.c new file +10 -0
+				 __func__);
+			return -EINVAL;
+		}
+	}
+
+	if (!cap_user_time_zero || !cap_user_time_short)
+		return -EOPNOTSUPP;
+
+	return 0;
+}

Should we implement the perf_event__synth_time_conv() method? As it can be supported on arm64 arch now.

These is also a tsc get method called rdtsc(), weak implementation in 'tools/perf/util/tsc.c', maybe we should rename it to an arch independent name, and implement the arm64 version (read_cntvct_el0 in patch 3) here. Thus we can also make the testcase generic, instead of adding a new one for arm64 :).

Thanks,
Wei

Quoted 27 lines
tools/perf/util/arm_arch_timer.h new file +20 -0
new file mode 100644
index 000000000000..a3263cc4e5cf
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __PERF_ARM_ARCH_TIMER_H
+#define __PERF_ARM_ARCH_TIMER_H
+
+#include <linux/types.h>
+
+struct perf_arch_timer_conversion {
+	u16 time_shift;
+	u32 time_mult;
+	u64 time_zero;
+	u64 time_cycles;
+	u64 time_mask;
+};
+
+struct perf_event_mmap_page;
+
+int perf_read_arch_timer_conversion(const struct perf_event_mmap_page *pc,
+				    struct perf_arch_timer_conversion *tc);
+
+#endif // __PERF_ARM_ARCH_TIMER_H
author
#3 lore raw

Re: [PATCH v2 1/4] perf tools: Support Arm arch timer counter

Hi Wei,

On Thu, Aug 20, 2020 at 10:56:46AM +0800, liwei (GF) wrote:

[...]

Quoted 31 lines
Quoted 31 lines
tools/perf/arch/arm64/util/arch_timer.c new file +31 -0
+int perf_read_arch_timer_conversion(const struct perf_event_mmap_page *pc,
+				    struct perf_arch_timer_conversion *tc)
+{
+	bool cap_user_time_zero, cap_user_time_short;
+	u32 seq;
+	int i = 0;
+
+	while (1) {
+		seq = pc->lock;
+		/* Add barrier between the sequence lock and data accessing */
+		rmb();
+
+		tc->time_mult = pc->time_mult;
+		tc->time_shift = pc->time_shift;
+		tc->time_zero = pc->time_zero;
+		tc->time_cycles = pc->time_cycles;
+		tc->time_mask = pc->time_mask;
+		cap_user_time_zero = pc->cap_user_time_zero;
+		cap_user_time_short = pc->cap_user_time_short;
+
+		/* Add barrier between the data accessing and sequence lock */
+		rmb();
+		if (pc->lock == seq && !(seq & 1))
+			break;
+		if (++i > 10000) {
+			pr_debug("%s: failed to get perf_event_mmap_page lock\n",
+				 __func__);
+			return -EINVAL;
+		}
+	}
+
Quoted 8 lines

tools/perf/arch/arm64/util/arch_timer.c line 50

Quoted 5 lines
tools/perf/arch/arm64/util/arch_timer.c new file +5 -0
+	if (!cap_user_time_zero || !cap_user_time_short)
+		return -EOPNOTSUPP;
+
+	return 0;
+}

Should we implement the perf_event__synth_time_conv() method? As it can be supported on arm64 arch now.

Thanks a lot for pointing out, agree that we should implement perf_event__synth_time_conv() for Arm64. Will do it in next spin.

Quoted 3 lines

These is also a tsc get method called rdtsc(), weak implementation in 'tools/perf/util/tsc.c', maybe we should rename it to an arch independent name, and implement the arm64 version (read_cntvct_el0 in patch 3) here.

If connect with your comment in patch 02, I think you are asking to consolidate for TSC common APIs and operations. I took time to review the codes for conversion between timer counter and time stamp, your suggestion is reasonable and feasible for me.

But the consolidation will impact the existed x86 implementation, before proceed to this direction for the next patch set, I'd like to get some review from x86's developers.

@PeterZ, could you take a look for this and let me know if you have any concern for the consolidation?

Quoted 2 lines

Thus we can also make the testcase generic,
instead of adding a new one for arm64 :).

Exactly. Will do this if we get agreement for consolidation.

Thanks for the reviewing,
Leo

author
#4 lore raw

PATCH v2 2/4 perf arm_arch_timer: Convert between counter and timestamp

In reply to Leo Yan

This patch introduces two new APIs, one is to calculate from converting counter to timestamp and provides a reverse flow to convert timestamp to counter.

---
 tools/perf/util/Build            |  1 +
 tools/perf/util/arm_arch_timer.c | 28 ++++++++++++++++++++++++++++
 tools/perf/util/arm_arch_timer.h |  3 +++
 3 files changed, 32 insertions(+)
 create mode 100644 tools/perf/util/arm_arch_timer.c
tools/perf/util/Build +1 -0
index 8d18380ecd10..ba504549844f 100644
@@ -101,6 +101,7 @@ perf-y += call-path.o
 perf-y += rwsem.o
 perf-y += thread-stack.o
 perf-y += spark.o
+perf-y += arm_arch_timer.o
 perf-$(CONFIG_AUXTRACE) += auxtrace.o
 perf-$(CONFIG_AUXTRACE) += intel-pt-decoder/
 perf-$(CONFIG_AUXTRACE) += intel-pt.o
tools/perf/util/arm_arch_timer.c new file +28 -0
new file mode 100644
index 000000000000..c37ffa4d9710
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/compiler.h>
+#include <linux/types.h>
+
+#include "arm_arch_timer.h"
+
+u64 perf_time_to_arch_timer_cyc(u64 ns, struct perf_arch_timer_conversion *tc)
+{
+	u64 t, quot, rem;
+
+	t = ns - tc->time_zero;
+	quot = t / tc->time_mult;
+	rem  = t % tc->time_mult;
+	return (quot << tc->time_shift) +
+	       (rem << tc->time_shift) / tc->time_mult;
+}
+
+u64 arch_timer_cyc_to_perf_time(u64 cyc, struct perf_arch_timer_conversion *tc)
+{
+	u64 quot, rem;
+
+	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 +
+	       ((rem * tc->time_mult) >> tc->time_shift);
+}
tools/perf/util/arm_arch_timer.h +3 -0
index a3263cc4e5cf..7d9271f544f2 100644
@@ -17,4 +17,7 @@ struct perf_event_mmap_page;
 int perf_read_arch_timer_conversion(const struct perf_event_mmap_page *pc,
 				    struct perf_arch_timer_conversion *tc);
 
+u64 arch_timer_cyc_to_perf_time(u64 cyc, struct perf_arch_timer_conversion *tc);
+u64 perf_time_to_arch_timer_cyc(u64 ns, struct perf_arch_timer_conversion *tc);
+
 #endif // __PERF_ARM_ARCH_TIMER_H
Signature · 1 line
2.17.1
#5 lore raw

Re: [PATCH v2 2/4] perf arm_arch_timer: Convert between counter and timestamp

Hi Leo,

Quoted 48 lines · Leo Yan

This patch introduces two new APIs, one is to calculate from converting counter to timestamp and provides a reverse flow to convert timestamp to counter.

---
 tools/perf/util/Build            |  1 +
 tools/perf/util/arm_arch_timer.c | 28 ++++++++++++++++++++++++++++
 tools/perf/util/arm_arch_timer.h |  3 +++
 3 files changed, 32 insertions(+)
 create mode 100644 tools/perf/util/arm_arch_timer.c
tools/perf/util/Build +1 -0
index 8d18380ecd10..ba504549844f 100644
@@ -101,6 +101,7 @@ perf-y += call-path.o
 perf-y += rwsem.o
 perf-y += thread-stack.o
 perf-y += spark.o
+perf-y += arm_arch_timer.o
 perf-$(CONFIG_AUXTRACE) += auxtrace.o
 perf-$(CONFIG_AUXTRACE) += intel-pt-decoder/
 perf-$(CONFIG_AUXTRACE) += intel-pt.o
tools/perf/util/arm_arch_timer.c new file +18 -0
new file mode 100644
index 000000000000..c37ffa4d9710
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/compiler.h>
+#include <linux/types.h>
+
+#include "arm_arch_timer.h"
+
+u64 perf_time_to_arch_timer_cyc(u64 ns, struct perf_arch_timer_conversion *tc)
+{
+	u64 t, quot, rem;
+
+	t = ns - tc->time_zero;
+	quot = t / tc->time_mult;
+	rem  = t % tc->time_mult;
+	return (quot << tc->time_shift) +
+	       (rem << tc->time_shift) / tc->time_mult;
+}
+
+u64 arch_timer_cyc_to_perf_time(u64 cyc, struct perf_arch_timer_conversion *tc)

tools/perf/util/arm_arch_timer.c line 28

Quoted 10 lines
tools/perf/util/arm_arch_timer.c new file +10 -0
+{
+	u64 quot, rem;
+
+	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 +
+	       ((rem * tc->time_mult) >> tc->time_shift);
+}

Can we merge these methods with 'tools/perf/util/tsc.c'? I think the converting between arch timestamp and the perf time should be arch independent. And in fact, we have built tsc_to_perf_time() into the perf on arm64. So maybe we can add cap_user_time_xxx into 'struct perf_tsc_conversion', then dispatch for different capabilities.

Thanks,
Wei

Quoted 13 lines
tools/perf/util/arm_arch_timer.h +3 -0
index a3263cc4e5cf..7d9271f544f2 100644
@@ -17,4 +17,7 @@ struct perf_event_mmap_page;
 int perf_read_arch_timer_conversion(const struct perf_event_mmap_page *pc,
 				    struct perf_arch_timer_conversion *tc);
 
+u64 arch_timer_cyc_to_perf_time(u64 cyc, struct perf_arch_timer_conversion *tc);
+u64 perf_time_to_arch_timer_cyc(u64 ns, struct perf_arch_timer_conversion *tc);
+
 #endif // __PERF_ARM_ARCH_TIMER_H
author
#6 lore raw

PATCH v2 3/4 perf arm_arch_timer: Test conversion between counter and timestamp

In reply to Leo Yan

x86 arch has provides the testing for conversion between tsc and perf time, this patch studies it and writes a similar testing for conversion between arch timer's counter and sample's time.

The testing approach firstly creates three time points:

Time point 1: 1st process's sample with perf time 'comm1_time'; Time point 2: read out arch timer counter 'test_arch_timer_cnt'; Time point 3: 2nd process's sample with perf time 'comm2_time';

The testing converts perf time to and from arch timer counter for these three values and the testing can pass only if the counter values and time values are in the order.

The test steps are as below:

  # perf test list
    [...]
    67: Convert perf time to arch timer counter
  # perf test 67 -v
    67: Convert perf time to arch timer counter
    --- start ---
    test child forked, pid 5463
    mmap size 528384B
    1st event perf time 2231755083020 arch timer cnt 113097053477
    test time           2231755087460 arch timer cnt 113097053699
    2nd event perf time 2231755090680 arch timer cnt 113097053860
    test child finished with 0
    ---- end ----
---
 tools/perf/arch/arm64/include/arch-tests.h    |   6 +
 tools/perf/arch/arm64/tests/Build             |   1 +
 tools/perf/arch/arm64/tests/arch-tests.c      |   4 +
 .../tests/perf-time-to-arch-timer-counter.c   | 189 ++++++++++++++++++
 4 files changed, 200 insertions(+)
 create mode 100644 tools/perf/arch/arm64/tests/perf-time-to-arch-timer-counter.c
tools/perf/arch/arm64/include/arch-tests.h +6 -0
index 90ec4c8cb880..12ad7592c9aa 100644
@@ -2,6 +2,12 @@
 #ifndef ARCH_TESTS_H
 #define ARCH_TESTS_H
 
+#include <linux/compiler.h>
+
+/* Tests */
+int test__perf_time_to_arch_timer_cnt(struct test *test __maybe_unused,
+				      int subtest __maybe_unused);
+
 #ifdef HAVE_DWARF_UNWIND_SUPPORT
 struct thread;
 struct perf_sample;
tools/perf/arch/arm64/tests/Build +1 -0
index a61c06bdb757..1fd819e4f80f 100644
@@ -2,3 +2,4 @@ perf-y += regs_load.o
 perf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o
 
 perf-y += arch-tests.o
+perf-y += perf-time-to-arch-timer-counter.o
tools/perf/arch/arm64/tests/arch-tests.c +4 -0
index 5b1543c98022..99d8ab865668 100644
@@ -4,6 +4,10 @@
 #include "arch-tests.h"
 
 struct test arch_tests[] = {
+	{
+		.desc = "Convert perf time to arch timer counter",
+		.func = test__perf_time_to_arch_timer_cnt,
+	},
 #ifdef HAVE_DWARF_UNWIND_SUPPORT
 	{
 		.desc = "DWARF unwind",
tools/perf/arch/arm64/tests/perf-time-to-arch-timer-counter.c new file +189 -0

189 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#7 lore raw

PATCH v2 4/4 perf arm-spe: Enable timestamp with arch timer counter

In reply to Leo Yan

Since the arch timer's counter is used for SPE tracing data, and now it's ready to use arch timer for sample's timestamp in Perf tool, this patch is to enable timestamp by convert the arch timer counter value to the time.

After enabling timestamp for Arm SPE with this patch, we can see the timestamp with 'time' field:

  $ perf script -F,+time
    dd  6799 [034] 25496.733475:          1              l1d-access:      ffff87f37b88 _dl_start+0x288 (/usr/lib/aarch64-linux-gnu/ld-2.28.so)
    dd  6799 [034] 25496.733475:          1              tlb-access:      ffff87f37b88 _dl_start+0x288 (/usr/lib/aarch64-linux-gnu/ld-2.28.so)
    dd  6799 [034] 25496.733479:          1              l1d-access:      ffff87f37c74 _dl_start+0x374 (/usr/lib/aarch64-linux-gnu/ld-2.28.so)
    dd  6799 [034] 25496.733479:          1              tlb-access:      ffff87f37c74 _dl_start+0x374 (/usr/lib/aarch64-linux-gnu/ld-2.28.so)
    dd  6799 [034] 25496.733485:          1              l1d-access:      ffff87f49af4 __GI___tunables_init+0x3c (/usr/lib/aarch64-linux-gnu/ld-2.28.so)
    dd  6799 [034] 25496.733485:          1              tlb-access:      ffff87f49af4 __GI___tunables_init+0x3c (/usr/lib/aarch64-linux-gnu/ld-2.28.so)
---
 tools/perf/arch/arm64/util/arm-spe.c | 17 +++++++++++++++++
 tools/perf/util/arm-spe.c            | 16 ++++++++++++++--
 tools/perf/util/arm-spe.h            |  5 +++++
 3 files changed, 36 insertions(+), 2 deletions(-)
tools/perf/arch/arm64/util/arm-spe.c +17 -0
index e3593063b3d1..a7cbd5fdb30e 100644
@@ -11,6 +11,7 @@
 #include <linux/zalloc.h>
 #include <time.h>
 
+#include "../../../util/arm_arch_timer.h"
 #include "../../../util/cpumap.h"
 #include "../../../util/event.h"
 #include "../../../util/evsel.h"
@@ -22,6 +23,7 @@
 #include "../../../util/auxtrace.h"
 #include "../../../util/record.h"
 #include "../../../util/arm-spe.h"
+#include "../../../util/mmap.h"
 
 #define KiB(x) ((x) * 1024)
 #define MiB(x) ((x) * 1024 * 1024)
@@ -47,6 +49,9 @@ static int arm_spe_info_fill(struct auxtrace_record *itr,
 	struct arm_spe_recording *sper =
 			container_of(itr, struct arm_spe_recording, itr);
 	struct perf_pmu *arm_spe_pmu = sper->arm_spe_pmu;
+	struct perf_event_mmap_page *pc;
+	struct perf_arch_timer_conversion tc = { 0 };
+	int err;
 
 	if (priv_size != ARM_SPE_AUXTRACE_PRIV_SIZE)
 		return -EINVAL;
@@ -54,8 +59,20 @@ static int arm_spe_info_fill(struct auxtrace_record *itr,
 	if (!session->evlist->core.nr_mmaps)
 		return -EINVAL;
 
+	pc = session->evlist->mmap[0].core.base;
+	if (pc) {
+		err = perf_read_arch_timer_conversion(pc, &tc);
+		if (err)
+			return err;
+	}
+
 	auxtrace_info->type = PERF_AUXTRACE_ARM_SPE;
 	auxtrace_info->priv[ARM_SPE_PMU_TYPE] = arm_spe_pmu->type;
+	auxtrace_info->priv[ARM_SPE_TIME_SHIFT] = tc.time_shift;
+	auxtrace_info->priv[ARM_SPE_TIME_MULT] = tc.time_mult;
+	auxtrace_info->priv[ARM_SPE_TIME_ZERO] = tc.time_zero;
+	auxtrace_info->priv[ARM_SPE_TIME_CYCLES] = tc.time_cycles;
+	auxtrace_info->priv[ARM_SPE_TIME_MASK] = tc.time_mask;
 
 	return 0;
 }
tools/perf/util/arm-spe.c +14 -2
index 3882a5360ada..07232664c927 100644
@@ -16,6 +16,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 
+#include "arm_arch_timer.h"
 #include "auxtrace.h"
 #include "color.h"
 #include "debug.h"
@@ -44,6 +45,7 @@ struct arm_spe {
 	struct perf_session		*session;
 	struct machine			*machine;
 	u32				pmu_type;
+	struct perf_arch_timer_conversion tc;
 
 	u8				timeless_decoding;
 	u8				data_queued;
@@ -229,7 +231,8 @@ static void arm_spe_prep_sample(struct arm_spe *spe,
 	struct arm_spe_record *record = &speq->decoder->record;
 
 	if (!spe->timeless_decoding)
-		sample->time = speq->timestamp;
+		sample->time = arch_timer_cyc_to_perf_time(speq->timestamp,
+							   &spe->tc);
 
 	sample->ip = record->from_ip;
 	sample->cpumode = arm_spe_cpumode(spe, sample->ip);
@@ -350,6 +353,7 @@ static int arm_spe_sample(struct arm_spe_queue *speq)
 static int arm_spe_run_decoder(struct arm_spe_queue *speq, u64 *timestamp)
 {
 	struct arm_spe *spe = speq->spe;
+	struct arm_spe_record *record;
 	int ret;
 
 	if (!spe->kernel_start)
@@ -369,6 +373,9 @@ static int arm_spe_run_decoder(struct arm_spe_queue *speq, u64 *timestamp)
 		if (ret < 0)
 			continue;
 
+		record = &speq->decoder->record;
+		speq->timestamp = record->timestamp;
+
 		ret = arm_spe_sample(speq);
 		if (ret)
 			return ret;
@@ -585,7 +592,7 @@ static int arm_spe_process_event(struct perf_session *session,
 	}
 
 	if (sample->time && (sample->time != (u64) -1))
-		timestamp = sample->time;
+		timestamp = perf_time_to_arch_timer_cyc(sample->time, &spe->tc);
 	else
 		timestamp = 0;
 
@@ -934,6 +941,11 @@ int arm_spe_process_auxtrace_info(union perf_event *event,
 	spe->machine = &session->machines.host; /* No kvm support */
 	spe->auxtrace_type = auxtrace_info->type;
 	spe->pmu_type = auxtrace_info->priv[ARM_SPE_PMU_TYPE];
+	spe->tc.time_shift = auxtrace_info->priv[ARM_SPE_TIME_SHIFT];
+	spe->tc.time_mult = auxtrace_info->priv[ARM_SPE_TIME_MULT];
+	spe->tc.time_zero = auxtrace_info->priv[ARM_SPE_TIME_ZERO];
+	spe->tc.time_cycles = auxtrace_info->priv[ARM_SPE_TIME_CYCLES];
+	spe->tc.time_mask = auxtrace_info->priv[ARM_SPE_TIME_MASK];
 
 	spe->timeless_decoding = arm_spe__is_timeless_decoding(spe);
 	spe->auxtrace.process_event = arm_spe_process_event;
tools/perf/util/arm-spe.h +5 -0
index 98d3235781c3..8baa32ad179d 100644
@@ -12,6 +12,11 @@
 enum {
 	ARM_SPE_PMU_TYPE,
 	ARM_SPE_PER_CPU_MMAPS,
+	ARM_SPE_TIME_SHIFT,
+	ARM_SPE_TIME_MULT,
+	ARM_SPE_TIME_ZERO,
+	ARM_SPE_TIME_CYCLES,
+	ARM_SPE_TIME_MASK,
 	ARM_SPE_AUXTRACE_PRIV_MAX,
 };
 
Signature · 1 line
2.17.1
#8 lore raw
In reply to Leo Yan

Hi Arnaldo,

Quoted 9 lines · Leo Yan

This patch set is to enable Arm arch timer counter and Arm SPE is the first customer to use arch timer counter for its timestamp.

Patches 01 ~ 03 enables Arm arch timer counter in Perf tool; patch 01 is to retrieve arch timer's parameters from mmaped page; patch 02 provides APIs for the conversion between arch timer's counter and time; patch 03 adds a test for patches 01 and 02.

Quoted 6 lines

As the first customer to use Arm arch timer counter in perf tool, patch 04 is to generate sample's timestamp for ARM SPE AUX trace data.

This patch set has been rebased on perf/core branch with the latest commit c4735d990268 ("perf evsel: Don't set sample_regs_intr/sample_regs_user for dummy event").

The ARM SPE perf tools code is orphan and I don't have the cycles to pick it up. Leo has spent a lot of time in that code and as such I suggest that he starts maintaining it, probably following the same kind of arrangement you and I have for coresight.

Thanks,
Mathieu

Quoted 56 lines

After changes:

  # perf test 67 -v
    67: Convert perf time to arch timer counter
    --- start ---
    test child forked, pid 5463
    mmap size 528384B
    1st event perf time 2231755083020 arch timer cnt 113097053477
    test time           2231755087460 arch timer cnt 113097053699
    2nd event perf time 2231755090680 arch timer cnt 113097053860
    test child finished with 0
    ---- end ----

Reports the SPE sample with timestamp:

  $ perf script -F,+time
    dd  6799 [034] 25496.733475:          1              l1d-access:      ffff87f37b88 _dl_start+0x288 (/usr/lib/aarch64-linux-gnu/ld-2.28.so)
    dd  6799 [034] 25496.733475:          1              tlb-access:      ffff87f37b88 _dl_start+0x288 (/usr/lib/aarch64-linux-gnu/ld-2.28.so)
    dd  6799 [034] 25496.733479:          1              l1d-access:      ffff87f37c74 _dl_start+0x374 (/usr/lib/aarch64-linux-gnu/ld-2.28.so)
    dd  6799 [034] 25496.733479:          1              tlb-access:      ffff87f37c74 _dl_start+0x374 (/usr/lib/aarch64-linux-gnu/ld-2.28.so)
    dd  6799 [034] 25496.733485:          1              l1d-access:      ffff87f49af4 __GI___tunables_init+0x3c (/usr/lib/aarch64-linux-gnu/ld-2.28.so)
    dd  6799 [034] 25496.733485:          1              tlb-access:      ffff87f49af4 __GI___tunables_init+0x3c (/usr/lib/aarch64-linux-gnu/ld-2.28.so)

Changes from v1:
* Rebased on the latest perf/core branch;
* Added a testing for Arm timer counter conversion (Ian Rogers).

Leo Yan (4):
perf tools: Support Arm arch timer counter
perf arm_arch_timer: Convert between counter and timestamp perf arm_arch_timer: Test conversion between counter and timestamp perf arm-spe: Enable timestamp with arch timer counter

 tools/perf/arch/arm64/include/arch-tests.h    |   6 +
 tools/perf/arch/arm64/tests/Build             |   1 +
 tools/perf/arch/arm64/tests/arch-tests.c      |   4 +
 .../tests/perf-time-to-arch-timer-counter.c   | 189 ++++++++++++++++++
 tools/perf/arch/arm64/util/Build              |   1 +
 tools/perf/arch/arm64/util/arch_timer.c       |  50 +++++
 tools/perf/arch/arm64/util/arm-spe.c          |  17 ++
 tools/perf/util/Build                         |   1 +
 tools/perf/util/arm-spe.c                     |  16 +-
 tools/perf/util/arm-spe.h                     |   5 +
 tools/perf/util/arm_arch_timer.c              |  28 +++
 tools/perf/util/arm_arch_timer.h              |  23 +++
 12 files changed, 339 insertions(+), 2 deletions(-)
 create mode 100644 tools/perf/arch/arm64/tests/perf-time-to-arch-timer-counter.c
 create mode 100644 tools/perf/arch/arm64/util/arch_timer.c
 create mode 100644 tools/perf/util/arm_arch_timer.c
 create mode 100644 tools/perf/util/arm_arch_timer.h

--
2.17.1

#9 lore raw

Em Wed, Aug 12, 2020 at 10:06:53AM -0600, Mathieu Poirier escreveu:

Quoted 15 lines

Hi Arnaldo,

Quoted 12 lines · Leo Yan

This patch set is to enable Arm arch timer counter and Arm SPE is the first customer to use arch timer counter for its timestamp.

Patches 01 ~ 03 enables Arm arch timer counter in Perf tool; patch 01 is to retrieve arch timer's parameters from mmaped page; patch 02 provides APIs for the conversion between arch timer's counter and time; patch 03 adds a test for patches 01 and 02.

As the first customer to use Arm arch timer counter in perf tool, patch 04 is to generate sample's timestamp for ARM SPE AUX trace data.

Quoted 8 lines
Quoted 3 lines

This patch set has been rebased on perf/core branch with the latest commit c4735d990268 ("perf evsel: Don't set sample_regs_intr/sample_regs_user for dummy event").

The ARM SPE perf tools code is orphan and I don't have the cycles to pick it up. Leo has spent a lot of time in that code and as such I suggest that he starts maintaining it, probably following the same kind of arrangement you and I have for coresight.

Thats ok with me, I think we should reflect that on the MAINTAINERS file, right?

We have this already:

PERFORMANCE EVENTS SUBSYSTEM ARM64 PMU EVENTS

R:      John Garry <[email protected]>
R:      Will Deacon <[email protected]>
L:      [email protected] (moderated for non-subscribers)
S:      Supported
F:      tools/perf/pmu-events/arch/arm64/

I think we should have entries for CoreSight and ARM SPE, one listing you as the maintainer and the other listing Leo, right?

Leo, it would be good for you to try and find someone at your organization or elsewhere that could help with this, this way I would wait a bit, see if someone else Acks it, and collect those, processing it from you after a while if nobody chimes in.

Please continue providing 'perf test' regression tests, etc, to help with maintaining this code being checked.

- Arnaldo

Quoted 59 lines

Thanks,
Mathieu

Quoted 56 lines

After changes:

  # perf test 67 -v
    67: Convert perf time to arch timer counter
    --- start ---
    test child forked, pid 5463
    mmap size 528384B
    1st event perf time 2231755083020 arch timer cnt 113097053477
    test time           2231755087460 arch timer cnt 113097053699
    2nd event perf time 2231755090680 arch timer cnt 113097053860
    test child finished with 0
    ---- end ----

Reports the SPE sample with timestamp:

  $ perf script -F,+time
    dd  6799 [034] 25496.733475:          1              l1d-access:      ffff87f37b88 _dl_start+0x288 (/usr/lib/aarch64-linux-gnu/ld-2.28.so)
    dd  6799 [034] 25496.733475:          1              tlb-access:      ffff87f37b88 _dl_start+0x288 (/usr/lib/aarch64-linux-gnu/ld-2.28.so)
    dd  6799 [034] 25496.733479:          1              l1d-access:      ffff87f37c74 _dl_start+0x374 (/usr/lib/aarch64-linux-gnu/ld-2.28.so)
    dd  6799 [034] 25496.733479:          1              tlb-access:      ffff87f37c74 _dl_start+0x374 (/usr/lib/aarch64-linux-gnu/ld-2.28.so)
    dd  6799 [034] 25496.733485:          1              l1d-access:      ffff87f49af4 __GI___tunables_init+0x3c (/usr/lib/aarch64-linux-gnu/ld-2.28.so)
    dd  6799 [034] 25496.733485:          1              tlb-access:      ffff87f49af4 __GI___tunables_init+0x3c (/usr/lib/aarch64-linux-gnu/ld-2.28.so)

Changes from v1:
* Rebased on the latest perf/core branch;
* Added a testing for Arm timer counter conversion (Ian Rogers).

Leo Yan (4):
perf tools: Support Arm arch timer counter
perf arm_arch_timer: Convert between counter and timestamp perf arm_arch_timer: Test conversion between counter and timestamp perf arm-spe: Enable timestamp with arch timer counter

 tools/perf/arch/arm64/include/arch-tests.h    |   6 +
 tools/perf/arch/arm64/tests/Build             |   1 +
 tools/perf/arch/arm64/tests/arch-tests.c      |   4 +
 .../tests/perf-time-to-arch-timer-counter.c   | 189 ++++++++++++++++++
 tools/perf/arch/arm64/util/Build              |   1 +
 tools/perf/arch/arm64/util/arch_timer.c       |  50 +++++
 tools/perf/arch/arm64/util/arm-spe.c          |  17 ++
 tools/perf/util/Build                         |   1 +
 tools/perf/util/arm-spe.c                     |  16 +-
 tools/perf/util/arm-spe.h                     |   5 +
 tools/perf/util/arm_arch_timer.c              |  28 +++
 tools/perf/util/arm_arch_timer.h              |  23 +++
 12 files changed, 339 insertions(+), 2 deletions(-)
 create mode 100644 tools/perf/arch/arm64/tests/perf-time-to-arch-timer-counter.c
 create mode 100644 tools/perf/arch/arm64/util/arch_timer.c
 create mode 100644 tools/perf/util/arm_arch_timer.c
 create mode 100644 tools/perf/util/arm_arch_timer.h

--
2.17.1

Signature · 1 line
- Arnaldo
author
#10 lore raw
Quoted 20 lines · Arnaldo Carvalho de Melo

Em Wed, Aug 12, 2020 at 10:06:53AM -0600, Mathieu Poirier escreveu:

Quoted 19 lines

Hi Arnaldo,

Quoted 15 lines · Leo Yan

This patch set is to enable Arm arch timer counter and Arm SPE is the first customer to use arch timer counter for its timestamp.

Patches 01 ~ 03 enables Arm arch timer counter in Perf tool; patch 01 is to retrieve arch timer's parameters from mmaped page; patch 02 provides APIs for the conversion between arch timer's counter and time; patch 03 adds a test for patches 01 and 02.

As the first customer to use Arm arch timer counter in perf tool, patch 04 is to generate sample's timestamp for ARM SPE AUX trace data.

This patch set has been rebased on perf/core branch with the latest commit c4735d990268 ("perf evsel: Don't set sample_regs_intr/sample_regs_user for dummy event").

Quoted 7 lines
Quoted 4 lines

The ARM SPE perf tools code is orphan and I don't have the cycles to pick it up. Leo has spent a lot of time in that code and as such I suggest that he starts maintaining it, probably following the same kind of arrangement you and I have for coresight.

Thats ok with me, I think we should reflect that on the MAINTAINERS file, right?

Very appreciate for the promoting, Mathieu and Arnaldo.

Quoted 9 lines

We have this already:

PERFORMANCE EVENTS SUBSYSTEM ARM64 PMU EVENTS

R:      John Garry <[email protected]>
R:      Will Deacon <[email protected]>
L:      [email protected] (moderated for non-subscribers)
S:      Supported
F:      tools/perf/pmu-events/arch/arm64/
Quoted 7 lines

I think we should have entries for CoreSight and ARM SPE, one listing you as the maintainer and the other listing Leo, right?

Leo, it would be good for you to try and find someone at your organization or elsewhere that could help with this, this way I would wait a bit, see if someone else Acks it, and collect those, processing it from you after a while if nobody chimes in.

I will follow up this and might offline to check with relevant maintainers (Will and John) for what's good way to proceed.

Quoted 2 lines

Please continue providing 'perf test' regression tests, etc, to help with maintaining this code being checked.

Sure, I'm glad to continue the maintaining and testing works :)

Thanks,
Leo

reviewer
#11 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 29 lines · Arnaldo Carvalho de Melo

Em Wed, Aug 12, 2020 at 10:06:53AM -0600, Mathieu Poirier escreveu:

Quoted 13 lines · Leo Yan
Quoted 12 lines

This patch set is to enable Arm arch timer counter and Arm SPE is the first customer to use arch timer counter for its timestamp.

Patches 01 ~ 03 enables Arm arch timer counter in Perf tool; patch 01 is to retrieve arch timer's parameters from mmaped page; patch 02 provides APIs for the conversion between arch timer's counter and time; patch 03 adds a test for patches 01 and 02.

As the first customer to use Arm arch timer counter in perf tool, patch 04 is to generate sample's timestamp for ARM SPE AUX trace data.

Quoted 8 lines
Quoted 3 lines

This patch set has been rebased on perf/core branch with the latest commit c4735d990268 ("perf evsel: Don't set sample_regs_intr/sample_regs_user for dummy event").

The ARM SPE perf tools code is orphan and I don't have the cycles to pick it up. Leo has spent a lot of time in that code and as such I suggest that he starts maintaining it, probably following the same kind of arrangement you and I have for coresight.

Thats ok with me, I think we should reflect that on the MAINTAINERS file, right?

We have this already:

PERFORMANCE EVENTS SUBSYSTEM ARM64 PMU EVENTS

Quoted 8 lines
R:      John Garry <[email protected]>
R:      Will Deacon <[email protected]>
L:      [email protected] (moderated for non-subscribers)
S:      Supported
F:      tools/perf/pmu-events/arch/arm64/

I think we should have entries for CoreSight and ARM SPE, one listing you as the maintainer and the other listing Leo, right?

Fine by me. I'll continue to maintain the in-kernel SPE driver, but I'd love to see somebody step up to looking after the userspace code. It's seriously unloved on arm64 :(

I'd even be happy to see one or two M: entries added for tools/perf/pmu-events/arch/arm64/. I realistically don't have the time to take that on, but I'd be thrilled if any/all of John, Mathieu and Leo were to be listed there if they are willing to do so and can spare the time to look after it. Even just silly things like making sure the thing cross-compiles have been broken in the recent past, so it's not necessarily about handling huge amounts of incoming patches.

In other words, rather than slice up the arm64 parts of the perf tool, I'd argue in favour of a joint maintainership model for all the arm64 bits, if we have a few willing volunteers.

Will

reviewer
#12 lore raw

[ Adding John, as I only just realised he wasn't on CC and we were talking
about him! ]

Quoted 39 lines · Will Deacon
Quoted 12 lines · Arnaldo Carvalho de Melo

Em Wed, Aug 12, 2020 at 10:06:53AM -0600, Mathieu Poirier escreveu:

Quoted 4 lines

The ARM SPE perf tools code is orphan and I don't have the cycles to pick it up. Leo has spent a lot of time in that code and as such I suggest that he starts maintaining it, probably following the same kind of arrangement you and I have for coresight.

Thats ok with me, I think we should reflect that on the MAINTAINERS file, right?

We have this already:

PERFORMANCE EVENTS SUBSYSTEM ARM64 PMU EVENTS

Quoted 8 lines
R:      John Garry <[email protected]>
R:      Will Deacon <[email protected]>
L:      [email protected] (moderated for non-subscribers)
S:      Supported
F:      tools/perf/pmu-events/arch/arm64/

I think we should have entries for CoreSight and ARM SPE, one listing you as the maintainer and the other listing Leo, right?

Fine by me. I'll continue to maintain the in-kernel SPE driver, but I'd love to see somebody step up to looking after the userspace code. It's seriously unloved on arm64 :(

I'd even be happy to see one or two M: entries added for tools/perf/pmu-events/arch/arm64/. I realistically don't have the time to take that on, but I'd be thrilled if any/all of John, Mathieu and Leo were to be listed there if they are willing to do so and can spare the time to look after it. Even just silly things like making sure the thing cross-compiles have been broken in the recent past, so it's not necessarily about handling huge amounts of incoming patches.

In other words, rather than slice up the arm64 parts of the perf tool, I'd argue in favour of a joint maintainership model for all the arm64 bits, if we have a few willing volunteers.

Will

#13 lore raw
Quoted 41 lines · Will Deacon

[ Adding John, as I only just realised he wasn't on CC and we were talking
about him! ]

Quoted 37 lines · Will Deacon
Quoted 12 lines · Arnaldo Carvalho de Melo

Em Wed, Aug 12, 2020 at 10:06:53AM -0600, Mathieu Poirier escreveu:

Quoted 4 lines

The ARM SPE perf tools code is orphan and I don't have the cycles to pick it up. Leo has spent a lot of time in that code and as such I suggest that he starts maintaining it, probably following the same kind of arrangement you and I have for coresight.

Thats ok with me, I think we should reflect that on the MAINTAINERS file, right?

We have this already:

PERFORMANCE EVENTS SUBSYSTEM ARM64 PMU EVENTS

Quoted 8 lines
R:      John Garry <[email protected]>
R:      Will Deacon <[email protected]>
L:      [email protected] (moderated for non-subscribers)
S:      Supported
F:      tools/perf/pmu-events/arch/arm64/

I think we should have entries for CoreSight and ARM SPE, one listing you as the maintainer and the other listing Leo, right?

Fine by me. I'll continue to maintain the in-kernel SPE driver, but I'd love to see somebody step up to looking after the userspace code. It's seriously unloved on arm64 :(

I'd even be happy to see one or two M: entries added for tools/perf/pmu-events/arch/arm64/. I realistically don't have the time to take that on, but I'd be thrilled if any/all of John, Mathieu and Leo were to be listed there if they are willing to do so and can spare the time to look after it. Even just silly things like making sure the thing cross-compiles have been broken in the recent past, so it's not necessarily about handling huge amounts of incoming patches.

In other words, rather than slice up the arm64 parts of the perf tool, I'd argue in favour of a joint maintainership model for all the arm64 bits, if we have a few willing volunteers.

Right, it makes sense not to chop up too much, so happy to see "PERFORMANCE EVENTS SUBSYSTEM ARM64 PMU EVENTS" expanded in terms of scope and membership.

#14 lore raw

Em Thu, Aug 13, 2020 at 01:08:02PM +0100, John Garry escreveu:

Quoted 39 lines · Will Deacon
Quoted 38 lines

[ Adding John, as I only just realised he wasn't on CC and we were talking
about him! ]

Quoted 34 lines · Will Deacon
Quoted 12 lines · Arnaldo Carvalho de Melo

Em Wed, Aug 12, 2020 at 10:06:53AM -0600, Mathieu Poirier escreveu:

Quoted 4 lines

The ARM SPE perf tools code is orphan and I don't have the cycles to pick it up. Leo has spent a lot of time in that code and as such I suggest that he starts maintaining it, probably following the same kind of arrangement you and I have for coresight.

Thats ok with me, I think we should reflect that on the MAINTAINERS file, right?

We have this already:

PERFORMANCE EVENTS SUBSYSTEM ARM64 PMU EVENTS

Quoted 8 lines
R:      John Garry <[email protected]>
R:      Will Deacon <[email protected]>
L:      [email protected] (moderated for non-subscribers)
S:      Supported
F:      tools/perf/pmu-events/arch/arm64/

I think we should have entries for CoreSight and ARM SPE, one listing you as the maintainer and the other listing Leo, right?

Fine by me. I'll continue to maintain the in-kernel SPE driver, but I'd love to see somebody step up to looking after the userspace code. It's seriously unloved on arm64 :(

I'd even be happy to see one or two M: entries added for tools/perf/pmu-events/arch/arm64/. I realistically don't have the time to take that on, but I'd be thrilled if any/all of John, Mathieu and Leo were to be listed there if they are willing to do so and can spare the time to look after it. Even just silly things like making sure the thing cross-compiles have been broken in the recent past, so it's not necessarily about handling huge amounts of incoming patches.

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

In other words, rather than slice up the arm64 parts of the perf tool, I'd argue in favour of a joint maintainership model for all the arm64 bits, if we have a few willing volunteers.

Right, it makes sense not to chop up too much, so happy to see "PERFORMANCE EVENTS SUBSYSTEM ARM64 PMU EVENTS" expanded in terms of scope and membership.

Discuss this as long as you need and then send me a patch for the MAINTAINERS file with your conclusion.

Great to see this happening,

- Arnaldo

#15 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 21 lines · Arnaldo Carvalho de Melo

Em Wed, Aug 12, 2020 at 10:06:53AM -0600, Mathieu Poirier escreveu:

Quoted 19 lines

Hi Arnaldo,

Quoted 15 lines · Leo Yan

This patch set is to enable Arm arch timer counter and Arm SPE is the first customer to use arch timer counter for its timestamp.

Patches 01 ~ 03 enables Arm arch timer counter in Perf tool; patch 01 is to retrieve arch timer's parameters from mmaped page; patch 02 provides APIs for the conversion between arch timer's counter and time; patch 03 adds a test for patches 01 and 02.

As the first customer to use Arm arch timer counter in perf tool, patch 04 is to generate sample's timestamp for ARM SPE AUX trace data.

This patch set has been rebased on perf/core branch with the latest commit c4735d990268 ("perf evsel: Don't set sample_regs_intr/sample_regs_user for dummy event").

Quoted 8 lines
Quoted 4 lines

The ARM SPE perf tools code is orphan and I don't have the cycles to pick it up. Leo has spent a lot of time in that code and as such I suggest that he starts maintaining it, probably following the same kind of arrangement you and I have for coresight.

Thats ok with me, I think we should reflect that on the MAINTAINERS file, right?

I agree, it is time to sort out this part.

Quoted 12 lines

We have this already:

PERFORMANCE EVENTS SUBSYSTEM ARM64 PMU EVENTS

R:      John Garry <[email protected]>
R:      Will Deacon <[email protected]>
L:      [email protected] (moderated for non-subscribers)
S:      Supported
F:      tools/perf/pmu-events/arch/arm64/

I think we should have entries for CoreSight and ARM SPE, one listing you as the maintainer and the other listing Leo, right?

Yes - I'll send you a patch for that once v5.9-rc1 comes out (unless you want it now).

Quoted 5 lines

Leo, it would be good for you to try and find someone at your organization or elsewhere that could help with this, this way I would wait a bit, see if someone else Acks it, and collect those, processing it from you after a while if nobody chimes in.

Right, the same kind of arrangement you and I have for coresight. So far this has worked quite well and I don't see a need to proceed differently.

Quoted 2 lines

Please continue providing 'perf test' regression tests, etc, to help with maintaining this code being checked.

Those are quite useful.

Quoted 66 lines

- Arnaldo

Quoted 59 lines

Thanks,
Mathieu

Quoted 56 lines

After changes:

  # perf test 67 -v
    67: Convert perf time to arch timer counter
    --- start ---
    test child forked, pid 5463
    mmap size 528384B
    1st event perf time 2231755083020 arch timer cnt 113097053477
    test time           2231755087460 arch timer cnt 113097053699
    2nd event perf time 2231755090680 arch timer cnt 113097053860
    test child finished with 0
    ---- end ----

Reports the SPE sample with timestamp:

  $ perf script -F,+time
    dd  6799 [034] 25496.733475:          1              l1d-access:      ffff87f37b88 _dl_start+0x288 (/usr/lib/aarch64-linux-gnu/ld-2.28.so)
    dd  6799 [034] 25496.733475:          1              tlb-access:      ffff87f37b88 _dl_start+0x288 (/usr/lib/aarch64-linux-gnu/ld-2.28.so)
    dd  6799 [034] 25496.733479:          1              l1d-access:      ffff87f37c74 _dl_start+0x374 (/usr/lib/aarch64-linux-gnu/ld-2.28.so)
    dd  6799 [034] 25496.733479:          1              tlb-access:      ffff87f37c74 _dl_start+0x374 (/usr/lib/aarch64-linux-gnu/ld-2.28.so)
    dd  6799 [034] 25496.733485:          1              l1d-access:      ffff87f49af4 __GI___tunables_init+0x3c (/usr/lib/aarch64-linux-gnu/ld-2.28.so)
    dd  6799 [034] 25496.733485:          1              tlb-access:      ffff87f49af4 __GI___tunables_init+0x3c (/usr/lib/aarch64-linux-gnu/ld-2.28.so)

Changes from v1:
* Rebased on the latest perf/core branch;
* Added a testing for Arm timer counter conversion (Ian Rogers).

Leo Yan (4):
perf tools: Support Arm arch timer counter
perf arm_arch_timer: Convert between counter and timestamp perf arm_arch_timer: Test conversion between counter and timestamp perf arm-spe: Enable timestamp with arch timer counter

 tools/perf/arch/arm64/include/arch-tests.h    |   6 +
 tools/perf/arch/arm64/tests/Build             |   1 +
 tools/perf/arch/arm64/tests/arch-tests.c      |   4 +
 .../tests/perf-time-to-arch-timer-counter.c   | 189 ++++++++++++++++++
 tools/perf/arch/arm64/util/Build              |   1 +
 tools/perf/arch/arm64/util/arch_timer.c       |  50 +++++
 tools/perf/arch/arm64/util/arm-spe.c          |  17 ++
 tools/perf/util/Build                         |   1 +
 tools/perf/util/arm-spe.c                     |  16 +-
 tools/perf/util/arm-spe.h                     |   5 +
 tools/perf/util/arm_arch_timer.c              |  28 +++
 tools/perf/util/arm_arch_timer.h              |  23 +++
 12 files changed, 339 insertions(+), 2 deletions(-)
 create mode 100644 tools/perf/arch/arm64/tests/perf-time-to-arch-timer-counter.c
 create mode 100644 tools/perf/arch/arm64/util/arch_timer.c
 create mode 100644 tools/perf/util/arm_arch_timer.c
 create mode 100644 tools/perf/util/arm_arch_timer.h

--
2.17.1

--

- Arnaldo