diff options
author | Mathieu Poirier <mathieu.poirier@linaro.org> | 2019-02-12 12:16:16 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-02-14 13:18:07 -0500 |
commit | f74f349c211e3e62bc7fe35a132918c7f2c0fafb (patch) | |
tree | d09645faeb1bfaab3a37fae7ab3523cad400d337 | |
parent | 23cfcd6d75cc0c1a7f95c44658dc91380fb40770 (diff) |
perf cs-etm: Modularize main decoder function
Making the main decoder block modular so that it can be called from
different decoding context (timeless vs. non-timeless), avoiding
to repeat code.
No change in functionality is introduced by this patch.
Signed-off-by: Mathieu 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-12-mathieu.poirier@linaro.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/util/cs-etm.c | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index d2c90b369e7c..cfa686fe223e 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c | |||
@@ -1491,9 +1491,36 @@ static int cs_etm__set_sample_flags(struct cs_etm_queue *etmq) | |||
1491 | return 0; | 1491 | return 0; |
1492 | } | 1492 | } |
1493 | 1493 | ||
1494 | static int cs_etm__decode_data_block(struct cs_etm_queue *etmq) | ||
1495 | { | ||
1496 | int ret = 0; | ||
1497 | size_t processed = 0; | ||
1498 | |||
1499 | /* | ||
1500 | * Packets are decoded and added to the decoder's packet queue | ||
1501 | * until the decoder packet processing callback has requested that | ||
1502 | * processing stops or there is nothing left in the buffer. Normal | ||
1503 | * operations that stop processing are a timestamp packet or a full | ||
1504 | * decoder buffer queue. | ||
1505 | */ | ||
1506 | ret = cs_etm_decoder__process_data_block(etmq->decoder, | ||
1507 | etmq->offset, | ||
1508 | &etmq->buf[etmq->buf_used], | ||
1509 | etmq->buf_len, | ||
1510 | &processed); | ||
1511 | if (ret) | ||
1512 | goto out; | ||
1513 | |||
1514 | etmq->offset += processed; | ||
1515 | etmq->buf_used += processed; | ||
1516 | etmq->buf_len -= processed; | ||
1517 | |||
1518 | out: | ||
1519 | return ret; | ||
1520 | } | ||
1521 | |||
1494 | static int cs_etm__run_decoder(struct cs_etm_queue *etmq) | 1522 | static int cs_etm__run_decoder(struct cs_etm_queue *etmq) |
1495 | { | 1523 | { |
1496 | size_t processed; | ||
1497 | int err = 0; | 1524 | int err = 0; |
1498 | 1525 | ||
1499 | /* Go through each buffer in the queue and decode them one by one */ | 1526 | /* Go through each buffer in the queue and decode them one by one */ |
@@ -1513,20 +1540,10 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq) | |||
1513 | 1540 | ||
1514 | /* Run trace decoder until buffer consumed or end of trace */ | 1541 | /* Run trace decoder until buffer consumed or end of trace */ |
1515 | do { | 1542 | do { |
1516 | processed = 0; | 1543 | err = cs_etm__decode_data_block(etmq); |
1517 | err = cs_etm_decoder__process_data_block( | ||
1518 | etmq->decoder, | ||
1519 | etmq->offset, | ||
1520 | &etmq->buf[etmq->buf_used], | ||
1521 | etmq->buf_len, | ||
1522 | &processed); | ||
1523 | if (err) | 1544 | if (err) |
1524 | return err; | 1545 | return err; |
1525 | 1546 | ||
1526 | etmq->offset += processed; | ||
1527 | etmq->buf_used += processed; | ||
1528 | etmq->buf_len -= processed; | ||
1529 | |||
1530 | /* Process each packet in this chunk */ | 1547 | /* Process each packet in this chunk */ |
1531 | while (1) { | 1548 | while (1) { |
1532 | err = cs_etm_decoder__get_packet(etmq->decoder, | 1549 | err = cs_etm_decoder__get_packet(etmq->decoder, |