diff mbox series

[v3,07/10] coresight: trbe: Do not truncate buffer on IRQ

Message ID 20210914102641.1852544-8-suzuki.poulose@arm.com (mailing list archive)
State New, archived
Headers show
Series coresight: TRBE and Self-Hosted trace fixes | expand

Commit Message

Suzuki K Poulose Sept. 14, 2021, 10:26 a.m. UTC
The TRBE driver marks the AUX buffer as TRUNCATED when we get an IRQ
on FILL event. This has rather unwanted side-effect of the event
being disabled when there may be more space in the ring buffer.

So, instead of TRUNCATE we need a different flag to indicate
that the trace may have lost a few bytes (i.e from the point of
generating the FILL event until the IRQ is consumed). Anyways, the
userspace must use the size from RECORD_AUX headers to restrict
the "trace" decoding.

Using PARTIAL flag causes the perf tool to generate the
following warning:

  Warning:
  AUX data had gaps in it XX times out of YY!

  Are you running a KVM guest in the background?

which is pointlessly scary for a user. The other remaining options
are :
  - COLLISION - Use by SPE to indicate samples collided
  - Add a new flag - Specifically for CoreSight, doesn't sound
    so good, if we can re-use something.

Given that we don't already use the "COLLISION" flag, the above
behavior can be notified using this flag for CoreSight.

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: James Clark <james.clark@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
Changes since v2:
  - The perf tool patch for reporting collisions is queued.
---
 drivers/hwtracing/coresight/coresight-trbe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Anshuman Khandual Sept. 15, 2021, 6:44 a.m. UTC | #1
On 9/14/21 3:56 PM, Suzuki K Poulose wrote:
> The TRBE driver marks the AUX buffer as TRUNCATED when we get an IRQ
> on FILL event. This has rather unwanted side-effect of the event
> being disabled when there may be more space in the ring buffer.
> 
> So, instead of TRUNCATE we need a different flag to indicate
> that the trace may have lost a few bytes (i.e from the point of
> generating the FILL event until the IRQ is consumed). Anyways, the
> userspace must use the size from RECORD_AUX headers to restrict
> the "trace" decoding.
> 
> Using PARTIAL flag causes the perf tool to generate the
> following warning:
> 
>   Warning:
>   AUX data had gaps in it XX times out of YY!
> 
>   Are you running a KVM guest in the background?
> 
> which is pointlessly scary for a user. The other remaining options
> are :
>   - COLLISION - Use by SPE to indicate samples collided
>   - Add a new flag - Specifically for CoreSight, doesn't sound
>     so good, if we can re-use something.
> 
> Given that we don't already use the "COLLISION" flag, the above
> behavior can be notified using this flag for CoreSight.
> 
> Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
> Cc: James Clark <james.clark@arm.com>
> Cc: Mike Leach <mike.leach@linaro.org>
> Cc: Anshuman Khandual <anshuman.khandual@arm.com>
> Cc: Leo Yan <leo.yan@linaro.org>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>

Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>

> ---
> Changes since v2:
>   - The perf tool patch for reporting collisions is queued.
> ---
>  drivers/hwtracing/coresight/coresight-trbe.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c
> index de99dd0aecd3..a1a15fa6c4ae 100644
> --- a/drivers/hwtracing/coresight/coresight-trbe.c
> +++ b/drivers/hwtracing/coresight/coresight-trbe.c
> @@ -612,7 +612,7 @@ static unsigned long arm_trbe_update_buffer(struct coresight_device *csdev,
>  		 * for correct size. Also, mark the buffer truncated.
>  		 */
>  		write = get_trbe_limit_pointer();
> -		perf_aux_output_flag(handle, PERF_AUX_FLAG_TRUNCATED);
> +		perf_aux_output_flag(handle, PERF_AUX_FLAG_COLLISION);
>  	}
>  
>  	offset = write - base;
> @@ -705,7 +705,7 @@ static void trbe_handle_overflow(struct perf_output_handle *handle)
>  	 * Mark the buffer as truncated, as we have stopped the trace
>  	 * collection upon the WRAP event, without stopping the source.
>  	 */
> -	perf_aux_output_flag(handle, PERF_AUX_FLAG_TRUNCATED);
> +	perf_aux_output_flag(handle, PERF_AUX_FLAG_COLLISION);
>  	perf_aux_output_end(handle, size);
>  	event_data = perf_aux_output_begin(handle, event);
>  	if (!event_data) {
>
Mathieu Poirier Sept. 21, 2021, 5:41 p.m. UTC | #2
On Tue, Sep 14, 2021 at 11:26:38AM +0100, Suzuki K Poulose wrote:
> The TRBE driver marks the AUX buffer as TRUNCATED when we get an IRQ
> on FILL event. This has rather unwanted side-effect of the event
> being disabled when there may be more space in the ring buffer.
> 
> So, instead of TRUNCATE we need a different flag to indicate
> that the trace may have lost a few bytes (i.e from the point of
> generating the FILL event until the IRQ is consumed). Anyways, the
> userspace must use the size from RECORD_AUX headers to restrict
> the "trace" decoding.
> 
> Using PARTIAL flag causes the perf tool to generate the
> following warning:
> 
>   Warning:
>   AUX data had gaps in it XX times out of YY!
> 
>   Are you running a KVM guest in the background?
> 
> which is pointlessly scary for a user. The other remaining options
> are :
>   - COLLISION - Use by SPE to indicate samples collided
>   - Add a new flag - Specifically for CoreSight, doesn't sound
>     so good, if we can re-use something.
> 
> Given that we don't already use the "COLLISION" flag, the above
> behavior can be notified using this flag for CoreSight.
> 
> Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
> Cc: James Clark <james.clark@arm.com>
> Cc: Mike Leach <mike.leach@linaro.org>
> Cc: Anshuman Khandual <anshuman.khandual@arm.com>
> Cc: Leo Yan <leo.yan@linaro.org>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
> Changes since v2:
>   - The perf tool patch for reporting collisions is queued.
> ---
>  drivers/hwtracing/coresight/coresight-trbe.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c
> index de99dd0aecd3..a1a15fa6c4ae 100644
> --- a/drivers/hwtracing/coresight/coresight-trbe.c
> +++ b/drivers/hwtracing/coresight/coresight-trbe.c
> @@ -612,7 +612,7 @@ static unsigned long arm_trbe_update_buffer(struct coresight_device *csdev,
>  		 * for correct size. Also, mark the buffer truncated.
>  		 */
>  		write = get_trbe_limit_pointer();
> -		perf_aux_output_flag(handle, PERF_AUX_FLAG_TRUNCATED);
> +		perf_aux_output_flag(handle, PERF_AUX_FLAG_COLLISION);

The rational in the changelog should be added here as a comment.

>  	}
>  
>  	offset = write - base;
> @@ -705,7 +705,7 @@ static void trbe_handle_overflow(struct perf_output_handle *handle)
>  	 * Mark the buffer as truncated, as we have stopped the trace
>  	 * collection upon the WRAP event, without stopping the source.
>  	 */
> -	perf_aux_output_flag(handle, PERF_AUX_FLAG_TRUNCATED);
> +	perf_aux_output_flag(handle, PERF_AUX_FLAG_COLLISION);

Same.

>  	perf_aux_output_end(handle, size);
>  	event_data = perf_aux_output_begin(handle, event);
>  	if (!event_data) {
> -- 
> 2.24.1
>
Mathieu Poirier Sept. 21, 2021, 5:50 p.m. UTC | #3
On Tue, Sep 21, 2021 at 11:41:10AM -0600, Mathieu Poirier wrote:
> On Tue, Sep 14, 2021 at 11:26:38AM +0100, Suzuki K Poulose wrote:
> > The TRBE driver marks the AUX buffer as TRUNCATED when we get an IRQ
> > on FILL event. This has rather unwanted side-effect of the event
> > being disabled when there may be more space in the ring buffer.
> > 
> > So, instead of TRUNCATE we need a different flag to indicate
> > that the trace may have lost a few bytes (i.e from the point of
> > generating the FILL event until the IRQ is consumed). Anyways, the
> > userspace must use the size from RECORD_AUX headers to restrict
> > the "trace" decoding.
> > 
> > Using PARTIAL flag causes the perf tool to generate the
> > following warning:
> > 
> >   Warning:
> >   AUX data had gaps in it XX times out of YY!
> > 
> >   Are you running a KVM guest in the background?
> > 
> > which is pointlessly scary for a user. The other remaining options
> > are :
> >   - COLLISION - Use by SPE to indicate samples collided
> >   - Add a new flag - Specifically for CoreSight, doesn't sound
> >     so good, if we can re-use something.
> > 
> > Given that we don't already use the "COLLISION" flag, the above
> > behavior can be notified using this flag for CoreSight.
> > 
> > Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
> > Cc: James Clark <james.clark@arm.com>
> > Cc: Mike Leach <mike.leach@linaro.org>
> > Cc: Anshuman Khandual <anshuman.khandual@arm.com>
> > Cc: Leo Yan <leo.yan@linaro.org>
> > Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> > ---
> > Changes since v2:
> >   - The perf tool patch for reporting collisions is queued.
> > ---
> >  drivers/hwtracing/coresight/coresight-trbe.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c
> > index de99dd0aecd3..a1a15fa6c4ae 100644
> > --- a/drivers/hwtracing/coresight/coresight-trbe.c
> > +++ b/drivers/hwtracing/coresight/coresight-trbe.c
> > @@ -612,7 +612,7 @@ static unsigned long arm_trbe_update_buffer(struct coresight_device *csdev,
> >  		 * for correct size. Also, mark the buffer truncated.
> >  		 */
> >  		write = get_trbe_limit_pointer();
> > -		perf_aux_output_flag(handle, PERF_AUX_FLAG_TRUNCATED);
> > +		perf_aux_output_flag(handle, PERF_AUX_FLAG_COLLISION);
> 
> The rational in the changelog should be added here as a comment.
> 
> >  	}
> >  
> >  	offset = write - base;
> > @@ -705,7 +705,7 @@ static void trbe_handle_overflow(struct perf_output_handle *handle)
> >  	 * Mark the buffer as truncated, as we have stopped the trace
> >  	 * collection upon the WRAP event, without stopping the source.
> >  	 */
> > -	perf_aux_output_flag(handle, PERF_AUX_FLAG_TRUNCATED);
> > +	perf_aux_output_flag(handle, PERF_AUX_FLAG_COLLISION);
> 
> Same.

... and I'm out of time for today.  I will continue tomorrow.

Thanks,
Mathieu

> 
> >  	perf_aux_output_end(handle, size);
> >  	event_data = perf_aux_output_begin(handle, event);
> >  	if (!event_data) {
> > -- 
> > 2.24.1
> >
diff mbox series

Patch

diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c
index de99dd0aecd3..a1a15fa6c4ae 100644
--- a/drivers/hwtracing/coresight/coresight-trbe.c
+++ b/drivers/hwtracing/coresight/coresight-trbe.c
@@ -612,7 +612,7 @@  static unsigned long arm_trbe_update_buffer(struct coresight_device *csdev,
 		 * for correct size. Also, mark the buffer truncated.
 		 */
 		write = get_trbe_limit_pointer();
-		perf_aux_output_flag(handle, PERF_AUX_FLAG_TRUNCATED);
+		perf_aux_output_flag(handle, PERF_AUX_FLAG_COLLISION);
 	}
 
 	offset = write - base;
@@ -705,7 +705,7 @@  static void trbe_handle_overflow(struct perf_output_handle *handle)
 	 * Mark the buffer as truncated, as we have stopped the trace
 	 * collection upon the WRAP event, without stopping the source.
 	 */
-	perf_aux_output_flag(handle, PERF_AUX_FLAG_TRUNCATED);
+	perf_aux_output_flag(handle, PERF_AUX_FLAG_COLLISION);
 	perf_aux_output_end(handle, size);
 	event_data = perf_aux_output_begin(handle, event);
 	if (!event_data) {