Non-volatile variables used for spinlock manipulation

Started by Antonin Houskaover 10 years ago3 messageshackers
Jump to latest
#1Antonin Houska
ah@cybertec.at

Since SpinLockAcquire() / SpinLockRelease() macros usually reference variables
declared as volatile, I wonder if the following changes should be applied.

--
Antonin Houska
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt
Web: http://www.postgresql-support.de, http://www.cybertec.at

Attachments:

volatile.patchtext/x-diffDownload+8-8
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Antonin Houska (#1)
Re: Non-volatile variables used for spinlock manipulation

Antonin Houska <ah@cybertec.at> writes:

Since SpinLockAcquire() / SpinLockRelease() macros usually reference variables
declared as volatile, I wonder if the following changes should be applied.

We've been making changes to remove that requirement, so I think that at
least in 9.5/HEAD this isn't an issue anymore.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Andres Freund
andres@anarazel.de
In reply to: Tom Lane (#2)
Re: Non-volatile variables used for spinlock manipulation

On 2015-09-04 09:42:20 -0400, Tom Lane wrote:

Antonin Houska <ah@cybertec.at> writes:

Since SpinLockAcquire() / SpinLockRelease() macros usually reference variables
declared as volatile, I wonder if the following changes should be applied.

We've been making changes to remove that requirement, so I think that at
least in 9.5/HEAD this isn't an issue anymore.

And even before that the pointer passed to SpinLockAcquire/Release()
didn't have to be volatile. The important thing was that read/writes
that are protected by the spinlock were only done via volatile
variables, to prevent them from being moved outside the critical
section. All the tas()/unlock section already force the pointer to the
lock to be volatile anyway.

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers