On Wed, Apr 07, 2021 at 01:24:12AM +0800, Boqun Feng wrote: > Actually, "old" riscv standard does provide fwd progress ;-) In > > https://riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf > > Section "7.2 Load-Reserved/Store-Conditional Instructions": > > """ > One advantage of CAS is that it guarantees that some hart eventually > makes progress, whereas an LR/SC atomic sequence could livelock > indefinitely on some systems. To avoid this concern, we added an This is not inherent to CAS, there's plenty of CAS implementations that are prone to livelock (unfortunately). > architectural guarantee of forward progress to LR/SC atomic sequences. > The restrictions on LR/SC sequence contents allows an implementation to > **capture a cache line on the LR and complete the LR/SC sequence by > holding off remote cache interventions for a bounded short time**. > """ > > The guarantee is removed later due to "Earlier versions of this > specification imposed a stronger starvation-freedom guarantee. However, > the weaker livelock-freedom guarantee is sufficient to implement the C11 > and C++11 languages, and is substantially easier to provide in some > microarchitectural styles." Pff, that's just stupid. I suppose the best you can say of the C11 memory model is that it's nice that the C committee realized they needed to catch up to the every day reality of SMP systems (which people have been writing 'C' for ever since the 70s, since SMP is older than C itself). There's so much wrong with the C11 memory model and atomics, using it to define an architecture is just backwards. C11 cannot do RCU, C11 cannot do seqlocks, C11 cannot do deterministic locks, C11 cannot do real systems. C11 is garbage. Yes, architectures need to support C11, because sadly C11 exists and people will use it. But architectures also need to be able to do real systems and thus should not limit themselves to C11.