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

Commit83aadbe

Browse files
committed
Require memory barrier support.
Previously we had a fallback implementation that made a harmless systemcall, based on the assumption that system calls must contain a memorybarrier. That shouldn't be reached on any current system, and it seemshighly likely that we can easily find out how to request explicit memorybarriers, if we've already had to find out how to do atomics on ahypothetical new system.Removed comments and a function name referred to a spinlock used forfallback memory barriers, but that changed in1b468a1, which left somemisleading words behind in a few places.Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>Suggested-by: Andres Freund <andres@anarazel.de>Discussion:https://postgr.es/m/721bf39a-ed8a-44b0-8b8e-be3bd81db748%40technowledgy.deDiscussion:https://postgr.es/m/3351991.1697728588%40sss.pgh.pa.us
1 parenta011dc3 commit83aadbe

File tree

4 files changed

+4
-49
lines changed

4 files changed

+4
-49
lines changed

‎src/backend/port/atomics.c‎

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,6 @@
1717
#include"port/atomics.h"
1818
#include"storage/spin.h"
1919

20-
#ifdefPG_HAVE_MEMORY_BARRIER_EMULATION
21-
#ifdefWIN32
22-
#error "barriers are required (and provided) on WIN32 platforms"
23-
#endif
24-
#include<signal.h>
25-
#endif
26-
27-
#ifdefPG_HAVE_MEMORY_BARRIER_EMULATION
28-
void
29-
pg_spinlock_barrier(void)
30-
{
31-
/*
32-
* NB: we have to be reentrant here, some barriers are placed in signal
33-
* handlers.
34-
*
35-
* We use kill(0) for the fallback barrier as we assume that kernels on
36-
* systems old enough to require fallback barrier support will include an
37-
* appropriate barrier while checking the existence of the postmaster pid.
38-
*/
39-
(void)kill(PostmasterPid,0);
40-
}
41-
#endif
42-
4320

4421
#ifdefPG_HAVE_ATOMIC_U64_SIMULATION
4522

‎src/include/port/atomics.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@
101101
#if !defined(pg_compiler_barrier_impl)
102102
#error "could not find an implementation of pg_compiler_barrier"
103103
#endif
104+
#if !defined(pg_memory_barrier_impl)
105+
#error "could not find an implementation of pg_memory_barrier_impl"
106+
#endif
107+
104108

105109
/*
106110
* Provide a spinlock-based implementation of the 64 bit variants, if

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,6 @@
1717
#error "should be included via atomics.h"
1818
#endif
1919

20-
#ifndefpg_memory_barrier_impl
21-
/*
22-
* If we have no memory barrier implementation for this architecture, we
23-
* fall back to acquiring and releasing a spinlock.
24-
*
25-
* It's not self-evident that every possible legal implementation of a
26-
* spinlock acquire-and-release would be equivalent to a full memory barrier.
27-
* For example, I'm not sure that Itanium's acq and rel add up to a full
28-
* fence. But all of our actual implementations seem OK in this regard.
29-
*/
30-
#definePG_HAVE_MEMORY_BARRIER_EMULATION
31-
32-
externvoidpg_spinlock_barrier(void);
33-
#definepg_memory_barrier_impl pg_spinlock_barrier
34-
#endif
35-
3620

3721
#if !defined(PG_HAVE_ATOMIC_U64_SUPPORT)
3822

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,19 +135,9 @@ pg_atomic_unlocked_test_flag_impl(volatile pg_atomic_flag *ptr)
135135
staticinlinevoid
136136
pg_atomic_clear_flag_impl(volatilepg_atomic_flag*ptr)
137137
{
138-
/*
139-
* Use a memory barrier + plain write if we have a native memory
140-
* barrier. But don't do so if memory barriers use spinlocks - that'd lead
141-
* to circularity if flags are used to implement spinlocks.
142-
*/
143-
#ifndefPG_HAVE_MEMORY_BARRIER_EMULATION
144138
/* XXX: release semantics suffice? */
145139
pg_memory_barrier_impl();
146140
pg_atomic_write_u32_impl(ptr,0);
147-
#else
148-
uint32value=1;
149-
pg_atomic_compare_exchange_u32_impl(ptr,&value,0);
150-
#endif
151141
}
152142

153143
#elif !defined(PG_HAVE_ATOMIC_TEST_SET_FLAG)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp