coresight: perf: Don't set the truncated flag in snapshot mode
authorMathieu Poirier <mathieu.poirier@linaro.org>
Wed, 19 Jun 2019 17:29:09 +0000 (11:29 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Jun 2019 18:29:14 +0000 (20:29 +0200)
This patch avoids setting the truncated flag when operating in snapshot
mode since the trace buffer is expected to be truncated and discontinuous
from one snapshot to another.  Moreover when the truncated flag is set
the perf core stops enabling the event, waiting for user space to consume
the data.  In snapshot mode this is clearly not what we want since it
results in stale data.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Tested-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hwtracing/coresight/coresight-etb10.c
drivers/hwtracing/coresight/coresight-tmc-etf.c
drivers/hwtracing/coresight/coresight-tmc-etr.c

index 60e753b1768d751bbad5bba48043ce0323a3976f..516d67cd7759b97324664ea8395adf50621e3f87 100644 (file)
@@ -512,7 +512,13 @@ static unsigned long etb_update_buffer(struct coresight_device *csdev,
                lost = true;
        }
 
-       if (lost)
+       /*
+        * Don't set the TRUNCATED flag in snapshot mode because 1) the
+        * captured buffer is expected to be truncated and 2) a full buffer
+        * prevents the event from being re-enabled by the perf core,
+        * resulting in stale data being send to user space.
+        */
+       if (!buf->snapshot && lost)
                perf_aux_output_flag(handle, PERF_AUX_FLAG_TRUNCATED);
 
        /* finally tell HW where we want to start reading from */
index 31d41e2ad9558e42a90e500685f3ef8dab5706ae..bd5f3b57eebddda65dae8f20aba9616a6ecd35d7 100644 (file)
@@ -518,7 +518,13 @@ static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev,
                lost = true;
        }
 
-       if (lost)
+       /*
+        * Don't set the TRUNCATED flag in snapshot mode because 1) the
+        * captured buffer is expected to be truncated and 2) a full buffer
+        * prevents the event from being re-enabled by the perf core,
+        * resulting in stale data being send to user space.
+        */
+       if (!buf->snapshot && lost)
                perf_aux_output_flag(handle, PERF_AUX_FLAG_TRUNCATED);
 
        cur = buf->cur;
index cc8401c76c399e52c79cf9edf6318eb376e45dfe..1fc3db8045e1e4e99f02ed5a62bfb236d1b230ee 100644 (file)
@@ -1511,7 +1511,13 @@ tmc_update_etr_buffer(struct coresight_device *csdev,
 
        lost |= etr_buf->full;
 out:
-       if (lost)
+       /*
+        * Don't set the TRUNCATED flag in snapshot mode because 1) the
+        * captured buffer is expected to be truncated and 2) a full buffer
+        * prevents the event from being re-enabled by the perf core,
+        * resulting in stale data being send to user space.
+        */
+       if (!etr_perf->snapshot && lost)
                perf_aux_output_flag(handle, PERF_AUX_FLAG_TRUNCATED);
        return size;
 }