List:Commits« Previous MessageNext Message »
From:Mikael Ronstrom Date:September 13 2012 1:24pm
Subject:bzr push into mysql-5.5-cluster-7.2 branch (mikael.ronstrom:3970 to 3971)
View as plain text  
 3971 Mikael Ronstrom	2012-09-13
      Added support for unlocking receive threads from locking to CPUs

    modified:
      mysql-test/suite/ndb/r/ndb_recv_thread_cpu_mask_basic.result
      mysql-test/suite/ndb/t/ndb_recv_thread_cpu_mask_basic.test
      sql/ha_ndbcluster.cc
      sql/ha_ndbcluster_connection.cc
      storage/ndb/include/ndbapi/ndb_cluster_connection.hpp
      storage/ndb/include/portlib/NdbThread.h
      storage/ndb/src/ndbapi/TransporterFacade.cpp
      storage/ndb/src/ndbapi/TransporterFacade.hpp
      storage/ndb/src/ndbapi/ndb_cluster_connection.cpp
 3970 Mikael Ronstrom	2012-09-12
      Make it possible to unlock, that is to remove CPU locking

    modified:
      storage/ndb/src/common/portlib/NdbThread.c
=== modified file 'mysql-test/suite/ndb/r/ndb_recv_thread_cpu_mask_basic.result'
--- a/mysql-test/suite/ndb/r/ndb_recv_thread_cpu_mask_basic.result	revid:mikael.ronstrom@stripped
+++ b/mysql-test/suite/ndb/r/ndb_recv_thread_cpu_mask_basic.result	revid:mikael.ronstrom@stripped
@@ -10,14 +10,13 @@ SELECT @@global.ndb_recv_thread_cpu_mask
 
 '#---------------------FN_DYNVARS_183_02-------------------------#'
 SET @@global.ndb_recv_thread_cpu_mask = NULL;
-ERROR 42000: Variable 'ndb_recv_thread_cpu_mask' can't be set to the value of 'NULL'
 SET @@global.ndb_recv_thread_cpu_mask = '';
 '#--------------------FN_DYNVARS_183_03------------------------#'
-SET @@global.ndb_recv_thread_cpu_mask = '0,1,2,3-5,6-8,9';
+SET @@global.ndb_recv_thread_cpu_mask = '0-1,2-3';
 SELECT @@global.ndb_recv_thread_cpu_mask;
 @@global.ndb_recv_thread_cpu_mask
 
-SET @@global.ndb_recv_thread_cpu_mask = '9';
+SET @@global.ndb_recv_thread_cpu_mask = '0';
 SELECT @@global.ndb_recv_thread_cpu_mask;
 @@global.ndb_recv_thread_cpu_mask
 
@@ -25,7 +24,7 @@ SET @@global.ndb_recv_thread_cpu_mask = 
 SELECT @@global.ndb_recv_thread_cpu_mask;
 @@global.ndb_recv_thread_cpu_mask
 
-SET @@global.ndb_recv_thread_cpu_mask = '0,1,2,3-5,9';
+SET @@global.ndb_recv_thread_cpu_mask = '0,1-2,3';
 SELECT @@global.ndb_recv_thread_cpu_mask;
 @@global.ndb_recv_thread_cpu_mask
 

=== modified file 'mysql-test/suite/ndb/t/ndb_recv_thread_cpu_mask_basic.test'
--- a/mysql-test/suite/ndb/t/ndb_recv_thread_cpu_mask_basic.test	revid:mikael.ronstrom@stripped
+++ b/mysql-test/suite/ndb/t/ndb_recv_thread_cpu_mask_basic.test	revid:mikael.ronstrom@stripped
@@ -52,7 +52,6 @@ SELECT @@global.ndb_recv_thread_cpu_mask
 #      Check if NULL or empty value is accepted         #
 ######################################################### 
 
---Error ER_WRONG_VALUE_FOR_VAR
 SET @@global.ndb_recv_thread_cpu_mask = NULL;
 
 SET @@global.ndb_recv_thread_cpu_mask = '';
@@ -62,16 +61,16 @@ SET @@global.ndb_recv_thread_cpu_mask = 
 #  Change the value of ndb_recv_thread_cpu_mask to a valid value    #
 #####################################################################
 
-SET @@global.ndb_recv_thread_cpu_mask = '0,1,2,3-5,6-8,9';
+SET @@global.ndb_recv_thread_cpu_mask = '0-1,2-3';
 SELECT @@global.ndb_recv_thread_cpu_mask;
 
-SET @@global.ndb_recv_thread_cpu_mask = '9';
+SET @@global.ndb_recv_thread_cpu_mask = '0';
 SELECT @@global.ndb_recv_thread_cpu_mask;
 
 SET @@global.ndb_recv_thread_cpu_mask = '0,1,2';
 SELECT @@global.ndb_recv_thread_cpu_mask;
 
-SET @@global.ndb_recv_thread_cpu_mask = '0,1,2,3-5,9';
+SET @@global.ndb_recv_thread_cpu_mask = '0,1-2,3';
 SELECT @@global.ndb_recv_thread_cpu_mask;
 
 --echo '#--------------------FN_DYNVARS_183_04-------------------------#'

=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	revid:mikael.ronstrom@stripped
+++ b/sql/ha_ndbcluster.cc	revid:mikael.ronstrom@stripped
@@ -11865,6 +11865,7 @@ static MYSQL_SYSVAR_STR(
 
 extern int ndb_dictionary_is_mysqld;
 
+Uint32 recv_thread_num_cpus;
 static int ndb_recv_thread_cpu_mask_check_str(const char *str);
 static void ndb_recv_thread_cpu_mask_update();
 
@@ -11929,7 +11930,10 @@ static int ndbcluster_init(void *p)
   /* Translate recv thread cpu mask if set */
   if (ndb_recv_thread_cpu_mask_check_str(opt_ndb_recv_thread_cpu_mask) == 0)
   {
-    ndb_recv_thread_cpu_mask_update();
+    if (recv_thread_num_cpus)
+    {
+      ndb_recv_thread_cpu_mask_update();
+    }
   }
 
   /* allocate connection resources and connect to cluster */
@@ -17157,7 +17161,6 @@ static MYSQL_SYSVAR_UINT(
 static const int ndb_recv_thread_cpu_mask_option_buf_size = 512;
 char ndb_recv_thread_cpu_mask_option_buf[ndb_recv_thread_cpu_mask_option_buf_size];
 Uint16 recv_thread_cpuid_array[MAX_NUM_RECV_THREADS * MAX_CLUSTER_CONNECTIONS];
-Uint32 recv_thread_num_cpus;
 
 static
 int
@@ -17181,7 +17184,10 @@ ndb_recv_thread_cpu_mask_check_str(const
 
   recv_thread_num_cpus = 0;
   if (str == 0)
-    goto error;
+  {
+    /* Setting to empty string is interpreted as remove locking to CPU */
+    return 0;
+  }
 
   if (parse_mask(str, bitmask) < 0)
   {
@@ -17212,7 +17218,7 @@ error:
 
 static
 void
-ndb_recv_thread_cpu_mask_update(void)
+ndb_recv_thread_cpu_mask_update()
 {
   ndb_set_recv_thread_cpu(recv_thread_cpuid_array,
                           opt_ndb_num_recv_threads,

=== modified file 'sql/ha_ndbcluster_connection.cc'
--- a/sql/ha_ndbcluster_connection.cc	revid:mikael.ronstrom@stripped
+++ b/sql/ha_ndbcluster_connection.cc	revid:mikael.ronstrom@stripped
@@ -312,6 +312,19 @@ ndb_set_recv_thread_cpu(Uint16 *cpuid_ar
 {
   Uint32 num_cpu_needed = num_recv_threads * g_pool_alloc;
   Uint32 cpu_index = 0;
+
+  if (cpuid_array_size == 0)
+  {
+    for (Uint32 i = 0; i < g_pool_alloc; i++)
+    {
+      for (Uint32 j = 0; j < num_recv_threads; j++)
+      {
+        g_pool[i]->unset_recv_thread_cpu(j);
+      }
+    }
+    return 0;
+  }
+
   if (cpuid_array_size < num_cpu_needed)
   {
     /* Ignore cpu masks that is too short */

=== modified file 'storage/ndb/include/ndbapi/ndb_cluster_connection.hpp'
--- a/storage/ndb/include/ndbapi/ndb_cluster_connection.hpp	revid:mikael.ronstrom@stripped
+++ b/storage/ndb/include/ndbapi/ndb_cluster_connection.hpp	revid:mikael.ronstrom@stripped
@@ -208,6 +208,7 @@ public:
    */
   int set_num_recv_threads(Uint32 num_recv_threads);
   int get_num_recv_threads() const;
+  int unset_recv_thread_cpu(Uint32 recv_thread_id);
   int set_recv_thread_cpu(Uint16 *cpuid_array,
                           Uint32 array_len,
                           Uint32 recv_thread_id = 0);

=== modified file 'storage/ndb/include/portlib/NdbThread.h'
--- a/storage/ndb/include/portlib/NdbThread.h	revid:mikael.ronstrom@stripped
+++ b/storage/ndb/include/portlib/NdbThread.h	revid:mikael.ronstrom@stripped
@@ -119,9 +119,10 @@ int NdbThread_GetTid(struct NdbThread*);
 int NdbThread_SetScheduler(struct NdbThread*, my_bool rt_prio, my_bool high_prio);
 
 /**
- * Lock Thread to CPU
+ * Lock/Unlock Thread to CPU
  */
 int NdbThread_LockCPU(struct NdbThread*, Uint32 cpu);
+int NdbThread_UnlockCPU(struct NdbThread*);
 
 /**
  * Fetch and set thread-local storage entry.

=== modified file 'storage/ndb/src/ndbapi/TransporterFacade.cpp'
--- a/storage/ndb/src/ndbapi/TransporterFacade.cpp	revid:mikael.ronstrom@stripped
+++ b/storage/ndb/src/ndbapi/TransporterFacade.cpp	revid:mikael.ronstrom@stripped
@@ -672,6 +672,17 @@ TransporterFacade::get_num_recv_threads(
 }
 
 int
+TransporterFacade::unset_recv_thread_cpu(Uint32 recv_thread_id)
+{
+  if (recv_thread_id != 0)
+  {
+    return -1;
+  }
+  unlock_recv_thread_cpu();
+  return 0;
+}
+
+int
 TransporterFacade::set_recv_thread_cpu(Uint16 *cpuid_array,
                                        Uint32 array_len,
                                        Uint32 recv_thread_id)
@@ -705,6 +716,12 @@ TransporterFacade::set_recv_thread_activ
 }
 
 void
+TransporterFacade::unlock_recv_thread_cpu()
+{
+  NdbThread_UnlockCPU(theReceiveThread);
+}
+
+void
 TransporterFacade::lock_recv_thread_cpu()
 {
   while (theReceiveThread == NULL)

=== modified file 'storage/ndb/src/ndbapi/TransporterFacade.hpp'
--- a/storage/ndb/src/ndbapi/TransporterFacade.hpp	revid:mikael.ronstrom@stripped
+++ b/storage/ndb/src/ndbapi/TransporterFacade.hpp	revid:mikael.ronstrom@stripped
@@ -186,6 +186,7 @@ public:
 #define NO_RECV_THREAD_CPU_ID 0xFFFF
   int set_num_recv_threads(Uint32 num_recv_threads);
   int get_num_recv_threads() const;
+  int unset_recv_thread_cpu(Uint32 recv_thread_id);
   int set_recv_thread_cpu(Uint16 *cpuid_array,
                           Uint32 array_len,
                           Uint32 recv_thread_id);
@@ -194,8 +195,9 @@ public:
   /* Variables to support configuration of receiver thread handling */
   Uint32 min_active_clients_recv_thread;
   Uint16 recv_thread_cpu_id;
-  /* Support method to lock the receiver thread to its CPU */
+  /* Support methods to lock/unlock the receiver thread to/from its CPU */
   void lock_recv_thread_cpu();
+  void unlock_recv_thread_cpu();
 
   trp_client * m_poll_owner;
   trp_client * m_poll_queue_head; // First in queue

=== modified file 'storage/ndb/src/ndbapi/ndb_cluster_connection.cpp'
--- a/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp	revid:mikael.ronstrom@stripped
+++ b/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp	revid:mikael.ronstrom@stripped
@@ -112,6 +112,16 @@ Ndb_cluster_connection::get_num_recv_thr
 }
 
 int
+Ndb_cluster_connection::unset_recv_thread_cpu(Uint32 recv_thread_id)
+{
+  if (m_impl.m_transporter_facade)
+  {
+    return m_impl.m_transporter_facade->unset_recv_thread_cpu(recv_thread_id);
+  }
+  return -1;
+}
+
+int
 Ndb_cluster_connection::set_recv_thread_cpu(Uint16 *cpuid_array,
                                             Uint32 array_len,
                                             Uint32 recv_thread_id)

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.5-cluster-7.2 branch (mikael.ronstrom:3970 to 3971) Mikael Ronstrom13 Sep