Re: valgrind versus pg_atomic_init()

From: Andres Freund <andres(at)anarazel(dot)de>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: valgrind versus pg_atomic_init()
Date: 2020-06-15 04:16:20
Message-ID: 20200615041620.u2u6oo75nscc6j4g@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2020-06-14 18:55:27 -0700, Noah Misch wrote:
> Does something guarantee the write will be globally-visible by the time the
> first concurrent accessor shows up?

The function comments say:

*
* Has to be done before any concurrent usage..
*
* No barrier semantics.

> (If not, one could (a) do an unlocked ptr->value=0, then the atomic
> write, or (b) revert and improve the suppression.) I don't doubt it's
> fine for the ways PostgreSQL uses atomics today, which generally
> initialize an atomic before the concurrent-accessor processes even
> exist.

I think it's unlikely that there are cases where you could safely
initialize the atomic without needing some form of synchronization
before it can be used. If a barrier were needed, what'd guarantee the
concurrent access happened after the initialization in the first place?

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2020-06-15 04:19:04 Re: valgrind versus pg_atomic_init()
Previous Message Tom Lane 2020-06-15 04:14:55 Re: create database with template doesn't copy database ACL