perf arm-spe: Remove size condition checking for events
authorLeo Yan <leo.yan@linaro.org>
Thu, 19 Nov 2020 15:24:36 +0000 (23:24 +0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 26 Nov 2020 12:31:46 +0000 (09:31 -0300)
In the Armv8 ARM (ARM DDI 0487F.c), chapter "D10.2.6 Events packet", it
describes the event bit is valid with specific payload requirement.  For
example, the Last Level cache access event, the bit is defined as:

  E[8], byte 1 bit [0], when SZ == 0b01 , when SZ == 0b10 ,
        or when SZ == 0b11

It requires the payload size is at least 2 bytes, when byte 1 (start
counting from 0) is valid, E[8] (bit 0 in byte 1) can be used for LLC
access event type.  For safety, the code checks the condition for
payload size firstly, if meet the requirement for payload size, then
continue to parse event type.

If review function arm_spe_get_payload(), it has used cast, so any bytes
beyond the valid size have been set to zeros.

For this reason, we don't need to check payload size anymore afterwards
when parse events, thus this patch removes payload size conditions.

Suggested-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Acked-by: Will Deacon <will@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Al Grant <Al.Grant@arm.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Dave Martin <Dave.Martin@arm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wei Li <liwei391@huawei.com>
Link: https://lore.kernel.org/r/20201119152441.6972-12-leo.yan@linaro.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/arm-spe-decoder/arm-spe-decoder.c
tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c

index cac2ef7..90d575c 100644 (file)
@@ -192,16 +192,13 @@ static int arm_spe_read_record(struct arm_spe_decoder *decoder)
                        if (payload & BIT(EV_TLB_ACCESS))
                                decoder->record.type |= ARM_SPE_TLB_ACCESS;
 
-                       if ((idx == 2 || idx == 4 || idx == 8) &&
-                           (payload & BIT(EV_LLC_MISS)))
+                       if (payload & BIT(EV_LLC_MISS))
                                decoder->record.type |= ARM_SPE_LLC_MISS;
 
-                       if ((idx == 2 || idx == 4 || idx == 8) &&
-                           (payload & BIT(EV_LLC_ACCESS)))
+                       if (payload & BIT(EV_LLC_ACCESS))
                                decoder->record.type |= ARM_SPE_LLC_ACCESS;
 
-                       if ((idx == 2 || idx == 4 || idx == 8) &&
-                           (payload & BIT(EV_REMOTE_ACCESS)))
+                       if (payload & BIT(EV_REMOTE_ACCESS))
                                decoder->record.type |= ARM_SPE_REMOTE_ACCESS;
 
                        if (payload & BIT(EV_MISPRED))
index 3f30b29..88bcf7e 100644 (file)
@@ -311,14 +311,12 @@ static int arm_spe_pkt_desc_event(const struct arm_spe_pkt *packet,
                arm_spe_pkt_out_string(&err, &buf, &buf_len, " NOT-TAKEN");
        if (payload & BIT(EV_MISPRED))
                arm_spe_pkt_out_string(&err, &buf, &buf_len, " MISPRED");
-       if (packet->index > 1) {
-               if (payload & BIT(EV_LLC_ACCESS))
-                       arm_spe_pkt_out_string(&err, &buf, &buf_len, " LLC-ACCESS");
-               if (payload & BIT(EV_LLC_MISS))
-                       arm_spe_pkt_out_string(&err, &buf, &buf_len, " LLC-REFILL");
-               if (payload & BIT(EV_REMOTE_ACCESS))
-                       arm_spe_pkt_out_string(&err, &buf, &buf_len, " REMOTE-ACCESS");
-       }
+       if (payload & BIT(EV_LLC_ACCESS))
+               arm_spe_pkt_out_string(&err, &buf, &buf_len, " LLC-ACCESS");
+       if (payload & BIT(EV_LLC_MISS))
+               arm_spe_pkt_out_string(&err, &buf, &buf_len, " LLC-REFILL");
+       if (payload & BIT(EV_REMOTE_ACCESS))
+               arm_spe_pkt_out_string(&err, &buf, &buf_len, " REMOTE-ACCESS");
 
        return err;
 }