Re: [PATCH v3 13/20] perf arm-spe: Add new function arm_spe_pkt_desc_event()

From: André Przywara
Date: Fri Oct 23 2020 - 20:33:02 EST


On 22/10/2020 15:58, Leo Yan wrote:

Hi,

> This patch moves out the event packet parsing from arm_spe_pkt_desc()
> to the new function arm_spe_pkt_desc_event().
>
> Signed-off-by: Leo Yan <leo.yan@xxxxxxxxxx>

diff -w says this is correct, so:

Reviewed-by: Andre Przywara <andre.przywara@xxxxxxx>

Thanks!
Andre

> ---
> .../arm-spe-decoder/arm-spe-pkt-decoder.c | 136 ++++++++++--------
> 1 file changed, 73 insertions(+), 63 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 6eebd30f3d78..8a6b50f32a52 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
> @@ -266,6 +266,78 @@ static int arm_spe_pkt_snprintf(char **buf_p, size_t *blen,
> return ret;
> }
>
> +static int arm_spe_pkt_desc_event(const struct arm_spe_pkt *packet,
> + char *buf, size_t buf_len)
> +{
> + u64 payload = packet->payload;
> + size_t blen = buf_len;
> + int ret;
> +
> + ret = arm_spe_pkt_snprintf(&buf, &blen, "EV");
> + if (ret < 0)
> + return ret;
> +
> + if (payload & 0x1) {
> + ret = arm_spe_pkt_snprintf(&buf, &blen, " EXCEPTION-GEN");
> + if (ret < 0)
> + return ret;
> + }
> + if (payload & 0x2) {
> + ret = arm_spe_pkt_snprintf(&buf, &blen, " RETIRED");
> + if (ret < 0)
> + return ret;
> + }
> + if (payload & 0x4) {
> + ret = arm_spe_pkt_snprintf(&buf, &blen, " L1D-ACCESS");
> + if (ret < 0)
> + return ret;
> + }
> + if (payload & 0x8) {
> + ret = arm_spe_pkt_snprintf(&buf, &blen, " L1D-REFILL");
> + if (ret < 0)
> + return ret;
> + }
> + if (payload & 0x10) {
> + ret = arm_spe_pkt_snprintf(&buf, &blen, " TLB-ACCESS");
> + if (ret < 0)
> + return ret;
> + }
> + if (payload & 0x20) {
> + ret = arm_spe_pkt_snprintf(&buf, &blen, " TLB-REFILL");
> + if (ret < 0)
> + return ret;
> + }
> + if (payload & 0x40) {
> + ret = arm_spe_pkt_snprintf(&buf, &blen, " NOT-TAKEN");
> + if (ret < 0)
> + return ret;
> + }
> + if (payload & 0x80) {
> + ret = arm_spe_pkt_snprintf(&buf, &blen, " MISPRED");
> + if (ret < 0)
> + return ret;
> + }
> + if (packet->index > 1) {
> + if (payload & 0x100) {
> + ret = arm_spe_pkt_snprintf(&buf, &blen, " LLC-ACCESS");
> + if (ret < 0)
> + return ret;
> + }
> + if (payload & 0x200) {
> + ret = arm_spe_pkt_snprintf(&buf, &blen, " LLC-REFILL");
> + if (ret < 0)
> + return ret;
> + }
> + if (payload & 0x400) {
> + ret = arm_spe_pkt_snprintf(&buf, &blen, " REMOTE-ACCESS");
> + if (ret < 0)
> + return ret;
> + }
> + }
> +
> + return buf_len - blen;
> +}
> +
> static int arm_spe_pkt_desc_addr(const struct arm_spe_pkt *packet,
> char *buf, size_t buf_len)
> {
> @@ -344,69 +416,7 @@ int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf,
> case ARM_SPE_END:
> return arm_spe_pkt_snprintf(&buf, &blen, "%s", name);
> case ARM_SPE_EVENTS:
> - ret = arm_spe_pkt_snprintf(&buf, &blen, "EV");
> - if (ret < 0)
> - return ret;
> -
> - if (payload & 0x1) {
> - ret = arm_spe_pkt_snprintf(&buf, &blen, " EXCEPTION-GEN");
> - if (ret < 0)
> - return ret;
> - }
> - if (payload & 0x2) {
> - ret = arm_spe_pkt_snprintf(&buf, &blen, " RETIRED");
> - if (ret < 0)
> - return ret;
> - }
> - if (payload & 0x4) {
> - ret = arm_spe_pkt_snprintf(&buf, &blen, " L1D-ACCESS");
> - if (ret < 0)
> - return ret;
> - }
> - if (payload & 0x8) {
> - ret = arm_spe_pkt_snprintf(&buf, &blen, " L1D-REFILL");
> - if (ret < 0)
> - return ret;
> - }
> - if (payload & 0x10) {
> - ret = arm_spe_pkt_snprintf(&buf, &blen, " TLB-ACCESS");
> - if (ret < 0)
> - return ret;
> - }
> - if (payload & 0x20) {
> - ret = arm_spe_pkt_snprintf(&buf, &blen, " TLB-REFILL");
> - if (ret < 0)
> - return ret;
> - }
> - if (payload & 0x40) {
> - ret = arm_spe_pkt_snprintf(&buf, &blen, " NOT-TAKEN");
> - if (ret < 0)
> - return ret;
> - }
> - if (payload & 0x80) {
> - ret = arm_spe_pkt_snprintf(&buf, &blen, " MISPRED");
> - if (ret < 0)
> - return ret;
> - }
> - if (idx > 1) {
> - if (payload & 0x100) {
> - ret = arm_spe_pkt_snprintf(&buf, &blen, " LLC-ACCESS");
> - if (ret < 0)
> - return ret;
> - }
> - if (payload & 0x200) {
> - ret = arm_spe_pkt_snprintf(&buf, &blen, " LLC-REFILL");
> - if (ret < 0)
> - return ret;
> - }
> - if (payload & 0x400) {
> - ret = arm_spe_pkt_snprintf(&buf, &blen, " REMOTE-ACCESS");
> - if (ret < 0)
> - return ret;
> - }
> - }
> - return buf_len - blen;
> -
> + return arm_spe_pkt_desc_event(packet, buf, buf_len);
> case ARM_SPE_OP_TYPE:
> switch (idx) {
> case 0:
>