aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlog.c
diff options
context:
space:
mode:
authorNathan Bossart <nathan@postgresql.org>2024-02-29 10:00:44 -0600
committerNathan Bossart <nathan@postgresql.org>2024-02-29 10:00:44 -0600
commitbd5132db558b6c8d11eb838be81e2177a95c7388 (patch)
treec27f73a66003401092c363a65dae5f88e568af2d /src/backend/access/transam/xlog.c
parent5f2e179bd31e5f5803005101eb12a8d7bf8db8f3 (diff)
downloadpostgresql-bd5132db558b6c8d11eb838be81e2177a95c7388.tar.gz
postgresql-bd5132db558b6c8d11eb838be81e2177a95c7388.zip
Introduce atomic read/write functions with full barrier semantics.
Writing correct code using atomic variables is often difficult due to the memory barrier semantics (or lack thereof) of the underlying operations. This commit introduces atomic read/write functions with full barrier semantics to ease this cognitive load. For example, some spinlocks protect a single value, and these new functions make it easy to convert the value to an atomic variable (thus eliminating the need for the spinlock) without modifying the barrier semantics previously provided by the spinlock. Since these functions may be less performant than the other atomic reads and writes, they are not suitable for every use-case. However, using a single atomic operation with full barrier semantics may be more performant in cases where a separate explicit barrier would otherwise be required. The base implementations for these new functions are atomic exchanges (for writes) and atomic fetch/adds with 0 (for reads). These implementations can be overwritten with better architecture- specific versions as they are discovered. This commit leaves converting existing code to use these new functions as a future exercise. Reviewed-by: Andres Freund, Yong Li, Jeff Davis Discussion: https://postgr.es/m/20231110205128.GB1315705%40nathanxps13
Diffstat (limited to 'src/backend/access/transam/xlog.c')
0 files changed, 0 insertions, 0 deletions