Path: ...!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Chris M. Thomasson" Newsgroups: comp.arch Subject: Re: Memory ordering Date: Mon, 18 Nov 2024 19:38:41 -0800 Organization: A noiseless patient Spider Lines: 38 Message-ID: References: <-rKdnTO4LdoWXKj6nZ2dnZfqnPWdnZ2d@supernews.com> <5yqdnU9eL_Y_GKv6nZ2dnZfqn_GdnZ2d@supernews.com> <2024Nov15.082512@mips.complang.tuwien.ac.at> <20241115152459.00004c86@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Tue, 19 Nov 2024 04:38:42 +0100 (CET) Injection-Info: dont-email.me; posting-host="9787b18f7626d1c750fb4a6ec8af4b65"; logging-data="1762481"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Zo5MzXkPJIj1oJi3Qhi0uHfrq1P3PEAk=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:l/PUMd+dtOznqS26Fa/QtoWkDHc= Content-Language: en-US In-Reply-To: Bytes: 2892 On 11/17/2024 1:30 PM, Chris M. Thomasson wrote: > On 11/17/2024 6:03 AM, jseigh wrote: >> On 11/16/24 16:21, Chris M. Thomasson wrote: >> >>> Fwiw, in C++ std::memory_order_consume is useful for traversing a >>> node based stack of something in RCU. In most systems it only acts >>> like a compiler barrier. On the Alpha, it must emit a membar >>> instruction. Iirc, mb for alpha? Cannot remember that one right now. >> >> That got deprecated.  Too hard for compilers to deal with.  It's now >> same as memory_order_acquire. > > Strange! C++ has: > > https://en.cppreference.com/w/cpp/atomic/atomic_signal_fence > > That only deals with compilers, not the arch memory order... Humm... > > Interesting Joe! > > >> Which brings up an interesting point.  Even if the hardware memory >> memory model is strongly ordered, compilers can reorder stuff, >> so you still have to program as if a weak memory model was in >> effect.   Or maybe disable reordering or optimization altogether >> for those target architectures. > > Indeed. The compiler needs to know about these things. Iirc, there was > an old post over c.p.t that deals with a compiler (think it was GCC) > that messed up a pthread try lock for a mutex. It's a very old post. But > I remember it for sure. > a song for contention: https://youtu.be/Sdq4T3iRV80?list=RDMMy3hf0T4qpYg ;^D