Обсуждение: [COMMITTERS] pgsql: Improve 64bit atomics support.
Improve 64bit atomics support. When adding atomics back in b64d92f1a, I added 64bit support as optional; there wasn't yet a direct user in sight. That turned out to be a bit short-sighted, it'd already have been useful a number of times. Add a fallback implementation of 64bit atomics, just like the one we have for 32bit atomics. Additionally optimize reads/writes to 64bit on a number of platforms where aligned writes of that size are atomic. This can now be tested with PG_HAVE_8BYTE_SINGLE_COPY_ATOMICITY. Author: Andres Freund Reviewed-By: Amit Kapila Discussion: https://postgr.es/m/20160330230914.GH13305@awork2.anarazel.de Branch ------ master Details ------- http://git.postgresql.org/pg/commitdiff/e8fdbd58fe564a29977f4331cd26f9697d76fc40 Modified Files -------------- src/backend/port/atomics.c | 65 +++++++++++++++++++++++++++++++++++- src/include/port/atomics.h | 13 +++----- src/include/port/atomics/arch-ia64.h | 3 ++ src/include/port/atomics/arch-ppc.h | 3 ++ src/include/port/atomics/arch-x86.h | 10 ++++++ src/include/port/atomics/fallback.h | 33 ++++++++++++++++++ src/include/port/atomics/generic.h | 22 +++++++++--- src/test/regress/regress.c | 4 --- 8 files changed, 136 insertions(+), 17 deletions(-)
On Sat, Apr 8, 2017 at 12:50 AM, Andres Freund <andres@anarazel.de> wrote:
Additionally optimize reads/writes to 64bit on a number of platforms
where aligned writes of that size are atomic. This can now be tested
with PG_HAVE_8BYTE_SINGLE_COPY_ATOMICITY.
BTW, PG_HAVE_8BYTE_SINGLE_COPY_ ATOMICITY is never used.
It's likely you meant something like this.
diff --git a/src/include/port/atomics/generic.h b/src/include/port/atomics/generic.h
new file mode 100644
index c094248..c430bf5
*** a/src/include/port/atomics/generic.h
--- b/src/include/port/atomics/generic.h
*************** pg_atomic_exchange_u64_impl(volatile pg_
*** 271,277 ****
}
#endif
! #ifndef PG_HAVE_ATOMIC_READ_U64
#define PG_HAVE_ATOMIC_READ_U64
static inline uint64
pg_atomic_read_u64_impl(volatile pg_atomic_uint64 *ptr)
--- 271,277 ----
}
#endif
! #if !defined(PG_HAVE_ATOMIC_READ_U64) && defined(PG_HAVE_8BYTE_SINGLE_COPY_ATOMICITY)
#define PG_HAVE_ATOMIC_READ_U64
static inline uint64
pg_atomic_read_u64_impl(volatile pg_atomic_uint64 *ptr)
*************** pg_atomic_read_u64_impl(volatile pg_atom
*** 280,286 ****
}
#endif
! #ifndef PG_HAVE_ATOMIC_WRITE_U64
#define PG_HAVE_ATOMIC_WRITE_U64
static inline void
pg_atomic_write_u64_impl(volatile pg_atomic_uint64 *ptr, uint64 val)
--- 280,286 ----
}
#endif
! #if !defined(PG_HAVE_ATOMIC_WRITE_U64) && defined(PG_HAVE_8BYTE_SINGLE_COPY_ATOMICITY)
#define PG_HAVE_ATOMIC_WRITE_U64
static inline void
pg_atomic_write_u64_impl(volatile pg_atomic_uint64 *ptr, uint64 val)
------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
On 2017-04-08 02:16:34 +0300, Alexander Korotkov wrote: > On Sat, Apr 8, 2017 at 12:50 AM, Andres Freund <andres@anarazel.de> wrote: > > > Additionally optimize reads/writes to 64bit on a number of platforms > > where aligned writes of that size are atomic. This can now be tested > > with PG_HAVE_8BYTE_SINGLE_COPY_ATOMICITY. > > > > BTW, PG_HAVE_8BYTE_SINGLE_COPY_ATOMICITY is never used. > > It's likely you meant something like this. Gah, indeed. Pushed a fix, but you're more than welcome to verify... - Andres