summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWander Lairson Costa <wander@redhat.com>2026-01-06 08:49:51 -0300
committerTomas Glozar <tglozar@redhat.com>2026-01-07 15:57:55 +0100
commitaf2962d68b970b15d8910be2b0386b4f147ed78b (patch)
tree56080ab24f15458cebd262ddd607647a7fd84115
parent02689ae385c5e84874620947ac010cf7b4950375 (diff)
rtla: Make stop_tracing variable volatile
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>
-rw-r--r--tools/tracing/rtla/src/common.c2
-rw-r--r--tools/tracing/rtla/src/common.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/tools/tracing/rtla/src/common.c b/tools/tracing/rtla/src/common.c
index 6f64c1fc1b62..ceff76a62a30 100644
--- a/tools/tracing/rtla/src/common.c
+++ b/tools/tracing/rtla/src/common.c
@@ -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)
{
diff --git a/tools/tracing/rtla/src/common.h b/tools/tracing/rtla/src/common.h
index ef17ea5be540..7602c5593ef5 100644
--- a/tools/tracing/rtla/src/common.h
+++ b/tools/tracing/rtla/src/common.h
@@ -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;