Re: Sync Rep v17 - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Sync Rep v17
Date
Msg-id 201102221109.49130.andres@anarazel.de
Whole thread Raw
In response to Re: Sync Rep v17  (Marti Raudsepp <marti@juffo.org>)
List pgsql-hackers
On Tuesday 22 February 2011 09:59:21 Marti Raudsepp wrote:
> On Tue, Feb 22, 2011 at 07:38, Fujii Masao <masao.fujii@gmail.com> wrote:
> > +       SpinLockAcquire(&WalSndCtl->ctlmutex);
> > +       result = WalSndCtl->sync_rep_service_available;
> > +       SpinLockRelease(&WalSndCtl->ctlmutex);
> > 
> > volatile pointer needs to be used to prevent code rearrangement.
> 
> I don't think that's necessary. Spinlock functions already prevent
> reordering using __asm__ __volatile__
> 
> Otherwise, surely they would be utterly broken?
Its not the spinlock thats the problem but that "result" may be already loaded 
into a register. Thats not prohibited by __asm__ __volatile__.

Andres


pgsql-hackers by date:

Previous
From: Cédric Villemain
Date:
Subject: Re: UNLOGGED tables in psql \d
Next
From: Itagaki Takahiro
Date:
Subject: Re: UNLOGGED tables in psql \d