26#define INT_ACCESS_ONCE(var) ((int)(*((volatile int *)&(var))))
196 if (strategy !=
NULL)
274 elog(
ERROR,
"no unpinned buffers available");
306 if (strategy !=
NULL)
495 elog(
ERROR,
"unrecognized buffer access strategy: %d",
537 strategy->
btype = btype;
553 if (strategy ==
NULL)
576 if (strategy ==
NULL)
579 switch (strategy->
btype)
611 if (strategy !=
NULL)
717 switch (strategy->
btype)
736 elog(
ERROR,
"unrecognized BufferAccessStrategyType: %d", strategy->
btype);
static bool pg_atomic_compare_exchange_u32(volatile pg_atomic_uint32 *ptr, uint32 *expected, uint32 newval)
static bool pg_atomic_compare_exchange_u64(volatile pg_atomic_uint64 *ptr, uint64 *expected, uint64 newval)
static void pg_atomic_init_u32(volatile pg_atomic_uint32 *ptr, uint32 val)
static uint32 pg_atomic_fetch_add_u32(volatile pg_atomic_uint32 *ptr, int32 add_)
static uint32 pg_atomic_read_u32(volatile pg_atomic_uint32 *ptr)
static uint32 pg_atomic_exchange_u32(volatile pg_atomic_uint32 *ptr, uint32 newval)
static uint64 pg_atomic_read_u64(volatile pg_atomic_uint64 *ptr)
struct BufferAccessStrategyData * BufferAccessStrategy
#define BUF_STATE_GET_USAGECOUNT(state)
#define BUF_USAGECOUNT_ONE
#define BUF_STATE_GET_REFCOUNT(state)
static BufferDesc * GetBufferDescriptor(uint32 id)
static Buffer BufferDescriptorGetBuffer(const BufferDesc *bdesc)
pg_noinline uint64 WaitBufHdrUnlocked(BufferDesc *buf)
int effective_io_concurrency
void TrackNewBufferPin(Buffer buf)
#define Assert(condition)
#define FLEXIBLE_ARRAY_MEMBER
int GetAccessStrategyPinLimit(BufferAccessStrategy strategy)
int StrategySyncStart(uint32 *complete_passes, uint32 *num_buf_alloc)
const ShmemCallbacks StrategyCtlShmemCallbacks
BufferAccessStrategy GetAccessStrategy(BufferAccessStrategyType btype)
static BufferStrategyControl * StrategyControl
BufferDesc * StrategyGetBuffer(BufferAccessStrategy strategy, uint64 *buf_state, bool *from_ring)
static uint32 ClockSweepTick(void)
BufferAccessStrategy GetAccessStrategyWithSize(BufferAccessStrategyType btype, int ring_size_kb)
static void AddBufferToRing(BufferAccessStrategy strategy, BufferDesc *buf)
int GetAccessStrategyBufferCount(BufferAccessStrategy strategy)
void FreeAccessStrategy(BufferAccessStrategy strategy)
#define INT_ACCESS_ONCE(var)
void StrategyNotifyBgWriter(int bgwprocno)
IOContext IOContextForStrategy(BufferAccessStrategy strategy)
static void StrategyCtlShmemRequest(void *arg)
bool StrategyRejectBuffer(BufferAccessStrategy strategy, BufferDesc *buf, bool from_ring)
static BufferDesc * GetBufferFromRing(BufferAccessStrategy strategy, uint64 *buf_state)
static void StrategyCtlShmemInit(void *arg)
void SetLatch(Latch *latch)
void pfree(void *pointer)
void * palloc0(Size size)
static char buf[DEFAULT_XLOG_SEG_SIZE]
#define GetPGProcByNumber(n)
#define ShmemRequestStruct(...)
static void SpinLockRelease(volatile slock_t *lock)
static void SpinLockAcquire(volatile slock_t *lock)
static void SpinLockInit(volatile slock_t *lock)
BufferAccessStrategyType btype
Buffer buffers[FLEXIBLE_ARRAY_MEMBER]
pg_atomic_uint32 nextVictimBuffer
pg_atomic_uint32 numBufferAllocs
slock_t buffer_strategy_lock
ShmemRequestCallback request_fn