In the previous patch set for fixing CoreSight snapshot mode [1], the patch for perf tool has been merged into the mainline kernel [2]; other two patches for CoreSight driver have been left out.
This patch series resends these two missed out patches, alongside patches 01 and 02 are updated with minor improvement commits.
This patch series has been tested on Arm64 Juno board.
Changes from v2: - Minor improvement the commits for patches 01 and 02.
[1] https://lore.kernel.org/lkml/20210701093537.90759-1-leo.yan@linaro.org/ [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i...
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 | 2 +- drivers/hwtracing/coresight/coresight-tmc-etf.c | 2 +- drivers/hwtracing/coresight/coresight-tmc-etr.c | 12 ++++-------- 3 files changed, 6 insertions(+), 10 deletions(-)
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.
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.
Updates the comments in drivers to reflect the changes.
Signed-off-by: Leo Yan leo.yan@linaro.org --- drivers/hwtracing/coresight/coresight-etb10.c | 2 +- drivers/hwtracing/coresight/coresight-tmc-etf.c | 2 +- drivers/hwtracing/coresight/coresight-tmc-etr.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index f775cbee12b8..1cdb627d6c38 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -557,7 +557,7 @@ 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 + * that were written. User space function __auxtrace_mmap__read() will * figure out how many bytes to get from the AUX buffer based on the * position of the head. */ diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c index cd0fb7bfba68..a895931a2766 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c @@ -546,7 +546,7 @@ 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 + * that were written. User space function __auxtrace_mmap__read() will * figure out how many bytes to get from the AUX buffer based on the * position of the head. */ diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index d23c7690f29a..941abb70b827 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -1573,7 +1573,7 @@ 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 + * that were written. User space function __auxtrace_mmap__read() will * figure out how many bytes to get from the AUX buffer based on the * position of the head. */
Hi Leo
On 05/09/2021 14:12, 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.
Updates the comments in drivers to reflect the changes.
As such I would avoid referencing "userspace" function names in the kernel driver. Please could we remove it or make it generic ?
Also, remember, perf is not the only userspace tool driving the kernel perf.
Cheers Suzuki
Signed-off-by: Leo Yan leo.yan@linaro.org
drivers/hwtracing/coresight/coresight-etb10.c | 2 +- drivers/hwtracing/coresight/coresight-tmc-etf.c | 2 +- drivers/hwtracing/coresight/coresight-tmc-etr.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index f775cbee12b8..1cdb627d6c38 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -557,7 +557,7 @@ 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
* that were written. User space function __auxtrace_mmap__read() will
*/
- figure out how many bytes to get from the AUX buffer based on the
- position of the head.
diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c index cd0fb7bfba68..a895931a2766 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c @@ -546,7 +546,7 @@ 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
* that were written. User space function __auxtrace_mmap__read() will
*/
- figure out how many bytes to get from the AUX buffer based on the
- position of the head.
diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index d23c7690f29a..941abb70b827 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -1573,7 +1573,7 @@ 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
* that were written. User space function __auxtrace_mmap__read() will
*/
- figure out how many bytes to get from the AUX buffer based on the
- position of the head.
Hi Suzuki,
On Mon, Sep 06, 2021 at 10:51:02AM +0100, Suzuki Kuruppassery Poulose wrote:
Hi Leo
On 05/09/2021 14:12, 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.
Updates the comments in drivers to reflect the changes.
As such I would avoid referencing "userspace" function names in the kernel driver. Please could we remove it or make it generic ?
Okay, I'd like to remove the specific function name from the comment so can make the comment generic as:
"User space will figure out how many bytes to get from the AUX buffer based on the position of the head."
This info can remind us how the userspace and kernel co-work for snapshot mode if later we read the code.
If no objection, I will respin with this way.
Also, remember, perf is not the only userspace tool driving the kernel perf.
Good point.
Thanks for review, Leo
On 06/09/2021 11:28, Leo Yan wrote:
Hi Suzuki,
On Mon, Sep 06, 2021 at 10:51:02AM +0100, Suzuki Kuruppassery Poulose wrote:
Hi Leo
On 05/09/2021 14:12, 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.
Updates the comments in drivers to reflect the changes.
As such I would avoid referencing "userspace" function names in the kernel driver. Please could we remove it or make it generic ?
Okay, I'd like to remove the specific function name from the comment so can make the comment generic as:
"User space will figure out how many bytes to get from the AUX buffer based on the position of the head."
Yes please, that sounds perfect.
Cheers Suzuki