Re: locked reads for atomics

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: John Morris <john(dot)morris(at)crunchydata(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: locked reads for atomics
Date: 2023-11-10 22:55:22
Message-ID: 20231110225522.GE1315705@nathanxps13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2023-11-10 23:11:50 Re: locked reads for atomics
Previous Message Andres Freund 2023-11-10 22:47:45 Re: Failure during Building Postgres in Windows with Meson