linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/6] Perf tool: Support TSC for Arm64
@ 2020-09-14 11:53 Leo Yan
  2020-09-14 11:53 ` [PATCH v4 1/6] perf tsc: Move out common functions from x86 Leo Yan
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Leo Yan @ 2020-09-14 11:53 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Will Deacon,
	Ingo Molnar, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, John Garry, Mathieu Poirier, Adrian Hunter,
	Kemeng Shi, Ian Rogers, Remi Bernon, Nick Gasson,
	Stephane Eranian, Andi Kleen, Steve MacLean, Gustavo A. R. Silva,
	Zou Wei, linux-kernel, linux-arm-kernel
  Cc: 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_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: Ok

Changes 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%)

-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v4 1/6] perf tsc: Move out common functions from x86
  2020-09-14 11:53 [PATCH v4 0/6] Perf tool: Support TSC for Arm64 Leo Yan
@ 2020-09-14 11:53 ` Leo Yan
  2020-09-14 11:53 ` [PATCH v4 2/6] perf tsc: Add rdtsc() for Arm64 Leo Yan
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Leo Yan @ 2020-09-14 11:53 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Will Deacon,
	Ingo Molnar, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, John Garry, Mathieu Poirier, Adrian Hunter,
	Kemeng Shi, Ian Rogers, Remi Bernon, Nick Gasson,
	Stephane Eranian, Andi Kleen, Steve MacLean, Gustavo A. R. Silva,
	Zou Wei, linux-kernel, linux-arm-kernel
  Cc: Leo Yan

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.

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

diff --git a/tools/perf/arch/x86/util/tsc.c b/tools/perf/arch/x86/util/tsc.c
index 2f55afb14e1f..559365f8fe52 100644
--- a/tools/perf/arch/x86/util/tsc.c
+++ b/tools/perf/arch/x86/util/tsc.c
@@ -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);
-}
diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c
index 89b390623b63..3ca5d9399680 100644
--- a/tools/perf/util/synthetic-events.c
+++ b/tools/perf/util/synthetic-events.c
@@ -2006,14 +2006,6 @@ int perf_event__synthesize_stat_events(struct perf_stat_config *config, struct p
 	return 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,
diff --git a/tools/perf/util/tsc.c b/tools/perf/util/tsc.c
index bfa782421cbd..9e3f04ddddf8 100644
--- a/tools/perf/util/tsc.c
+++ b/tools/perf/util/tsc.c
@@ -1,7 +1,16 @@
 // SPDX-License-Identifier: GPL-2.0
+#include <errno.h>
+
 #include <linux/compiler.h>
+#include <linux/perf_event.h>
+#include <linux/stddef.h>
 #include <linux/types.h>
 
+#include <asm/barrier.h>
+
+#include "event.h"
+#include "synthetic-events.h"
+#include "debug.h"
 #include "tsc.h"
 
 u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc)
@@ -25,6 +34,68 @@ u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc)
 	       ((rem * tc->time_mult) >> tc->time_shift);
 }
 
+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;
+}
+
+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);
+}
+
 u64 __weak rdtsc(void)
 {
 	return 0;
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v4 2/6] perf tsc: Add rdtsc() for Arm64
  2020-09-14 11:53 [PATCH v4 0/6] Perf tool: Support TSC for Arm64 Leo Yan
  2020-09-14 11:53 ` [PATCH v4 1/6] perf tsc: Move out common functions from x86 Leo Yan
@ 2020-09-14 11:53 ` Leo Yan
  2020-09-14 11:53 ` [PATCH v4 3/6] perf tsc: Calculate timestamp with cap_user_time_short Leo Yan
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Leo Yan @ 2020-09-14 11:53 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Will Deacon,
	Ingo Molnar, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, John Garry, Mathieu Poirier, Adrian Hunter,
	Kemeng Shi, Ian Rogers, Remi Bernon, Nick Gasson,
	Stephane Eranian, Andi Kleen, Steve MacLean, Gustavo A. R. Silva,
	Zou Wei, linux-kernel, linux-arm-kernel
  Cc: Leo Yan

The system register CNTVCT_EL0 can be used to retrieve the counter from
user space.  Add rdtsc() for Arm64.

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

diff --git a/tools/perf/arch/arm64/util/Build b/tools/perf/arch/arm64/util/Build
index 5c13438c7bd4..b53294d74b01 100644
--- a/tools/perf/arch/arm64/util/Build
+++ b/tools/perf/arch/arm64/util/Build
@@ -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
diff --git a/tools/perf/arch/arm64/util/tsc.c b/tools/perf/arch/arm64/util/tsc.c
new file mode 100644
index 000000000000..cc85bd9e73f1
--- /dev/null
+++ b/tools/perf/arch/arm64/util/tsc.c
@@ -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.
+	 */
+	asm volatile("mrs %0, cntvct_el0" : "=r" (val));
+
+	return val;
+}
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v4 3/6] perf tsc: Calculate timestamp with cap_user_time_short
  2020-09-14 11:53 [PATCH v4 0/6] Perf tool: Support TSC for Arm64 Leo Yan
  2020-09-14 11:53 ` [PATCH v4 1/6] perf tsc: Move out common functions from x86 Leo Yan
  2020-09-14 11:53 ` [PATCH v4 2/6] perf tsc: Add rdtsc() for Arm64 Leo Yan
@ 2020-09-14 11:53 ` Leo Yan
  2020-09-14 11:53 ` [PATCH v4 4/6] perf tsc: Support cap_user_time_short for event TIME_CONV Leo Yan
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Leo Yan @ 2020-09-14 11:53 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Will Deacon,
	Ingo Molnar, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, John Garry, Mathieu Poirier, Adrian Hunter,
	Kemeng Shi, Ian Rogers, Remi Bernon, Nick Gasson,
	Stephane Eranian, Andi Kleen, Steve MacLean, Gustavo A. R. Silva,
	Zou Wei, linux-kernel, linux-arm-kernel
  Cc: Leo Yan

The 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.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
 tools/perf/util/tsc.c | 12 +++++++++---
 tools/perf/util/tsc.h |  5 +++++
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/tsc.c b/tools/perf/util/tsc.c
index 9e3f04ddddf8..c0ca40204649 100644
--- a/tools/perf/util/tsc.c
+++ b/tools/perf/util/tsc.c
@@ -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;
diff --git a/tools/perf/util/tsc.h b/tools/perf/util/tsc.h
index 3c5a632ee57c..72a15419f3b3 100644
--- a/tools/perf/util/tsc.h
+++ b/tools/perf/util/tsc.h
@@ -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;
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v4 4/6] perf tsc: Support cap_user_time_short for event TIME_CONV
  2020-09-14 11:53 [PATCH v4 0/6] Perf tool: Support TSC for Arm64 Leo Yan
                   ` (2 preceding siblings ...)
  2020-09-14 11:53 ` [PATCH v4 3/6] perf tsc: Calculate timestamp with cap_user_time_short Leo Yan
@ 2020-09-14 11:53 ` Leo Yan
  2020-09-14 11:53 ` [PATCH v4 5/6] perf tests tsc: Make tsc testing as a common testing Leo Yan
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Leo Yan @ 2020-09-14 11:53 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Will Deacon,
	Ingo Molnar, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, John Garry, Mathieu Poirier, Adrian Hunter,
	Kemeng Shi, Ian Rogers, Remi Bernon, Nick Gasson,
	Stephane Eranian, Andi Kleen, Steve MacLean, Gustavo A. R. Silva,
	Zou Wei, linux-kernel, linux-arm-kernel
  Cc: Leo Yan

The 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.

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

diff --git a/tools/lib/perf/include/perf/event.h b/tools/lib/perf/include/perf/event.h
index 842028858d66..a6dbba6b9073 100644
--- a/tools/lib/perf/include/perf/event.h
+++ b/tools/lib/perf/include/perf/event.h
@@ -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 {
diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c
index 0804308ef285..055bab7a92b3 100644
--- a/tools/perf/util/jitdump.c
+++ b/tools/perf/util/jitdump.c
@@ -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);
diff --git a/tools/perf/util/tsc.c b/tools/perf/util/tsc.c
index c0ca40204649..62b4c75c966c 100644
--- a/tools/perf/util/tsc.c
+++ b/tools/perf/util/tsc.c
@@ -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);
 }
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v4 5/6] perf tests tsc: Make tsc testing as a common testing
  2020-09-14 11:53 [PATCH v4 0/6] Perf tool: Support TSC for Arm64 Leo Yan
                   ` (3 preceding siblings ...)
  2020-09-14 11:53 ` [PATCH v4 4/6] perf tsc: Support cap_user_time_short for event TIME_CONV Leo Yan
@ 2020-09-14 11:53 ` Leo Yan
  2020-09-14 11:53 ` [PATCH v4 6/6] perf tests tsc: Add checking helper is_supported() Leo Yan
  2020-09-22 12:07 ` [PATCH v4 0/6] Perf tool: Support TSC for Arm64 Leo Yan
  6 siblings, 0 replies; 13+ messages in thread
From: Leo Yan @ 2020-09-14 11:53 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Will Deacon,
	Ingo Molnar, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, John Garry, Mathieu Poirier, Adrian Hunter,
	Kemeng Shi, Ian Rogers, Remi Bernon, Nick Gasson,
	Stephane Eranian, Andi Kleen, Steve MacLean, Gustavo A. R. Silva,
	Zou Wei, linux-kernel, linux-arm-kernel
  Cc: Leo Yan

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

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

diff --git a/tools/perf/arch/x86/include/arch-tests.h b/tools/perf/arch/x86/include/arch-tests.h
index c41c5affe4be..6a54b94f1c25 100644
--- a/tools/perf/arch/x86/include/arch-tests.h
+++ b/tools/perf/arch/x86/include/arch-tests.h
@@ -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);
diff --git a/tools/perf/arch/x86/tests/Build b/tools/perf/arch/x86/tests/Build
index 2997c506550c..36d4f248b51d 100644
--- a/tools/perf/arch/x86/tests/Build
+++ b/tools/perf/arch/x86/tests/Build
@@ -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
diff --git a/tools/perf/arch/x86/tests/arch-tests.c b/tools/perf/arch/x86/tests/arch-tests.c
index 6763135aec17..bc25d727b4e9 100644
--- a/tools/perf/arch/x86/tests/arch-tests.c
+++ b/tools/perf/arch/x86/tests/arch-tests.c
@@ -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",
diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build
index 69bea7996f18..8ddf81447344 100644
--- a/tools/perf/tests/Build
+++ b/tools/perf/tests/Build
@@ -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)
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 651b8ea3354a..0abb5ce88962 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -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,
 	},
diff --git a/tools/perf/arch/x86/tests/perf-time-to-tsc.c b/tools/perf/tests/perf-time-to-tsc.c
similarity index 100%
rename from tools/perf/arch/x86/tests/perf-time-to-tsc.c
rename to tools/perf/tests/perf-time-to-tsc.c
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index ef0f33c6ba23..60a1c317b8db 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -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);
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v4 6/6] perf tests tsc: Add checking helper is_supported()
  2020-09-14 11:53 [PATCH v4 0/6] Perf tool: Support TSC for Arm64 Leo Yan
                   ` (4 preceding siblings ...)
  2020-09-14 11:53 ` [PATCH v4 5/6] perf tests tsc: Make tsc testing as a common testing Leo Yan
@ 2020-09-14 11:53 ` Leo Yan
  2020-09-22 12:07 ` [PATCH v4 0/6] Perf tool: Support TSC for Arm64 Leo Yan
  6 siblings, 0 replies; 13+ messages in thread
From: Leo Yan @ 2020-09-14 11:53 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Will Deacon,
	Ingo Molnar, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, John Garry, Mathieu Poirier, Adrian Hunter,
	Kemeng Shi, Ian Rogers, Remi Bernon, Nick Gasson,
	Stephane Eranian, Andi Kleen, Steve MacLean, Gustavo A. R. Silva,
	Zou Wei, linux-kernel, linux-arm-kernel
  Cc: Leo Yan

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

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

diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 0abb5ce88962..60682e945f9b 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -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,
diff --git a/tools/perf/tests/perf-time-to-tsc.c b/tools/perf/tests/perf-time-to-tsc.c
index 026d32ed078e..41dadd4cd097 100644
--- a/tools/perf/tests/perf-time-to-tsc.c
+++ b/tools/perf/tests/perf-time-to-tsc.c
@@ -171,3 +171,16 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe
 	evlist__delete(evlist);
 	return err;
 }
+
+bool test__tsc_is_supported(void)
+{
+	/*
+	 * Except x86_64/i386 and Arm64, other archs don't support TSC in perf.
+	 * Just enable the test for x86_64/i386 and Arm64 archs.
+	 */
+#if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__)
+	return true;
+#else
+	return false;
+#endif
+}
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 60a1c317b8db..9f1eedb21eee 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -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
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v4 0/6] Perf tool: Support TSC for Arm64
  2020-09-14 11:53 [PATCH v4 0/6] Perf tool: Support TSC for Arm64 Leo Yan
                   ` (5 preceding siblings ...)
  2020-09-14 11:53 ` [PATCH v4 6/6] perf tests tsc: Add checking helper is_supported() Leo Yan
@ 2020-09-22 12:07 ` Leo Yan
  2020-09-22 16:49   ` Arnaldo Carvalho de Melo
  6 siblings, 1 reply; 13+ messages in thread
From: Leo Yan @ 2020-09-22 12:07 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Will Deacon,
	Ingo Molnar, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, John Garry, Mathieu Poirier, Adrian Hunter,
	Kemeng Shi, Ian Rogers, Remi Bernon, Nick Gasson,
	Stephane Eranian, Andi Kleen, Steve MacLean, Gustavo A. R. Silva,
	Zou Wei, linux-kernel, linux-arm-kernel

Hi Arnaldo,

On Mon, Sep 14, 2020 at 07:53:05PM +0800, Leo Yan wrote:
> 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.

Could you pick up this patch set?  Thanks!

Leo

>   $ 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: Ok
> 
> Changes 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%)
> 
> -- 
> 2.17.1
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v4 0/6] Perf tool: Support TSC for Arm64
  2020-09-22 12:07 ` [PATCH v4 0/6] Perf tool: Support TSC for Arm64 Leo Yan
@ 2020-09-22 16:49   ` Arnaldo Carvalho de Melo
  2020-09-23  8:12     ` Leo Yan
  2020-09-23 15:27     ` Arnaldo Carvalho de Melo
  0 siblings, 2 replies; 13+ messages in thread
From: Arnaldo Carvalho de Melo @ 2020-09-22 16:49 UTC (permalink / raw)
  To: Leo Yan
  Cc: Mark Rutland, Ian Rogers, Remi Bernon, Andi Kleen,
	Mathieu Poirier, Kemeng Shi, Peter Zijlstra, Will Deacon,
	John Garry, Adrian Hunter, Stephane Eranian, Gustavo A. R. Silva,
	Alexander Shishkin, Ingo Molnar, Steve MacLean, linux-arm-kernel,
	Nick Gasson, Namhyung Kim, Zou Wei, Jiri Olsa, linux-kernel

Em Tue, Sep 22, 2020 at 08:07:32PM +0800, Leo Yan escreveu:
> Hi Arnaldo,
> 
> On Mon, Sep 14, 2020 at 07:53:05PM +0800, Leo Yan wrote:
> > 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.
> 
> 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
 
> Leo
> 
> >   $ 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: Ok
> > 
> > Changes 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%)
> > 
> > -- 
> > 2.17.1
> > 

-- 

- Arnaldo

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v4 0/6] Perf tool: Support TSC for Arm64
  2020-09-22 16:49   ` Arnaldo Carvalho de Melo
@ 2020-09-23  8:12     ` Leo Yan
  2020-09-23 15:27     ` Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 13+ messages in thread
From: Leo Yan @ 2020-09-23  8:12 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Mark Rutland, Ian Rogers, Remi Bernon, Andi Kleen,
	Mathieu Poirier, Kemeng Shi, Peter Zijlstra, Will Deacon,
	John Garry, Adrian Hunter, Stephane Eranian, Gustavo A. R. Silva,
	Alexander Shishkin, Ingo Molnar, Steve MacLean, linux-arm-kernel,
	Nick Gasson, Namhyung Kim, Zou Wei, Jiri Olsa, linux-kernel

On Tue, Sep 22, 2020 at 01:49:06PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Tue, Sep 22, 2020 at 08:07:32PM +0800, Leo Yan escreveu:
> > Hi Arnaldo,
> > 
> > On Mon, Sep 14, 2020 at 07:53:05PM +0800, Leo Yan wrote:
> > > 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.
> > 
> > Could you pick up this patch set?  Thanks!
> 
> Yeah, I picked it up now, its a pity nobody provided Acks :-\

Thanks, Arnaldo!

> 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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v4 0/6] Perf tool: Support TSC for Arm64
  2020-09-22 16:49   ` Arnaldo Carvalho de Melo
  2020-09-23  8:12     ` Leo Yan
@ 2020-09-23 15:27     ` Arnaldo Carvalho de Melo
  2020-09-23 15:55       ` Arnaldo Carvalho de Melo
  1 sibling, 1 reply; 13+ messages in thread
From: Arnaldo Carvalho de Melo @ 2020-09-23 15:27 UTC (permalink / raw)
  To: Leo Yan
  Cc: Mark Rutland, Ian Rogers, Remi Bernon, Andi Kleen,
	Mathieu Poirier, Kemeng Shi, Peter Zijlstra, Will Deacon,
	John Garry, Adrian Hunter, Stephane Eranian, Gustavo A. R. Silva,
	Alexander Shishkin, Ingo Molnar, Steve MacLean, linux-arm-kernel,
	Nick Gasson, Namhyung Kim, Zou Wei, Jiri Olsa, linux-kernel

Em Tue, Sep 22, 2020 at 01:49:06PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Tue, Sep 22, 2020 at 08:07:32PM +0800, Leo Yan escreveu:
> > Hi Arnaldo,
> > 
> > On Mon, Sep 14, 2020 at 07:53:05PM +0800, Leo Yan wrote:
> > > 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.
> > 
> > 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.o
tests/perf-time-to-tsc.c:24:10: fatal error: arch-tests.h: No such file or directory
   24 | #include "arch-tests.h"
      |          ^~~~~~~~~~~~~~
compilation terminated.
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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v4 0/6] Perf tool: Support TSC for Arm64
  2020-09-23 15:27     ` Arnaldo Carvalho de Melo
@ 2020-09-23 15:55       ` Arnaldo Carvalho de Melo
  2020-09-23 23:48         ` Leo Yan
  0 siblings, 1 reply; 13+ messages in thread
From: Arnaldo Carvalho de Melo @ 2020-09-23 15:55 UTC (permalink / raw)
  To: Leo Yan
  Cc: Mark Rutland, Ian Rogers, Remi Bernon, Andi Kleen,
	Mathieu Poirier, Kemeng Shi, Peter Zijlstra, Will Deacon,
	John Garry, Adrian Hunter, Stephane Eranian, Gustavo A. R. Silva,
	Alexander Shishkin, Ingo Molnar, Steve MacLean, linux-arm-kernel,
	Nick Gasson, Namhyung Kim, Zou Wei, Jiri Olsa, linux-kernel

Em Wed, Sep 23, 2020 at 12:27:53PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Tue, Sep 22, 2020 at 01:49:06PM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Tue, Sep 22, 2020 at 08:07:32PM +0800, Leo Yan escreveu:
> > > Hi Arnaldo,
> > > 
> > > On Mon, Sep 14, 2020 at 07:53:05PM +0800, Leo Yan wrote:
> > > > 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.
> > > 
> > > 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 <leo.yan@linaro.org>
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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v4 0/6] Perf tool: Support TSC for Arm64
  2020-09-23 15:55       ` Arnaldo Carvalho de Melo
@ 2020-09-23 23:48         ` Leo Yan
  0 siblings, 0 replies; 13+ messages in thread
From: Leo Yan @ 2020-09-23 23:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Mark Rutland, Ian Rogers, Remi Bernon, Andi Kleen,
	Mathieu Poirier, Kemeng Shi, Peter Zijlstra, Will Deacon,
	John Garry, Adrian Hunter, Stephane Eranian, Gustavo A. R. Silva,
	Alexander Shishkin, Ingo Molnar, Steve MacLean, linux-arm-kernel,
	Nick Gasson, Namhyung Kim, Zou Wei, Jiri Olsa, linux-kernel

Hi Arnaldo,

On Wed, Sep 23, 2020 at 12:55:57PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Wed, Sep 23, 2020 at 12:27:53PM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Tue, Sep 22, 2020 at 01:49:06PM -0300, Arnaldo Carvalho de Melo escreveu:
> > > Em Tue, Sep 22, 2020 at 08:07:32PM +0800, Leo Yan escreveu:
> > > > Hi Arnaldo,
> > > > 
> > > > On Mon, Sep 14, 2020 at 07:53:05PM +0800, Leo Yan wrote:
> > > > > 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.
> > > > 
> > > > 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 <leo.yan@linaro.org>
> 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.

Will monitor perf/core branch and after you push onto it, I will fix
the issue ASAP.   Sorry for inconvenience.

Thanks,
Leo

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2020-09-23 23:50 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-14 11:53 [PATCH v4 0/6] Perf tool: Support TSC for Arm64 Leo Yan
2020-09-14 11:53 ` [PATCH v4 1/6] perf tsc: Move out common functions from x86 Leo Yan
2020-09-14 11:53 ` [PATCH v4 2/6] perf tsc: Add rdtsc() for Arm64 Leo Yan
2020-09-14 11:53 ` [PATCH v4 3/6] perf tsc: Calculate timestamp with cap_user_time_short Leo Yan
2020-09-14 11:53 ` [PATCH v4 4/6] perf tsc: Support cap_user_time_short for event TIME_CONV Leo Yan
2020-09-14 11:53 ` [PATCH v4 5/6] perf tests tsc: Make tsc testing as a common testing Leo Yan
2020-09-14 11:53 ` [PATCH v4 6/6] perf tests tsc: Add checking helper is_supported() Leo Yan
2020-09-22 12:07 ` [PATCH v4 0/6] Perf tool: Support TSC for Arm64 Leo Yan
2020-09-22 16:49   ` Arnaldo Carvalho de Melo
2020-09-23  8:12     ` Leo Yan
2020-09-23 15:27     ` Arnaldo Carvalho de Melo
2020-09-23 15:55       ` Arnaldo Carvalho de Melo
2020-09-23 23:48         ` 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).