58 #define MIN_SPINS_PER_DELAY 10
59 #define MAX_SPINS_PER_DELAY 1000
60 #define NUM_DELAYS 1000
61 #define MIN_DELAY_USEC 1000L
62 #define MAX_DELAY_USEC 1000000L
84 #if defined(S_LOCK_TEST)
86 "\nStuck spinlock detected at %s, %s:%d.\n",
90 elog(
PANIC,
"stuck spinlock detected at %s, %s:%d",
99 s_lock(
volatile slock_t *lock,
const char *file,
int line,
const char *func)
112 return delayStatus.
delays;
115 #ifdef USE_DEFAULT_S_UNLOCK
117 s_unlock(
volatile slock_t *lock)
119 #ifdef TAS_ACTIVE_WORD
121 *TAS_ACTIVE_WORD(lock) = -1;
158 #if defined(S_LOCK_TEST)
241 #if defined(S_LOCK_TEST)
247 struct test_lock_struct
254 volatile struct test_lock_struct test_lock;
261 test_lock.pad1 = test_lock.pad2 = 0x44;
265 if (test_lock.pad1 != 0x44 || test_lock.pad2 != 0x44)
267 printf(
"S_LOCK_TEST: failed, declared datatype is wrong size\n");
273 printf(
"S_LOCK_TEST: failed, lock not initialized\n");
279 if (test_lock.pad1 != 0x44 || test_lock.pad2 != 0x44)
281 printf(
"S_LOCK_TEST: failed, declared datatype is wrong size\n");
287 printf(
"S_LOCK_TEST: failed, lock not locked\n");
293 if (test_lock.pad1 != 0x44 || test_lock.pad2 != 0x44)
295 printf(
"S_LOCK_TEST: failed, declared datatype is wrong size\n");
301 printf(
"S_LOCK_TEST: failed, lock not unlocked\n");
307 if (test_lock.pad1 != 0x44 || test_lock.pad2 != 0x44)
309 printf(
"S_LOCK_TEST: failed, declared datatype is wrong size\n");
315 printf(
"S_LOCK_TEST: failed, lock not re-locked\n");
320 printf(
" exit with a 'stuck spinlock' message\n");
321 printf(
" if S_LOCK() and TAS() are working.\n");
324 s_lock(&test_lock.lock, __FILE__, __LINE__, __func__);
326 printf(
"S_LOCK_TEST: failed, lock not locked\n");
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
#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)