Commit 3fa0e83e authored by Mathieu Poirier's avatar Mathieu Poirier Committed by Arnaldo Carvalho de Melo

perf cs-etm: Modularize main packet processing loop

Making the main packet processing loop modular so that it can be called
from different decoding context (timeless vs. non-timless), avoiding to
repeat code.
Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Suzuki K Poulouse <suzuki.poulose@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/20190212171618.25355-13-mathieu.poirier@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent f74f349c
......@@ -1519,36 +1519,15 @@ static int cs_etm__decode_data_block(struct cs_etm_queue *etmq)
return ret;
}
static int cs_etm__run_decoder(struct cs_etm_queue *etmq)
static int cs_etm__process_decoder_queue(struct cs_etm_queue *etmq)
{
int err = 0;
/* Go through each buffer in the queue and decode them one by one */
while (1) {
if (!etmq->buf_len) {
err = cs_etm__get_trace(etmq);
if (err <= 0)
return err;
/*
* We cannot assume consecutive blocks in the data file
* are contiguous, reset the decoder to force re-sync.
*/
err = cs_etm_decoder__reset(etmq->decoder);
if (err != 0)
return err;
}
/* Run trace decoder until buffer consumed or end of trace */
do {
err = cs_etm__decode_data_block(etmq);
if (err)
return err;
int ret;
/* Process each packet in this chunk */
while (1) {
err = cs_etm_decoder__get_packet(etmq->decoder,
ret = cs_etm_decoder__get_packet(etmq->decoder,
etmq->packet);
if (err <= 0)
if (ret <= 0)
/*
* Stop processing this chunk on
* end of data or error
......@@ -1562,8 +1541,8 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq)
* prior to switch() statement to use address
* information before packets swapping.
*/
err = cs_etm__set_sample_flags(etmq);
if (err < 0)
ret = cs_etm__set_sample_flags(etmq);
if (ret < 0)
break;
switch (etmq->packet->sample_type) {
......@@ -1602,6 +1581,42 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq)
break;
}
}
return ret;
}
static int cs_etm__run_decoder(struct cs_etm_queue *etmq)
{
int err = 0;
/* Go through each buffer in the queue and decode them one by one */
while (1) {
if (!etmq->buf_len) {
err = cs_etm__get_trace(etmq);
if (err <= 0)
return err;
/*
* We cannot assume consecutive blocks in the data file
* are contiguous, reset the decoder to force re-sync.
*/
err = cs_etm_decoder__reset(etmq->decoder);
if (err != 0)
return err;
}
/* Run trace decoder until buffer consumed or end of trace */
do {
err = cs_etm__decode_data_block(etmq);
if (err)
return err;
/*
* Process each packet in this chunk, nothing to do if
* an error occurs other than hoping the next one will
* be better.
*/
err = cs_etm__process_decoder_queue(etmq);
} while (etmq->buf_len);
if (err == 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment