News for hackers. Stuff that matters.
Re:Memory Consistency Models: A Tutorial by liblfds-temp on Tuesday May 14, 2024 @03:00AM (#40352398)
> A barrier instruction forces all memory operations before it to complete before any memory operation after it can begin. That is, a barrier instruction effectively reinstates sequential consistency at a particular point in program execution.

> Of course, this is exactly the behavior we were trying to avoid by introducing store buffers and other optimizations. Barriers are an escape hatch to be used sparingly: they can cost hundreds of cycles.

I may be wrong, but I think to readers who do not already know what barriers do and are, this makes barriers seem like blocking behaviours.

Re:Memory Consistency Models: A Tutorial by throwaway17_17 on Tuesday May 14, 2024 @09:28AM (#40355030)
Just to clarify your comment via a question: are you pointing out that barrier instructions are a scheduling ‘issue’ that the processor uses to order instructions versus something like a memory read that actually requires a pause in the execution of instructions?
Re:Memory Consistency Models: A Tutorial by liblfds-temp on Monday May 20, 2024 @02:37AM (#40412911)
Mmm. Sort of the former, but really my thought was this : "you have a barrier, fine, but that does not mean once you hit/pass the barrier, all prior read/writes are complete - in fact, the completion of earlier reads/writes only occurs at the first read/write after the barrier".
Re:Memory Consistency Models: A Tutorial by Maxatar on Tuesday May 14, 2024 @10:05AM (#40355360)
Barriers can induce blocking behavior though. A store barrier followed by a store operation can result in a blocking operation until the store buffer is flushed, and similarly for a load barrier.
Re:Memory Consistency Models: A Tutorial by gpderetta on Tuesday May 14, 2024 @11:06AM (#40355969)
The usual way that barriers were implemented was to simply stall the CPU pipeline. So yes, they do indeed have blocking semantics. IIRC mfence still does stall the pipeline on x86, but I think the CPU is a bit smarter for locked instructions.