diff options
Diffstat (limited to 'storage/innobase/include/srw_lock.h')
-rw-r--r-- | storage/innobase/include/srw_lock.h | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/storage/innobase/include/srw_lock.h b/storage/innobase/include/srw_lock.h index f305a4de124..34105636e2e 100644 --- a/storage/innobase/include/srw_lock.h +++ b/storage/innobase/include/srw_lock.h @@ -73,9 +73,13 @@ public: #ifndef UNIV_PFS_RWLOCK # define SRW_LOCK_INIT(key) init() +# define SRW_LOCK_ARGS(file, line) /* nothing */ +# define SRW_LOCK_CALL /* nothing */ typedef srw_lock_low srw_lock; #else # define SRW_LOCK_INIT(key) init(key) +# define SRW_LOCK_ARGS(file, line) file, line +# define SRW_LOCK_CALL __FILE__, __LINE__ /** Slim reader-writer lock with PERFORMANCE_SCHEMA instrumentation */ class srw_lock @@ -83,6 +87,8 @@ class srw_lock srw_lock_low lock; PSI_rwlock *pfs_psi; + ATTRIBUTE_NOINLINE void psi_rd_lock(const char *file, unsigned line); + ATTRIBUTE_NOINLINE void psi_wr_lock(const char *file, unsigned line); public: void init(mysql_pfs_key_t key) { @@ -98,22 +104,12 @@ public: } lock.destroy(); } - void rd_lock() + void rd_lock(const char *file, unsigned line) { - uint32_t l; - if (lock.read_trylock(l)) - return; - if (pfs_psi) - { - PSI_rwlock_locker_state state; - PSI_rwlock_locker *locker= PSI_RWLOCK_CALL(start_rwlock_rdwait) - (&state, pfs_psi, PSI_RWLOCK_READLOCK, __FILE__, __LINE__); - lock.read_lock(l); - if (locker) - PSI_RWLOCK_CALL(end_rwlock_rdwait)(locker, 0); - return; - } - lock.read_lock(l); + if (psi_likely(pfs_psi != nullptr)) + psi_rd_lock(file, line); + else + lock.rd_lock(); } void rd_unlock() { @@ -121,21 +117,12 @@ public: PSI_RWLOCK_CALL(unlock_rwlock)(pfs_psi); lock.rd_unlock(); } - void wr_lock() + void wr_lock(const char *file, unsigned line) { - if (lock.write_trylock()) - return; - if (pfs_psi) - { - PSI_rwlock_locker_state state; - PSI_rwlock_locker *locker= PSI_RWLOCK_CALL(start_rwlock_wrwait) - (&state, pfs_psi, PSI_RWLOCK_WRITELOCK, __FILE__, __LINE__); - lock.write_lock(); - if (locker) - PSI_RWLOCK_CALL(end_rwlock_rdwait)(locker, 0); - return; - } - lock.write_lock(); + if (psi_likely(pfs_psi != nullptr)) + psi_wr_lock(file, line); + else + lock.wr_lock(); } void wr_unlock() { |