Avoid need for valgrind suppressions for pg_atomic_init_u64 on some platforms.
authorAndres Freund <[email protected]>
Tue, 9 Jun 2020 02:52:19 +0000 (19:52 -0700)
committerAndres Freund <[email protected]>
Tue, 9 Jun 2020 03:02:52 +0000 (20:02 -0700)
commit980a3cd48a08689f0526a7ed0537899e155bd9f4
tree5a1f9c6f5c9b1d17686c6c19a64197ee3dc370c6
parent72766ad6397a1795f2739bda95370b02d5738a3f
Avoid need for valgrind suppressions for pg_atomic_init_u64 on some platforms.

Previously we used pg_atomic_write_64_impl inside
pg_atomic_init_u64. That works correctly, but on platforms without
64bit single copy atomicity it could trigger spurious valgrind errors
about uninitialized memory, because we use compare_and_swap for atomic
writes on such platforms.

I previously suppressed one instance of this problem (6c878edc1df),
but as Tom reports that wasn't enough. As the atomic variable cannot
yet be concurrently accessible during initialization, it seems better
to have pg_atomic_init_64_impl set the value directly.

Change pg_atomic_init_u32_impl for symmetry.

Reported-By: Tom Lane
Author: Andres Freund
Discussion: https://postgr.es/m/1714601.1591503815@sss.pgh.pa.us
Backpatch: 9.5-
src/include/port/atomics/generic.h
src/tools/valgrind.supp