]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tracing: Remove pointless memory barriers
authorNam Cao <namcao@linutronix.de>
Thu, 26 Jun 2025 15:19:40 +0000 (17:19 +0200)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Wed, 23 Jul 2025 00:15:51 +0000 (20:15 -0400)
Memory barriers are useful to ensure memory accesses from one CPU appear in
the original order as seen by other CPUs.

Some smp_rmb() and smp_wmb() are used, but they are not ordering multiple
memory accesses.

Remove them.

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Gabriele Monaco <gmonaco@redhat.com>
Link: https://lore.kernel.org/20250626151940.1756398-1-namcao@linutronix.de
Signed-off-by: Nam Cao <namcao@linutronix.de>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
kernel/trace/rv/rv.c
kernel/trace/trace.c

index e4077500a91dbb4a70ed8ae7ec6cef80981532e6..c04a49da43286aaa88bd9490c224cc18b8226ba0 100644 (file)
@@ -675,8 +675,6 @@ static bool __read_mostly monitoring_on;
  */
 bool rv_monitoring_on(void)
 {
-       /* Ensures that concurrent monitors read consistent monitoring_on */
-       smp_rmb();
        return READ_ONCE(monitoring_on);
 }
 
@@ -696,8 +694,6 @@ static ssize_t monitoring_on_read_data(struct file *filp, char __user *user_buf,
 static void turn_monitoring_off(void)
 {
        WRITE_ONCE(monitoring_on, false);
-       /* Ensures that concurrent monitors read consistent monitoring_on */
-       smp_wmb();
 }
 
 static void reset_all_monitors(void)
@@ -713,8 +709,6 @@ static void reset_all_monitors(void)
 static void turn_monitoring_on(void)
 {
        WRITE_ONCE(monitoring_on, true);
-       /* Ensures that concurrent monitors read consistent monitoring_on */
-       smp_wmb();
 }
 
 static void turn_monitoring_on_with_reset(void)
index 95ae7c4e58357f1d22f4e49d3c0308087c224d34..0dff4298fc0e5c34706de7d5c76964d73448ad08 100644 (file)
@@ -936,7 +936,6 @@ int tracing_is_enabled(void)
         * return the mirror variable of the state of the ring buffer.
         * It's a little racy, but we don't really care.
         */
-       smp_rmb();
        return !global_trace.buffer_disabled;
 }
 
@@ -1107,8 +1106,6 @@ void tracer_tracing_on(struct trace_array *tr)
         * important to be fast than accurate.
         */
        tr->buffer_disabled = 0;
-       /* Make the flag seen by readers */
-       smp_wmb();
 }
 
 /**
@@ -1640,8 +1637,6 @@ void tracer_tracing_off(struct trace_array *tr)
         * important to be fast than accurate.
         */
        tr->buffer_disabled = 1;
-       /* Make the flag seen by readers */
-       smp_wmb();
 }
 
 /**
@@ -2710,8 +2705,6 @@ void trace_buffered_event_enable(void)
 
 static void enable_trace_buffered_event(void *data)
 {
-       /* Probably not needed, but do it anyway */
-       smp_rmb();
        this_cpu_dec(trace_buffered_event_cnt);
 }