linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/3] Perf tool: Enable Arm arch timer counter and arm-spe's timestamp
@ 2020-07-15  2:33 Leo Yan
  2020-07-15  2:33 ` [PATCH v1 1/3] perf tools: Support Arm arch timer counter Leo Yan
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Leo Yan @ 2020-07-15  2:33 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Mark Rutland, Peter Zijlstra,
	Ingo Molnar, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Kemeng Shi, Nick Desaulniers, Ian Rogers, Mathieu Poirier,
	Adrian Hunter, Igor Lubashev, Andi Kleen, Jin Yao, James Clark,
	linux-kernel
  Cc: 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.

The 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 is to enable timestamp based on the new introduced
APIs for timestamp related calculation.

Note, this patch set is depend on the kernel changes for "arm64: perf:
Proper cap_user_time* support" [1].

This patch set has been rebased on mainline kernel with the latest
commit 11ba468877bb ("Linux 5.8-rc5") and also applied on top of patch
set [1].  After enabling the timestamp, the samples can show the
timestamp, and the timestamp is consistent with the kernel's timestamp
by checking the kernel log:

  $ 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)

[1] https://patchwork.kernel.org/project/linux-arm-kernel/list/?series=318401


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

 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 ++++++++++++
 8 files changed, 139 insertions(+), 2 deletions(-)
 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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v1 1/3] perf tools: Support Arm arch timer counter
  2020-07-15  2:33 [PATCH v1 0/3] Perf tool: Enable Arm arch timer counter and arm-spe's timestamp Leo Yan
@ 2020-07-15  2:33 ` Leo Yan
  2020-07-15  2:34 ` [PATCH v1 2/3] perf arm_arch_timer: Convert between counter and timestamp Leo Yan
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Leo Yan @ 2020-07-15  2:33 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Mark Rutland, Peter Zijlstra,
	Ingo Molnar, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Kemeng Shi, Nick Desaulniers, Ian Rogers, Mathieu Poirier,
	Adrian Hunter, Igor Lubashev, Andi Kleen, Jin Yao, James Clark,
	linux-kernel
  Cc: 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.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
 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

diff --git a/tools/perf/arch/arm64/util/Build b/tools/perf/arch/arm64/util/Build
index 5c13438c7bd4..77f4d7b30932 100644
--- a/tools/perf/arch/arm64/util/Build
+++ b/tools/perf/arch/arm64/util/Build
@@ -1,3 +1,4 @@
+perf-y += arch_timer.o
 perf-y += header.o
 perf-y += machine.o
 perf-y += perf_regs.o
diff --git a/tools/perf/arch/arm64/util/arch_timer.c b/tools/perf/arch/arm64/util/arch_timer.c
new file mode 100644
index 000000000000..dcc217c294fc
--- /dev/null
+++ b/tools/perf/arch/arm64/util/arch_timer.c
@@ -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",
+				 __func__);
+			return -EINVAL;
+		}
+	}
+
+	if (!cap_user_time_zero || !cap_user_time_short)
+		return -EOPNOTSUPP;
+
+	return 0;
+}
diff --git a/tools/perf/util/arm_arch_timer.h b/tools/perf/util/arm_arch_timer.h
new file mode 100644
index 000000000000..a3263cc4e5cf
--- /dev/null
+++ b/tools/perf/util/arm_arch_timer.h
@@ -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
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v1 2/3] perf arm_arch_timer: Convert between counter and timestamp
  2020-07-15  2:33 [PATCH v1 0/3] Perf tool: Enable Arm arch timer counter and arm-spe's timestamp Leo Yan
  2020-07-15  2:33 ` [PATCH v1 1/3] perf tools: Support Arm arch timer counter Leo Yan
@ 2020-07-15  2:34 ` Leo Yan
  2020-07-15  2:34 ` [PATCH v1 3/3] perf arm-spe: Enable timestamp with arch timer counter Leo Yan
  2020-07-15 16:31 ` [PATCH v1 0/3] Perf tool: Enable Arm arch timer counter and arm-spe's timestamp Ian Rogers
  3 siblings, 0 replies; 6+ messages in thread
From: Leo Yan @ 2020-07-15  2:34 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Mark Rutland, Peter Zijlstra,
	Ingo Molnar, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Kemeng Shi, Nick Desaulniers, Ian Rogers, Mathieu Poirier,
	Adrian Hunter, Igor Lubashev, Andi Kleen, Jin Yao, James Clark,
	linux-kernel
  Cc: 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.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
 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

diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 8d18380ecd10..ba504549844f 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -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
diff --git a/tools/perf/util/arm_arch_timer.c b/tools/perf/util/arm_arch_timer.c
new file mode 100644
index 000000000000..c37ffa4d9710
--- /dev/null
+++ b/tools/perf/util/arm_arch_timer.c
@@ -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);
+}
diff --git a/tools/perf/util/arm_arch_timer.h b/tools/perf/util/arm_arch_timer.h
index a3263cc4e5cf..7d9271f544f2 100644
--- a/tools/perf/util/arm_arch_timer.h
+++ b/tools/perf/util/arm_arch_timer.h
@@ -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
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v1 3/3] perf arm-spe: Enable timestamp with arch timer counter
  2020-07-15  2:33 [PATCH v1 0/3] Perf tool: Enable Arm arch timer counter and arm-spe's timestamp Leo Yan
  2020-07-15  2:33 ` [PATCH v1 1/3] perf tools: Support Arm arch timer counter Leo Yan
  2020-07-15  2:34 ` [PATCH v1 2/3] perf arm_arch_timer: Convert between counter and timestamp Leo Yan
@ 2020-07-15  2:34 ` Leo Yan
  2020-07-15 16:31 ` [PATCH v1 0/3] Perf tool: Enable Arm arch timer counter and arm-spe's timestamp Ian Rogers
  3 siblings, 0 replies; 6+ messages in thread
From: Leo Yan @ 2020-07-15  2:34 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Mark Rutland, Peter Zijlstra,
	Ingo Molnar, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Kemeng Shi, Nick Desaulniers, Ian Rogers, Mathieu Poirier,
	Adrian Hunter, Igor Lubashev, Andi Kleen, Jin Yao, James Clark,
	linux-kernel
  Cc: 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)

Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
 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(-)

diff --git a/tools/perf/arch/arm64/util/arm-spe.c b/tools/perf/arch/arm64/util/arm-spe.c
index e3593063b3d1..a7cbd5fdb30e 100644
--- a/tools/perf/arch/arm64/util/arm-spe.c
+++ b/tools/perf/arch/arm64/util/arm-spe.c
@@ -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;
 }
diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c
index 3882a5360ada..07232664c927 100644
--- a/tools/perf/util/arm-spe.c
+++ b/tools/perf/util/arm-spe.c
@@ -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;
diff --git a/tools/perf/util/arm-spe.h b/tools/perf/util/arm-spe.h
index 98d3235781c3..8baa32ad179d 100644
--- a/tools/perf/util/arm-spe.h
+++ b/tools/perf/util/arm-spe.h
@@ -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,
 };
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 0/3] Perf tool: Enable Arm arch timer counter and arm-spe's timestamp
  2020-07-15  2:33 [PATCH v1 0/3] Perf tool: Enable Arm arch timer counter and arm-spe's timestamp Leo Yan
                   ` (2 preceding siblings ...)
  2020-07-15  2:34 ` [PATCH v1 3/3] perf arm-spe: Enable timestamp with arch timer counter Leo Yan
@ 2020-07-15 16:31 ` Ian Rogers
  2020-07-16  1:17   ` Leo Yan
  3 siblings, 1 reply; 6+ messages in thread
From: Ian Rogers @ 2020-07-15 16:31 UTC (permalink / raw)
  To: Leo Yan
  Cc: Arnaldo Carvalho de Melo, Mark Rutland, Peter Zijlstra,
	Ingo Molnar, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Kemeng Shi, Nick Desaulniers, Mathieu Poirier, Adrian Hunter,
	Igor Lubashev, Andi Kleen, Jin Yao, James Clark, LKML

On Tue, Jul 14, 2020 at 7:34 PM Leo Yan <leo.yan@linaro.org> wrote:
>
> 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.
>
> The 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 is to enable timestamp based on the new introduced
> APIs for timestamp related calculation.
>
> Note, this patch set is depend on the kernel changes for "arm64: perf:
> Proper cap_user_time* support" [1].
>
> This patch set has been rebased on mainline kernel with the latest
> commit 11ba468877bb ("Linux 5.8-rc5") and also applied on top of patch
> set [1].  After enabling the timestamp, the samples can show the
> timestamp, and the timestamp is consistent with the kernel's timestamp
> by checking the kernel log:
>
>   $ 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)
>
> [1] https://patchwork.kernel.org/project/linux-arm-kernel/list/?series=318401

This looks good to me! Would it be possible to add a test on the
functionality? It's possible to add a C test in
tools/perf/arch/arm64/tests or something related to you perf script
command line in tools/perf/tests/shell.

Thanks,
Ian

> Leo Yan (3):
>   perf tools: Support Arm arch timer counter
>   perf arm_arch_timer: Convert between counter and timestamp
>   perf arm-spe: Enable timestamp with arch timer counter
>
>  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 ++++++++++++
>  8 files changed, 139 insertions(+), 2 deletions(-)
>  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
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 0/3] Perf tool: Enable Arm arch timer counter and arm-spe's timestamp
  2020-07-15 16:31 ` [PATCH v1 0/3] Perf tool: Enable Arm arch timer counter and arm-spe's timestamp Ian Rogers
@ 2020-07-16  1:17   ` Leo Yan
  0 siblings, 0 replies; 6+ messages in thread
From: Leo Yan @ 2020-07-16  1:17 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Arnaldo Carvalho de Melo, Mark Rutland, Peter Zijlstra,
	Ingo Molnar, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Kemeng Shi, Nick Desaulniers, Mathieu Poirier, Adrian Hunter,
	Igor Lubashev, Andi Kleen, Jin Yao, James Clark, LKML

Hi Ian,

On Wed, Jul 15, 2020 at 09:31:14AM -0700, Ian Rogers wrote:
> On Tue, Jul 14, 2020 at 7:34 PM Leo Yan <leo.yan@linaro.org> wrote:
> >
> > 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.
> >
> > The 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 is to enable timestamp based on the new introduced
> > APIs for timestamp related calculation.
> >
> > Note, this patch set is depend on the kernel changes for "arm64: perf:
> > Proper cap_user_time* support" [1].
> >
> > This patch set has been rebased on mainline kernel with the latest
> > commit 11ba468877bb ("Linux 5.8-rc5") and also applied on top of patch
> > set [1].  After enabling the timestamp, the samples can show the
> > timestamp, and the timestamp is consistent with the kernel's timestamp
> > by checking the kernel log:
> >
> >   $ 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)
> >
> > [1] https://patchwork.kernel.org/project/linux-arm-kernel/list/?series=318401
> 
> This looks good to me! Would it be possible to add a test on the
> functionality? It's possible to add a C test in
> tools/perf/arch/arm64/tests or something related to you perf script
> command line in tools/perf/tests/shell.

Yeah, will look into testing and it's good add two testing cases,
one is for arch timer testing in C, another is for SPE testing
with shell script.

Thanks for suggestions,
Leo

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-07-16  1:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-15  2:33 [PATCH v1 0/3] Perf tool: Enable Arm arch timer counter and arm-spe's timestamp Leo Yan
2020-07-15  2:33 ` [PATCH v1 1/3] perf tools: Support Arm arch timer counter Leo Yan
2020-07-15  2:34 ` [PATCH v1 2/3] perf arm_arch_timer: Convert between counter and timestamp Leo Yan
2020-07-15  2:34 ` [PATCH v1 3/3] perf arm-spe: Enable timestamp with arch timer counter Leo Yan
2020-07-15 16:31 ` [PATCH v1 0/3] Perf tool: Enable Arm arch timer counter and arm-spe's timestamp Ian Rogers
2020-07-16  1:17   ` Leo Yan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).