linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/2] coresight: Fix for snapshot mode
@ 2021-09-12 12:57 Leo Yan
  2021-09-12 12:57 ` [PATCH v4 1/2] coresight: tmc-etr: Use perf_output_handle::head for AUX ring buffer Leo Yan
  2021-09-12 12:57 ` [PATCH v4 2/2] coresight: Update comments for removing cs_etm_find_snapshot() Leo Yan
  0 siblings, 2 replies; 5+ messages in thread
From: Leo Yan @ 2021-09-12 12:57 UTC (permalink / raw)
  To: Mathieu Poirier, Suzuki K Poulose, Mike Leach,
	Alexander Shishkin, coresight, linux-arm-kernel, linux-kernel
  Cc: Leo Yan

This patch series fixes the snapshot mode in the CoreSight driver.

The first patch simplifies the head pointer handling for AUX buffer, the
second patch updates the driver comments to reflect the latest status
for perf tool.

Changes from v3:
- Made the comments generic in CoreSight drivers (Suzuki).

Changes from v2:
- Minor improvement the commits for patches 01 and 02.


Leo Yan (2):
  coresight: tmc-etr: Use perf_output_handle::head for AUX ring buffer
  coresight: Update comments for removing cs_etm_find_snapshot()

 drivers/hwtracing/coresight/coresight-etb10.c   |  5 ++---
 drivers/hwtracing/coresight/coresight-tmc-etf.c |  5 ++---
 drivers/hwtracing/coresight/coresight-tmc-etr.c | 15 +++++----------
 3 files changed, 9 insertions(+), 16 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v4 1/2] coresight: tmc-etr: Use perf_output_handle::head for AUX ring buffer
  2021-09-12 12:57 [PATCH v4 0/2] coresight: Fix for snapshot mode Leo Yan
@ 2021-09-12 12:57 ` Leo Yan
  2021-09-12 12:57 ` [PATCH v4 2/2] coresight: Update comments for removing cs_etm_find_snapshot() Leo Yan
  1 sibling, 0 replies; 5+ messages in thread
From: Leo Yan @ 2021-09-12 12:57 UTC (permalink / raw)
  To: Mathieu Poirier, Suzuki K Poulose, Mike Leach,
	Alexander Shishkin, coresight, linux-arm-kernel, linux-kernel
  Cc: Leo Yan

When enable the Arm CoreSight PMU event, the context for AUX ring buffer
is prepared in the structure perf_output_handle, and its field "head"
points the head of the AUX ring buffer and it is updated after filling
AUX trace data into buffer.

Current code uses an extra field etr_perf_buffer::head to maintain the
header for the AUX ring buffer which is not necessary; alternatively,
it's better to directly use perf_output_handle::head.

This patch removes the field etr_perf_buffer::head and directly uses
perf_output_handle::head for the head of AUX ring buffer.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/hwtracing/coresight/coresight-tmc-etr.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c
index a049b525a274..d23c7690f29a 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;
 };
@@ -1455,16 +1453,16 @@ static void tmc_free_etr_buffer(void *config)
  * buffer to the perf ring buffer.
  */
 static void tmc_etr_sync_perf_buffer(struct etr_perf_buffer *etr_perf,
+				     unsigned long head,
 				     unsigned long src_offset,
 				     unsigned long to_copy)
 {
 	long bytes;
 	long pg_idx, pg_offset;
-	unsigned long head = etr_perf->head;
 	char **dst_pages, *src_buf;
 	struct etr_buf *etr_buf = etr_perf->etr_buf;
 
-	head = etr_perf->head;
+	head = PERF_IDX2OFF(head, etr_perf);
 	pg_idx = head >> PAGE_SHIFT;
 	pg_offset = head & (PAGE_SIZE - 1);
 	dst_pages = (char **)etr_perf->pages;
@@ -1571,7 +1569,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(etr_perf, handle->head, offset, size);
 
 	/*
 	 * In snapshot mode we simply increment the head by the number of byte
@@ -1623,8 +1621,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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v4 2/2] coresight: Update comments for removing cs_etm_find_snapshot()
  2021-09-12 12:57 [PATCH v4 0/2] coresight: Fix for snapshot mode Leo Yan
  2021-09-12 12:57 ` [PATCH v4 1/2] coresight: tmc-etr: Use perf_output_handle::head for AUX ring buffer Leo Yan
@ 2021-09-12 12:57 ` Leo Yan
  2021-09-14  9:27   ` Suzuki K Poulose
  1 sibling, 1 reply; 5+ messages in thread
From: Leo Yan @ 2021-09-12 12:57 UTC (permalink / raw)
  To: Mathieu Poirier, Suzuki K Poulose, Mike Leach,
	Alexander Shishkin, coresight, linux-arm-kernel, linux-kernel
  Cc: Leo Yan

Commit 2f01c200d440 ("perf cs-etm: Remove callback cs_etm_find_snapshot()")
has removed the function cs_etm_find_snapshot() from the perf tool in the
user space, now CoreSight trace directly uses the perf common function
__auxtrace_mmap__read() to calcualte the head and size for AUX trace data
in snapshot mode.

This patch updates the comments in drivers to make them generic and not
stick to any specific function from perf tool.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
 drivers/hwtracing/coresight/coresight-etb10.c   | 5 ++---
 drivers/hwtracing/coresight/coresight-tmc-etf.c | 5 ++---
 drivers/hwtracing/coresight/coresight-tmc-etr.c | 5 ++---
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c
index f775cbee12b8..efa39820acec 100644
--- a/drivers/hwtracing/coresight/coresight-etb10.c
+++ b/drivers/hwtracing/coresight/coresight-etb10.c
@@ -557,9 +557,8 @@ static unsigned long etb_update_buffer(struct coresight_device *csdev,
 
 	/*
 	 * In snapshot mode we simply increment the head by the number of byte
-	 * that were written.  User space function  cs_etm_find_snapshot() will
-	 * figure out how many bytes to get from the AUX buffer based on the
-	 * position of the head.
+	 * that were written.  User space will figure out how many bytes to get
+	 * from the AUX buffer based on the position of the head.
 	 */
 	if (buf->snapshot)
 		handle->head += to_read;
diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c
index cd0fb7bfba68..b416b1951d3e 100644
--- a/drivers/hwtracing/coresight/coresight-tmc-etf.c
+++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c
@@ -546,9 +546,8 @@ static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev,
 
 	/*
 	 * In snapshot mode we simply increment the head by the number of byte
-	 * that were written.  User space function  cs_etm_find_snapshot() will
-	 * figure out how many bytes to get from the AUX buffer based on the
-	 * position of the head.
+	 * that were written.  User space will figure out how many bytes to get
+	 * from the AUX buffer based on the position of the head.
 	 */
 	if (buf->snapshot)
 		handle->head += to_read;
diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c
index d23c7690f29a..ce14eb83925c 100644
--- a/drivers/hwtracing/coresight/coresight-tmc-etr.c
+++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c
@@ -1573,9 +1573,8 @@ tmc_update_etr_buffer(struct coresight_device *csdev,
 
 	/*
 	 * In snapshot mode we simply increment the head by the number of byte
-	 * that were written.  User space function  cs_etm_find_snapshot() will
-	 * figure out how many bytes to get from the AUX buffer based on the
-	 * position of the head.
+	 * that were written.  User space will figure out how many bytes to get
+	 * from the AUX buffer based on the position of the head.
 	 */
 	if (etr_perf->snapshot)
 		handle->head += size;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 2/2] coresight: Update comments for removing cs_etm_find_snapshot()
  2021-09-12 12:57 ` [PATCH v4 2/2] coresight: Update comments for removing cs_etm_find_snapshot() Leo Yan
@ 2021-09-14  9:27   ` Suzuki K Poulose
  2021-09-14 10:08     ` Leo Yan
  0 siblings, 1 reply; 5+ messages in thread
From: Suzuki K Poulose @ 2021-09-14  9:27 UTC (permalink / raw)
  To: Leo Yan, Mathieu Poirier, Mike Leach, Alexander Shishkin,
	coresight, linux-arm-kernel, linux-kernel

On 12/09/2021 13:57, Leo Yan wrote:
> Commit 2f01c200d440 ("perf cs-etm: Remove callback cs_etm_find_snapshot()")
> has removed the function cs_etm_find_snapshot() from the perf tool in the
> user space, now CoreSight trace directly uses the perf common function
> __auxtrace_mmap__read() to calcualte the head and size for AUX trace data
> in snapshot mode.
> 
> This patch updates the comments in drivers to make them generic and not
> stick to any specific function from perf tool.
> 
> Signed-off-by: Leo Yan <leo.yan@linaro.org>
> ---
>   drivers/hwtracing/coresight/coresight-etb10.c   | 5 ++---
>   drivers/hwtracing/coresight/coresight-tmc-etf.c | 5 ++---
>   drivers/hwtracing/coresight/coresight-tmc-etr.c | 5 ++---
>   3 files changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c
> index f775cbee12b8..efa39820acec 100644
> --- a/drivers/hwtracing/coresight/coresight-etb10.c
> +++ b/drivers/hwtracing/coresight/coresight-etb10.c
> @@ -557,9 +557,8 @@ static unsigned long etb_update_buffer(struct coresight_device *csdev,
>   
>   	/*
>   	 * In snapshot mode we simply increment the head by the number of byte
> -	 * that were written.  User space function  cs_etm_find_snapshot() will
> -	 * figure out how many bytes to get from the AUX buffer based on the
> -	 * position of the head.
> +	 * that were written.  User space will figure out how many bytes to get
> +	 * from the AUX buffer based on the position of the head.
>   	 */
>   	if (buf->snapshot)
>   		handle->head += to_read;
> diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c
> index cd0fb7bfba68..b416b1951d3e 100644
> --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c
> +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c
> @@ -546,9 +546,8 @@ static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev,
>   
>   	/*
>   	 * In snapshot mode we simply increment the head by the number of byte
> -	 * that were written.  User space function  cs_etm_find_snapshot() will
> -	 * figure out how many bytes to get from the AUX buffer based on the
> -	 * position of the head.
> +	 * that were written.  User space will figure out how many bytes to get
> +	 * from the AUX buffer based on the position of the head.
>   	 */
>   	if (buf->snapshot)
>   		handle->head += to_read;
> diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c
> index d23c7690f29a..ce14eb83925c 100644
> --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c
> +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c
> @@ -1573,9 +1573,8 @@ tmc_update_etr_buffer(struct coresight_device *csdev,
>   
>   	/*
>   	 * In snapshot mode we simply increment the head by the number of byte
> -	 * that were written.  User space function  cs_etm_find_snapshot() will
> -	 * figure out how many bytes to get from the AUX buffer based on the
> -	 * position of the head.
> +	 * that were written.  User space will figure out how many bytes to get
> +	 * from the AUX buffer based on the position of the head.
>   	 */
>   	if (etr_perf->snapshot)
>   		handle->head += size;
> 


Thanks for the revised patch, I have queued both the patches.

Kind regards
Suzuki


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 2/2] coresight: Update comments for removing cs_etm_find_snapshot()
  2021-09-14  9:27   ` Suzuki K Poulose
@ 2021-09-14 10:08     ` Leo Yan
  0 siblings, 0 replies; 5+ messages in thread
From: Leo Yan @ 2021-09-14 10:08 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: Mathieu Poirier, Mike Leach, Alexander Shishkin, coresight,
	linux-arm-kernel, linux-kernel

On Tue, Sep 14, 2021 at 10:27:26AM +0100, Suzuki Kuruppassery Poulose wrote:

[...]

> > diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c
> > index d23c7690f29a..ce14eb83925c 100644
> > --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c
> > +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c
> > @@ -1573,9 +1573,8 @@ tmc_update_etr_buffer(struct coresight_device *csdev,
> >   	/*
> >   	 * In snapshot mode we simply increment the head by the number of byte
> > -	 * that were written.  User space function  cs_etm_find_snapshot() will
> > -	 * figure out how many bytes to get from the AUX buffer based on the
> > -	 * position of the head.
> > +	 * that were written.  User space will figure out how many bytes to get
> > +	 * from the AUX buffer based on the position of the head.
> >   	 */
> >   	if (etr_perf->snapshot)
> >   		handle->head += size;
> > 
> 
> 
> Thanks for the revised patch, I have queued both the patches.

Cool, and thanks Suzuki!

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-09-14 10:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-12 12:57 [PATCH v4 0/2] coresight: Fix for snapshot mode Leo Yan
2021-09-12 12:57 ` [PATCH v4 1/2] coresight: tmc-etr: Use perf_output_handle::head for AUX ring buffer Leo Yan
2021-09-12 12:57 ` [PATCH v4 2/2] coresight: Update comments for removing cs_etm_find_snapshot() Leo Yan
2021-09-14  9:27   ` Suzuki K Poulose
2021-09-14 10:08     ` Leo Yan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).