diff mbox series

[3/5] hwtracing: hisi_ptt: Optimize the trace data committing

Message ID 20230809081825.11518-4-yangyicong@huawei.com (mailing list archive)
State Superseded
Headers show
Series Several updates for PTT driver | expand

Commit Message

Yicong Yang Aug. 9, 2023, 8:18 a.m. UTC
From: Yicong Yang <yangyicong@hisilicon.com>

Currently during the PTT trace, we'll only commit the data
to the perf core when its full, which means after 4 interrupts
and totally 16MiB data while the AUX buffer is 16MiB length.
Then the userspace gets notified and handle the data. The driver
cannot apply a new AUX buffer immediately until the committed data
are handled and there's enough room in the buffer again.

This patch tries to optimize this by commit the data in every
interrupts in a 4MiB granularity. Then the userspace can have
enough time to consume the data and there's always enough room
in the AUX buffer.

Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
---
 drivers/hwtracing/ptt/hisi_ptt.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

Comments

Jonathan Cameron Aug. 25, 2023, 11:24 a.m. UTC | #1
On Wed, 9 Aug 2023 16:18:23 +0800
Yicong Yang <yangyicong@huawei.com> wrote:

> From: Yicong Yang <yangyicong@hisilicon.com>
> 
> Currently during the PTT trace, we'll only commit the data
> to the perf core when its full, which means after 4 interrupts
> and totally 16MiB data while the AUX buffer is 16MiB length.
> Then the userspace gets notified and handle the data. The driver
> cannot apply a new AUX buffer immediately until the committed data
> are handled and there's enough room in the buffer again.
> 
> This patch tries to optimize this by commit the data in every
> interrupts in a 4MiB granularity. Then the userspace can have
> enough time to consume the data and there's always enough room
> in the AUX buffer.
> 
> Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>

Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/hwtracing/ptt/hisi_ptt.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/hwtracing/ptt/hisi_ptt.c b/drivers/hwtracing/ptt/hisi_ptt.c
> index 89638ed96cf9..3aba7bb6e548 100644
> --- a/drivers/hwtracing/ptt/hisi_ptt.c
> +++ b/drivers/hwtracing/ptt/hisi_ptt.c
> @@ -274,15 +274,14 @@ static int hisi_ptt_update_aux(struct hisi_ptt *hisi_ptt, int index, bool stop)
>  	buf->pos += size;
>  
>  	/*
> -	 * Just commit the traced data if we're going to stop. Otherwise if the
> -	 * resident AUX buffer cannot contain the data of next trace buffer,
> -	 * apply a new one.
> +	 * Always commit the data to the AUX buffer in time to make sure
> +	 * userspace got enough time to consume the data.
> +	 *
> +	 * If we're not going to stop, apply a new one and check whether
> +	 * there's enough room for the next trace.
>  	 */
> -	if (stop) {
> -		perf_aux_output_end(handle, buf->pos);
> -	} else if (buf->length - buf->pos < HISI_PTT_TRACE_BUF_SIZE) {
> -		perf_aux_output_end(handle, buf->pos);
> -
> +	perf_aux_output_end(handle, size);
> +	if (!stop) {
>  		buf = perf_aux_output_begin(handle, event);
>  		if (!buf)
>  			return -EINVAL;
diff mbox series

Patch

diff --git a/drivers/hwtracing/ptt/hisi_ptt.c b/drivers/hwtracing/ptt/hisi_ptt.c
index 89638ed96cf9..3aba7bb6e548 100644
--- a/drivers/hwtracing/ptt/hisi_ptt.c
+++ b/drivers/hwtracing/ptt/hisi_ptt.c
@@ -274,15 +274,14 @@  static int hisi_ptt_update_aux(struct hisi_ptt *hisi_ptt, int index, bool stop)
 	buf->pos += size;
 
 	/*
-	 * Just commit the traced data if we're going to stop. Otherwise if the
-	 * resident AUX buffer cannot contain the data of next trace buffer,
-	 * apply a new one.
+	 * Always commit the data to the AUX buffer in time to make sure
+	 * userspace got enough time to consume the data.
+	 *
+	 * If we're not going to stop, apply a new one and check whether
+	 * there's enough room for the next trace.
 	 */
-	if (stop) {
-		perf_aux_output_end(handle, buf->pos);
-	} else if (buf->length - buf->pos < HISI_PTT_TRACE_BUF_SIZE) {
-		perf_aux_output_end(handle, buf->pos);
-
+	perf_aux_output_end(handle, size);
+	if (!stop) {
 		buf = perf_aux_output_begin(handle, event);
 		if (!buf)
 			return -EINVAL;