aboutsummaryrefslogtreecommitdiff
path: root/tools/perf/arch/arm/util/cs-etm.c
diff options
context:
space:
mode:
authorMathieu Poirier <mathieu.poirier@linaro.org>2019-04-30 20:44:46 +0000
committerMathieu Poirier <mathieu.poirier@linaro.org>2019-05-03 09:35:28 -0600
commit4b012cdc3d8cf7b29ad5bd7b9029fb07a4ecacfd (patch)
tree70691068f013beb463a385315dbea1cd24e89968 /tools/perf/arch/arm/util/cs-etm.c
parent527c29fbd89f69c186d29280cae5279f5d1a494e (diff)
perf tools: Properly set the value of 'old' in snapshot mode
In snapshot mode the value of the 'old' pointer needs to be adjusted when 'head' has wrapped around in order to get the latest information in the buffer and be compatible with the generic AUX ring buffer mechanic. Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Diffstat (limited to 'tools/perf/arch/arm/util/cs-etm.c')
-rw-r--r--tools/perf/arch/arm/util/cs-etm.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c
index 911426721170..4e73fe1a6978 100644
--- a/tools/perf/arch/arm/util/cs-etm.c
+++ b/tools/perf/arch/arm/util/cs-etm.c
@@ -541,11 +541,19 @@ static int cs_etm_find_snapshot(struct auxtrace_record *itr __maybe_unused,
unsigned char *data __maybe_unused,
u64 *head, u64 *old)
{
+ bool wrapped;
+
pr_debug3("%s: mmap index %d old head %zu new head %zu size %zu\n",
__func__, idx, (size_t)*old, (size_t)*head, mm->len);
- *old = *head;
- *head += mm->len;
+ /*
+ * If the last byte in the ring buffer isn't zero, the head has
+ * wrapped around.
+ */
+ wrapped = !!(data[mm->len - 1]);
+
+ if (wrapped)
+ *old = *head - mm->len;
return 0;
}