Skip to content

Commit c73cab9

Browse files
lenticularis39rostedt
authored andcommitted
rtla/timerlat_hist: Stop timerlat tracer on signal
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: [email protected] Cc: John Kacur <[email protected]> Cc: Luis Goncalves <[email protected]> Cc: Gabriele Monaco <[email protected]> Link: https://lore.kernel.org/[email protected] Fixes: 1eeb632 ("rtla/timerlat: Add timerlat hist mode") Signed-off-by: Tomas Glozar <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent e879b5d commit c73cab9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tools/tracing/rtla/src/timerlat_hist.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1131,9 +1131,12 @@ static struct osnoise_tool
11311131
}
11321132

11331133
static int stop_tracing;
1134+
static struct trace_instance *hist_inst = NULL;
11341135
static void stop_hist(int sig)
11351136
{
11361137
stop_tracing = 1;
1138+
if (hist_inst)
1139+
trace_instance_stop(hist_inst);
11371140
}
11381141

11391142
/*
@@ -1180,6 +1183,12 @@ int timerlat_hist_main(int argc, char *argv[])
11801183
}
11811184

11821185
trace = &tool->trace;
1186+
/*
1187+
* Save trace instance into global variable so that SIGINT can stop
1188+
* the timerlat tracer.
1189+
* Otherwise, rtla could loop indefinitely when overloaded.
1190+
*/
1191+
hist_inst = trace;
11831192

11841193
retval = enable_timerlat(trace);
11851194
if (retval) {
@@ -1348,7 +1357,7 @@ int timerlat_hist_main(int argc, char *argv[])
13481357

13491358
return_value = 0;
13501359

1351-
if (trace_is_off(&tool->trace, &record->trace)) {
1360+
if (trace_is_off(&tool->trace, &record->trace) && !stop_tracing) {
13521361
printf("rtla timerlat hit stop tracing\n");
13531362

13541363
if (!params->no_aa)

0 commit comments

Comments
 (0)