summaryrefslogtreecommitdiff
path: root/storage/xtradb/include/sync0rw.ic
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2011-07-18 23:04:24 +0200
committerSergei Golubchik <sergii@pisem.net>2011-07-18 23:04:24 +0200
commit4e46d8e5bff140f2549841167dc4b65a3c0a645d (patch)
treec6612dcc1d0fbd801c084e6c36307d9e5913a293 /storage/xtradb/include/sync0rw.ic
parent9a02c69f5c6766eaf552284a2a4dd0f1d26ecd2c (diff)
parentd4d7a8fa62c406be73f6c0f6d75e795293db548b (diff)
downloadmariadb-git-4e46d8e5bff140f2549841167dc4b65a3c0a645d.tar.gz
merge with xtradb-5.5.15
fix test cases
Diffstat (limited to 'storage/xtradb/include/sync0rw.ic')
-rw-r--r--storage/xtradb/include/sync0rw.ic257
1 files changed, 257 insertions, 0 deletions
diff --git a/storage/xtradb/include/sync0rw.ic b/storage/xtradb/include/sync0rw.ic
index 7116f1b7c9b..a6dfa603c59 100644
--- a/storage/xtradb/include/sync0rw.ic
+++ b/storage/xtradb/include/sync0rw.ic
@@ -622,3 +622,260 @@ rw_lock_x_unlock_direct(
rw_x_exit_count++;
#endif
}
+
+#ifdef UNIV_PFS_RWLOCK
+
+/******************************************************************//**
+Performance schema instrumented wrap function for rw_lock_create_func().
+NOTE! Please use the corresponding macro rw_lock_create(), not directly
+this function! */
+UNIV_INLINE
+void
+pfs_rw_lock_create_func(
+/*====================*/
+ mysql_pfs_key_t key, /*!< in: key registered with
+ performance schema */
+ rw_lock_t* lock, /*!< in: pointer to memory */
+# ifdef UNIV_DEBUG
+# ifdef UNIV_SYNC_DEBUG
+ ulint level, /*!< in: level */
+# endif /* UNIV_SYNC_DEBUG */
+ const char* cfile_name, /*!< in: file name where created */
+ ulint cline, /*!< in: file line where created */
+# endif /* UNIV_DEBUG */
+ const char* cmutex_name) /*!< in: mutex name */
+{
+ /* Initialize the rwlock for performance schema */
+ lock->pfs_psi = (PSI_server && PFS_IS_INSTRUMENTED(key))
+ ? PSI_server->init_rwlock(key, lock)
+ : NULL;
+
+ /* The actual function to initialize an rwlock */
+ rw_lock_create_func(lock,
+# ifdef UNIV_DEBUG
+# ifdef UNIV_SYNC_DEBUG
+ level,
+# endif /* UNIV_SYNC_DEBUG */
+ cfile_name,
+ cline,
+# endif /* UNIV_DEBUG */
+ cmutex_name);
+}
+/******************************************************************//**
+Performance schema instrumented wrap function for rw_lock_x_lock_func()
+NOTE! Please use the corresponding macro rw_lock_x_lock(), not directly
+this function! */
+UNIV_INLINE
+void
+pfs_rw_lock_x_lock_func(
+/*====================*/
+ rw_lock_t* lock, /*!< in: pointer to rw-lock */
+ ulint pass, /*!< in: pass value; != 0, if the lock will
+ be passed to another thread to unlock */
+ const char* file_name,/*!< in: file name where lock requested */
+ ulint line) /*!< in: line where requested */
+{
+ struct PSI_rwlock_locker* locker = NULL;
+ PSI_rwlock_locker_state state;
+
+ /* Record the entry of rw x lock request in performance schema */
+ if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
+ locker = PSI_server->get_thread_rwlock_locker(
+ &state, lock->pfs_psi, PSI_RWLOCK_WRITELOCK);
+
+ if (locker) {
+ PSI_server->start_rwlock_wrwait(locker,
+ file_name, line);
+ }
+ }
+
+ rw_lock_x_lock_func(lock, pass, file_name, line);
+
+ if (locker) {
+ PSI_server->end_rwlock_wrwait(locker, 0);
+ }
+}
+/******************************************************************//**
+Performance schema instrumented wrap function for
+rw_lock_x_lock_func_nowait()
+NOTE! Please use the corresponding macro rw_lock_x_lock_func(),
+not directly this function!
+@return TRUE if success */
+UNIV_INLINE
+ibool
+pfs_rw_lock_x_lock_func_nowait(
+/*===========================*/
+ rw_lock_t* lock, /*!< in: pointer to rw-lock */
+ const char* file_name,/*!< in: file name where lock
+ requested */
+ ulint line) /*!< in: line where requested */
+{
+ struct PSI_rwlock_locker* locker = NULL;
+ PSI_rwlock_locker_state state;
+ ibool ret;
+
+ /* Record the entry of rw x lock request in performance schema */
+ if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
+ locker = PSI_server->get_thread_rwlock_locker(
+ &state, lock->pfs_psi, PSI_RWLOCK_WRITELOCK);
+
+ if (locker) {
+ PSI_server->start_rwlock_wrwait(locker,
+ file_name, line);
+ }
+ }
+
+ ret = rw_lock_x_lock_func_nowait(lock, file_name, line);
+
+ if (locker) {
+ PSI_server->end_rwlock_wrwait(locker, 0);
+ }
+
+ return(ret);
+}
+/******************************************************************//**
+Performance schema instrumented wrap function for rw_lock_free_func()
+NOTE! Please use the corresponding macro rw_lock_free(), not directly
+this function! */
+UNIV_INLINE
+void
+pfs_rw_lock_free_func(
+/*==================*/
+ rw_lock_t* lock) /*!< in: pointer to rw-lock */
+{
+ if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
+ PSI_server->destroy_rwlock(lock->pfs_psi);
+ lock->pfs_psi = NULL;
+ }
+
+ rw_lock_free_func(lock);
+}
+/******************************************************************//**
+Performance schema instrumented wrap function for rw_lock_s_lock_func()
+NOTE! Please use the corresponding macro rw_lock_s_lock(), not
+directly this function! */
+UNIV_INLINE
+void
+pfs_rw_lock_s_lock_func(
+/*====================*/
+ rw_lock_t* lock, /*!< in: pointer to rw-lock */
+ ulint pass, /*!< in: pass value; != 0, if the
+ lock will be passed to another
+ thread to unlock */
+ const char* file_name,/*!< in: file name where lock
+ requested */
+ ulint line) /*!< in: line where requested */
+{
+ struct PSI_rwlock_locker* locker = NULL;
+ PSI_rwlock_locker_state state;
+
+ /* Instrumented to inform we are aquiring a shared rwlock */
+ if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
+ locker = PSI_server->get_thread_rwlock_locker(
+ &state, lock->pfs_psi, PSI_RWLOCK_READLOCK);
+ if (locker) {
+ PSI_server->start_rwlock_rdwait(locker,
+ file_name, line);
+ }
+ }
+
+ rw_lock_s_lock_func(lock, pass, file_name, line);
+
+ if (locker) {
+ PSI_server->end_rwlock_rdwait(locker, 0);
+ }
+}
+/******************************************************************//**
+Performance schema instrumented wrap function for rw_lock_s_lock_func()
+NOTE! Please use the corresponding macro rw_lock_s_lock(), not
+directly this function!
+@return TRUE if success */
+UNIV_INLINE
+ibool
+pfs_rw_lock_s_lock_low(
+/*===================*/
+ rw_lock_t* lock, /*!< in: pointer to rw-lock */
+ ulint pass, /*!< in: pass value; != 0, if the
+ lock will be passed to another
+ thread to unlock */
+ const char* file_name, /*!< in: file name where lock requested */
+ ulint line) /*!< in: line where requested */
+{
+ struct PSI_rwlock_locker* locker = NULL;
+ PSI_rwlock_locker_state state;
+ ibool ret;
+
+ /* Instrumented to inform we are aquiring a shared rwlock */
+ if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
+ locker = PSI_server->get_thread_rwlock_locker(
+ &state, lock->pfs_psi, PSI_RWLOCK_READLOCK);
+ if (locker) {
+ PSI_server->start_rwlock_rdwait(locker,
+ file_name, line);
+ }
+ }
+
+ ret = rw_lock_s_lock_low(lock, pass, file_name, line);
+
+ if (locker) {
+ PSI_server->end_rwlock_rdwait(locker, 0);
+ }
+
+ return(ret);
+}
+
+/******************************************************************//**
+Performance schema instrumented wrap function for rw_lock_x_unlock_func()
+NOTE! Please use the corresponding macro rw_lock_x_unlock(), not directly
+this function! */
+UNIV_INLINE
+void
+pfs_rw_lock_x_unlock_func(
+/*======================*/
+#ifdef UNIV_SYNC_DEBUG
+ ulint pass, /*!< in: pass value; != 0, if the
+ lock may have been passed to another
+ thread to unlock */
+#endif
+ rw_lock_t* lock) /*!< in/out: rw-lock */
+{
+ /* Inform performance schema we are unlocking the lock */
+ if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
+ PSI_server->unlock_rwlock(lock->pfs_psi);
+ }
+
+ rw_lock_x_unlock_func(
+#ifdef UNIV_SYNC_DEBUG
+ pass,
+#endif
+ lock);
+}
+
+/******************************************************************//**
+Performance schema instrumented wrap function for rw_lock_s_unlock_func()
+NOTE! Please use the corresponding macro pfs_rw_lock_s_unlock(), not
+directly this function! */
+UNIV_INLINE
+void
+pfs_rw_lock_s_unlock_func(
+/*======================*/
+#ifdef UNIV_SYNC_DEBUG
+ ulint pass, /*!< in: pass value; != 0, if the
+ lock may have been passed to another
+ thread to unlock */
+#endif
+ rw_lock_t* lock) /*!< in/out: rw-lock */
+{
+ /* Inform performance schema we are unlocking the lock */
+ if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
+ PSI_server->unlock_rwlock(lock->pfs_psi);
+ }
+
+ rw_lock_s_unlock_func(
+#ifdef UNIV_SYNC_DEBUG
+ pass,
+#endif
+ lock);
+
+}
+#endif /* UNIV_PFS_RWLOCK */