aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2018-08-16 11:10:56 -0700
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2018-08-16 11:10:56 -0700
commit13fe7056bebb4015c6231a07a1be4d3aebbfe979 (patch)
tree8aefa59a61c081c402bc85f2b47c17e1374eabdd /tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
parentMAINTAINERS: Add PhoenixRC Flight Controller Adapter (diff)
parentInput: do not use WARN() in input_alloc_absinfo() (diff)
downloadlinux-dev-13fe7056bebb4015c6231a07a1be4d3aebbfe979.tar.xz
linux-dev-13fe7056bebb4015c6231a07a1be4d3aebbfe979.zip
Merge branch 'next' into for-linus
Prepare input updates for 4.19 merge window.
Diffstat (limited to 'tools/perf/util/cs-etm-decoder/cs-etm-decoder.c')
-rw-r--r--tools/perf/util/cs-etm-decoder/cs-etm-decoder.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
index c8b98fa22997..4d5fc374e730 100644
--- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
+++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
@@ -96,11 +96,19 @@ int cs_etm_decoder__get_packet(struct cs_etm_decoder *decoder,
/* Nothing to do, might as well just return */
if (decoder->packet_count == 0)
return 0;
+ /*
+ * The queueing process in function cs_etm_decoder__buffer_packet()
+ * increments the tail *before* using it. This is somewhat counter
+ * intuitive but it has the advantage of centralizing tail management
+ * at a single location. Because of that we need to follow the same
+ * heuristic with the head, i.e we increment it before using its
+ * value. Otherwise the first element of the packet queue is not
+ * used.
+ */
+ decoder->head = (decoder->head + 1) & (MAX_BUFFER - 1);
*packet = decoder->packet_buffer[decoder->head];
- decoder->head = (decoder->head + 1) & (MAX_BUFFER - 1);
-
decoder->packet_count--;
return 1;