24#define INT_ACCESS_ONCE(var) ((int)(*((volatile int *)&(var))))
186 if (strategy !=
NULL)
264 elog(
ERROR,
"no unpinned buffers available");
296 if (strategy !=
NULL)
328 result = nextVictimBuffer %
NBuffers;
530 elog(
ERROR,
"unrecognized buffer access strategy: %d",
572 strategy->
btype = btype;
588 if (strategy ==
NULL)
611 if (strategy ==
NULL)
614 switch (strategy->
btype)
646 if (strategy !=
NULL)
752 switch (strategy->
btype)
771 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)
void InitBufTable(int size)
Size BufTableShmemSize(int size)
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)
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)
void StrategyInitialize(bool init)
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)
Size StrategyShmemSize(void)
bool StrategyRejectBuffer(BufferAccessStrategy strategy, BufferDesc *buf, bool from_ring)
static BufferDesc * GetBufferFromRing(BufferAccessStrategy strategy, uint64 *buf_state)
void SetLatch(Latch *latch)
#define NUM_BUFFER_PARTITIONS
void pfree(void *pointer)
void * palloc0(Size size)
static char buf[DEFAULT_XLOG_SEG_SIZE]
#define GetPGProcByNumber(n)
Size add_size(Size s1, Size s2)
void * ShmemInitStruct(const char *name, Size size, bool *foundPtr)
#define SpinLockInit(lock)
#define SpinLockRelease(lock)
#define SpinLockAcquire(lock)
BufferAccessStrategyType btype
Buffer buffers[FLEXIBLE_ARRAY_MEMBER]
pg_atomic_uint32 nextVictimBuffer
pg_atomic_uint32 numBufferAllocs
slock_t buffer_strategy_lock