perf arm-spe: Refactor arm_spe_get_events()

In function arm_spe_get_events(), the event packet's 'index' is assigned
as payload length, but the flow is not directive: it firstly gets the
packet length from the return value of arm_spe_get_payload(), the value
includes header length (1) and payload length:

  int ret = arm_spe_get_payload(buf, len, packet);

and then reduces header length from packet length, so finally get the
payload length:

  packet->index = ret - 1;

To simplify the code, this patch directly assigns payload length to
event packet's index; and at the end it calls arm_spe_get_payload() to
return the payload value.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Link: https://lore.kernel.org/r/20201111071149.815-5-leo.yan@linaro.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Leo Yan 2020-11-11 15:11:31 +08:00 committed by Arnaldo Carvalho de Melo
parent b2ded2e2e2
commit b65577baf4

View File

@ -136,8 +136,6 @@ static int arm_spe_get_timestamp(const unsigned char *buf, size_t len,
static int arm_spe_get_events(const unsigned char *buf, size_t len,
struct arm_spe_pkt *packet)
{
int ret = arm_spe_get_payload(buf, len, packet);
packet->type = ARM_SPE_EVENTS;
/* we use index to identify Events with a less number of
@ -145,9 +143,9 @@ static int arm_spe_get_events(const unsigned char *buf, size_t len,
* LLC-REFILL, and REMOTE-ACCESS events are identified if
* index > 1.
*/
packet->index = ret - 1;
packet->index = arm_spe_payload_len(buf[0]);
return ret;
return arm_spe_get_payload(buf, len, packet);
}
static int arm_spe_get_data_source(const unsigned char *buf, size_t len,