From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Noah Misch <noah(at)leadboat(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: valgrind versus pg_atomic_init() |
Date: | 2020-06-15 04:19:04 |
Message-ID: | 20200615041904.wo37x45iv5zcmmnu@alap3.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
On 2020-06-14 22:30:25 -0400, Tom Lane wrote:
> Noah Misch <noah(at)leadboat(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2020-06-15 04:26:02 | Re: valgrind versus pg_atomic_init() |
Previous Message | Andres Freund | 2020-06-15 04:16:20 | Re: valgrind versus pg_atomic_init() |