[PATCH v3 2/6] perf arm-spe: Save clock parameters from TIME_CONV event

Leo Yan leo.yan at linaro.org
Sat Apr 10 06:00:42 BST 2021


During the recording phase, "perf record" tool synthesizes event
PERF_RECORD_TIME_CONV for the hardware clock parameters and saves the
event into the data file.

Afterwards, when processing the data file, the event TIME_CONV will be
processed at the very early time and is stored into session context.

This patch extracts these parameters from the session context and saves
into the structure "spe->tc" with the type perf_tsc_conversion, so that
the parameters are ready for conversion between clock counter and time
stamp.

Signed-off-by: Leo Yan <leo.yan at linaro.org>
---
 tools/perf/util/arm-spe.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c
index 2539d4baec44..b48816d5c0b4 100644
--- a/tools/perf/util/arm-spe.c
+++ b/tools/perf/util/arm-spe.c
@@ -26,6 +26,7 @@
 #include "symbol.h"
 #include "thread.h"
 #include "thread-stack.h"
+#include "tsc.h"
 #include "tool.h"
 #include "util/synthetic-events.h"
 
@@ -45,6 +46,8 @@ struct arm_spe {
 	struct machine			*machine;
 	u32				pmu_type;
 
+	struct perf_tsc_conversion	tc;
+
 	u8				timeless_decoding;
 	u8				data_queued;
 
@@ -1027,6 +1030,22 @@ int arm_spe_process_auxtrace_info(union perf_event *event,
 	spe->pmu_type = auxtrace_info->priv[ARM_SPE_PMU_TYPE];
 
 	spe->timeless_decoding = arm_spe__is_timeless_decoding(spe);
+
+	/*
+	 * The synthesized event PERF_RECORD_TIME_CONV has been handled
+	 * ahead and the parameters for hardware clock are stored in
+	 * the session context.  Passes these parameters to the structure
+	 * perf_tsc_conversion in "spe->tc", which is used for later
+	 * conversion between clock counter and timestamp.
+	 */
+	spe->tc.time_shift = session->time_conv.time_shift;
+	spe->tc.time_mult = session->time_conv.time_mult;
+	spe->tc.time_zero = session->time_conv.time_zero;
+	spe->tc.time_cycles = session->time_conv.time_cycles;
+	spe->tc.time_mask = session->time_conv.time_mask;
+	spe->tc.cap_user_time_zero = session->time_conv.cap_user_time_zero;
+	spe->tc.cap_user_time_short = session->time_conv.cap_user_time_short;
+
 	spe->auxtrace.process_event = arm_spe_process_event;
 	spe->auxtrace.process_auxtrace_event = arm_spe_process_auxtrace_event;
 	spe->auxtrace.flush_events = arm_spe_flush;
-- 
2.25.1




More information about the linux-arm-kernel mailing list