All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Kiss <daniel.kiss@arm.com>
To: coresight@lists.linaro.org
Cc: denik@google.com, leo.yan@linaro.org,
	linux-arm-kernel@lists.infradead.org, mathieu.poirier@linaro.org,
	mike.leach@linaro.org, suzuki.poulose@arm.com,
	Daniel Kiss <daniel.kiss@arm.com>
Subject: [PATCHv2 1/4] coresight: tmc-etr: Use handle->head from perf_output_handle directly.
Date: Tue, 13 Jul 2021 14:15:29 +0200	[thread overview]
Message-ID: <20210713121532.836244-2-daniel.kiss@arm.com> (raw)
In-Reply-To: <20210713121532.836244-1-daniel.kiss@arm.com>

Polling might call update multiple times and the cached buffer head will
be out of sync without advancing it. Using the head directly from the
perf_output_handle solves this problem.

Signed-off-by: Daniel Kiss <daniel.kiss@arm.com>
---
 drivers/hwtracing/coresight/coresight-tmc-etr.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c
index acdb59e0e6614..589bb2d56e802 100644
--- a/drivers/hwtracing/coresight/coresight-tmc-etr.c
+++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c
@@ -32,7 +32,6 @@ struct etr_flat_buf {
  * @etr_buf		- Actual buffer used by the ETR
  * @pid			- The PID this etr_perf_buffer belongs to.
  * @snaphost		- Perf session mode
- * @head		- handle->head at the beginning of the session.
  * @nr_pages		- Number of pages in the ring buffer.
  * @pages		- Array of Pages in the ring buffer.
  */
@@ -41,7 +40,6 @@ struct etr_perf_buffer {
 	struct etr_buf		*etr_buf;
 	pid_t			pid;
 	bool			snapshot;
-	unsigned long		head;
 	int			nr_pages;
 	void			**pages;
 };
@@ -1436,17 +1434,18 @@ static void tmc_free_etr_buffer(void *config)
  * tmc_etr_sync_perf_buffer: Copy the actual trace data from the hardware
  * buffer to the perf ring buffer.
  */
-static void tmc_etr_sync_perf_buffer(struct etr_perf_buffer *etr_perf,
+static void tmc_etr_sync_perf_buffer(struct perf_output_handle *handle,
+				     struct etr_perf_buffer *etr_perf,
 				     unsigned long src_offset,
 				     unsigned long to_copy)
 {
 	long bytes;
 	long pg_idx, pg_offset;
-	unsigned long head = etr_perf->head;
+	unsigned long head;
 	char **dst_pages, *src_buf;
 	struct etr_buf *etr_buf = etr_perf->etr_buf;
 
-	head = etr_perf->head;
+	head = PERF_IDX2OFF(handle->head, etr_perf);
 	pg_idx = head >> PAGE_SHIFT;
 	pg_offset = head & (PAGE_SIZE - 1);
 	dst_pages = (char **)etr_perf->pages;
@@ -1553,7 +1552,7 @@ tmc_update_etr_buffer(struct coresight_device *csdev,
 	/* Insert barrier packets at the beginning, if there was an overflow */
 	if (lost)
 		tmc_etr_buf_insert_barrier_packet(etr_buf, offset);
-	tmc_etr_sync_perf_buffer(etr_perf, offset, size);
+	tmc_etr_sync_perf_buffer(handle, etr_perf, offset, size);
 
 	/*
 	 * In snapshot mode we simply increment the head by the number of byte
@@ -1605,8 +1604,6 @@ static int tmc_enable_etr_sink_perf(struct coresight_device *csdev, void *data)
 		goto unlock_out;
 	}
 
-	etr_perf->head = PERF_IDX2OFF(handle->head, etr_perf);
-
 	/*
 	 * No HW configuration is needed if the sink is already in
 	 * use for this session.
-- 
2.25.1


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

  reply	other threads:[~2021-07-13 12:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-13 12:15 [PATCHv2 0/4] coresight: Add ETR-PERF polling Daniel Kiss
2021-07-13 12:15 ` Daniel Kiss [this message]
2021-07-13 12:15 ` [PATCHv2 2/4] coresight: tmc-etr: Track perf handler Daniel Kiss
2021-08-25 17:02   ` Mathieu Poirier
2021-08-25 19:09     ` Mathieu Poirier
2021-07-13 12:15 ` [PATCHv2 3/4] coresight: etm-perf: Export etm_event_cpu_path Daniel Kiss
2021-07-13 12:15 ` [PATCHv2 4/4] coresight: Add ETR-PERF polling Daniel Kiss
2021-08-26 16:41   ` Mathieu Poirier
2021-08-26 17:32   ` Mathieu Poirier
2021-08-31 13:31     ` Mike Leach
2021-09-01 18:02       ` 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=20210713121532.836244-2-daniel.kiss@arm.com \
    --to=daniel.kiss@arm.com \
    --cc=coresight@lists.linaro.org \
    --cc=denik@google.com \
    --cc=leo.yan@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=mike.leach@linaro.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.