diff options
| -rw-r--r-- | tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 12 |
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, | |||
| 96 | /* Nothing to do, might as well just return */ | 96 | /* Nothing to do, might as well just return */ |
| 97 | if (decoder->packet_count == 0) | 97 | if (decoder->packet_count == 0) |
| 98 | return 0; | 98 | return 0; |
| 99 | /* | ||
| 100 | * The queueing process in function cs_etm_decoder__buffer_packet() | ||
| 101 | * increments the tail *before* using it. This is somewhat counter | ||
| 102 | * intuitive but it has the advantage of centralizing tail management | ||
| 103 | * at a single location. Because of that we need to follow the same | ||
| 104 | * heuristic with the head, i.e we increment it before using its | ||
| 105 | * value. Otherwise the first element of the packet queue is not | ||
| 106 | * used. | ||
| 107 | */ | ||
| 108 | decoder->head = (decoder->head + 1) & (MAX_BUFFER - 1); | ||
| 99 | 109 | ||
| 100 | *packet = decoder->packet_buffer[decoder->head]; | 110 | *packet = decoder->packet_buffer[decoder->head]; |
| 101 | 111 | ||
| 102 | decoder->head = (decoder->head + 1) & (MAX_BUFFER - 1); | ||
| 103 | |||
| 104 | decoder->packet_count--; | 112 | decoder->packet_count--; |
| 105 | 113 | ||
| 106 | return 1; | 114 | return 1; |
