I spotted the weird-looking pattern of: atomic_set(atomic_load() <some operation> N) in a few palces and one variable in the graph-lock code which was used with atomics except for a single case, which also seemed suspicious.
I'm not sure if there are any known compiler-optimizations or ordering semantics already ensuring that these operations are indeed working correctly atomically, so I thought I'd point them out and ask about it by sending patches. In patch 2 the ordering is changed (see the note in its mail) Wolfgang Bumiller (2): graph-lock: make sure reader_count access is atomic atomics: replace fetch-use-store with direct atomic operations block/graph-lock.c | 8 +++----- util/aio-posix.c | 3 +-- util/aio-win32.c | 3 +-- util/async.c | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) -- 2.39.2