]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
rtla: Make stop_tracing variable volatile
authorWander Lairson Costa <wander@redhat.com>
Tue, 6 Jan 2026 11:49:51 +0000 (08:49 -0300)
committerTomas Glozar <tglozar@redhat.com>
Wed, 7 Jan 2026 14:57:55 +0000 (15:57 +0100)
The stop_tracing global variable is accessed from both the signal
handler context and the main program flow without synchronization.
This creates a potential race condition where compiler optimizations
could cache the variable value in registers, preventing the signal
handler's updates from being visible to other parts of the program.

Add the volatile qualifier to stop_tracing in both common.c and
common.h to ensure all accesses to this variable bypass compiler
optimizations and read directly from memory. This guarantees that
when the signal handler sets stop_tracing, the change is immediately
visible to the main program loop, preventing potential hangs or
delayed shutdown when termination signals are received.

Signed-off-by: Wander Lairson Costa <wander@redhat.com>
Link: https://lore.kernel.org/r/20260106133655.249887-16-wander@redhat.com
Signed-off-by: Tomas Glozar <tglozar@redhat.com>
tools/tracing/rtla/src/common.c
tools/tracing/rtla/src/common.h

index 6f64c1fc1b621a25af073d5e3fdea05f6e1fb079..ceff76a62a30b836ee14fdfc2c26b5bb0dc38b4a 100644 (file)
@@ -10,7 +10,7 @@
 #include "common.h"
 
 struct trace_instance *trace_inst;
-int stop_tracing;
+volatile int stop_tracing;
 
 static void stop_trace(int sig)
 {
index ef17ea5be540a79a2e39ce1d74a4d98f87ce82dc..7602c5593ef5d978e7d2788db358e68cfec9a8d3 100644 (file)
@@ -54,7 +54,7 @@ struct osnoise_context {
 };
 
 extern struct trace_instance *trace_inst;
-extern int stop_tracing;
+extern volatile int stop_tracing;
 
 struct hist_params {
        char                    no_irq;