bufmgr: Use atomic sub for unpinning buffers

Andres Freund <andres@anarazel.de>

Commit: 5310fac6e0fcb1c7fcefb3446767673f9107328c
Author: Andres Freund <andres@anarazel.de>
Date: 2025-11-06T21:43:16Z
bufmgr: Use atomic sub for unpinning buffers

The prior commit made it legal to modify BufferDesc.state while the buffer
header spinlock is held. This allows us to replace the CAS loop
inUnpinBufferNoOwner() with an atomic sub. This improves scalability
significantly. See the prior commits for more background.

Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Discussion: https://postgr.es/m/fvfmkr5kk4nyex56ejgxj3uzi63isfxovp2biecb4bspbjrze7@az2pljabhnff

Files

PathChange+/−
src/backend/storage/buffer/bufmgr.c modified +3 −26

Discussion