postgres.git / summary / log / commit / refs

commit    3801532918eba64d26265bb6f137805fe3c7d2ab
Author:   Andres Freund <andres@anarazel.de>
Date:     Tue Jun 09 02:52:19 2020 +0000
First released in: 14.0, 9.5.23, 9.6.19, 10.14, 11.9, 12.4, 13.0

    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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/include/port/atomics/generic.h b/src/include/port/atomics/generic.h index ec140e4a1e0..3c6a8f59ca5 100644 --- a/src/include/port/atomics/generic.h +++ b/src/include/port/atomics/generic.h @@ -162,7 +162,7 @@ pg_atomic_clear_flag_impl(volatile pg_atomic_flag *ptr) static inline void pg_atomic_init_u32_impl(volatile pg_atomic_uint32 *ptr, uint32 val_) { - pg_atomic_write_u32_impl(ptr, val_); + ptr->value = val_; } #endif @@ -312,7 +312,7 @@ pg_atomic_read_u64_impl(volatile pg_atomic_uint64 *ptr) static inline void pg_atomic_init_u64_impl(volatile pg_atomic_uint64 *ptr, uint64 val_) { - pg_atomic_write_u64_impl(ptr, val_); + ptr->value = val_; } #endif [parent: 09dc17486393]