57#define MIN_SPINS_PER_DELAY 10
58#define MAX_SPINS_PER_DELAY 1000
59#define NUM_DELAYS 1000
60#define MIN_DELAY_USEC 1000L
61#define MAX_DELAY_USEC 1000000L
83#if defined(S_LOCK_TEST)
85 "\nStuck spinlock detected at %s, %s:%d.\n",
89 elog(
PANIC,
"stuck spinlock detected at %s, %s:%d",
98s_lock(
volatile slock_t *lock,
const char *file,
int line,
const char *func)
111 return delayStatus.
delays;
114#ifdef USE_DEFAULT_S_UNLOCK
152#if defined(S_LOCK_TEST)
235#if defined(S_LOCK_TEST)
241struct test_lock_struct
248volatile struct test_lock_struct test_lock;
255 test_lock.pad1 = test_lock.pad2 = 0x44;
259 if (test_lock.pad1 != 0x44 || test_lock.pad2 != 0x44)
261 printf(
"S_LOCK_TEST: failed, declared datatype is wrong size\n");
267 printf(
"S_LOCK_TEST: failed, lock not initialized\n");
273 if (test_lock.pad1 != 0x44 || test_lock.pad2 != 0x44)
275 printf(
"S_LOCK_TEST: failed, declared datatype is wrong size\n");
281 printf(
"S_LOCK_TEST: failed, lock not locked\n");
287 if (test_lock.pad1 != 0x44 || test_lock.pad2 != 0x44)
289 printf(
"S_LOCK_TEST: failed, declared datatype is wrong size\n");
295 printf(
"S_LOCK_TEST: failed, lock not unlocked\n");
301 if (test_lock.pad1 != 0x44 || test_lock.pad2 != 0x44)
303 printf(
"S_LOCK_TEST: failed, declared datatype is wrong size\n");
309 printf(
"S_LOCK_TEST: failed, lock not re-locked\n");
314 printf(
" exit with a 'stuck spinlock' message\n");
315 printf(
" if S_LOCK() and TAS() are working.\n");
318 s_lock(&test_lock.lock, __FILE__, __LINE__, __func__);
320 printf(
"S_LOCK_TEST: failed, lock not locked\n");
#define fprintf(file, fmt, msg)
static void const char fflush(stdout)
int main(int argc, char **argv)
double pg_prng_double(pg_prng_state *state)
void pg_prng_seed(pg_prng_state *state, uint64 seed)
pg_prng_state pg_global_prng_state
void set_spins_per_delay(int shared_spins_per_delay)
void perform_spin_delay(SpinDelayStatus *status)
void finish_spin_delay(SpinDelayStatus *status)
int s_lock(volatile slock_t *lock, const char *file, int line, const char *func)
#define MAX_SPINS_PER_DELAY
void s_unlock(volatile slock_t *lock)
#define MIN_SPINS_PER_DELAY
int update_spins_per_delay(int shared_spins_per_delay)
static int spins_per_delay
static void s_lock_stuck(const char *file, int line, const char *func)
#define DEFAULT_SPINS_PER_DELAY
#define S_LOCK_FREE(lock)
static void init_spin_delay(SpinDelayStatus *status, const char *file, int line, const char *func)
#define S_INIT_LOCK(lock)
void pg_usleep(long microsec)
static uint32 local_my_wait_event_info
uint32 * my_wait_event_info
static void pgstat_report_wait_start(uint32 wait_event_info)
static void pgstat_report_wait_end(void)