better atomics - v0.5

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Geoghegan <pg(at)heroku(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Ants Aasma <ants(at)cybertec(dot)at>
Subject: better atomics - v0.5
Date: 2014-06-25 17:14:34
Message-ID: 20140625171434.GG24114@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

[sorry for the second copy Robert]

Attached is a new version of the atomic operations patch. Lots has
changed since the last post:

* gcc, msvc work. acc, xlc, sunpro have blindly written support which
should be relatively easy to fix up. All try to implement TAS, 32 bit
atomic add, 32 bit compare exchange; some do it for 64bit as well.

* x86 gcc inline assembly means that we support every gcc version on x86
>= i486; even when the __sync APIs aren't available yet.

* 'inline' support isn't required anymore. We fall back to
ATOMICS_INCLUDE_DEFINITIONS/STATIC_IF_INLINE etc. trickery.

* When the current platform doesn't have support for atomic operations a
spinlock backed implementation is used. This can be forced using
--disable-atomics.

That even works when semaphores are used to implement spinlocks (a
separate array is used there to avoid nesting problems). It contrast
to an earlier implementation this even works when atomics are mapped
to different addresses in individual processes (think dsm).

* s_lock.h falls back to the atomics.h provided APIs iff it doesn't have
native support for the current platform. This can be forced by
defining USE_ATOMICS_BASED_SPINLOCKS. Due to generic compiler
intrinsics based implementations that should make it easier to bring
up postgres on different platfomrs.

* I tried to improve the documentation of the facilities in
src/include/storage/atomics.h. Including documentation of the various
barrier semantics.

* There's tests in regress.c that get call via a SQL function from the
regression tests.

* Lots of other details changed, but that's the major pieces.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Attachment Content-Type Size
0001-Basic-atomic-ops-implementation.patch text/x-patch 109.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2014-06-25 17:17:56 Re: PostgreSQL for VAX on NetBSD/OpenBSD
Previous Message Heikki Linnakangas 2014-06-25 17:09:55 Re: Bug in spg_range_quad_inner_consistent for adjacent operator (was Re: Add a filed to PageHeaderData)