diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/mysql/psi/mysql_file.h | 94 | ||||
-rw-r--r-- | include/mysql/psi/mysql_thread.h | 71 | ||||
-rw-r--r-- | include/mysql/psi/psi.h | 251 | ||||
-rw-r--r-- | include/mysql/psi/psi_abi_v1.h.pp | 101 | ||||
-rw-r--r-- | include/mysql/psi/psi_abi_v2.h.pp | 25 |
5 files changed, 443 insertions, 99 deletions
diff --git a/include/mysql/psi/mysql_file.h b/include/mysql/psi/mysql_file.h index 820979f16ee..de145f642e1 100644 --- a/include/mysql/psi/mysql_file.h +++ b/include/mysql/psi/mysql_file.h @@ -506,9 +506,10 @@ inline_mysql_file_fgets( char *result; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server && file->m_psi)) { - locker= PSI_server->get_thread_file_stream_locker(file->m_psi, + locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, PSI_FILE_READ); if (likely(locker != NULL)) PSI_server->start_file_wait(locker, (size_t) size, src_file, src_line); @@ -532,9 +533,10 @@ inline_mysql_file_fgetc( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server && file->m_psi)) { - locker= PSI_server->get_thread_file_stream_locker(file->m_psi, + locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, PSI_FILE_READ); if (likely(locker != NULL)) PSI_server->start_file_wait(locker, (size_t) 1, src_file, src_line); @@ -558,10 +560,11 @@ inline_mysql_file_fputs( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; size_t bytes= 0; if (likely(PSI_server && file->m_psi)) { - locker= PSI_server->get_thread_file_stream_locker(file->m_psi, + locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, PSI_FILE_WRITE); if (likely(locker != NULL)) { @@ -588,9 +591,10 @@ inline_mysql_file_fputc( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server && file->m_psi)) { - locker= PSI_server->get_thread_file_stream_locker(file->m_psi, + locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, PSI_FILE_WRITE); if (likely(locker != NULL)) PSI_server->start_file_wait(locker, (size_t) 1, src_file, src_line); @@ -614,9 +618,10 @@ inline_mysql_file_fprintf(MYSQL_FILE *file, const char *format, ...) va_list args; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server && file->m_psi)) { - locker= PSI_server->get_thread_file_stream_locker(file->m_psi, + locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, PSI_FILE_WRITE); if (likely(locker != NULL)) PSI_server->start_file_wait(locker, (size_t) 0, __FILE__, __LINE__); @@ -642,9 +647,10 @@ inline_mysql_file_vfprintf( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server && file->m_psi)) { - locker= PSI_server->get_thread_file_stream_locker(file->m_psi, + locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, PSI_FILE_WRITE); if (likely(locker != NULL)) PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line); @@ -668,9 +674,10 @@ inline_mysql_file_fflush( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server && file->m_psi)) { - locker= PSI_server->get_thread_file_stream_locker(file->m_psi, + locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, PSI_FILE_FLUSH); if (likely(locker != NULL)) PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line); @@ -700,9 +707,10 @@ inline_mysql_file_fstat( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server != NULL)) { - locker= PSI_server->get_thread_file_descriptor_locker(filenr, + locker= PSI_server->get_thread_file_descriptor_locker(&state, filenr, PSI_FILE_FSTAT); if (likely(locker != NULL)) PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line); @@ -726,9 +734,11 @@ inline_mysql_file_stat( MY_STAT *result; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server != NULL)) { - locker= PSI_server->get_thread_file_name_locker(key, PSI_FILE_STAT, + locker= PSI_server->get_thread_file_name_locker(&state, + key, PSI_FILE_STAT, path, &locker); if (likely(locker != NULL)) PSI_server->start_file_open_wait(locker, src_file, src_line); @@ -752,9 +762,10 @@ inline_mysql_file_chsize( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server != NULL)) { - locker= PSI_server->get_thread_file_descriptor_locker(file, + locker= PSI_server->get_thread_file_descriptor_locker(&state, file, PSI_FILE_CHSIZE); if (likely(locker != NULL)) PSI_server->start_file_wait(locker, (size_t) newlength, src_file, @@ -784,10 +795,11 @@ inline_mysql_file_fopen( { #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server != NULL)) { locker= PSI_server->get_thread_file_name_locker - (key, PSI_FILE_STREAM_OPEN, filename, that); + (&state, key, PSI_FILE_STREAM_OPEN, filename, that); if (likely(locker != NULL)) that->m_psi= PSI_server->start_file_open_wait(locker, src_file, src_line); @@ -820,10 +832,11 @@ inline_mysql_file_fclose( { #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; DBUG_ASSERT(file != NULL); if (likely(PSI_server && file->m_psi)) { - locker= PSI_server->get_thread_file_stream_locker(file->m_psi, + locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, PSI_FILE_STREAM_CLOSE); if (likely(locker != NULL)) PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line); @@ -849,9 +862,10 @@ inline_mysql_file_fread( size_t result= 0; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server && file->m_psi)) { - locker= PSI_server->get_thread_file_stream_locker(file->m_psi, + locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, PSI_FILE_READ); if (likely(locker != NULL)) PSI_server->start_file_wait(locker, count, src_file, src_line); @@ -882,9 +896,10 @@ inline_mysql_file_fwrite( size_t result= 0; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server && file->m_psi)) { - locker= PSI_server->get_thread_file_stream_locker(file->m_psi, + locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, PSI_FILE_WRITE); if (likely(locker != NULL)) PSI_server->start_file_wait(locker, count, src_file, src_line); @@ -915,9 +930,10 @@ inline_mysql_file_fseek( my_off_t result; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server && file->m_psi)) { - locker= PSI_server->get_thread_file_stream_locker(file->m_psi, + locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, PSI_FILE_SEEK); if (likely(locker != NULL)) PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line); @@ -941,9 +957,10 @@ inline_mysql_file_ftell( my_off_t result; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server && file->m_psi)) { - locker= PSI_server->get_thread_file_stream_locker(file->m_psi, + locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, PSI_FILE_TELL); if (likely(locker != NULL)) PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line); @@ -967,9 +984,10 @@ inline_mysql_file_create( File file; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server != NULL)) { - locker= PSI_server->get_thread_file_name_locker(key, PSI_FILE_CREATE, + locker= PSI_server->get_thread_file_name_locker(&state, key, PSI_FILE_CREATE, filename, &locker); if (likely(locker != NULL)) PSI_server->start_file_open_wait(locker, src_file, src_line); @@ -1014,9 +1032,10 @@ inline_mysql_file_open( File file; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server != NULL)) { - locker= PSI_server->get_thread_file_name_locker(key, PSI_FILE_OPEN, + locker= PSI_server->get_thread_file_name_locker(&state, key, PSI_FILE_OPEN, filename, &locker); if (likely(locker != NULL)) PSI_server->start_file_open_wait(locker, src_file, src_line); @@ -1040,9 +1059,10 @@ inline_mysql_file_close( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server != NULL)) { - locker= PSI_server->get_thread_file_descriptor_locker(file, + locker= PSI_server->get_thread_file_descriptor_locker(&state, file, PSI_FILE_CLOSE); if (likely(locker != NULL)) PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line); @@ -1066,9 +1086,10 @@ inline_mysql_file_read( size_t result= 0; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server != NULL)) { - locker= PSI_server->get_thread_file_descriptor_locker(file, + locker= PSI_server->get_thread_file_descriptor_locker(&state, file, PSI_FILE_READ); if (likely(locker != NULL)) PSI_server->start_file_wait(locker, count, src_file, src_line); @@ -1099,9 +1120,10 @@ inline_mysql_file_write( size_t result; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server != NULL)) { - locker= PSI_server->get_thread_file_descriptor_locker(file, + locker= PSI_server->get_thread_file_descriptor_locker(&state, file, PSI_FILE_WRITE); if (likely(locker != NULL)) PSI_server->start_file_wait(locker, count, src_file, src_line); @@ -1132,9 +1154,10 @@ inline_mysql_file_pread( size_t result; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server != NULL)) { - locker= PSI_server->get_thread_file_descriptor_locker(file, PSI_FILE_READ); + locker= PSI_server->get_thread_file_descriptor_locker(&state, file, PSI_FILE_READ); if (likely(locker != NULL)) PSI_server->start_file_wait(locker, count, src_file, src_line); } @@ -1164,9 +1187,10 @@ inline_mysql_file_pwrite( size_t result; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server != NULL)) { - locker= PSI_server->get_thread_file_descriptor_locker(file, + locker= PSI_server->get_thread_file_descriptor_locker(&state, file, PSI_FILE_WRITE); if (likely(locker != NULL)) PSI_server->start_file_wait(locker, count, src_file, src_line); @@ -1197,9 +1221,10 @@ inline_mysql_file_seek( my_off_t result; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server != NULL)) { - locker= PSI_server->get_thread_file_descriptor_locker(file, PSI_FILE_SEEK); + locker= PSI_server->get_thread_file_descriptor_locker(&state, file, PSI_FILE_SEEK); if (likely(locker != NULL)) PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line); } @@ -1222,9 +1247,10 @@ inline_mysql_file_tell( my_off_t result; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server != NULL)) { - locker= PSI_server->get_thread_file_descriptor_locker(file, PSI_FILE_TELL); + locker= PSI_server->get_thread_file_descriptor_locker(&state, file, PSI_FILE_TELL); if (likely(locker != NULL)) PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line); } @@ -1247,9 +1273,10 @@ inline_mysql_file_delete( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server != NULL)) { - locker= PSI_server->get_thread_file_name_locker(key, PSI_FILE_DELETE, + locker= PSI_server->get_thread_file_name_locker(&state, key, PSI_FILE_DELETE, name, &locker); if (likely(locker != NULL)) PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line); @@ -1273,9 +1300,10 @@ inline_mysql_file_rename( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server != NULL)) { - locker= PSI_server->get_thread_file_name_locker(key, PSI_FILE_RENAME, + locker= PSI_server->get_thread_file_name_locker(&state, key, PSI_FILE_RENAME, to, &locker); if (likely(locker != NULL)) PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line); @@ -1300,9 +1328,10 @@ inline_mysql_file_create_with_symlink( File file; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server != NULL)) { - locker= PSI_server->get_thread_file_name_locker(key, PSI_FILE_CREATE, + locker= PSI_server->get_thread_file_name_locker(&state, key, PSI_FILE_CREATE, filename, &locker); if (likely(locker != NULL)) PSI_server->start_file_open_wait(locker, src_file, src_line); @@ -1327,9 +1356,10 @@ inline_mysql_file_delete_with_symlink( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server != NULL)) { - locker= PSI_server->get_thread_file_name_locker(key, PSI_FILE_DELETE, + locker= PSI_server->get_thread_file_name_locker(&state, key, PSI_FILE_DELETE, name, &locker); if (likely(locker != NULL)) PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line); @@ -1353,9 +1383,10 @@ inline_mysql_file_rename_with_symlink( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server != NULL)) { - locker= PSI_server->get_thread_file_name_locker(key, PSI_FILE_RENAME, + locker= PSI_server->get_thread_file_name_locker(&state, key, PSI_FILE_RENAME, to, &locker); if (likely(locker != NULL)) PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line); @@ -1379,9 +1410,10 @@ inline_mysql_file_sync( int result= 0; #ifdef HAVE_PSI_INTERFACE struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; if (likely(PSI_server != NULL)) { - locker= PSI_server->get_thread_file_descriptor_locker(fd, PSI_FILE_SYNC); + locker= PSI_server->get_thread_file_descriptor_locker(&state, fd, PSI_FILE_SYNC); if (likely(locker != NULL)) PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line); } diff --git a/include/mysql/psi/mysql_thread.h b/include/mysql/psi/mysql_thread.h index 193cb89647d..d133f2655fb 100644 --- a/include/mysql/psi/mysql_thread.h +++ b/include/mysql/psi/mysql_thread.h @@ -625,9 +625,10 @@ static inline int inline_mysql_mutex_lock( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_mutex_locker *locker= NULL; + PSI_mutex_locker_state state; if (likely(PSI_server && that->m_psi)) { - locker= PSI_server->get_thread_mutex_locker(that->m_psi, PSI_MUTEX_LOCK); + locker= PSI_server->get_thread_mutex_locker(&state, that->m_psi, PSI_MUTEX_LOCK); if (likely(locker != NULL)) PSI_server->start_mutex_wait(locker, src_file, src_line); } @@ -654,9 +655,10 @@ static inline int inline_mysql_mutex_trylock( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_mutex_locker *locker= NULL; + PSI_mutex_locker_state state; if (likely(PSI_server && that->m_psi)) { - locker= PSI_server->get_thread_mutex_locker(that->m_psi, PSI_MUTEX_TRYLOCK); + locker= PSI_server->get_thread_mutex_locker(&state, that->m_psi, PSI_MUTEX_TRYLOCK); if (likely(locker != NULL)) PSI_server->start_mutex_wait(locker, src_file, src_line); } @@ -682,13 +684,8 @@ static inline int inline_mysql_mutex_unlock( { int result; #ifdef HAVE_PSI_INTERFACE - struct PSI_thread *thread; if (likely(PSI_server && that->m_psi)) - { - thread= PSI_server->get_thread(); - if (likely(thread != NULL)) - PSI_server->unlock_mutex(thread, that->m_psi); - } + PSI_server->unlock_mutex(that->m_psi); #endif #ifdef SAFE_MUTEX result= safe_mutex_unlock(&that->m_mutex, src_file, src_line); @@ -771,9 +768,10 @@ static inline int inline_mysql_rwlock_rdlock( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_rwlock_locker *locker= NULL; + PSI_rwlock_locker_state state; if (likely(PSI_server && that->m_psi)) { - locker= PSI_server->get_thread_rwlock_locker(that->m_psi, + locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi, PSI_RWLOCK_READLOCK); if (likely(locker != NULL)) PSI_server->start_rwlock_rdwait(locker, src_file, src_line); @@ -798,9 +796,10 @@ static inline int inline_mysql_prlock_rdlock( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_rwlock_locker *locker= NULL; + PSI_rwlock_locker_state state; if (likely(PSI_server && that->m_psi)) { - locker= PSI_server->get_thread_rwlock_locker(that->m_psi, + locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi, PSI_RWLOCK_READLOCK); if (likely(locker != NULL)) PSI_server->start_rwlock_rdwait(locker, src_file, src_line); @@ -825,9 +824,10 @@ static inline int inline_mysql_rwlock_wrlock( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_rwlock_locker *locker= NULL; + PSI_rwlock_locker_state state; if (likely(PSI_server && that->m_psi)) { - locker= PSI_server->get_thread_rwlock_locker(that->m_psi, + locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi, PSI_RWLOCK_WRITELOCK); if (likely(locker != NULL)) PSI_server->start_rwlock_wrwait(locker, src_file, src_line); @@ -852,9 +852,10 @@ static inline int inline_mysql_prlock_wrlock( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_rwlock_locker *locker= NULL; + PSI_rwlock_locker_state state; if (likely(PSI_server && that->m_psi)) { - locker= PSI_server->get_thread_rwlock_locker(that->m_psi, + locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi, PSI_RWLOCK_WRITELOCK); if (likely(locker != NULL)) PSI_server->start_rwlock_wrwait(locker, src_file, src_line); @@ -879,9 +880,10 @@ static inline int inline_mysql_rwlock_tryrdlock( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_rwlock_locker *locker= NULL; + PSI_rwlock_locker_state state; if (likely(PSI_server && that->m_psi)) { - locker= PSI_server->get_thread_rwlock_locker(that->m_psi, + locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi, PSI_RWLOCK_TRYREADLOCK); if (likely(locker != NULL)) PSI_server->start_rwlock_rdwait(locker, src_file, src_line); @@ -906,9 +908,10 @@ static inline int inline_mysql_prlock_tryrdlock( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_rwlock_locker *locker= NULL; + PSI_rwlock_locker_state state; if (likely(PSI_server && that->m_psi)) { - locker= PSI_server->get_thread_rwlock_locker(that->m_psi, + locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi, PSI_RWLOCK_TRYREADLOCK); if (likely(locker != NULL)) PSI_server->start_rwlock_rdwait(locker, src_file, src_line); @@ -933,9 +936,10 @@ static inline int inline_mysql_rwlock_trywrlock( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_rwlock_locker *locker= NULL; + PSI_rwlock_locker_state state; if (likely(PSI_server && that->m_psi)) { - locker= PSI_server->get_thread_rwlock_locker(that->m_psi, + locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi, PSI_RWLOCK_TRYWRITELOCK); if (likely(locker != NULL)) PSI_server->start_rwlock_wrwait(locker, src_file, src_line); @@ -960,9 +964,10 @@ static inline int inline_mysql_prlock_trywrlock( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_rwlock_locker *locker= NULL; + PSI_rwlock_locker_state state; if (likely(PSI_server && that->m_psi)) { - locker= PSI_server->get_thread_rwlock_locker(that->m_psi, + locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi, PSI_RWLOCK_TRYWRITELOCK); if (likely(locker != NULL)) PSI_server->start_rwlock_wrwait(locker, src_file, src_line); @@ -982,13 +987,8 @@ static inline int inline_mysql_rwlock_unlock( { int result; #ifdef HAVE_PSI_INTERFACE - struct PSI_thread *thread; if (likely(PSI_server && that->m_psi)) - { - thread= PSI_server->get_thread(); - if (likely(thread != NULL)) - PSI_server->unlock_rwlock(thread, that->m_psi); - } + PSI_server->unlock_rwlock(that->m_psi); #endif result= rw_unlock(&that->m_rwlock); return result; @@ -1000,13 +1000,8 @@ static inline int inline_mysql_prlock_unlock( { int result; #ifdef HAVE_PSI_INTERFACE - struct PSI_thread *thread; if (likely(PSI_server && that->m_psi)) - { - thread= PSI_server->get_thread(); - if (likely(thread != NULL)) - PSI_server->unlock_rwlock(thread, that->m_psi); - } + PSI_server->unlock_rwlock(that->m_psi); #endif result= rw_pr_unlock(&that->m_prlock); return result; @@ -1053,9 +1048,10 @@ static inline int inline_mysql_cond_wait( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_cond_locker *locker= NULL; + PSI_cond_locker_state state; if (likely(PSI_server && that->m_psi)) { - locker= PSI_server->get_thread_cond_locker(that->m_psi, mutex->m_psi, + locker= PSI_server->get_thread_cond_locker(&state, that->m_psi, mutex->m_psi, PSI_COND_WAIT); if (likely(locker != NULL)) PSI_server->start_cond_wait(locker, src_file, src_line); @@ -1081,9 +1077,10 @@ static inline int inline_mysql_cond_timedwait( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_cond_locker *locker= NULL; + PSI_cond_locker_state state; if (likely(PSI_server && that->m_psi)) { - locker= PSI_server->get_thread_cond_locker(that->m_psi, mutex->m_psi, + locker= PSI_server->get_thread_cond_locker(&state, that->m_psi, mutex->m_psi, PSI_COND_TIMEDWAIT); if (likely(locker != NULL)) PSI_server->start_cond_wait(locker, src_file, src_line); @@ -1102,13 +1099,8 @@ static inline int inline_mysql_cond_signal( { int result; #ifdef HAVE_PSI_INTERFACE - struct PSI_thread *thread; if (likely(PSI_server && that->m_psi)) - { - thread= PSI_server->get_thread(); - if (likely(thread != NULL)) - PSI_server->signal_cond(thread, that->m_psi); - } + PSI_server->signal_cond(that->m_psi); #endif result= pthread_cond_signal(&that->m_cond); return result; @@ -1119,13 +1111,8 @@ static inline int inline_mysql_cond_broadcast( { int result; #ifdef HAVE_PSI_INTERFACE - struct PSI_thread *thread; if (likely(PSI_server && that->m_psi)) - { - thread= PSI_server->get_thread(); - if (likely(thread != NULL)) - PSI_server->broadcast_cond(thread, that->m_psi); - } + PSI_server->broadcast_cond(that->m_psi); #endif result= pthread_cond_broadcast(&that->m_cond); return result; diff --git a/include/mysql/psi/psi.h b/include/mysql/psi/psi.h index 1cab6c3a11a..562e4a80fd5 100644 --- a/include/mysql/psi/psi.h +++ b/include/mysql/psi/psi.h @@ -422,6 +422,175 @@ struct PSI_file_info_v1 int m_flags; }; +/** + State data storage for @c get_thread_mutex_locker_v1_t. + This structure provide temporary storage to a mutex locker. + The content of this structure is considered opaque, + the fields are only hints of what an implementation + of the psi interface can use. + This memory is provided by the instrumented code for performance reasons. + @sa get_thread_mutex_locker_v1_t +*/ +struct PSI_mutex_locker_state_v1 +{ + /** Internal state. */ + uint m_flags; + /** Current mutex. */ + struct PSI_mutex *m_mutex; + /** Current thread. */ + struct PSI_thread *m_thread; + /** Timer start. */ + ulonglong m_timer_start; + /** Timer function. */ + ulonglong (*m_timer)(void); + /** Current operation. */ + enum PSI_mutex_operation m_operation; + /** Source file. */ + const char* m_src_file; + /** Source line number. */ + int m_src_line; + /** Internal data. */ + void *m_wait; +}; + +/** + State data storage for @c get_thread_rwlock_locker_v1_t. + This structure provide temporary storage to a rwlock locker. + The content of this structure is considered opaque, + the fields are only hints of what an implementation + of the psi interface can use. + This memory is provided by the instrumented code for performance reasons. + @sa get_thread_rwlock_locker_v1_t +*/ +struct PSI_rwlock_locker_state_v1 +{ + /** Internal state. */ + uint m_flags; + /** Current rwlock. */ + struct PSI_rwlock *m_rwlock; + /** Current thread. */ + struct PSI_thread *m_thread; + /** Timer start. */ + ulonglong m_timer_start; + /** Timer function. */ + ulonglong (*m_timer)(void); + /** Current operation. */ + enum PSI_rwlock_operation m_operation; + /** Source file. */ + const char* m_src_file; + /** Source line number. */ + int m_src_line; + /** Internal data. */ + void *m_wait; +}; + +/** + State data storage for @c get_thread_cond_locker_v1_t. + This structure provide temporary storage to a condition locker. + The content of this structure is considered opaque, + the fields are only hints of what an implementation + of the psi interface can use. + This memory is provided by the instrumented code for performance reasons. + @sa get_thread_cond_locker_v1_t +*/ +struct PSI_cond_locker_state_v1 +{ + /** Internal state. */ + uint m_flags; + /** Current condition. */ + struct PSI_cond *m_cond; + /** Current mutex. */ + struct PSI_mutex *m_mutex; + /** Current thread. */ + struct PSI_thread *m_thread; + /** Timer start. */ + ulonglong m_timer_start; + /** Timer function. */ + ulonglong (*m_timer)(void); + /** Current operation. */ + enum PSI_cond_operation m_operation; + /** Source file. */ + const char* m_src_file; + /** Source line number. */ + int m_src_line; + /** Internal data. */ + void *m_wait; +}; + +/** + State data storage for @c get_thread_file_name_locker_v1_t. + This structure provide temporary storage to a file locker. + The content of this structure is considered opaque, + the fields are only hints of what an implementation + of the psi interface can use. + This memory is provided by the instrumented code for performance reasons. + @sa get_thread_file_name_locker_v1_t + @sa get_thread_file_stream_locker_v1_t + @sa get_thread_file_descriptor_locker_v1_t +*/ +struct PSI_file_locker_state_v1 +{ + /** Internal state. */ + uint m_flags; + /** Current file. */ + struct PSI_file *m_file; + /** Current thread. */ + struct PSI_thread *m_thread; + /** Operation number of bytes. */ + size_t m_number_of_bytes; + /** Timer start. */ + ulonglong m_timer_start; + /** Timer function. */ + ulonglong (*m_timer)(void); + /** Current operation. */ + enum PSI_file_operation m_operation; + /** Source file. */ + const char* m_src_file; + /** Source line number. */ + int m_src_line; + /** Internal data. */ + void *m_wait; +}; + +/** + State data storage for @c get_thread_table_locker_v1_t. + This structure provide temporary storage to a table locker. + The content of this structure is considered opaque, + the fields are only hints of what an implementation + of the psi interface can use. + This memory is provided by the instrumented code for performance reasons. + @sa get_thread_table_locker_v1_t +*/ +struct PSI_table_locker_state_v1 +{ + /** Internal state. */ + uint m_flags; + /** Current table handle. */ + struct PSI_table *m_table; + /** Current table share. */ + struct PSI_table_share *m_table_share; + /** Instrumentation class. */ + void *m_class; + /** Current thread. */ + struct PSI_thread *m_thread; + /** Timer start. */ + ulonglong m_timer_start; + /** Timer function. */ + ulonglong (*m_timer)(void); + /* Current operation (waiting for WL#4895). */ + /* enum PSI_table_operation m_operation; */ + /** Current table io index. */ + uint m_index; + /** Current table lock index. */ + uint m_lock_index; + /** Source file. */ + const char* m_src_file; + /** Source line number. */ + int m_src_line; + /** Internal data. */ + void *m_wait; +}; + /* Using typedef to make reuse between PSI_v1 and PSI_v2 easier later. */ /** @@ -619,40 +788,51 @@ typedef void (*delete_thread_v1_t)(struct PSI_thread *thread); /** Get a mutex instrumentation locker. + @param state data storage for the locker @param mutex the instrumented mutex to lock @return a mutex locker, or NULL */ typedef struct PSI_mutex_locker* (*get_thread_mutex_locker_v1_t) - (struct PSI_mutex *mutex, enum PSI_mutex_operation op); + (struct PSI_mutex_locker_state_v1 *state, + struct PSI_mutex *mutex, + enum PSI_mutex_operation op); /** Get a rwlock instrumentation locker. + @param state data storage for the locker @param rwlock the instrumented rwlock to lock @return a rwlock locker, or NULL */ typedef struct PSI_rwlock_locker* (*get_thread_rwlock_locker_v1_t) - (struct PSI_rwlock *rwlock, enum PSI_rwlock_operation op); + (struct PSI_rwlock_locker_state_v1 *state, + struct PSI_rwlock *rwlock, + enum PSI_rwlock_operation op); /** Get a cond instrumentation locker. + @param state data storage for the locker @param cond the instrumented condition to wait on @param mutex the instrumented mutex associated with the condition @return a condition locker, or NULL */ typedef struct PSI_cond_locker* (*get_thread_cond_locker_v1_t) - (struct PSI_cond *cond, struct PSI_mutex *mutex, + (struct PSI_cond_locker_state_v1 *state, + struct PSI_cond *cond, struct PSI_mutex *mutex, enum PSI_cond_operation op); /** Get a table instrumentation locker. + @param state data storage for the locker @param table the instrumented table to lock @return a table locker, or NULL */ typedef struct PSI_table_locker* (*get_thread_table_locker_v1_t) - (struct PSI_table *table); + (struct PSI_table_locker_state_v1 *state, + struct PSI_table *table); /** Get a file instrumentation locker, for opening or creating a file. + @param state data storage for the locker @param key the file instrumentation key @param op the operation to perform @param name the file name @@ -660,58 +840,59 @@ typedef struct PSI_table_locker* (*get_thread_table_locker_v1_t) @return a file locker, or NULL */ typedef struct PSI_file_locker* (*get_thread_file_name_locker_v1_t) - (PSI_file_key key, enum PSI_file_operation op, const char *name, + (struct PSI_file_locker_state_v1 *state, + PSI_file_key key, enum PSI_file_operation op, const char *name, const void *identity); /** Get a file stream instrumentation locker. + @param state data storage for the locker @param file the file stream to access @param op the operation to perform @return a file locker, or NULL */ typedef struct PSI_file_locker* (*get_thread_file_stream_locker_v1_t) - (struct PSI_file *file, enum PSI_file_operation op); + (struct PSI_file_locker_state_v1 *state, + struct PSI_file *file, enum PSI_file_operation op); /** Get a file instrumentation locker. + @param state data storage for the locker @param file the file descriptor to access @param op the operation to perform @return a file locker, or NULL */ typedef struct PSI_file_locker* (*get_thread_file_descriptor_locker_v1_t) - (File file, enum PSI_file_operation op); + (struct PSI_file_locker_state_v1 *state, + File file, enum PSI_file_operation op); /** Record a mutex instrumentation unlock event. - @param thread the running thread instrumentation @param mutex the mutex instrumentation */ typedef void (*unlock_mutex_v1_t) - (struct PSI_thread *thread, struct PSI_mutex *mutex); + (struct PSI_mutex *mutex); /** Record a rwlock instrumentation unlock event. - @param thread the running thread instrumentation @param rwlock the rwlock instrumentation */ typedef void (*unlock_rwlock_v1_t) - (struct PSI_thread *thread, struct PSI_rwlock *rwlock); + (struct PSI_rwlock *rwlock); /** Record a condition instrumentation signal event. - @param thread the running thread instrumentation @param cond the cond instrumentation */ typedef void (*signal_cond_v1_t) - (struct PSI_thread *thread, struct PSI_cond *cond); + (struct PSI_cond *cond); /** Record a condition instrumentation broadcast event. - @param thread the running thread instrumentation @param cond the cond instrumentation */ typedef void (*broadcast_cond_v1_t) - (struct PSI_thread *thread, struct PSI_cond *cond); + (struct PSI_cond *cond); /** Record a mutex instrumentation wait start event. @@ -1013,6 +1194,36 @@ struct PSI_file_info_v2 int placeholder; }; +struct PSI_mutex_locker_state_v2 +{ + /** Placeholder */ + int placeholder; +}; + +struct PSI_rwlock_locker_state_v2 +{ + /** Placeholder */ + int placeholder; +}; + +struct PSI_cond_locker_state_v2 +{ + /** Placeholder */ + int placeholder; +}; + +struct PSI_file_locker_state_v2 +{ + /** Placeholder */ + int placeholder; +}; + +struct PSI_table_locker_state_v2 +{ + /** Placeholder */ + int placeholder; +}; + /** @} (end of group Group_PSI_v2) */ #endif /* HAVE_PSI_2 */ @@ -1056,6 +1267,11 @@ typedef struct PSI_rwlock_info_v1 PSI_rwlock_info; typedef struct PSI_cond_info_v1 PSI_cond_info; typedef struct PSI_thread_info_v1 PSI_thread_info; typedef struct PSI_file_info_v1 PSI_file_info; +typedef struct PSI_mutex_locker_state_v1 PSI_mutex_locker_state; +typedef struct PSI_rwlock_locker_state_v1 PSI_rwlock_locker_state; +typedef struct PSI_cond_locker_state_v1 PSI_cond_locker_state; +typedef struct PSI_file_locker_state_v1 PSI_file_locker_state; +typedef struct PSI_table_locker_state_v1 PSI_table_locker_state; #endif #ifdef USE_PSI_2 @@ -1065,6 +1281,11 @@ typedef struct PSI_rwlock_info_v2 PSI_rwlock_info; typedef struct PSI_cond_info_v2 PSI_cond_info; typedef struct PSI_thread_info_v2 PSI_thread_info; typedef struct PSI_file_info_v2 PSI_file_info; +typedef struct PSI_mutex_locker_state_v2 PSI_mutex_locker_state; +typedef struct PSI_rwlock_locker_state_v2 PSI_rwlock_locker_state; +typedef struct PSI_cond_locker_state_v2 PSI_cond_locker_state; +typedef struct PSI_file_locker_state_v2 PSI_file_locker_state; +typedef struct PSI_table_locker_state_v2 PSI_table_locker_state; #endif #else /* HAVE_PSI_INTERFACE */ diff --git a/include/mysql/psi/psi_abi_v1.h.pp b/include/mysql/psi/psi_abi_v1.h.pp index 6ecd0f3098d..adb3010469b 100644 --- a/include/mysql/psi/psi_abi_v1.h.pp +++ b/include/mysql/psi/psi_abi_v1.h.pp @@ -88,6 +88,71 @@ struct PSI_file_info_v1 const char *m_name; int m_flags; }; +struct PSI_mutex_locker_state_v1 +{ + uint m_flags; + struct PSI_mutex *m_mutex; + struct PSI_thread *m_thread; + ulonglong m_timer_start; + ulonglong (*m_timer)(void); + enum PSI_mutex_operation m_operation; + const char* m_src_file; + int m_src_line; + void *m_wait; +}; +struct PSI_rwlock_locker_state_v1 +{ + uint m_flags; + struct PSI_rwlock *m_rwlock; + struct PSI_thread *m_thread; + ulonglong m_timer_start; + ulonglong (*m_timer)(void); + enum PSI_rwlock_operation m_operation; + const char* m_src_file; + int m_src_line; + void *m_wait; +}; +struct PSI_cond_locker_state_v1 +{ + uint m_flags; + struct PSI_cond *m_cond; + struct PSI_mutex *m_mutex; + struct PSI_thread *m_thread; + ulonglong m_timer_start; + ulonglong (*m_timer)(void); + enum PSI_cond_operation m_operation; + const char* m_src_file; + int m_src_line; + void *m_wait; +}; +struct PSI_file_locker_state_v1 +{ + uint m_flags; + struct PSI_file *m_file; + struct PSI_thread *m_thread; + size_t m_number_of_bytes; + ulonglong m_timer_start; + ulonglong (*m_timer)(void); + enum PSI_file_operation m_operation; + const char* m_src_file; + int m_src_line; + void *m_wait; +}; +struct PSI_table_locker_state_v1 +{ + uint m_flags; + struct PSI_table *m_table; + struct PSI_table_share *m_table_share; + void *m_class; + struct PSI_thread *m_thread; + ulonglong m_timer_start; + ulonglong (*m_timer)(void); + uint m_index; + uint m_lock_index; + const char* m_src_file; + int m_src_line; + void *m_wait; +}; typedef void (*register_mutex_v1_t) (const char *category, struct PSI_mutex_info_v1 *info, int count); typedef void (*register_rwlock_v1_t) @@ -129,29 +194,38 @@ typedef void (*set_thread_v1_t)(struct PSI_thread *thread); typedef void (*delete_current_thread_v1_t)(void); typedef void (*delete_thread_v1_t)(struct PSI_thread *thread); typedef struct PSI_mutex_locker* (*get_thread_mutex_locker_v1_t) - (struct PSI_mutex *mutex, enum PSI_mutex_operation op); + (struct PSI_mutex_locker_state_v1 *state, + struct PSI_mutex *mutex, + enum PSI_mutex_operation op); typedef struct PSI_rwlock_locker* (*get_thread_rwlock_locker_v1_t) - (struct PSI_rwlock *rwlock, enum PSI_rwlock_operation op); + (struct PSI_rwlock_locker_state_v1 *state, + struct PSI_rwlock *rwlock, + enum PSI_rwlock_operation op); typedef struct PSI_cond_locker* (*get_thread_cond_locker_v1_t) - (struct PSI_cond *cond, struct PSI_mutex *mutex, + (struct PSI_cond_locker_state_v1 *state, + struct PSI_cond *cond, struct PSI_mutex *mutex, enum PSI_cond_operation op); typedef struct PSI_table_locker* (*get_thread_table_locker_v1_t) - (struct PSI_table *table); + (struct PSI_table_locker_state_v1 *state, + struct PSI_table *table); typedef struct PSI_file_locker* (*get_thread_file_name_locker_v1_t) - (PSI_file_key key, enum PSI_file_operation op, const char *name, + (struct PSI_file_locker_state_v1 *state, + PSI_file_key key, enum PSI_file_operation op, const char *name, const void *identity); typedef struct PSI_file_locker* (*get_thread_file_stream_locker_v1_t) - (struct PSI_file *file, enum PSI_file_operation op); + (struct PSI_file_locker_state_v1 *state, + struct PSI_file *file, enum PSI_file_operation op); typedef struct PSI_file_locker* (*get_thread_file_descriptor_locker_v1_t) - (File file, enum PSI_file_operation op); + (struct PSI_file_locker_state_v1 *state, + File file, enum PSI_file_operation op); typedef void (*unlock_mutex_v1_t) - (struct PSI_thread *thread, struct PSI_mutex *mutex); + (struct PSI_mutex *mutex); typedef void (*unlock_rwlock_v1_t) - (struct PSI_thread *thread, struct PSI_rwlock *rwlock); + (struct PSI_rwlock *rwlock); typedef void (*signal_cond_v1_t) - (struct PSI_thread *thread, struct PSI_cond *cond); + (struct PSI_cond *cond); typedef void (*broadcast_cond_v1_t) - (struct PSI_thread *thread, struct PSI_cond *cond); + (struct PSI_cond *cond); typedef void (*start_mutex_wait_v1_t) (struct PSI_mutex_locker *locker, const char *src_file, uint src_line); typedef void (*end_mutex_wait_v1_t) @@ -240,5 +314,10 @@ typedef struct PSI_rwlock_info_v1 PSI_rwlock_info; typedef struct PSI_cond_info_v1 PSI_cond_info; typedef struct PSI_thread_info_v1 PSI_thread_info; typedef struct PSI_file_info_v1 PSI_file_info; +typedef struct PSI_mutex_locker_state_v1 PSI_mutex_locker_state; +typedef struct PSI_rwlock_locker_state_v1 PSI_rwlock_locker_state; +typedef struct PSI_cond_locker_state_v1 PSI_cond_locker_state; +typedef struct PSI_file_locker_state_v1 PSI_file_locker_state; +typedef struct PSI_table_locker_state_v1 PSI_table_locker_state; extern MYSQL_PLUGIN_IMPORT PSI *PSI_server; C_MODE_END diff --git a/include/mysql/psi/psi_abi_v2.h.pp b/include/mysql/psi/psi_abi_v2.h.pp index b32415a59b4..63f8c52c50a 100644 --- a/include/mysql/psi/psi_abi_v2.h.pp +++ b/include/mysql/psi/psi_abi_v2.h.pp @@ -82,11 +82,36 @@ struct PSI_file_info_v2 { int placeholder; }; +struct PSI_mutex_locker_state_v2 +{ + int placeholder; +}; +struct PSI_rwlock_locker_state_v2 +{ + int placeholder; +}; +struct PSI_cond_locker_state_v2 +{ + int placeholder; +}; +struct PSI_file_locker_state_v2 +{ + int placeholder; +}; +struct PSI_table_locker_state_v2 +{ + int placeholder; +}; typedef struct PSI_v2 PSI; typedef struct PSI_mutex_info_v2 PSI_mutex_info; typedef struct PSI_rwlock_info_v2 PSI_rwlock_info; typedef struct PSI_cond_info_v2 PSI_cond_info; typedef struct PSI_thread_info_v2 PSI_thread_info; typedef struct PSI_file_info_v2 PSI_file_info; +typedef struct PSI_mutex_locker_state_v2 PSI_mutex_locker_state; +typedef struct PSI_rwlock_locker_state_v2 PSI_rwlock_locker_state; +typedef struct PSI_cond_locker_state_v2 PSI_cond_locker_state; +typedef struct PSI_file_locker_state_v2 PSI_file_locker_state; +typedef struct PSI_table_locker_state_v2 PSI_table_locker_state; extern MYSQL_PLUGIN_IMPORT PSI *PSI_server; C_MODE_END |