| From: | Andres Freund <andres(at)2ndquadrant(dot)com> |
|---|---|
| To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
| Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Latches and barriers |
| Date: | 2015-01-12 17:52:49 |
| Message-ID: | 20150112175249.GD2092@awork2.anarazel.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 2015-01-12 12:44:56 -0500, Robert Haas wrote:
> On Mon, Jan 12, 2015 at 11:27 AM, Andres Freund <andres(at)2ndquadrant(dot)com> wrote:
> > On 2015-01-12 11:03:42 -0500, Tom Lane wrote:
> >> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> >> > While it might not be required for existing latch uses (I'm *not* sure
> >> > that's true)
> >
> > I think at least syncrep.c might not be correct. In SyncRepWakeQueue()
> > it sets PGPROC->syncRepState without the necessary barriers (via locks),
> > although it does use them in SyncRepWaitForLSN().
> >
> > It is, perhaps surprisingly to many, not sufficient to take a spinlock,
> > change the flag, release it and then set the latch - the release alone
> > doesn't guarantee a sufficient barrier unless looking at the flag is
> > also protected by the spinlock.
>
> I thought we decided that a spinlock acquire or release should be a
> full barrier.
Acquire + release, yes. But not release alone? The x86 spinlock release
currently is just a store - that won't ever be a full barrier.
Greetings,
Andres Freund
--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andres Freund | 2015-01-12 17:55:38 | Re: Latches and barriers |
| Previous Message | Tom Lane | 2015-01-12 17:49:53 | Re: Latches and barriers |