On Mon, 25 Nov 2024, Richard Biener wrote:

> >  The full `-msafe-bwa' feature is required for a fix, as the data race 
> > comes from *outside* rather than from any lack of atomicity of the store 
> > to the object itself.  As the previous value of the object itself is 
> > discarded, a plain RMW sequence is already atomic, because the RM part 
> > only applies to data outside the object accessed.  However a similar RMW 
> > sequence made to update data located within the same longword *outside* 
> > the atomic object concerned will clobber it.
> 
> Note this is why the C++ memory model constrains what "outside" parts
> of a memory location may be accessed by such a RMW sequence to
> avoid producing data-races for data that isn't accessed by the program.
 Ack, good to know.

> I don't think you can reliably fix this without enforcing atomic
> sequences on every access that isn't constrained to memory within itself.

 That's what the `-msafe-bwa' and `-msafe-partial' features combined do, 
although at the price of requiring the kernel to emulate unaligned atomic 
operations, which it does not do at the moment.  There is a performance 
hit, but it seems bearable for a legacy architecture, and overall Alpha is
an exception here rather than the norm and may even be the only target we 
support that cannot do plain stores narrower than the word size without 
disturbing memory outside the object addressed.

 Thank you for your input.

  Maciej

Reply via email to