On Mon, 16 Mar 2026 14:31:43 +0000
Bruce Richardson <[email protected]> wrote:

> On Tue, Mar 10, 2026 at 09:09:55AM -0700, Stephen Hemminger wrote:
> > Using volatile for statistics is not necessary since only one
> > thread is allowed to operate on a queue at a time.
> > 
> > Signed-off-by: Stephen Hemminger <[email protected]>
> > ---  
> 
> Well only one queue is allowed to change them, but other threads could read
> them, so using volatile is correct in that it tells the compiler not to
> cache the values in registers or on the stack. Technically the compiler
> could have the stats stored locally somewhere between updates, but in
> practice I don't think that situation could ever arise for stats. Therefore
> I'm ok with stats being either volatile or not, I doubt the resulting code
> will be any different.
> 
> Acked-by: Bruce Richardson <[email protected]>


I went back and forth on this. The compiler unless statically linked
with LTO has no chance or seeing across calls.

The other option would be relaxed atomics would also solve
the torn 32 bit counter roll over problem on 32 bit CPU's.

Reply via email to