Re: locked reads for atomics - Mailing list pgsql-hackers

From Nathan Bossart
Subject Re: locked reads for atomics
Date
Msg-id 20231110225522.GE1315705@nathanxps13
Whole thread Raw
In response to Re: locked reads for atomics  (John Morris <john.morris@crunchydata.com>)
List pgsql-hackers
On Fri, Nov 10, 2023 at 09:49:06PM +0000, John Morris wrote:
> Most out-of-order machines include “read acquire” and “write release”
> which are pretty close to what you’re suggesting. With the current
> routines, we only have “read relaxed” and  “write relaxed”. I think
> implementing acquire/release semantics is a very good idea,

We do have both pg_atomic_write_u32() and pg_atomic_unlocked_write_u32()
(see commit b0779ab), but AFAICT those only differ in the fallback/spinlock
implementations.  I suppose there could be an unlocked 64-bit write on
platforms that have 8-byte single-copy atomicity but still need to use the
fallback/spinlock implementation for some reason, but that might be a bit
of a stretch, and the use-cases might be few and far between...

> I would also like to clarify the properties of atomics. One very
> important question: Are atomics also volatile?

The PostgreSQL atomics support appears to ensure they are volatile.

-- 
Nathan Bossart
Amazon Web Services: https://aws.amazon.com



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Failure during Building Postgres in Windows with Meson
Next
From: Andres Freund
Date:
Subject: Re: locked reads for atomics