perf cs-etm: Swap packets for instruction samples
If use option '--itrace=iNNN' with Arm CoreSight trace data, perf tool fails inject instruction samples; the root cause is the packets are only swapped for branch samples and last branches but not for instruction samples, so the new coming packets cannot be properly handled for only synthesizing instruction samples. To fix this issue, this patch refactors the code with a new function cs_etm__packet_swap() which is used to swap packets and adds the condition for instruction samples. Signed-off-by: Leo Yan <leo.yan@linaro.org> Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org> Reviewed-by: Mike Leach <mike.leach@linaro.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Robert Walker <robert.walker@arm.com> Cc: Suzuki Poulouse <suzuki.poulose@arm.com> Cc: coresight ml <coresight@lists.linaro.org> Cc: linux-arm-kernel@lists.infradead.org Link: http://lore.kernel.org/lkml/20200219021811.20067-2-leo.yan@linaro.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
bdadd647cb
commit
d01751563c
|
@ -363,6 +363,23 @@ struct cs_etm_packet_queue
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void cs_etm__packet_swap(struct cs_etm_auxtrace *etm,
|
||||
struct cs_etm_traceid_queue *tidq)
|
||||
{
|
||||
struct cs_etm_packet *tmp;
|
||||
|
||||
if (etm->sample_branches || etm->synth_opts.last_branch ||
|
||||
etm->sample_instructions) {
|
||||
/*
|
||||
* Swap PACKET with PREV_PACKET: PACKET becomes PREV_PACKET for
|
||||
* the next incoming packet.
|
||||
*/
|
||||
tmp = tidq->packet;
|
||||
tidq->packet = tidq->prev_packet;
|
||||
tidq->prev_packet = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
static void cs_etm__packet_dump(const char *pkt_string)
|
||||
{
|
||||
const char *color = PERF_COLOR_BLUE;
|
||||
|
@ -1342,7 +1359,6 @@ static int cs_etm__sample(struct cs_etm_queue *etmq,
|
|||
struct cs_etm_traceid_queue *tidq)
|
||||
{
|
||||
struct cs_etm_auxtrace *etm = etmq->etm;
|
||||
struct cs_etm_packet *tmp;
|
||||
int ret;
|
||||
u8 trace_chan_id = tidq->trace_chan_id;
|
||||
u64 instrs_executed = tidq->packet->instr_count;
|
||||
|
@ -1406,15 +1422,7 @@ static int cs_etm__sample(struct cs_etm_queue *etmq,
|
|||
}
|
||||
}
|
||||
|
||||
if (etm->sample_branches || etm->synth_opts.last_branch) {
|
||||
/*
|
||||
* Swap PACKET with PREV_PACKET: PACKET becomes PREV_PACKET for
|
||||
* the next incoming packet.
|
||||
*/
|
||||
tmp = tidq->packet;
|
||||
tidq->packet = tidq->prev_packet;
|
||||
tidq->prev_packet = tmp;
|
||||
}
|
||||
cs_etm__packet_swap(etm, tidq);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1443,7 +1451,6 @@ static int cs_etm__flush(struct cs_etm_queue *etmq,
|
|||
{
|
||||
int err = 0;
|
||||
struct cs_etm_auxtrace *etm = etmq->etm;
|
||||
struct cs_etm_packet *tmp;
|
||||
|
||||
/* Handle start tracing packet */
|
||||
if (tidq->prev_packet->sample_type == CS_ETM_EMPTY)
|
||||
|
@ -1478,15 +1485,7 @@ static int cs_etm__flush(struct cs_etm_queue *etmq,
|
|||
}
|
||||
|
||||
swap_packet:
|
||||
if (etm->sample_branches || etm->synth_opts.last_branch) {
|
||||
/*
|
||||
* Swap PACKET with PREV_PACKET: PACKET becomes PREV_PACKET for
|
||||
* the next incoming packet.
|
||||
*/
|
||||
tmp = tidq->packet;
|
||||
tidq->packet = tidq->prev_packet;
|
||||
tidq->prev_packet = tmp;
|
||||
}
|
||||
cs_etm__packet_swap(etm, tidq);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue