All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: linux-arm-kernel@lists.infradead.org
Cc: corbet@lwn.net, alexander.shishkin@linux.intel.com,
	coresight@lists.linaro.org, suzuki.poulose@arm.com,
	acme@kernel.org, peterz@infradead.org, mingo@redhat.com,
	mike.leach@arm.com, leo.yan@linaro.org
Subject: [PATCH 3/5] coresight: perf: Don't set the truncated flag in snapshot mode
Date: Wed,  1 May 2019 11:50:50 -0600	[thread overview]
Message-ID: <20190501175052.29667-4-mathieu.poirier@linaro.org> (raw)
In-Reply-To: <20190501175052.29667-1-mathieu.poirier@linaro.org>

This patch avoids setting the truncated flag when operaring 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>
---
 drivers/hwtracing/coresight/coresight-etb10.c   | 8 +++++++-
 drivers/hwtracing/coresight/coresight-tmc-etf.c | 8 +++++++-
 drivers/hwtracing/coresight/coresight-tmc-etr.c | 8 +++++++-
 3 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c
index 0764647b92bc..6ff48be91f61 100644
--- a/drivers/hwtracing/coresight/coresight-etb10.c
+++ b/drivers/hwtracing/coresight/coresight-etb10.c
@@ -535,7 +535,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 */
diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c
index d3025634f5e6..8039bd389034 100644
--- a/drivers/hwtracing/coresight/coresight-tmc-etf.c
+++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c
@@ -538,7 +538,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;
diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c
index b9881d6d41ba..718586a083af 100644
--- a/drivers/hwtracing/coresight/coresight-tmc-etr.c
+++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c
@@ -1516,7 +1516,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;
 }
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2019-05-01 17:51 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-01 17:50 [PATCH 0/5] coresight: Fix snapshot mode Mathieu Poirier
2019-05-01 17:50 ` [PATCH 1/5] coresight: Fix buffer size in " Mathieu Poirier
2019-05-07  7:38   ` Leo Yan
2019-05-07 17:24     ` Mathieu Poirier
2019-05-07  8:50   ` Suzuki K Poulose
2019-05-07 20:22     ` Mathieu Poirier
2019-05-01 17:50 ` [PATCH 2/5] coresight: tmc-etf: Fix snapshot mode update function Mathieu Poirier
2019-05-07  8:13   ` Leo Yan
2019-05-07 17:16     ` Mathieu Poirier
2019-05-07  9:22   ` Suzuki K Poulose
2019-05-01 17:50 ` Mathieu Poirier [this message]
2019-05-07  8:29   ` [PATCH 3/5] coresight: perf: Don't set the truncated flag in snapshot mode Leo Yan
2019-05-07 17:44     ` Mathieu Poirier
2019-05-01 17:50 ` [PATCH 4/5] perf tools: Properly set the value of 'old' " Mathieu Poirier
2019-05-07  8:44   ` Leo Yan
2019-05-07 17:59     ` Mathieu Poirier
2019-05-01 17:50 ` [PATCH 5/5] docs: coresight: Document " Mathieu Poirier
2019-05-11  7:32   ` Leo Yan
2019-05-13  8:37     ` Suzuki K Poulose
2019-05-13 11:16       ` Leo Yan
2019-05-13 20:01         ` Mathieu Poirier
2019-05-13 20:12           ` Mathieu Poirier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190501175052.29667-4-mathieu.poirier@linaro.org \
    --to=mathieu.poirier@linaro.org \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=corbet@lwn.net \
    --cc=coresight@lists.linaro.org \
    --cc=leo.yan@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mike.leach@arm.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=suzuki.poulose@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.