MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Marc Alff Date:September 25 2009 1:19pm
Subject:bzr commit into mysql-trunk-perfschema branch (marc.alff:2893) WL#2360
View as plain text  
#At file:///home/malff/BZR_TREE/mysql-trunk-perfschema/ based on revid:marc.alff@stripped

 2893 Marc Alff	2009-09-25
      WL#2360 Performance schema
      
      Manual port, continued.
      Server instrumentation keys (mutexes)

    modified:
      sql/event_queue.cc
      sql/event_queue.h
      sql/event_scheduler.cc
      sql/events.cc
      sql/events.h
      sql/ha_ndbcluster.cc
      sql/ha_ndbcluster_binlog.cc
      sql/ha_ndbcluster_binlog.h
      sql/ha_partition.cc
      sql/hostname.cc
      sql/item_func.cc
      sql/log.cc
      sql/log.h
      sql/mysql_priv.h
      sql/mysqld.cc
      sql/repl_failsafe.cc
      sql/rpl_mi.cc
      sql/rpl_reporting.cc
      sql/rpl_reporting.h
      sql/rpl_rli.cc
      sql/sp_cache.cc
      sql/sql_base.cc
      sql/sql_cache.cc
      sql/sql_class.cc
      sql/sql_db.cc
      sql/sql_insert.cc
      sql/sql_manager.cc
      sql/sql_servers.cc
      sql/sql_table.cc
      sql/sql_udf.cc
      sql/table.cc
=== modified file 'sql/event_queue.cc'
--- a/sql/event_queue.cc	2009-09-14 12:17:47 +0000
+++ b/sql/event_queue.cc	2009-09-25 13:18:54 +0000
@@ -94,8 +94,8 @@ Event_queue::Event_queue()
    mutex_queue_data_attempting_lock(FALSE),
    waiting_on_cond(FALSE)
 {
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_event_queue, MY_MUTEX_INIT_FAST);
-  mysql_cond_init(INSTRUMENT_ME, &COND_queue_state, NULL);
+  mysql_mutex_init(key_LOCK_event_queue, &LOCK_event_queue, MY_MUTEX_INIT_FAST);
+  mysql_cond_init(key_COND_queue_state, &COND_queue_state, NULL);
 }
 
 

=== modified file 'sql/event_queue.h'
--- a/sql/event_queue.h	2009-09-14 12:17:47 +0000
+++ b/sql/event_queue.h	2009-09-25 13:18:54 +0000
@@ -25,6 +25,11 @@
   Queue of events awaiting execution.
 */
 
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_LOCK_event_queue;
+extern PSI_cond_key key_COND_queue_state;
+#endif /* HAVE_PSI_INTERFACE */
+
 class Event_basic;
 class Event_queue_element;
 class Event_queue_element_for_exec;

=== modified file 'sql/event_scheduler.cc'
--- a/sql/event_scheduler.cc	2009-09-23 08:41:25 +0000
+++ b/sql/event_scheduler.cc	2009-09-25 13:18:54 +0000
@@ -336,8 +336,9 @@ Event_scheduler::Event_scheduler(Event_q
   waiting_on_cond(FALSE),
   started_events(0)
 {
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_scheduler_state, MY_MUTEX_INIT_FAST);
-  mysql_cond_init(INSTRUMENT_ME, &COND_state, NULL);
+  mysql_mutex_init(key_event_scheduler_LOCK_scheduler_state,
+                   &LOCK_scheduler_state, MY_MUTEX_INIT_FAST);
+  mysql_cond_init(key_event_scheduler_COND_state, &COND_state, NULL);
 }
 
 
@@ -404,7 +405,7 @@ Event_scheduler::start()
   DBUG_PRINT("info", ("Setting state go RUNNING"));
   state= RUNNING;
   DBUG_PRINT("info", ("Forking new thread for scheduler. THD: 0x%lx", (long) new_thd));
-  if (mysql_thread_create(INSTRUMENT_ME,
+  if (mysql_thread_create(key_thread_event_scheduler,
                           &th, &connection_attrib, event_scheduler_thread,
                           (void*)scheduler_param_value))
   {
@@ -533,7 +534,7 @@ Event_scheduler::execute_top(Event_queue
     reasonable level.
   */
   /* Major failure */
-  if ((res= mysql_thread_create(INSTRUMENT_ME,
+  if ((res= mysql_thread_create(key_thread_event_worker,
                                 &th, &connection_attrib, event_worker_thread,
                                 event_name)))
     goto error;

=== modified file 'sql/events.cc'
--- a/sql/events.cc	2009-09-22 16:22:25 +0000
+++ b/sql/events.cc	2009-09-25 13:18:54 +0000
@@ -1032,6 +1032,51 @@ Events::deinit()
   DBUG_VOID_RETURN;
 }
 
+#ifdef HAVE_PSI_INTERFACE
+PSI_mutex_key key_LOCK_event_metadata, key_LOCK_event_queue,
+              key_event_scheduler_LOCK_scheduler_state;
+
+static PSI_mutex_info all_events_mutexes[]=
+{
+  { &key_LOCK_event_metadata, "LOCK_event_metadata", PSI_FLAG_GLOBAL},
+  { &key_LOCK_event_queue, "LOCK_event_queue", PSI_FLAG_GLOBAL},
+  { &key_event_scheduler_LOCK_scheduler_state, "Event_scheduler::LOCK_scheduler_state", PSI_FLAG_GLOBAL}
+};
+
+PSI_cond_key key_event_scheduler_COND_state, key_COND_queue_state;
+
+static PSI_cond_info all_events_conds[]=
+{
+  { &key_event_scheduler_COND_state, "Event_scheduler::COND_state", PSI_FLAG_GLOBAL},
+  { &key_COND_queue_state, "COND_queue_state", PSI_FLAG_GLOBAL},
+};
+
+PSI_thread_key key_thread_event_scheduler, key_thread_event_worker;
+
+static PSI_thread_info all_events_threads[]=
+{
+  { &key_thread_event_scheduler, "event_scheduler", PSI_FLAG_GLOBAL},
+  { &key_thread_event_worker, "event_worker", 0}
+};
+
+static void init_events_psi_keys(void)
+{
+  const char* category= "sql";
+  int count;
+
+  if (PSI_server == NULL)
+    return;
+
+  count= array_elements(all_events_mutexes);
+  PSI_server->register_mutex(category, all_events_mutexes, count);
+
+  count= array_elements(all_events_conds);
+  PSI_server->register_cond(category, all_events_conds, count);
+
+  count= array_elements(all_events_threads);
+  PSI_server->register_thread(category, all_events_threads, count);
+}
+#endif /* HAVE_PSI_INTERFACE */
 
 /**
   Inits Events mutexes
@@ -1044,7 +1089,12 @@ Events::deinit()
 void
 Events::init_mutexes()
 {
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_event_metadata, MY_MUTEX_INIT_FAST);
+#ifdef HAVE_PSI_INTERFACE
+  init_events_psi_keys();
+#endif
+
+  mysql_mutex_init(key_LOCK_event_metadata,
+                   &LOCK_event_metadata, MY_MUTEX_INIT_FAST);
 }
 
 

=== modified file 'sql/events.h'
--- a/sql/events.h	2009-09-14 12:17:47 +0000
+++ b/sql/events.h	2009-09-25 13:18:54 +0000
@@ -25,6 +25,13 @@
   A public interface of Events_Scheduler module.
 */
 
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_LOCK_event_metadata,
+                     key_event_scheduler_LOCK_scheduler_state;
+extern PSI_cond_key key_event_scheduler_COND_state;
+extern PSI_thread_key key_thread_event_scheduler, key_thread_event_worker;
+#endif /* HAVE_PSI_INTERFACE */
+
 class Event_parse_data;
 class Event_db_repository;
 class Event_queue;

=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2009-09-23 08:41:25 +0000
+++ b/sql/ha_ndbcluster.cc	2009-09-25 13:18:54 +0000
@@ -7362,6 +7362,75 @@ static int connect_callback()
 extern int ndb_dictionary_is_mysqld;
 extern mysql_mutex_t LOCK_plugin;
 
+#ifdef HAVE_PSI_INTERFACE
+
+#ifdef HAVE_NDB_BINLOG
+PSI_mutex_key key_injector_mutex, key_ndb_schema_share_mutex,
+              key_ndb_schema_object_mutex;
+#endif /* HAVE_NDB_BINLOG */
+
+PSI_mutex_key key_NDB_SHARE_mutex, key_ndbcluster_mutex,
+              key_LOCK_ndb_util_thread;
+
+static PSI_mutex_info all_ndbcluster_mutexes[]=
+{
+#ifdef HAVE_NDB_BINLOG
+  {& key_injector_mutex, "injector_mutex", PSI_FLAG_GLOBAL},
+  {& key_ndb_schema_share_mutex, "ndb_schema_share_mutex", PSI_FLAG_GLOBAL},
+  {& key_ndb_schema_object_mutex, "ndb_schema_object_mutex", PSI_FLAG_GLOBAL},
+#endif /* HAVE_NDB_BINLOG */
+  {& key_NDB_SHARE_mutex, "NDB_SHARE::mutex", PSI_FLAG_GLOBAL},
+  {& key_ndbcluster_mutex, "ndbcluster_mutex", PSI_FLAG_GLOBAL},
+  {& key_LOCK_ndb_util_thread, "LOCK_ndb_util_thread", PSI_FLAG_GLOBAL}
+};
+
+#ifdef HAVE_NDB_BINLOG
+PSI_cond_key key_injector_cond;
+#endif /* HAVE_NDB_BINLOG */
+
+PSI_cond_key key_COND_ndb_util_thread, key_COND_ndb_util_ready;
+
+static PSI_cond_info all_ndbcluster_conds[]=
+{
+#ifdef HAVE_NDB_BINLOG
+  {& key_injector_cond, "injector_cond", PSI_FLAG_GLOBAL},
+#endif /* HAVE_NDB_BINLOG */
+  {& key_COND_ndb_util_thread, "COND_ndb_util_thread", PSI_FLAG_GLOBAL},
+  {& key_COND_ndb_util_ready, "COND_ndb_util_ready", PSI_FLAG_GLOBAL}
+};
+
+#ifdef HAVE_NDB_BINLOG
+PSI_thread_key key_thread_ndb_binlog;
+#endif /* HAVE_NDB_BINLOG */
+PSI_thread_key key_thread_ndb_util;
+
+static PSI_thread_info all_ndbcluster_threads[]=
+{
+#ifdef HAVE_NDB_BINLOG
+  { &key_thread_ndb_binlog, "ndb_binlog", PSI_FLAG_GLOBAL},
+#endif /* HAVE_NDB_BINLOG */
+  { &key_thread_ndb_util, "ndb_util", PSI_FLAG_GLOBAL}
+};
+
+void init_ndbcluster_psi_keys()
+{
+  const char* category= "ndbcluster";
+  int count;
+
+  if (PSI_server == NULL)
+    return;
+
+  count= array_elements(all_ndbcluster_mutexes);
+  PSI_server->register_mutex(category, all_ndbcluster_mutexes, count);
+
+  count= array_elements(all_ndbcluster_conds);
+  PSI_server->register_cond(category, all_ndbcluster_conds, count);
+
+  count= array_elements(all_ndbcluster_threads);
+  PSI_server->register_thread(category, all_ndbcluster_threads, count);
+}
+#endif /* HAVE_PSI_INTERFACE */
+
 static int ndbcluster_init(void *p)
 {
   int res;
@@ -7370,6 +7439,10 @@ static int ndbcluster_init(void *p)
   if (ndbcluster_inited)
     DBUG_RETURN(FALSE);
 
+#ifdef HAVE_PSI_INTERFACE
+  init_ndbcluster_psi_keys();
+#endif
+
   /*
     Below we create new THD's. They'll need LOCK_plugin, but it's taken now by
     plugin initialization code. Release it to avoid deadlocks.  It's safe, as
@@ -7377,10 +7450,12 @@ static int ndbcluster_init(void *p)
   */
   mysql_mutex_unlock(&LOCK_plugin);
 
-  mysql_mutex_init(INSTRUMENT_ME, &ndbcluster_mutex, MY_MUTEX_INIT_FAST);
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_ndb_util_thread, MY_MUTEX_INIT_FAST);
-  mysql_cond_init(INSTRUMENT_ME, &COND_ndb_util_thread, NULL);
-  mysql_cond_init(INSTRUMENT_ME, &COND_ndb_util_ready, NULL);
+  mysql_mutex_init(key_ndbcluster_mutex,
+                   &ndbcluster_mutex, MY_MUTEX_INIT_FAST);
+  mysql_mutex_init(key_LOCK_ndb_util_thread,
+                   &LOCK_ndb_util_thread, MY_MUTEX_INIT_FAST);
+  mysql_cond_init(key_COND_ndb_util_thread, &COND_ndb_util_thread, NULL);
+  mysql_cond_init(key_COND_ndb_util_ready, &COND_ndb_util_ready, NULL);
   ndb_util_thread_running= -1;
   ndbcluster_terminating= 0;
   ndb_dictionary_is_mysqld= 1;
@@ -7489,7 +7564,7 @@ static int ndbcluster_init(void *p)
   ndb_cache_check_time = opt_ndb_cache_check_time;
   // Create utility thread
   pthread_t tmp;
-  if (mysql_thread_create(INSTRUMENT_ME,
+  if (mysql_thread_create(key_thread_ndb_util,
                           &tmp, &connection_attrib, ndb_util_thread_func, 0))
   {
     DBUG_PRINT("error", ("Could not create ndb utility thread"));
@@ -8450,7 +8525,7 @@ NDB_SHARE *ndbcluster_get_share(const ch
         DBUG_RETURN(0);
       }
       thr_lock_init(&share->lock);
-      mysql_mutex_init(INSTRUMENT_ME, &share->mutex, MY_MUTEX_INIT_FAST);
+      mysql_mutex_init(key_NDB_SHARE_mutex, &share->mutex, MY_MUTEX_INIT_FAST);
       share->commit_count= 0;
       share->commit_count_lock= 0;
       share->db= share->key + length + 1;

=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc	2009-09-23 08:41:25 +0000
+++ b/sql/ha_ndbcluster_binlog.cc	2009-09-25 13:18:54 +0000
@@ -2458,12 +2458,13 @@ int ndbcluster_binlog_start()
     DBUG_RETURN(-1);
   }
 
-  mysql_mutex_init(INSTRUMENT_ME, &injector_mutex, MY_MUTEX_INIT_FAST);
-  mysql_cond_init(INSTRUMENT_ME, &injector_cond, NULL);
-  mysql_mutex_init(INSTRUMENT_ME, &ndb_schema_share_mutex, MY_MUTEX_INIT_FAST);
+  mysql_mutex_init(key_injector_mutex, &injector_mutex, MY_MUTEX_INIT_FAST);
+  mysql_cond_init(key_injector_cond, &injector_cond, NULL);
+  mysql_mutex_init(key_ndb_schema_share_mutex,
+                   &ndb_schema_share_mutex, MY_MUTEX_INIT_FAST);
 
   /* Create injector thread */
-  if (mysql_thread_create(INSTRUMENT_ME,
+  if (mysql_thread_create(key_thread_ndb_binlog,
                           &ndb_binlog_thread, &connection_attrib,
                           ndb_binlog_thread_func, 0))
   {
@@ -3583,7 +3584,7 @@ static NDB_SCHEMA_OBJECT *ndb_get_schema
       my_free((uchar*) ndb_schema_object, 0);
       break;
     }
-    mysql_mutex_init(INSTRUMENT_ME, &ndb_schema_object->mutex, MY_MUTEX_INIT_FAST);
+    mysql_mutex_init(key_ndb_schema_object_mutex, &ndb_schema_object->mutex, MY_MUTEX_INIT_FAST);
     bitmap_init(&ndb_schema_object->slock_bitmap, ndb_schema_object->slock,
                 sizeof(ndb_schema_object->slock)*8, FALSE);
     bitmap_clear_all(&ndb_schema_object->slock_bitmap);

=== modified file 'sql/ha_ndbcluster_binlog.h'
--- a/sql/ha_ndbcluster_binlog.h	2009-09-15 15:00:13 +0000
+++ b/sql/ha_ndbcluster_binlog.h	2009-09-25 13:18:54 +0000
@@ -103,6 +103,14 @@ private:
 };
 
 #ifdef HAVE_NDB_BINLOG
+
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_injector_mutex, key_ndb_schema_share_mutex,
+                     key_ndb_schema_object_mutex;
+extern PSI_cond_key key_injector_cond;
+extern PSI_thread_key key_thread_ndb_binlog;
+#endif /* HAVE_PSI_INTERFACE */
+
 extern pthread_t ndb_binlog_thread;
 extern mysql_mutex_t injector_mutex;
 extern mysql_cond_t  injector_cond;

=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc	2009-09-22 16:22:25 +0000
+++ b/sql/ha_partition.cc	2009-09-25 13:18:54 +0000
@@ -6486,7 +6486,7 @@ static PARTITION_SHARE *get_share(const
     if (my_hash_insert(&partition_open_tables, (uchar *) share))
       goto error;
     thr_lock_init(&share->lock);
-    mysql_mutex_init(&share->mutex, MY_MUTEX_INIT_FAST);
+    mysql_mutex_init(0, &share->mutex, MY_MUTEX_INIT_FAST);
   }
   share->use_count++;
   mysql_mutex_unlock(&partition_mutex);

=== modified file 'sql/hostname.cc'
--- a/sql/hostname.cc	2009-09-14 12:17:47 +0000
+++ b/sql/hostname.cc	2009-09-25 13:18:54 +0000
@@ -68,7 +68,8 @@ bool hostname_cache_init()
 				     &my_charset_bin)))
     return 1;
   hostname_cache->clear();
-  (void) mysql_mutex_init(INSTRUMENT_ME, &LOCK_hostname,MY_MUTEX_INIT_SLOW);
+  mysql_mutex_init(key_hostname_cache_LOCK_hostname,
+                   &LOCK_hostname, MY_MUTEX_INIT_SLOW);
   return 0;
 }
 

=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc	2009-09-22 16:22:25 +0000
+++ b/sql/item_func.cc	2009-09-25 13:18:54 +0000
@@ -3270,7 +3270,7 @@ public:
     :key_length(length),count(1),locked(1), thread_id(id)
   {
     key= (uchar*) my_memdup(key_arg,length,MYF(0));
-    mysql_cond_init(INSTRUMENT_ME, &cond, NULL);
+    mysql_cond_init(key_user_level_lock_cond, &cond, NULL);
     if (key)
     {
       if (my_hash_insert(&hash_user_locks,(uchar*) this))
@@ -3302,12 +3302,36 @@ uchar *ull_get_key(const User_level_lock
   return ull->key;
 }
 
+#ifdef HAVE_PSI_INTERFACE
+static PSI_mutex_key key_LOCK_user_locks;
+
+static PSI_mutex_info all_user_mutexes[]=
+{
+  { &key_LOCK_user_locks, "LOCK_user_locks", PSI_FLAG_GLOBAL}
+};
+
+static void init_user_lock_psi_keys(void)
+{
+  const char* category= "sql";
+  int count;
+
+  if (PSI_server == NULL)
+    return;
+
+  count= array_elements(all_user_mutexes);
+  PSI_server->register_mutex(category, all_user_mutexes, count);
+}
+#endif
 
 static bool item_user_lock_inited= 0;
 
 void item_user_lock_init(void)
 {
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_user_locks, MY_MUTEX_INIT_SLOW);
+#ifdef HAVE_PSI_INTERFACE
+  init_user_lock_psi_keys();
+#endif
+
+  mysql_mutex_init(key_LOCK_user_locks, &LOCK_user_locks, MY_MUTEX_INIT_SLOW);
   hash_init(&hash_user_locks,system_charset_info,
 	    16,0,0,(hash_get_key) ull_get_key,NULL,0);
   item_user_lock_inited= 1;
@@ -3739,7 +3763,7 @@ longlong Item_func_sleep::val_int()
     
   set_timespec_nsec(abstime, (ulonglong)(time * ULL(1000000000)));
 
-  mysql_cond_init(INSTRUMENT_ME, &cond, NULL);
+  mysql_cond_init(key_item_func_sleep_cond, &cond, NULL);
   mysql_mutex_lock(&LOCK_user_locks);
 
   thd_proc_info(thd, "User sleep");

=== modified file 'sql/log.cc'
--- a/sql/log.cc	2009-09-22 16:22:25 +0000
+++ b/sql/log.cc	2009-09-25 13:18:54 +0000
@@ -896,7 +896,7 @@ void LOGGER::init_base()
   init_error_log(LOG_FILE);
 
   file_log_handler->init_pthread_objects();
-  mysql_rwlock_init(INSTRUMENT_ME, &LOCK_logger);
+  mysql_rwlock_init(key_rwlock_LOCK_logger, &LOCK_logger);
 }
 
 
@@ -2002,7 +2002,7 @@ void MYSQL_LOG::init_pthread_objects()
 {
   DBUG_ASSERT(inited == 0);
   inited= 1;
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_log, MY_MUTEX_INIT_SLOW);
+  mysql_mutex_init(key_LOG_LOCK_log, &LOCK_log, MY_MUTEX_INIT_SLOW);
 }
 
 /*
@@ -2454,9 +2454,9 @@ void MYSQL_BIN_LOG::init_pthread_objects
 {
   DBUG_ASSERT(inited == 0);
   inited= 1;
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_log, MY_MUTEX_INIT_SLOW);
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_index, MY_MUTEX_INIT_SLOW);
-  mysql_cond_init(INSTRUMENT_ME, &update_cond, 0);
+  mysql_mutex_init(key_LOG_LOCK_log, &LOCK_log, MY_MUTEX_INIT_SLOW);
+  mysql_mutex_init(key_BINLOG_LOCK_index, &LOCK_index, MY_MUTEX_INIT_SLOW);
+  mysql_cond_init(key_BINLOG_update_cond, &update_cond, 0);
 }
 
 
@@ -5096,8 +5096,8 @@ int TC_LOG_MMAP::open(const char *opt_na
     pg->next=pg+1;
     pg->waiters=0;
     pg->state=POOL;
-    mysql_mutex_init(INSTRUMENT_ME, &pg->lock, MY_MUTEX_INIT_FAST);
-    mysql_cond_init(INSTRUMENT_ME, &pg->cond, 0);
+    mysql_mutex_init(key_PAGE_lock, &pg->lock, MY_MUTEX_INIT_FAST);
+    mysql_cond_init(key_PAGE_cond, &pg->cond, 0);
     pg->start=(my_xid *)(data + i*tc_log_page_size);
     pg->end=(my_xid *)(pg->start + tc_log_page_size);
     pg->size=pg->free=tc_log_page_size/sizeof(my_xid);
@@ -5116,11 +5116,11 @@ int TC_LOG_MMAP::open(const char *opt_na
   my_msync(fd, data, tc_log_page_size, MS_SYNC);
   inited=5;
 
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_sync, MY_MUTEX_INIT_FAST);
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_active, MY_MUTEX_INIT_FAST);
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_pool, MY_MUTEX_INIT_FAST);
-  mysql_cond_init(INSTRUMENT_ME, &COND_active, 0);
-  mysql_cond_init(INSTRUMENT_ME, &COND_pool, 0);
+  mysql_mutex_init(key_LOCK_sync, &LOCK_sync, MY_MUTEX_INIT_FAST);
+  mysql_mutex_init(key_LOCK_active, &LOCK_active, MY_MUTEX_INIT_FAST);
+  mysql_mutex_init(key_LOCK_pool, &LOCK_pool, MY_MUTEX_INIT_FAST);
+  mysql_cond_init(key_COND_active, &COND_active, 0);
+  mysql_cond_init(key_COND_pool, &COND_pool, 0);
 
   inited=6;
 
@@ -5495,8 +5495,9 @@ int TC_LOG_BINLOG::open(const char *opt_
   DBUG_ASSERT(total_ha_2pc > 1);
   DBUG_ASSERT(opt_name && opt_name[0]);
 
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_prep_xids, MY_MUTEX_INIT_FAST);
-  mysql_cond_init(INSTRUMENT_ME, &COND_prep_xids, 0);
+  mysql_mutex_init(key_BINLOG_LOCK_prep_xids,
+                   &LOCK_prep_xids, MY_MUTEX_INIT_FAST);
+  mysql_cond_init(key_BINLOG_COND_prep_xids, &COND_prep_xids, 0);
 
   if (!my_b_inited(&index_file))
   {

=== modified file 'sql/log.h'
--- a/sql/log.h	2009-09-15 15:00:13 +0000
+++ b/sql/log.h	2009-09-25 13:18:54 +0000
@@ -123,6 +123,10 @@ extern TC_LOG_DUMMY tc_log_dummy;
 
 class Relay_log_info;
 
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_LOG_INFO_lock;
+#endif
+
 typedef struct st_log_info
 {
   char log_file_name[FN_REFLEN];
@@ -135,7 +139,7 @@ typedef struct st_log_info
       pos(0), fatal(0)
     {
       log_file_name[0] = '\0';
-      mysql_mutex_init(INSTRUMENT_ME, &lock, MY_MUTEX_INIT_FAST);
+      mysql_mutex_init(key_LOG_INFO_lock, &lock, MY_MUTEX_INIT_FAST);
     }
   ~st_log_info() { mysql_mutex_destroy(&lock);}
 } LOG_INFO;

=== modified file 'sql/mysql_priv.h'
--- a/sql/mysql_priv.h	2009-09-23 08:41:25 +0000
+++ b/sql/mysql_priv.h	2009-09-25 13:18:54 +0000
@@ -2557,17 +2557,70 @@ extern "C" int test_if_data_home_dir(con
 
 #ifdef MYSQL_SERVER
 #ifdef HAVE_PSI_INTERFACE
-
-extern PSI_mutex_key key_hash_filo_lock;
-
-extern PSI_rwlock_key key_LOCK_grant;
-
-extern PSI_cond_key key_COND_server_started;
-
-extern PSI_thread_key key_thread_main;
+#ifdef HAVE_MMAP
+extern PSI_mutex_key key_PAGE_lock, key_LOCK_sync, key_LOCK_active,
+       key_LOCK_pool;
+#endif /* HAVE_MMAP */
+
+#ifdef HAVE_OPENSSL
+extern PSI_mutex_key key_LOCK_des_key_file;
+#endif
+
+extern PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_prep_xids,
+  key_delayed_insert_mutex, key_hash_filo_lock,
+  key_hostname_cache_LOCK_hostname, key_LOCK_active_mi,
+  key_LOCK_connection_count, key_LOCK_crypt, key_LOCK_delayed_create,
+  key_LOCK_delayed_insert, key_LOCK_delayed_status, key_LOCK_error_log,
+  key_LOCK_gdl, key_LOCK_global_read_lock, key_LOCK_global_system_variables,
+  key_LOCK_lock_db, key_LOCK_logger, key_LOCK_manager, key_LOCK_mapped_file,
+  key_LOCK_mysql_create_db, key_LOCK_open, key_LOCK_prepared_stmt_count,
+  key_LOCK_rpl_status, key_LOCK_server_started, key_LOCK_status,
+  key_LOCK_table_share, key_LOCK_thd_data,
+  key_LOCK_user_conn, key_LOCK_uuid_generator, key_LOG_LOCK_log,
+  key_master_info_data_lock, key_master_info_run_lock,
+  key_mutex_slave_reporting_capability_err_lock, key_relay_log_info_data_lock,
+  key_relay_log_info_log_space_lock, key_relay_log_info_run_lock,
+  key_structure_guard_mutex, key_TABLE_SHARE_mutex;
+
+extern PSI_rwlock_key key_rwlock_LOCK_grant, key_rwlock_LOCK_logger,
+  key_rwlock_LOCK_sys_init_connect, key_rwlock_LOCK_sys_init_slave,
+  key_rwlock_LOCK_system_variables_hash, key_rwlock_query_cache_query_lock;
+
+#ifdef HAVE_MMAP
+extern PSI_cond_key key_PAGE_cond, key_COND_active, key_COND_pool;
+#endif /* HAVE_MMAP */
+
+extern PSI_cond_key key_BINLOG_COND_prep_xids, key_BINLOG_update_cond,
+  key_COND_cache_status_changed, key_COND_global_read_lock, key_COND_manager,
+  key_COND_refresh, key_COND_rpl_status, key_COND_server_started,
+  key_delayed_insert_cond, key_delayed_insert_cond_client,
+  key_item_func_sleep_cond, key_master_info_data_cond,
+  key_master_info_start_cond, key_master_info_stop_cond,
+  key_relay_log_info_data_cond, key_relay_log_info_log_space_cond,
+  key_relay_log_info_start_cond, key_relay_log_info_stop_cond,
+  key_TABLE_SHARE_cond, key_user_level_lock_cond;
+
+#ifdef __NT__
+extern PSI_thread_key key_thread_handle_con_namedpipes;
+#endif /* __NT__ */
+
+#ifdef HAVE_SMEM
+extern PSI_thread_key key_thread_handle_con_sharedmem;
+#endif /* HAVE_SMEM */
+
+#if (defined(__NT__) || defined(HAVE_SMEM))
+extern PSI_thread_key key_thread_handle_con_sockets;
+#endif /* __NT__ || HAVE_SMEM */
+
+#ifdef __WIN__
+extern PSI_thread_key key_thread_handle_shutdown;
+#endif /* __WIN__ */
+
+extern PSI_thread_key key_thread_bootstrap, key_thread_delayed_insert,
+  key_thread_handle_manager, key_thread_kill_server, key_thread_main,
+  key_thread_one_connection, key_thread_signal_hand;
 
 void init_server_psi_keys();
-
 #endif /* HAVE_PSI_INTERFACE */
 #endif /* MYSQL_SERVER */
 

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2009-09-23 08:41:25 +0000
+++ b/sql/mysqld.cc	2009-09-25 13:18:54 +0000
@@ -1123,7 +1123,7 @@ void kill_mysql(void)
   {
     pthread_t tmp;
     abort_loop=1;
-    if (mysql_thread_create(INSTRUMENT_ME,
+    if (mysql_thread_create(key_thread_kill_server,
                             &tmp, &connection_attrib, kill_server_thread,
                             (void*) 0))
       sql_print_error("Can't create thread to kill server");
@@ -2709,7 +2709,7 @@ static void start_signal_handler(void)
 #endif
 
   pthread_mutex_lock(&LOCK_thread_count);
-  if ((error= mysql_thread_create(INSTRUMENT_ME,
+  if ((error= mysql_thread_create(key_thread_signal_hand,
                                   &signal_thread, &thr_attr, signal_hand, 0)))
   {
     sql_print_error("Can't create interrupt-thread (error %d, errno: %d)",
@@ -2817,7 +2817,7 @@ pthread_handler_t signal_hand(void *arg
 	pthread_t tmp;
 	if (!(opt_specialflag & SPECIAL_NO_PRIOR))
 	  my_pthread_attr_setprio(&connection_attrib,INTERRUPT_PRIOR);
-	if (mysql_thread_create(INSTRUMENT_ME,
+	if (mysql_thread_create(key_thread_kill_server,
                                 &tmp, &connection_attrib, kill_server_thread,
                                 (void*) &sig))
 	  sql_print_error("Can't create thread to kill server");
@@ -3624,28 +3624,40 @@ You should consider changing lower_case_
 
 static int init_thread_environment()
 {
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_mysql_create_db,MY_MUTEX_INIT_SLOW);
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_lock_db,MY_MUTEX_INIT_SLOW);
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_open, MY_MUTEX_INIT_FAST);
+  mysql_mutex_init(key_LOCK_mysql_create_db,
+                   &LOCK_mysql_create_db,MY_MUTEX_INIT_SLOW);
+  mysql_mutex_init(key_LOCK_lock_db, &LOCK_lock_db,MY_MUTEX_INIT_SLOW);
+  mysql_mutex_init(key_LOCK_open, &LOCK_open, MY_MUTEX_INIT_FAST);
   pthread_mutex_init(&LOCK_thread_count,MY_MUTEX_INIT_FAST);
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_mapped_file,MY_MUTEX_INIT_SLOW);
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_status,MY_MUTEX_INIT_FAST);
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_error_log,MY_MUTEX_INIT_FAST);
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_delayed_insert,MY_MUTEX_INIT_FAST);
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_delayed_status,MY_MUTEX_INIT_FAST);
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_delayed_create,MY_MUTEX_INIT_SLOW);
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_manager,MY_MUTEX_INIT_FAST);
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_crypt,MY_MUTEX_INIT_FAST);
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_user_conn, MY_MUTEX_INIT_FAST);
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_active_mi, MY_MUTEX_INIT_FAST);
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_global_system_variables, MY_MUTEX_INIT_FAST);
-  mysql_rwlock_init(INSTRUMENT_ME, &LOCK_system_variables_hash);
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_global_read_lock, MY_MUTEX_INIT_FAST);
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_prepared_stmt_count, MY_MUTEX_INIT_FAST);
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_uuid_generator, MY_MUTEX_INIT_FAST);
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_connection_count, MY_MUTEX_INIT_FAST);
+  mysql_mutex_init(key_LOCK_mapped_file, &LOCK_mapped_file,MY_MUTEX_INIT_SLOW);
+  mysql_mutex_init(key_LOCK_status, &LOCK_status,MY_MUTEX_INIT_FAST);
+  mysql_mutex_init(key_LOCK_error_log, &LOCK_error_log,MY_MUTEX_INIT_FAST);
+  mysql_mutex_init(key_LOCK_delayed_insert,
+                   &LOCK_delayed_insert,MY_MUTEX_INIT_FAST);
+  mysql_mutex_init(key_LOCK_delayed_status,
+                   &LOCK_delayed_status,MY_MUTEX_INIT_FAST);
+  mysql_mutex_init(key_LOCK_delayed_create,
+                   &LOCK_delayed_create,MY_MUTEX_INIT_SLOW);
+  mysql_mutex_init(key_LOCK_manager,
+                   &LOCK_manager,MY_MUTEX_INIT_FAST);
+  mysql_mutex_init(key_LOCK_crypt, &LOCK_crypt, MY_MUTEX_INIT_FAST);
+  mysql_mutex_init(key_LOCK_user_conn, &LOCK_user_conn, MY_MUTEX_INIT_FAST);
+  mysql_mutex_init(key_LOCK_active_mi, &LOCK_active_mi, MY_MUTEX_INIT_FAST);
+  mysql_mutex_init(key_LOCK_global_system_variables,
+                   &LOCK_global_system_variables, MY_MUTEX_INIT_FAST);
+  mysql_rwlock_init(key_rwlock_LOCK_system_variables_hash,
+                    &LOCK_system_variables_hash);
+  mysql_mutex_init(key_LOCK_global_read_lock,
+                   &LOCK_global_read_lock, MY_MUTEX_INIT_FAST);
+  mysql_mutex_init(key_LOCK_prepared_stmt_count,
+                   &LOCK_prepared_stmt_count, MY_MUTEX_INIT_FAST);
+  mysql_mutex_init(key_LOCK_uuid_generator,
+                   &LOCK_uuid_generator, MY_MUTEX_INIT_FAST);
+  mysql_mutex_init(key_LOCK_connection_count,
+                   &LOCK_connection_count, MY_MUTEX_INIT_FAST);
 #ifdef HAVE_OPENSSL
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_des_key_file, MY_MUTEX_INIT_FAST);
+  mysql_mutex_init(key_LOCK_des_key_file,
+                   &LOCK_des_key_file, MY_MUTEX_INIT_FAST);
 #ifndef HAVE_YASSL
   openssl_stdlocks= (openssl_lock_t*) OPENSSL_malloc(CRYPTO_num_locks() *
                                                      sizeof(openssl_lock_t));
@@ -3658,21 +3670,22 @@ static int init_thread_environment()
   CRYPTO_set_id_callback(openssl_id_function);
 #endif
 #endif
-  mysql_rwlock_init(INSTRUMENT_ME, &LOCK_sys_init_connect);
-  mysql_rwlock_init(INSTRUMENT_ME, &LOCK_sys_init_slave);
-  mysql_rwlock_init(key_LOCK_grant, &LOCK_grant);
+  mysql_rwlock_init(key_rwlock_LOCK_sys_init_connect, &LOCK_sys_init_connect);
+  mysql_rwlock_init(key_rwlock_LOCK_sys_init_slave, &LOCK_sys_init_slave);
+  mysql_rwlock_init(key_rwlock_LOCK_grant, &LOCK_grant);
   pthread_cond_init(&COND_thread_count, NULL);
-  mysql_cond_init(INSTRUMENT_ME, &COND_refresh, NULL);
-  mysql_cond_init(INSTRUMENT_ME, &COND_global_read_lock, NULL);
+  mysql_cond_init(key_COND_refresh, &COND_refresh, NULL);
+  mysql_cond_init(key_COND_global_read_lock, &COND_global_read_lock, NULL);
   pthread_cond_init(&COND_thread_cache, NULL);
   pthread_cond_init(&COND_flush_thread_cache, NULL);
-  mysql_cond_init(INSTRUMENT_ME, &COND_manager, NULL);
+  mysql_cond_init(key_COND_manager, &COND_manager, NULL);
 #ifdef HAVE_REPLICATION
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_rpl_status, MY_MUTEX_INIT_FAST);
-  mysql_cond_init(INSTRUMENT_ME, &COND_rpl_status, NULL);
+  mysql_mutex_init(key_LOCK_rpl_status, &LOCK_rpl_status, MY_MUTEX_INIT_FAST);
+  mysql_cond_init(key_COND_rpl_status, &COND_rpl_status, NULL);
 #endif
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_server_started, MY_MUTEX_INIT_FAST);
-  mysql_cond_init(INSTRUMENT_ME, &COND_server_started, NULL);
+  mysql_mutex_init(key_LOCK_server_started,
+                   &LOCK_server_started, MY_MUTEX_INIT_FAST);
+  mysql_cond_init(key_COND_server_started, &COND_server_started, NULL);
   sp_cache_init();
 #ifdef HAVE_EVENT_SCHEDULER
   Events::init_mutexes();
@@ -4205,7 +4218,7 @@ static void create_shutdown_thread()
 #ifdef __WIN__
   hEventShutdown=CreateEvent(0, FALSE, FALSE, shutdown_event_name);
   pthread_t hThread;
-  if (mysql_thread_create(INSTRUMENT_ME,
+  if (mysql_thread_create(key_thread_handle_shutdown,
                           &hThread, &connection_attrib, handle_shutdown, 0))
     sql_print_warning("Can't create thread to handle shutdown requests");
 
@@ -4239,7 +4252,8 @@ static void handle_connections_methods()
   if (hPipe != INVALID_HANDLE_VALUE)
   {
     handler_count++;
-    if (mysql_thread_create(INSTRUMENT_ME, &hThread, &connection_attrib,
+    if (mysql_thread_create(key_thread_handle_con_namedpipes,
+                            &hThread, &connection_attrib,
 		            handle_connections_namedpipes, 0))
     {
       sql_print_warning("Can't create thread to handle named pipes");
@@ -4250,7 +4264,7 @@ static void handle_connections_methods()
   if (have_tcpip && !opt_disable_networking)
   {
     handler_count++;
-    if (mysql_thread_create(INSTRUMENT_ME,
+    if (mysql_thread_create(key_thread_handle_con_sockets,
                             &hThread, &connection_attrib,
                             handle_connections_sockets, 0))
     {
@@ -4262,7 +4276,7 @@ static void handle_connections_methods()
   if (opt_enable_shared_memory)
   {
     handler_count++;
-    if (mysql_thread_create(INSTRUMENT_ME,
+    if (mysql_thread_create(key_thread_handle_con_sharedmem,
                             &hThread, &connection_attrib,
                             handle_connections_shared_memory, 0))
     {
@@ -4981,7 +4995,7 @@ static void bootstrap(FILE *file)
 
   bootstrap_file=file;
 #ifndef EMBEDDED_LIBRARY			// TODO:  Enable this
-  if (mysql_thread_create(INSTRUMENT_ME,
+  if (mysql_thread_create(key_thread_bootstrap,
                           &thd->real_id, &connection_attrib, handle_bootstrap,
                           (void*) thd))
   {
@@ -5064,7 +5078,7 @@ void create_thread_to_handle_connection(
     threads.append(thd);
     DBUG_PRINT("info",(("creating thread %lu"), thd->thread_id));
     thd->prior_thr_create_utime= thd->start_utime= my_micro_time();
-    if ((error= mysql_thread_create(INSTRUMENT_ME,
+    if ((error= mysql_thread_create(key_thread_one_connection,
                                     &thd->real_id, &connection_attrib,
                                     handle_one_connection,
                                     (void*) thd)))
@@ -9207,33 +9221,186 @@ template class I_List_iterator<Statement
 #endif
 
 #ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_MMAP
+PSI_mutex_key key_PAGE_lock, key_LOCK_sync, key_LOCK_active, key_LOCK_pool;
+#endif /* HAVE_MMAP */
+
+#ifdef HAVE_OPENSSL
+PSI_mutex_key key_LOCK_des_key_file;
+#endif /* HAVE_OPENSSL */
 
-PSI_mutex_key key_hash_filo_lock;
+PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_prep_xids,
+  key_delayed_insert_mutex, key_hash_filo_lock,
+  key_hostname_cache_LOCK_hostname, key_LOCK_active_mi,
+  key_LOCK_connection_count, key_LOCK_crypt, key_LOCK_delayed_create,
+  key_LOCK_delayed_insert, key_LOCK_delayed_status, key_LOCK_error_log,
+  key_LOCK_gdl, key_LOCK_global_read_lock, key_LOCK_global_system_variables,
+  key_LOCK_lock_db, key_LOCK_manager, key_LOCK_mapped_file,
+  key_LOCK_mysql_create_db, key_LOCK_open, key_LOCK_prepared_stmt_count,
+  key_LOCK_rpl_status, key_LOCK_server_started, key_LOCK_status,
+  key_LOCK_system_variables_hash, key_LOCK_table_share, key_LOCK_thd_data,
+  key_LOCK_user_conn, key_LOCK_uuid_generator, key_LOG_LOCK_log,
+  key_master_info_data_lock, key_master_info_run_lock,
+  key_mutex_slave_reporting_capability_err_lock, key_relay_log_info_data_lock,
+  key_relay_log_info_log_space_lock, key_relay_log_info_run_lock,
+  key_structure_guard_mutex, key_TABLE_SHARE_mutex, key_LOG_INFO_lock;
 
 static PSI_mutex_info all_server_mutexes[]=
 {
-  { & key_hash_filo_lock, "hash_filo::lock", 0}
+#ifdef HAVE_MMAP
+  { &key_PAGE_lock, "PAGE::lock", 0},
+  { &key_LOCK_sync, "TC_LOG_MMAP::LOCK_sync", 0},
+  { &key_LOCK_active, "TC_LOG_MMAP::LOCK_active", 0},
+  { &key_LOCK_pool, "TC_LOG_MMAP::LOCK_pool", 0},
+#endif /* HAVE_MMAP */
+
+#ifdef HAVE_OPENSSL
+  { &key_LOCK_des_key_file, "LOCK_des_key_file", PSI_FLAG_GLOBAL},
+#endif /* HAVE_OPENSSL */
+
+  { &key_BINLOG_LOCK_index, "MYSQL_BIN_LOG::LOCK_index", 0},
+  { &key_BINLOG_LOCK_prep_xids, "MYSQL_BIN_LOG::LOCK_prep_xids", 0},
+  { &key_delayed_insert_mutex, "Delayed_insert::mutex", 0},
+  { &key_hash_filo_lock, "hash_filo::lock", 0},
+  { &key_hostname_cache_LOCK_hostname, "LOCK_hostname", 0},
+  { &key_LOCK_active_mi, "LOCK_active_mi", PSI_FLAG_GLOBAL},
+  { &key_LOCK_connection_count, "LOCK_connection_count", PSI_FLAG_GLOBAL},
+  { &key_LOCK_crypt, "LOCK_crypt", PSI_FLAG_GLOBAL},
+  { &key_LOCK_delayed_create, "LOCK_delayed_create", PSI_FLAG_GLOBAL},
+  { &key_LOCK_delayed_insert, "LOCK_delayed_insert", PSI_FLAG_GLOBAL},
+  { &key_LOCK_delayed_status, "LOCK_delayed_status", PSI_FLAG_GLOBAL},
+  { &key_LOCK_error_log, "LOCK_error_log", PSI_FLAG_GLOBAL},
+  { &key_LOCK_gdl, "LOCK_gdl", PSI_FLAG_GLOBAL},
+  { &key_LOCK_global_read_lock, "LOCK_global_read_lock", PSI_FLAG_GLOBAL},
+  { &key_LOCK_global_system_variables, "LOCK_global_system_variables", PSI_FLAG_GLOBAL},
+  { &key_LOCK_lock_db, "LOCK_lock_db", PSI_FLAG_GLOBAL},
+  { &key_LOCK_manager, "LOCK_manager", PSI_FLAG_GLOBAL},
+  { &key_LOCK_mapped_file, "LOCK_mapped_file", PSI_FLAG_GLOBAL},
+  { &key_LOCK_mysql_create_db, "LOCK_mysql_create_db", PSI_FLAG_GLOBAL},
+  { &key_LOCK_open, "LOCK_open", PSI_FLAG_GLOBAL},
+  { &key_LOCK_prepared_stmt_count, "LOCK_prepared_stmt_count", PSI_FLAG_GLOBAL},
+  { &key_LOCK_rpl_status, "LOCK_rpl_status", PSI_FLAG_GLOBAL},
+  { &key_LOCK_server_started, "LOCK_server_started", PSI_FLAG_GLOBAL},
+  { &key_LOCK_status, "LOCK_status", PSI_FLAG_GLOBAL},
+  { &key_LOCK_system_variables_hash, "LOCK_system_variables_hash", PSI_FLAG_GLOBAL},
+  { &key_LOCK_table_share, "LOCK_table_share", PSI_FLAG_GLOBAL},
+  { &key_LOCK_thd_data, "THD::LOCK_thd_data", 0},
+  { &key_LOCK_user_conn, "LOCK_user_conn", PSI_FLAG_GLOBAL},
+  { &key_LOCK_uuid_generator, "LOCK_uuid_generator", PSI_FLAG_GLOBAL},
+  { &key_LOG_LOCK_log, "LOG::LOCK_log", 0},
+  { &key_master_info_data_lock, "Master_info::data_lock", 0},
+  { &key_master_info_run_lock, "Master_info::run_lock", 0},
+  { &key_mutex_slave_reporting_capability_err_lock, "Slave_reporting_capability::err_lock", 0},
+  { &key_relay_log_info_data_lock, "Relay_log_info::data_lock", 0},
+  { &key_relay_log_info_log_space_lock, "Relay_log_info::log_space_lock", 0},
+  { &key_relay_log_info_run_lock, "Relay_log_info::run_lock", 0},
+  { &key_structure_guard_mutex, "Query_cache::structure_guard_mutex", 0},
+  { &key_TABLE_SHARE_mutex, "TABLE_SHARE::mutex", 0},
+  { &key_LOG_INFO_lock, "LOG_INFO::lock", 0}
 };
 
-PSI_rwlock_key key_LOCK_grant;
+PSI_rwlock_key key_rwlock_LOCK_grant, key_rwlock_LOCK_logger,
+  key_rwlock_LOCK_sys_init_connect, key_rwlock_LOCK_sys_init_slave,
+  key_rwlock_LOCK_system_variables_hash, key_rwlock_query_cache_query_lock;
 
 static PSI_rwlock_info all_server_rwlocks[]=
 {
-  { & key_LOCK_grant, "LOCK_grant", PSI_FLAG_GLOBAL}
+  { &key_rwlock_LOCK_grant, "LOCK_grant", PSI_FLAG_GLOBAL},
+  { &key_rwlock_LOCK_logger, "LOGGER::LOCK_logger", 0},
+  { &key_rwlock_LOCK_sys_init_connect, "LOCK_sys_init_connect", PSI_FLAG_GLOBAL},
+  { &key_rwlock_LOCK_sys_init_slave, "LOCK_sys_init_slave", PSI_FLAG_GLOBAL},
+  { &key_rwlock_LOCK_system_variables_hash, "LOCK_system_variables_hash", PSI_FLAG_GLOBAL},
+  { &key_rwlock_query_cache_query_lock, "Query_cache_query::lock", 0}
 };
 
-PSI_cond_key key_COND_server_started;
+#ifdef HAVE_MMAP
+PSI_cond_key key_PAGE_cond, key_COND_active, key_COND_pool;
+#endif /* HAVE_MMAP */
+
+PSI_cond_key key_BINLOG_COND_prep_xids, key_BINLOG_update_cond,
+  key_COND_cache_status_changed, key_COND_global_read_lock, key_COND_manager,
+  key_COND_refresh, key_COND_rpl_status, key_COND_server_started,
+  key_delayed_insert_cond, key_delayed_insert_cond_client,
+  key_item_func_sleep_cond, key_master_info_data_cond,
+  key_master_info_start_cond, key_master_info_stop_cond,
+  key_relay_log_info_data_cond, key_relay_log_info_log_space_cond,
+  key_relay_log_info_start_cond, key_relay_log_info_stop_cond,
+  key_TABLE_SHARE_cond, key_user_level_lock_cond;
 
 static PSI_cond_info all_server_conds[]=
 {
-  { & key_COND_server_started, "COND_server_started", PSI_FLAG_GLOBAL}
+#ifdef HAVE_MMAP
+  { &key_PAGE_cond, "PAGE::cond", 0},
+  { &key_COND_active, "TC_LOG_MMAP::COND_active", 0},
+  { &key_COND_pool, "TC_LOG_MMAP::COND_pool", 0},
+#endif /* HAVE_MMAP */
+  { &key_BINLOG_COND_prep_xids, "MYSQL_BIN_LOG::COND_prep_xids", 0},
+  { &key_BINLOG_update_cond, "MYSQL_BIN_LOG::update_cond", 0},
+  { &key_COND_cache_status_changed, "Query_cache::COND_cache_status_changed", 0},
+  { &key_COND_global_read_lock, "COND_global_read_lock", PSI_FLAG_GLOBAL},
+  { &key_COND_manager, "COND_manager", PSI_FLAG_GLOBAL},
+  { &key_COND_refresh, "COND_refresh", PSI_FLAG_GLOBAL},
+  { &key_COND_rpl_status, "COND_rpl_status", PSI_FLAG_GLOBAL},
+  { &key_COND_server_started, "COND_server_started", PSI_FLAG_GLOBAL},
+  { &key_delayed_insert_cond, "Delayed_insert::cond", 0},
+  { &key_delayed_insert_cond_client, "Delayed_insert::cond_client", 0},
+  { &key_item_func_sleep_cond, "Item_func_sleep::cond", 0},
+  { &key_master_info_data_cond, "Master_info::data_cond", 0},
+  { &key_master_info_start_cond, "Master_info::start_cond", 0},
+  { &key_master_info_stop_cond, "Master_info::stop_cond", 0},
+  { &key_relay_log_info_data_cond, "Relay_log_info::data_cond", 0},
+  { &key_relay_log_info_log_space_cond, "Relay_log_info::log_space_cond", 0},
+  { &key_relay_log_info_start_cond, "Relay_log_info::start_cond", 0},
+  { &key_relay_log_info_stop_cond, "Relay_log_info::stop_cond", 0},
+  { &key_TABLE_SHARE_cond, "TABLE_SHARE::cond", 0},
+  { &key_user_level_lock_cond, "User_level_lock::cond", 0}
 };
 
-PSI_thread_key key_thread_main;
+#ifdef __NT__
+PSI_thread_key key_thread_handle_con_namedpipes;
+#endif /* __NT__ */
+
+#ifdef HAVE_SMEM
+PSI_thread_key key_thread_handle_con_sharedmem;
+#endif /* HAVE_SMEM */
+
+#if (defined(__NT__) || defined(HAVE_SMEM))
+PSI_thread_key key_thread_handle_con_sockets;
+#endif /* __NT__ || HAVE_SMEM */
+
+#ifdef __WIN__
+PSI_thread_key key_thread_handle_shutdown;
+#endif /* __WIN__ */
+
+PSI_thread_key key_thread_bootstrap, key_thread_delayed_insert,
+  key_thread_handle_manager, key_thread_kill_server, key_thread_main,
+  key_thread_one_connection, key_thread_signal_hand;
 
 static PSI_thread_info all_server_threads[]=
 {
-  { & key_thread_main, "Main", PSI_FLAG_GLOBAL}
+#ifdef __NT__
+  { &key_thread_handle_con_namedpipes, "con_named_pipes", PSI_FLAG_GLOBAL},
+#endif /* __NT__ */
+
+#ifdef HAVE_SMEM
+  { &key_thread_handle_con_sharedmem, "con_shared_mem", PSI_FLAG_GLOBAL},
+#endif /* HAVE_SMEM */
+
+#if (defined(__NT__) || defined(HAVE_SMEM))
+  { &key_thread_handle_con_sockets, "con_sockets", PSI_FLAG_GLOBAL},
+#endif /* __NT__ || HAVE_SMEM */
+
+#ifdef __WIN__
+  { &key_thread_handle_shutdown, "shutdown", PSI_FLAG_GLOBAL},
+#endif /* __WIN__ */
+
+  { &key_thread_bootstrap, "bootstrap", PSI_FLAG_GLOBAL},
+  { &key_thread_delayed_insert, "delayed_insert", 0},
+  { &key_thread_handle_manager, "manager", PSI_FLAG_GLOBAL},
+  { &key_thread_kill_server, "kill_server", PSI_FLAG_GLOBAL},
+  { &key_thread_main, "main", PSI_FLAG_GLOBAL},
+  { &key_thread_one_connection, "one_connection", 0},
+  { &key_thread_signal_hand, "signal_handler", PSI_FLAG_GLOBAL}
 };
 
 

=== modified file 'sql/repl_failsafe.cc'
--- a/sql/repl_failsafe.cc	2009-09-21 09:32:33 +0000
+++ b/sql/repl_failsafe.cc	2009-09-25 13:18:54 +0000
@@ -219,11 +219,36 @@ extern "C" void slave_info_free(void *s)
   my_free(s, MYF(MY_WME));
 }
 
+#ifdef HAVE_PSI_INTERFACE
+static PSI_mutex_key key_LOCK_slave_list;
+
+static PSI_mutex_info all_slave_list_mutexes[]=
+{
+  { &key_LOCK_slave_list, "LOCK_slave_list", PSI_FLAG_GLOBAL}
+};
+
+static void init_all_slave_list_mutexes(void)
+{
+  const char* category= "sql";
+  int count;
+
+  if (PSI_server == NULL)
+    return;
+
+  count= array_elements(all_slave_list_mutexes);
+  PSI_server->register_mutex(category, all_slave_list_mutexes, count);
+}
+#endif /* HAVE_PSI_INTERFACE */
+
 void init_slave_list()
 {
+#ifdef HAVE_PSI_INTERFACE
+  init_all_slave_list_mutexes();
+#endif
+
   hash_init(&slave_list, system_charset_info, SLAVE_LIST_CHUNK, 0, 0,
 	    (hash_get_key) slave_list_key, (hash_free_key) slave_info_free, 0);
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_slave_list, MY_MUTEX_INIT_FAST);
+  mysql_mutex_init(key_LOCK_slave_list, &LOCK_slave_list, MY_MUTEX_INIT_FAST);
 }
 
 void end_slave_list()

=== modified file 'sql/rpl_mi.cc'
--- a/sql/rpl_mi.cc	2009-09-14 12:17:47 +0000
+++ b/sql/rpl_mi.cc	2009-09-25 13:18:54 +0000
@@ -38,11 +38,11 @@ Master_info::Master_info()
   ssl_cipher[0]= 0; ssl_key[0]= 0;
 
   bzero((char*) &file, sizeof(file));
-  mysql_mutex_init(INSTRUMENT_ME, &run_lock, MY_MUTEX_INIT_FAST);
-  mysql_mutex_init(INSTRUMENT_ME, &data_lock, MY_MUTEX_INIT_FAST);
-  mysql_cond_init(INSTRUMENT_ME, &data_cond, NULL);
-  mysql_cond_init(INSTRUMENT_ME, &start_cond, NULL);
-  mysql_cond_init(INSTRUMENT_ME, &stop_cond, NULL);
+  mysql_mutex_init(key_master_info_run_lock, &run_lock, MY_MUTEX_INIT_FAST);
+  mysql_mutex_init(key_master_info_data_lock, &data_lock, MY_MUTEX_INIT_FAST);
+  mysql_cond_init(key_master_info_data_cond, &data_cond, NULL);
+  mysql_cond_init(key_master_info_start_cond, &start_cond, NULL);
+  mysql_cond_init(key_master_info_stop_cond, &stop_cond, NULL);
 }
 
 Master_info::~Master_info()

=== modified file 'sql/rpl_reporting.cc'
--- a/sql/rpl_reporting.cc	2009-09-14 12:17:47 +0000
+++ b/sql/rpl_reporting.cc	2009-09-25 13:18:54 +0000
@@ -2,6 +2,13 @@
 #include "mysql_priv.h"
 #include "rpl_reporting.h"
 
+Slave_reporting_capability::Slave_reporting_capability(char const *thread_name)
+  : m_thread_name(thread_name)
+{
+  mysql_mutex_init(key_mutex_slave_reporting_capability_err_lock,
+                   &err_lock, MY_MUTEX_INIT_FAST);
+}
+
 void
 Slave_reporting_capability::report(loglevel level, int err_code,
                                    const char *msg, ...) const

=== modified file 'sql/rpl_reporting.h'
--- a/sql/rpl_reporting.h	2009-09-14 12:17:47 +0000
+++ b/sql/rpl_reporting.h	2009-09-25 13:18:54 +0000
@@ -23,11 +23,7 @@ public:
 
      @param thread_name Printable name of the slave thread that is reporting.
    */
-  Slave_reporting_capability(char const *thread_name)
-    : m_thread_name(thread_name)
-  {
-    mysql_mutex_init(INSTRUMENT_ME, &err_lock, MY_MUTEX_INIT_FAST);
-  }
+  Slave_reporting_capability(char const *thread_name);
 
   /**
      Writes a message and, if it's an error message, to Last_Error

=== modified file 'sql/rpl_rli.cc'
--- a/sql/rpl_rli.cc	2009-09-14 12:17:47 +0000
+++ b/sql/rpl_rli.cc	2009-09-25 13:18:54 +0000
@@ -53,13 +53,15 @@ Relay_log_info::Relay_log_info()
   bzero((char*) &info_file, sizeof(info_file));
   bzero((char*) &cache_buf, sizeof(cache_buf));
   cached_charset_invalidate();
-  mysql_mutex_init(INSTRUMENT_ME, &run_lock, MY_MUTEX_INIT_FAST);
-  mysql_mutex_init(INSTRUMENT_ME, &data_lock, MY_MUTEX_INIT_FAST);
-  mysql_mutex_init(INSTRUMENT_ME, &log_space_lock, MY_MUTEX_INIT_FAST);
-  mysql_cond_init(INSTRUMENT_ME, &data_cond, NULL);
-  mysql_cond_init(INSTRUMENT_ME, &start_cond, NULL);
-  mysql_cond_init(INSTRUMENT_ME, &stop_cond, NULL);
-  mysql_cond_init(INSTRUMENT_ME, &log_space_cond, NULL);
+  mysql_mutex_init(key_relay_log_info_run_lock, &run_lock, MY_MUTEX_INIT_FAST);
+  mysql_mutex_init(key_relay_log_info_data_lock,
+                   &data_lock, MY_MUTEX_INIT_FAST);
+  mysql_mutex_init(key_relay_log_info_log_space_lock,
+                   &log_space_lock, MY_MUTEX_INIT_FAST);
+  mysql_cond_init(key_relay_log_info_data_cond, &data_cond, NULL);
+  mysql_cond_init(key_relay_log_info_start_cond, &start_cond, NULL);
+  mysql_cond_init(key_relay_log_info_stop_cond, &stop_cond, NULL);
+  mysql_cond_init(key_relay_log_info_log_space_cond, &log_space_cond, NULL);
   relay_log.init_pthread_objects();
   DBUG_VOID_RETURN;
 }

=== modified file 'sql/sp_cache.cc'
--- a/sql/sp_cache.cc	2009-09-14 12:17:47 +0000
+++ b/sql/sp_cache.cc	2009-09-25 13:18:54 +0000
@@ -74,12 +74,36 @@ private:
   HASH m_hashtable;
 }; // class sp_cache
 
+#ifdef HAVE_PSI_INTERFACE
+static PSI_mutex_key key_Cversion_lock;
+
+static PSI_mutex_info all_sp_cache_mutexes[]=
+{
+  { &key_Cversion_lock, "Cversion_lock", PSI_FLAG_GLOBAL}
+};
+
+static void init_sp_cache_psi_keys(void)
+{
+  const char* category= "sql";
+  int count;
+
+  if (PSI_server == NULL)
+    return;
+
+  count= array_elements(all_sp_cache_mutexes);
+  PSI_server->register_mutex(category, all_sp_cache_mutexes, count);
+}
+#endif
 
 /* Initialize the SP caching once at startup */
 
 void sp_cache_init()
 {
-  mysql_mutex_init(INSTRUMENT_ME, &Cversion_lock, MY_MUTEX_INIT_FAST);
+#ifdef HAVE_PSI_INTERFACE
+  init_sp_cache_psi_keys();
+#endif
+
+  mysql_mutex_init(key_Cversion_lock, &Cversion_lock, MY_MUTEX_INIT_FAST);
 }
 
 

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2009-09-22 16:22:25 +0000
+++ b/sql/sql_base.cc	2009-09-25 13:18:54 +0000
@@ -276,7 +276,7 @@ static void table_def_free_entry(TABLE_S
 bool table_def_init(void)
 {
   table_def_inited= 1;
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_table_share, MY_MUTEX_INIT_FAST);
+  mysql_mutex_init(key_LOCK_table_share, &LOCK_table_share, MY_MUTEX_INIT_FAST);
   oldest_unused_share= &end_of_unused_share;
   end_of_unused_share.prev= &oldest_unused_share;
 

=== modified file 'sql/sql_cache.cc'
--- a/sql/sql_cache.cc	2009-09-15 15:00:13 +0000
+++ b/sql/sql_cache.cc	2009-09-25 13:18:54 +0000
@@ -737,7 +737,7 @@ void Query_cache_query::init_n_lock()
 {
   DBUG_ENTER("Query_cache_query::init_n_lock");
   res=0; wri = 0; len = 0;
-  mysql_rwlock_init(INSTRUMENT_ME, &lock);
+  mysql_rwlock_init(key_rwlock_query_cache_query_lock, &lock);
   lock_writing();
   DBUG_PRINT("qcache", ("inited & locked query for block 0x%lx",
 			(long) (((uchar*) this) -
@@ -1925,8 +1925,10 @@ void Query_cache::destroy()
 void Query_cache::init()
 {
   DBUG_ENTER("Query_cache::init");
-  mysql_mutex_init(INSTRUMENT_ME, &structure_guard_mutex, MY_MUTEX_INIT_FAST);
-  mysql_cond_init(INSTRUMENT_ME, &COND_cache_status_changed, NULL);
+  mysql_mutex_init(key_structure_guard_mutex,
+                   &structure_guard_mutex, MY_MUTEX_INIT_FAST);
+  mysql_cond_init(key_COND_cache_status_changed,
+                  &COND_cache_status_changed, NULL);
   m_cache_lock_status= Query_cache::UNLOCKED;
   initialized = 1;
   DBUG_VOID_RETURN;
@@ -3761,7 +3763,7 @@ my_bool Query_cache::move_by_type(uchar
       } while ( result_block != first_result_block );
     }
     Query_cache_query *new_query= ((Query_cache_query *) new_block->data());
-    mysql_rwlock_init(INSTRUMENT_ME, &new_query->lock);
+    mysql_rwlock_init(key_rwlock_query_cache_query_lock, &new_query->lock);
 
     /* 
       If someone is writing to this block, inform the writer that the block

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2009-09-22 16:22:25 +0000
+++ b/sql/sql_class.cc	2009-09-25 13:18:54 +0000
@@ -652,7 +652,7 @@ THD::THD()
 #ifdef SIGNAL_WITH_VIO_CLOSE
   active_vio = 0;
 #endif
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_thd_data, MY_MUTEX_INIT_FAST);
+  mysql_mutex_init(key_LOCK_thd_data, &LOCK_thd_data, MY_MUTEX_INIT_FAST);
 
   /* Variables with default values */
   proc_info="login";
@@ -3203,9 +3203,34 @@ void xid_free_hash(void *ptr)
     my_free((uchar*)ptr, MYF(0));
 }
 
+#ifdef HAVE_PSI_INTERFACE
+static PSI_mutex_key key_LOCK_xid_cache;
+
+static PSI_mutex_info all_xid_mutexes[]=
+{
+  { &key_LOCK_xid_cache, "LOCK_xid_cache", PSI_FLAG_GLOBAL}
+};
+
+static void init_xid_psi_keys(void)
+{
+  const char* category= "sql";
+  int count;
+
+  if (PSI_server == NULL)
+    return;
+
+  count= array_elements(all_xid_mutexes);
+  PSI_server->register_mutex(category, all_xid_mutexes, count);
+}
+#endif /* HAVE_PSI_INTERFACE */
+
 bool xid_cache_init()
 {
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_xid_cache, MY_MUTEX_INIT_FAST);
+#ifdef HAVE_PSI_INTERFACE
+  init_xid_psi_keys();
+#endif
+
+  mysql_mutex_init(key_LOCK_xid_cache, &LOCK_xid_cache, MY_MUTEX_INIT_FAST);
   return hash_init(&xid_cache, &my_charset_bin, 100, 0, 0,
                    xid_get_hash_key, xid_free_hash, 0) != 0;
 }

=== modified file 'sql/sql_db.cc'
--- a/sql/sql_db.cc	2009-09-22 16:22:25 +0000
+++ b/sql/sql_db.cc	2009-09-25 13:18:54 +0000
@@ -199,6 +199,26 @@ void free_dbopt(void *dbopt)
   my_free((uchar*) dbopt, MYF(0));
 }
 
+#ifdef HAVE_PSI_INTERFACE
+static PSI_rwlock_key key_rwlock_LOCK_dboptions;
+
+static PSI_rwlock_info all_database_names_rwlocks[]=
+{
+  { &key_rwlock_LOCK_dboptions, "LOCK_dboptions", PSI_FLAG_GLOBAL}
+};
+
+static void init_database_names_psi_keys(void)
+{
+  const char* category= "sql";
+  int count;
+
+  if (PSI_server == NULL)
+    return;
+
+  count= array_elements(all_database_names_rwlocks);
+  PSI_server->register_rwlock(category, all_database_names_rwlocks, count);
+}
+#endif
 
 /* 
   Initialize database option hash and locked database hash.
@@ -216,8 +236,12 @@ void free_dbopt(void *dbopt)
 
 bool my_database_names_init(void)
 {
+#ifdef HAVE_PSI_INTERFACE
+  init_database_names_psi_keys();
+#endif
+
   bool error= 0;
-  mysql_rwlock_init(INSTRUMENT_ME, &LOCK_dboptions);
+  mysql_rwlock_init(key_rwlock_LOCK_dboptions, &LOCK_dboptions);
   if (!dboptions_init)
   {
     dboptions_init= 1;

=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc	2009-09-23 08:41:25 +0000
+++ b/sql/sql_insert.cc	2009-09-25 13:18:54 +0000
@@ -1742,9 +1742,9 @@ public:
     thd.system_thread= SYSTEM_THREAD_DELAYED_INSERT;
     thd.security_ctx->host_or_ip= "";
     bzero((char*) &info,sizeof(info));
-    mysql_mutex_init(INSTRUMENT_ME, &mutex, MY_MUTEX_INIT_FAST);
-    mysql_cond_init(INSTRUMENT_ME, &cond, NULL);
-    mysql_cond_init(INSTRUMENT_ME, &cond_client, NULL);
+    mysql_mutex_init(key_delayed_insert_mutex, &mutex, MY_MUTEX_INIT_FAST);
+    mysql_cond_init(key_delayed_insert_cond, &cond, NULL);
+    mysql_cond_init(key_delayed_insert_cond_client, &cond_client, NULL);
     pthread_mutex_lock(&LOCK_thread_count);
     delayed_insert_threads++;
     delayed_lock= global_system_variables.low_priority_updates ?
@@ -1923,7 +1923,7 @@ bool delayed_get_table(THD *thd, TABLE_L
       di->table_list.db= di->thd.db;
       di->lock();
       mysql_mutex_lock(&di->mutex);
-      if ((error= mysql_thread_create(INSTRUMENT_ME,
+      if ((error= mysql_thread_create(key_thread_delayed_insert,
                                       &di->thd.real_id, &connection_attrib,
                                       handle_delayed_insert, (void*) di)))
       {

=== modified file 'sql/sql_manager.cc'
--- a/sql/sql_manager.cc	2009-09-23 08:41:25 +0000
+++ b/sql/sql_manager.cc	2009-09-25 13:18:54 +0000
@@ -134,7 +134,7 @@ void start_handle_manager()
   if (flush_time && flush_time != ~(ulong) 0L)
   {
     pthread_t hThread;
-    if (mysql_thread_create(INSTRUMENT_ME,
+    if (mysql_thread_create(key_thread_handle_manager,
                             &hThread, &connection_attrib, handle_manager, 0))
       sql_print_warning("Can't create handle_manager thread");
   }

=== modified file 'sql/sql_servers.cc'
--- a/sql/sql_servers.cc	2009-09-15 15:00:13 +0000
+++ b/sql/sql_servers.cc	2009-09-25 13:18:54 +0000
@@ -89,6 +89,26 @@ static uchar *servers_cache_get_key(FORE
   DBUG_RETURN((uchar*) server->server_name);
 }
 
+#ifdef HAVE_PSI_INTERFACE
+static PSI_rwlock_key key_rwlock_THR_LOCK_servers;
+
+static PSI_rwlock_info all_servers_cache_rwlocks[]=
+{
+  { &key_rwlock_THR_LOCK_servers, "THR_LOCK_servers", PSI_FLAG_GLOBAL}
+};
+
+static void init_servers_cache_psi_keys(void)
+{
+  const char* category= "sql";
+  int count;
+
+  if (PSI_server == NULL)
+    return;
+
+  count= array_elements(all_servers_cache_rwlocks);
+  PSI_server->register_rwlock(category, all_servers_cache_rwlocks, count);
+}
+#endif /* HAVE_PSI_INTERFACE */
 
 /*
   Initialize structures responsible for servers used in federated
@@ -115,8 +135,12 @@ bool servers_init(bool dont_read_servers
   bool return_val= FALSE;
   DBUG_ENTER("servers_init");
 
+#ifdef HAVE_PSI_INTERFACE
+  init_servers_cache_psi_keys();
+#endif
+
   /* init the mutex */
-  if (mysql_rwlock_init(INSTRUMENT_ME, &THR_LOCK_servers))
+  if (mysql_rwlock_init(key_rwlock_THR_LOCK_servers, &THR_LOCK_servers))
     DBUG_RETURN(TRUE);
 
   /* initialise our servers cache */

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2009-09-22 16:22:25 +0000
+++ b/sql/sql_table.cc	2009-09-25 13:18:54 +0000
@@ -761,7 +761,7 @@ static uint read_ddl_log_header()
   global_ddl_log.first_free= NULL;
   global_ddl_log.first_used= NULL;
   global_ddl_log.num_entries= 0;
-  mysql_mutex_init(INSTRUMENT_ME, &LOCK_gdl, MY_MUTEX_INIT_FAST);
+  mysql_mutex_init(key_LOCK_gdl, &LOCK_gdl, MY_MUTEX_INIT_FAST);
   global_ddl_log.do_release= true;
   DBUG_RETURN(entry_no);
 }

=== modified file 'sql/sql_udf.cc'
--- a/sql/sql_udf.cc	2009-09-15 15:00:13 +0000
+++ b/sql/sql_udf.cc	2009-09-25 13:18:54 +0000
@@ -100,6 +100,26 @@ extern "C" uchar* get_hash_key(const uch
   return (uchar*) udf->name.str;
 }
 
+#ifdef HAVE_PSI_INTERFACE
+static PSI_rwlock_key key_rwlock_THR_LOCK_udf;
+
+static PSI_rwlock_info all_udf_rwlocks[]=
+{
+  { &key_rwlock_THR_LOCK_udf, "THR_LOCK_udf", PSI_FLAG_GLOBAL}
+};
+
+static void init_udf_psi_keys(void)
+{
+  const char* category= "sql";
+  int count;
+
+  if (PSI_server == NULL)
+    return;
+
+  count= array_elements(all_udf_rwlocks);
+  PSI_server->register_rwlock(category, all_udf_rwlocks, count);
+}
+#endif
 
 /*
   Read all predeclared functions from mysql.func and accept all that
@@ -119,8 +139,12 @@ void udf_init()
   if (initialized)
     DBUG_VOID_RETURN;
 
-  mysql_rwlock_init(INSTRUMENT_ME, &THR_LOCK_udf);
-  
+#ifdef HAVE_PSI_INTERFACE
+  init_udf_psi_keys();
+#endif
+
+  mysql_rwlock_init(key_rwlock_THR_LOCK_udf, &THR_LOCK_udf);
+
   init_sql_alloc(&mem, UDF_ALLOC_BLOCK_SIZE, 0);
   THD *new_thd = new THD;
   if (!new_thd ||

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2009-09-23 08:41:25 +0000
+++ b/sql/table.cc	2009-09-25 13:18:54 +0000
@@ -318,8 +318,8 @@ TABLE_SHARE *alloc_table_share(TABLE_LIS
     share->cached_row_logging_check= -1;
 
     memcpy((char*) &share->mem_root, (char*) &mem_root, sizeof(mem_root));
-    mysql_mutex_init(INSTRUMENT_ME, &share->mutex, MY_MUTEX_INIT_FAST);
-    mysql_cond_init(INSTRUMENT_ME, &share->cond, NULL);
+    mysql_mutex_init(key_TABLE_SHARE_mutex, &share->mutex, MY_MUTEX_INIT_FAST);
+    mysql_cond_init(key_TABLE_SHARE_cond, &share->cond, NULL);
   }
   DBUG_RETURN(share);
 }


Attachment: [text/bzr-bundle] bzr/marc.alff@sun.com-20090925131854-xdfpl5p2lfuwj39e.bundle
Thread
bzr commit into mysql-trunk-perfschema branch (marc.alff:2893) WL#2360Marc Alff25 Sep