Commit 1f31fad9 authored by Tomas Glozar's avatar Tomas Glozar Committed by Wentao Guan
Browse files

rtla/timerlat_top: Stop timerlat tracer on signal

stable inclusion
from stable-v6.6.78
commit 52ad6195bdb9b453d6d96f3284d284df9c435bf4
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBX1M5

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=52ad6195bdb9b453d6d96f3284d284df9c435bf4

--------------------------------

commit a4dfce7559d75430c464294ddee554be2a413c4a upstream.

Currently, when either SIGINT from the user or SIGALRM from the duration
timer is caught by rtla-timerlat, stop_tracing is set to break out of
the main loop. This is not sufficient for cases where the timerlat
tracer is producing more data than rtla can consume, since in that case,
rtla is looping indefinitely inside tracefs_iterate_raw_events, never
reaches the check of stop_tracing and hangs.

In addition to setting stop_tracing, also stop the timerlat tracer on
received signal (SIGINT or SIGALRM). This will stop new samples so that
the existing samples may be processed and tracefs_iterate_raw_events
eventually exits.

Cc: stable@vger.kernel.org
Cc: John Kacur <jkacur@redhat.com>
Cc: Luis Goncalves <lgoncalv@redhat.com>
Cc: Gabriele Monaco <gmonaco@redhat.com>
Link: https://lore.kernel.org/20250116144931.649593-4-tglozar@redhat.com


Fixes: a828cd18 ("rtla: Add timerlat tool and timelart top mode")
Signed-off-by: default avatarTomas Glozar <tglozar@redhat.com>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 52ad6195bdb9b453d6d96f3284d284df9c435bf4)
Signed-off-by: default avatarWentao Guan <guanwentao@uniontech.com>
parent c680562d
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -728,9 +728,12 @@ static struct osnoise_tool
}

static int stop_tracing;
static struct trace_instance *top_inst = NULL;
static void stop_top(int sig)
{
	stop_tracing = 1;
	if (top_inst)
		trace_instance_stop(top_inst);
}

/*
@@ -777,6 +780,13 @@ int timerlat_top_main(int argc, char *argv[])
	}

	trace = &top->trace;
	/*
	* Save trace instance into global variable so that SIGINT can stop
	* the timerlat tracer.
	* Otherwise, rtla could loop indefinitely when overloaded.
	*/
	top_inst = trace;


	retval = enable_timerlat(trace);
	if (retval) {
@@ -925,7 +935,7 @@ int timerlat_top_main(int argc, char *argv[])

	return_value = 0;

	if (trace_is_off(&top->trace, &record->trace)) {
	if (trace_is_off(&top->trace, &record->trace) && !stop_tracing) {
		printf("rtla timerlat hit stop tracing\n");

		if (!params->no_aa)