[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250711092946.1bbd58ef@pumpkin>
Date: Fri, 11 Jul 2025 09:29:46 +0100
From: David Laight <david.laight.linux@...il.com>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Nam Cao <namcao@...utronix.de>, Gabriele Monaco <gmonaco@...hat.com>,
John Ogness <john.ogness@...utronix.de>, Masami Hiramatsu
<mhiramat@...nel.org>, Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
linux-trace-kernel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] tracing: Remove pointless memory barriers
On Wed, 9 Jul 2025 11:08:27 -0400
Steven Rostedt <rostedt@...dmis.org> wrote:
> On Tue, 8 Jul 2025 09:42:19 +0200
> Nam Cao <namcao@...utronix.de> wrote:
>
> > So yes, smp_rmb() is only useful inbetween reads, and smp_wmb() is
> > only userful inbetween writes.
>
> Hmm, I wonder if barriers isn't needed but atomic values are?
>
> That is, it looks like rv_monitoring_on() is looking to read the
> current state, where as turn_monitoring_on/off() changes the state.
>
> Perhaps instead of barriers, it should use atomics?
>
> bool rv_monitoring_on(void)
> {
> return atomic_read(&monitoring_on);
> }
>
> static void turn_monitoring_off(void)
> {
> atomic_set(&monitoring_on, 0);
> }
>
>
> Doesn't atomic make sure the values are seen when they are changed?
No.
It normally just ensures the read/write aren't 'torn'.
Atomics are used for read-modify-writes to ensure two cpu don't
do read-read-modify-modify-write-write losing one of the changes.
(They can need special instructions for read and write - but normally don't.)
So here just the same as the volatile accesses READ_ONCE() and WRITE_ONCE().
David
>
> As this code is more about looking at state and not ordering, and I
> think that's what atomics are about.
>
> -- Steve
>
Powered by blists - more mailing lists