On Wed, 9 Jul 2025 11:08:27 -0400 Steven Rostedt <rost...@goodmis.org> wrote:
> On Tue, 8 Jul 2025 09:42:19 +0200 > Nam Cao <nam...@linutronix.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 >