On Mon, Aug 5, 2024 at 10:26 PM Yonghong Song <yonghong.song@xxxxxxxxx> wrote: > > > >> > >> Maybe we could special process the above to generate > >> a locked insn if > >> - atomicrmw operator > >> - monotonic (related) consistency > >> - return value is not used This sounds like a good idea, but... > >> > >> So this will not violate original program semantics. > >> Does this sound a reasonable apporach? > > Whether monotonic consistency is desired (ordered writes) can be > > probably deduced from the memory_order_* flag of the built-ins, but I > > don't know what atomiccrmw is... what is it in non-llvm terms? > > The llvm language reference for atomicrmw: > > https://llvm.org/docs/LangRef.html#atomicrmw-instruction I read it back and forth, but couldn't find whether it's ok for the backend to use stronger ordering insn when weaker ordering is specified in atomicrmw. It's probably ok. Otherwise atomicrmw with monotnic (memory_order_relaxed) and return value is used cannot be mapped to any bpf insn. x86 doesn't have monotonic either, but I suspect the backend still generates the code without any warnings. Would be good to clarify before we proceed with the above plan.