pgsql: Change the spinlock primitives to function as compiler barriers. - Mailing list pgsql-committers

From Robert Haas
Subject pgsql: Change the spinlock primitives to function as compiler barriers.
Date
Msg-id E1XRTJl-00080P-Ir@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Change the spinlock primitives to function as compiler barriers.

Previously, they functioned as barriers against CPU reordering but not
compiler reordering, an odd API that required extensive use of volatile
everywhere that spinlocks are used.  That's error-prone and has negative
implications for performance, so change it.

In theory, this makes it safe to remove many of the uses of volatile
that we currently have in our code base, but we may find that there are
some bugs in this effort when we do.  In the long run, though, this
should make for much more maintainable code.

Patch by me.  Review by Andres Freund.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/0709b7ee72e4bc71ad07b7120acd117265ab51d0

Modified Files
--------------
src/backend/storage/lmgr/s_lock.c |   12 ++++++
src/include/storage/s_lock.h      |   83 ++++++++++++++++++++++++++++++-------
2 files changed, 79 insertions(+), 16 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Add width_bucket(anyelement, anyarray).
Next
From: Andres Freund
Date:
Subject: pgsql: Fix spinlock implementation for some !solaris sparc platforms.