]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rtla: Stop the record trace on interrupt
authorCrystal Wood <crwood@redhat.com>
Tue, 12 May 2026 17:37:31 +0000 (12:37 -0500)
committerTomas Glozar <tglozar@redhat.com>
Mon, 18 May 2026 09:00:52 +0000 (11:00 +0200)
Before, when rtla got a signal, it stopped the main trace but not the
record trace.  With "--on-end trace", this can lead to
save_trace_to_file() failing to keep up, especially on a debug kernel.
Plus, it adds post-stoppage noise to the trace file.

Signed-off-by: Crystal Wood <crwood@redhat.com>
Fixes: c73cab9dbed0 ("rtla/timerlat_hist: Stop timerlat tracer on signal")
Fixes: a4dfce7559d7 ("rtla/timerlat_top: Stop timerlat tracer on signal")
Fixes: 3aadb65db5d6 ("rtla/timerlat: Add action on end feature")
Link: https://lore.kernel.org/r/20260512173731.2151841-1-crwood@redhat.com
Signed-off-by: Tomas Glozar <tglozar@redhat.com>
tools/tracing/rtla/src/common.c
tools/tracing/rtla/src/common.h
tools/tracing/rtla/src/timerlat.c

index 35e3d3aa922e2d1dceb7931036b9f0b90df20931..effad523e8cfbcc298aef91e6a62ce8ff09a0d45 100644 (file)
@@ -10,7 +10,7 @@
 
 #include "common.h"
 
-struct trace_instance *trace_inst;
+struct osnoise_tool *trace_tool;
 volatile int stop_tracing;
 int nr_cpus;
 
@@ -21,12 +21,16 @@ static void stop_trace(int sig)
                 * Stop requested twice in a row; abort event processing and
                 * exit immediately
                 */
-               tracefs_iterate_stop(trace_inst->inst);
+               if (trace_tool)
+                       tracefs_iterate_stop(trace_tool->trace.inst);
                return;
        }
        stop_tracing = 1;
-       if (trace_inst)
-               trace_instance_stop(trace_inst);
+       if (trace_tool) {
+               trace_instance_stop(&trace_tool->trace);
+               if (trace_tool->record)
+                       trace_instance_stop(&trace_tool->record->trace);
+       }
 }
 
 /*
@@ -273,11 +277,10 @@ int run_tool(struct tool_ops *ops, int argc, char *argv[])
        tool->params = params;
 
        /*
-        * Save trace instance into global variable so that SIGINT can stop
-        * the timerlat tracer.
+        * Expose the tool to signal handlers so they can stop the trace.
         * Otherwise, rtla could loop indefinitely when overloaded.
         */
-       trace_inst = &tool->trace;
+       trace_tool = tool;
 
        retval = ops->apply_config(tool);
        if (retval) {
@@ -285,7 +288,7 @@ int run_tool(struct tool_ops *ops, int argc, char *argv[])
                goto out_free;
        }
 
-       retval = enable_tracer_by_name(trace_inst->inst, ops->tracer);
+       retval = enable_tracer_by_name(tool->trace.inst, ops->tracer);
        if (retval) {
                err_msg("Failed to enable %s tracer\n", ops->tracer);
                goto out_free;
index 51665db4ffce807758ff30e196d7aa1f07dd790b..eba40b6d950438190ba5974f333baf5b2a5de9af 100644 (file)
@@ -54,7 +54,6 @@ struct osnoise_context {
        int                     opt_workload;
 };
 
-extern struct trace_instance *trace_inst;
 extern volatile int stop_tracing;
 
 struct hist_params {
index f8c057518d22373499e55dc555f7a22ec88d704b..637f68d684f5f509d1852ca576c1e814681c3dc8 100644 (file)
@@ -202,7 +202,7 @@ void timerlat_analyze(struct osnoise_tool *tool, bool stopped)
                 * If the trace did not stop with --aa-only, at least print
                 * the max known latency.
                 */
-               max_lat = tracefs_instance_file_read(trace_inst->inst, "tracing_max_latency", NULL);
+               max_lat = tracefs_instance_file_read(tool->trace.inst, "tracing_max_latency", NULL);
                if (max_lat) {
                        printf("  Max latency was %s\n", max_lat);
                        free(max_lat);