lkml.org 
[lkml]   [2020]   [Oct]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v6 12/21] perf arm-spe: Add new function arm_spe_pkt_desc_counter()
Date
This patch moves out the counter packet parsing code from
arm_spe_pkt_desc() to the new function arm_spe_pkt_desc_counter().

Signed-off-by: Leo Yan <leo.yan@linaro.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
---
.../arm-spe-decoder/arm-spe-pkt-decoder.c | 48 +++++++++++--------
1 file changed, 29 insertions(+), 19 deletions(-)

diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
index e4ab43ba80bd..403eb15c13d7 100644
--- a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
+++ b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
@@ -301,6 +301,34 @@ static int arm_spe_pkt_desc_addr(const struct arm_spe_pkt *packet,
}
}

+static int arm_spe_pkt_desc_counter(const struct arm_spe_pkt *packet,
+ char *buf, size_t buf_len)
+{
+ u64 payload = packet->payload;
+ const char *name = arm_spe_pkt_name(packet->type);
+ size_t blen = buf_len;
+ int err = 0;
+
+ arm_spe_pkt_snprintf(&err, &buf, &blen, "%s %d ", name,
+ (unsigned short)payload);
+
+ switch (packet->index) {
+ case 0:
+ arm_spe_pkt_snprintf(&err, &buf, &blen, "TOT");
+ break;
+ case 1:
+ arm_spe_pkt_snprintf(&err, &buf, &blen, "ISSUE");
+ break;
+ case 2:
+ arm_spe_pkt_snprintf(&err, &buf, &blen, "XLAT");
+ break;
+ default:
+ break;
+ }
+
+ return err ?: (int)(buf_len - blen);
+}
+
int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf,
size_t buf_len)
{
@@ -388,25 +416,7 @@ int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf,
return arm_spe_pkt_snprintf(&err, &buf, &blen, "%s 0x%lx el%d",
name, (unsigned long)payload, idx + 1);
case ARM_SPE_COUNTER:
- arm_spe_pkt_snprintf(&err, &buf, &blen, "%s %d ", name,
- (unsigned short)payload);
-
- switch (idx) {
- case 0:
- arm_spe_pkt_snprintf(&err, &buf, &blen, "TOT");
- break;
- case 1:
- arm_spe_pkt_snprintf(&err, &buf, &blen, "ISSUE");
- break;
- case 2:
- arm_spe_pkt_snprintf(&err, &buf, &blen, "XLAT");
- break;
- default:
- break;
- }
-
- return err ?: (int)(buf_len - blen);
-
+ return arm_spe_pkt_desc_counter(packet, buf, buf_len);
default:
break;
}
--
2.17.1
\
 
 \ /
  Last update: 2020-10-30 03:59    [W:0.198 / U:2.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site