From dea6ed2c980286e89caf4166ad329f506abbff29 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas <heikki.linnakangas@iki.fi> Date: Fri, 21 Mar 2014 23:11:24 +0100 Subject: [PATCH] Fix build with LWLOCK_STATS or dtrace. Also fix the name of the dtrace probe for LWLockAcquireOrWait(). The function was renamed from LWLockWaitUntilFree to LWLockAqcuireOrWait, but the dtrace probe was neglected. Pointed out by Andres Freund and the buildfarm. --- src/backend/storage/lmgr/lwlock.c | 19 ++++++++++++++----- src/backend/utils/probes.d | 4 ++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c index f9c9bb299f4..36b4b8bbeaa 100644 --- a/src/backend/storage/lmgr/lwlock.c +++ b/src/backend/storage/lmgr/lwlock.c @@ -859,13 +859,13 @@ LWLockAcquireOrWait(LWLock *l, LWLockMode mode) /* Failed to get lock, so release interrupt holdoff */ RESUME_INTERRUPTS(); LOG_LWDEBUG("LWLockAcquireOrWait", T_NAME(l), T_ID(l), "failed"); - TRACE_POSTGRESQL_LWLOCK_WAIT_UNTIL_FREE_FAIL(T_NAME(l), T_ID(l), mode); + TRACE_POSTGRESQL_LWLOCK_ACQUIRE_OR_WAIT_FAIL(T_NAME(l), T_ID(l), mode); } else { /* Add lock to list of locks held by this backend */ held_lwlocks[num_held_lwlocks++] = l; - TRACE_POSTGRESQL_LWLOCK_WAIT_UNTIL_FREE(T_NAME(l), T_ID(l), mode); + TRACE_POSTGRESQL_LWLOCK_ACQUIRE_OR_WAIT(T_NAME(l), T_ID(l), mode); } return !mustwait; @@ -897,6 +897,15 @@ LWLockWaitForVar(LWLock *l, uint64 *valptr, uint64 oldval, uint64 *newval) PGPROC *proc = MyProc; int extraWaits = 0; bool result = false; +#ifdef LWLOCK_STATS + lwlock_stats *lwstats; +#endif + + PRINT_LWDEBUG("LWLockWaitForVar", lock); + +#ifdef LWLOCK_STATS + lwstats = get_lwlock_stats_entry(l); +#endif /* LWLOCK_STATS */ /* * Quick test first to see if it the slot is free right now. @@ -986,7 +995,7 @@ LWLockWaitForVar(LWLock *l, uint64 *valptr, uint64 oldval, uint64 *newval) lwstats->block_count++; #endif - TRACE_POSTGRESQL_LWLOCK_WAIT_START(T_NAME(l), T_ID(l), mode); + TRACE_POSTGRESQL_LWLOCK_WAIT_START(T_NAME(l), T_ID(l), LW_EXCLUSIVE); for (;;) { @@ -997,7 +1006,7 @@ LWLockWaitForVar(LWLock *l, uint64 *valptr, uint64 oldval, uint64 *newval) extraWaits++; } - TRACE_POSTGRESQL_LWLOCK_WAIT_DONE(T_NAME(l), T_ID(l), mode); + TRACE_POSTGRESQL_LWLOCK_WAIT_DONE(T_NAME(l), T_ID(l), LW_EXCLUSIVE); LOG_LWDEBUG("LWLockWaitForVar", T_NAME(l), T_ID(l), "awakened"); @@ -1007,7 +1016,7 @@ LWLockWaitForVar(LWLock *l, uint64 *valptr, uint64 oldval, uint64 *newval) /* We are done updating shared state of the lock itself. */ SpinLockRelease(&lock->mutex); - TRACE_POSTGRESQL_LWLOCK_ACQUIRE(T_NAME(l), T_ID(l), mode); + TRACE_POSTGRESQL_LWLOCK_ACQUIRE(T_NAME(l), T_ID(l), LW_EXCLUSIVE); /* * Fix the process wait semaphore's count for any absorbed wakeups. diff --git a/src/backend/utils/probes.d b/src/backend/utils/probes.d index 804ba6ae62a..fbfe53dc06f 100644 --- a/src/backend/utils/probes.d +++ b/src/backend/utils/probes.d @@ -34,8 +34,8 @@ provider postgresql { probe lwlock__wait__done(const char *, int, LWLockMode); probe lwlock__condacquire(const char *, int, LWLockMode); probe lwlock__condacquire__fail(const char *, int, LWLockMode); - probe lwlock__wait__until__free(const char *, int, LWLockMode); - probe lwlock__wait__until__free__fail(const char *, int, LWLockMode); + probe lwlock__acquire__or__wait(const char *, int, LWLockMode); + probe lwlock__acquire__or__wait__fail(const char *, int, LWLockMode); probe lock__wait__start(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, LOCKMODE); probe lock__wait__done(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, LOCKMODE); -- GitLab