pgsql: Change the spinlock primitives to function as compiler barriers.

From: Robert Haas <rhaas(at)postgresql(dot)org>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Change the spinlock primitives to function as compiler barriers.
Date: 2014-09-09 21:51:17
Message-ID: E1XRTJl-00080P-Ir@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2014-09-09 21:52:51 pgsql: Fix spinlock implementation for some !solaris sparc platforms.
Previous Message Tom Lane 2014-09-09 19:34:38 pgsql: Add width_bucket(anyelement, anyarray).