Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit47c7187

Browse files
committed
Avoid need for valgrind suppressions for pg_atomic_init_u64 on some platforms.
Previously we used pg_atomic_write_64_impl insidepg_atomic_init_u64. That works correctly, but on platforms without64bit single copy atomicity it could trigger spurious valgrind errorsabout uninitialized memory, because we use compare_and_swap for atomicwrites on such platforms.I previously suppressed one instance of this problem (6c878ed),but as Tom reports that wasn't enough. As the atomic variable cannotyet be concurrently accessible during initialization, it seems betterto have pg_atomic_init_64_impl set the value directly.Change pg_atomic_init_u32_impl for symmetry.Reported-By: Tom LaneAuthor: Andres FreundDiscussion:https://postgr.es/m/1714601.1591503815@sss.pgh.pa.usBackpatch: 9.5-
1 parentc2e71cb commit47c7187

File tree

2 files changed

+2
-16
lines changed

2 files changed

+2
-16
lines changed

‎src/include/port/atomics/generic.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ pg_atomic_clear_flag_impl(volatile pg_atomic_flag *ptr)
160160
staticinlinevoid
161161
pg_atomic_init_u32_impl(volatilepg_atomic_uint32*ptr,uint32val_)
162162
{
163-
pg_atomic_write_u32_impl(ptr,val_);
163+
ptr->value=val_;
164164
}
165165
#endif
166166

@@ -330,7 +330,7 @@ pg_atomic_read_u64_impl(volatile pg_atomic_uint64 *ptr)
330330
staticinlinevoid
331331
pg_atomic_init_u64_impl(volatilepg_atomic_uint64*ptr,uint64val_)
332332
{
333-
pg_atomic_write_u64_impl(ptr,val_);
333+
ptr->value=val_;
334334
}
335335
#endif
336336

‎src/tools/valgrind.supp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -134,20 +134,6 @@
134134
fun:IsBinaryCoercible
135135
}
136136

137-
# Atomic writes to 64bit atomic vars uses compare/exchange to
138-
# guarantee atomic writes of 64bit variables. pg_atomic_write is used
139-
# during initialization of the atomic variable; that leads to an
140-
# initial read of the old, undefined, memory value. But that's just to
141-
# make sure the swap works correctly.
142-
{
143-
uninitialized_atomic_init_u64
144-
Memcheck:Cond
145-
fun:pg_atomic_exchange_u64_impl
146-
fun:pg_atomic_write_u64_impl
147-
fun:pg_atomic_init_u64_impl
148-
}
149-
150-
151137
# Python's allocator does some low-level tricks for efficiency. Those
152138
# can be disabled for better instrumentation; but few people testing
153139
# postgres will have such a build of python. So add broad

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp