Re: valgrind versus pg_atomic_init()

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: valgrind versus pg_atomic_init()
Дата
Msg-id 20200615041904.wo37x45iv5zcmmnu@alap3.anarazel.de
обсуждение исходный текст
Ответ на Re: valgrind versus pg_atomic_init()  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: valgrind versus pg_atomic_init()  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi,

On 2020-06-14 22:30:25 -0400, Tom Lane wrote:
> Noah Misch <noah@leadboat.com> writes:
> > On Sun, Jun 07, 2020 at 12:23:35AM -0400, Tom Lane wrote:
> >> ...  But on thinking more about this, it seems like
> >> generic.h's version of pg_atomic_init_u64_impl is just fundamentally
> >> misguided.  Why isn't it simply assigning the value with an ordinary
> >> unlocked write?  By definition, we had better not be using this function
> >> in any circumstance where there might be conflicting accesses
> 
> > Does something guarantee the write will be globally-visible by the time the
> > first concurrent accessor shows up?  (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.
> 
> Perhaps it'd be worth putting a memory barrier at the end of the _init
> function(s)?  As you say, this is hypothetical right now, but that'd be
> a cheap improvement.

I don't think it'd be that cheap for some cases. There's an atomic for
every shared buffer, making their initialization full memory barriers
would likely be noticable for larger shared_buffers values.

As you say:

> In practice, if that line is so fine that we need a memory sync operation
> to enforce it, things are probably broken anyhow.

Greetings,

Andres Freund



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: valgrind versus pg_atomic_init()
Следующее
От: Tom Lane
Дата:
Сообщение: Re: valgrind versus pg_atomic_init()