[PATCH 5/5] rtla/timerlat_top: Abort event processing on second signal

Tomas Glozar posted 5 patches 11 months ago
[PATCH 5/5] rtla/timerlat_top: Abort event processing on second signal
Posted by Tomas Glozar 11 months ago
Apply the changes from the previous patch also to timerlat-top.

Signed-off-by: Tomas Glozar <tglozar@redhat.com>
---
 tools/tracing/rtla/src/timerlat_top.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c
index d21a21053917..d358cd39f360 100644
--- a/tools/tracing/rtla/src/timerlat_top.c
+++ b/tools/tracing/rtla/src/timerlat_top.c
@@ -903,6 +903,14 @@ static int stop_tracing;
 static struct trace_instance *top_inst = NULL;
 static void stop_top(int sig)
 {
+	if (stop_tracing) {
+		/*
+		 * Stop requested twice in a row; abort event processing and
+		 * exit immediately
+		 */
+		tracefs_iterate_stop(top_inst->inst);
+		return;
+	}
 	stop_tracing = 1;
 	if (top_inst)
 		trace_instance_stop(top_inst);
-- 
2.47.1
Re: [PATCH 5/5] rtla/timerlat_top: Abort event processing on second signal
Posted by Gabriele Monaco 11 months ago
On Thu, 2025-01-16 at 15:49 +0100, Tomas Glozar wrote:
> Apply the changes from the previous patch also to timerlat-top.
> 
> Signed-off-by: Tomas Glozar <tglozar@redhat.com>
> ---
>  tools/tracing/rtla/src/timerlat_top.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/tools/tracing/rtla/src/timerlat_top.c
> b/tools/tracing/rtla/src/timerlat_top.c
> index d21a21053917..d358cd39f360 100644
> --- a/tools/tracing/rtla/src/timerlat_top.c
> +++ b/tools/tracing/rtla/src/timerlat_top.c
> @@ -903,6 +903,14 @@ static int stop_tracing;
>  static struct trace_instance *top_inst = NULL;
>  static void stop_top(int sig)
>  {
> +	if (stop_tracing) {
> +		/*
> +		 * Stop requested twice in a row; abort event
> processing and
> +		 * exit immediately
> +		 */
> +		tracefs_iterate_stop(top_inst->inst);
> +		return;
> +	}
>  	stop_tracing = 1;
>  	if (top_inst)
>  		trace_instance_stop(top_inst);

I confirm the patchset works as expected on a 128 cores machine.
That is like the machine where the problem was first observed: run
timerlat with -p 100 and it would hang.

Now running it with -d terminates (a bit) after the expiration of the
timer with a sane report, sending a SIGINT terminates it too and
sending 2 SIGINT terminates it almost instantaneously.	

This works on both timerlat top and hist, with both -u and -k .
The report only gets printed in the end (as if -q was passed), but
these patches are not meant to fix that.

Tested-by: Gabriele Monaco <gmonaco@redhat.com>
Re: [PATCH 5/5] rtla/timerlat_top: Abort event processing on second signal
Posted by Steven Rostedt 11 months ago
On Thu, 16 Jan 2025 15:49:31 +0100
Tomas Glozar <tglozar@redhat.com> wrote:

> Apply the changes from the previous patch also to timerlat-top.
> 

Same here. I replaced this with:

    rtla/timerlat_top: Abort event processing on second signal
    
    If either SIGINT is received twice, or after a SIGALRM (that is, after
    timerlat was supposed to stop), abort processing events currently left
    in the tracefs buffer and exit immediately.
    
    This allows the user to exit rtla without waiting for processing all
    events, should that take longer than wanted, at the cost of not
    processing all samples.

-- Steve