Re: Spinlocks and compiler/memory barriers

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Spinlocks and compiler/memory barriers
Date: 2014-06-27 17:04:02
Message-ID: CA+TgmoZGuSrnxrWpbVDh29p643JguoZGu3EAbn413g8n1iuGkQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jun 26, 2014 at 6:40 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
>> On 2014-06-26 14:13:07 -0700, Tom Lane wrote:
>>> Surely it had better be a read barrier as well?
>
>> I don't immediately see why it has to be read barrier? Hoisting a load
>> from after the release into the locked area of code should be safe?
>
> No doubt, but delaying a read till after the unlocking write would
> certainly not be safe.
>
> AFAICT, README.barrier completely fails to define what we think the
> semantics of pg_read_barrier and pg_write_barrier actually are, so if
> you believe that a write barrier prevents reordering of reads relative to
> writes, you'd better propose some new text for that file. It certainly
> doesn't say that today.

The relevant text is in barrier.h

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2014-06-27 17:12:31 Re: Atomics hardware support table & supported architectures
Previous Message Robert Haas 2014-06-27 17:00:34 Re: Spinlocks and compiler/memory barriers