On Mon, 26 Jan 2026 19:35:38 +0100
Eric Dumazet <[email protected]> wrote:

> On Mon, Jan 26, 2026 at 7:29 PM David Laight
> <[email protected]> wrote:
> >
> > On Sat, 24 Jan 2026 00:21:36 +0800
> > David Yang <[email protected]> wrote:
> >  
> > > On 64bit arches, struct u64_stats_sync is empty and provides no help
> > > against load/store tearing. struct copying should not be considered
> > > tear-free. Use u64_stats_reads() instead.  
> >
> > Except that the compiler doesn't ever generate 'tearing accesses' for
> > aligned 64bit accesses on any 64bit architecture.
> > Similarly memcpy() won't generate problematic accesses.
> >
> > The problem is purely theoretical - the C language lets the compiler
> > split accesses, but it doesn't.  
> 
> Yeah, although we still have races that KCSAN can detect.
> 
> data_race() or READ_ONCE() would be necessary to avoid noisy KCSAN reports.
> 
> While many KCSAN reports are boring, some of them point to real bugs.
> 

Could something be put in u64_stats_fetch_begin() to stop KCSAN bleating?

With the way READ_ONCE and WRITE_ONCE now get enforced I do wonder if
some data shouldn't just be marked 'volatile'?
That would give 'non-tearing' accesses, but without the inter-cpu
ordering that (I think) READ/WRITE_ONCE also give.
For stats counters that is enough.

        David
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to