From: Jonas Oreland Date: November 7 2008 1:31pm Subject: bzr push into mysql-5.1 branch (jonas:3053 to 3055) List-Archive: http://lists.mysql.com/commits/58176 Message-Id: <20081107133108.4D9554E4A3@perch.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3055 Jonas Oreland 2008-11-07 ndbmtd - add lock-to-cpu and realtime settings modified: storage/ndb/src/kernel/main.cpp storage/ndb/src/kernel/vm/Configuration.cpp storage/ndb/src/kernel/vm/Configuration.hpp storage/ndb/src/kernel/vm/ThreadConfig.cpp storage/ndb/src/kernel/vm/ThreadConfig.hpp storage/ndb/src/kernel/vm/mt.cpp storage/ndb/src/mgmsrv/ConfigInfo.cpp 3054 Jonas Oreland 2008-11-07 [merge] merge 64-main modified: BUILD/SETUP.sh mysql-test/suite/ndb/t/ndb_dbug_lock.test sql/mysqld.cc storage/ndb/include/ndbinfo.h storage/ndb/src/common/debugger/EventLogger.cpp storage/ndb/src/common/logger/FileLogHandler.cpp storage/ndb/src/common/transporter/TransporterRegistry.cpp storage/ndb/src/cw/cpcd/APIService.cpp storage/ndb/src/cw/cpcd/Process.cpp storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp storage/ndb/src/kernel/vm/ndbd_malloc_impl.cpp storage/ndb/src/mgmsrv/Services.cpp storage/ndb/src/ndbapi/ObjectMap.cpp support-files/compiler_warnings.supp 3053 Jonas Oreland 2008-11-07 ndb - try to fix windows compile error modified: storage/ndb/src/common/util/Bitmask.cpp === modified file 'BUILD/SETUP.sh' --- a/BUILD/SETUP.sh 2008-11-06 17:18:50 +0000 +++ b/BUILD/SETUP.sh 2008-11-07 11:57:27 +0000 @@ -92,7 +92,8 @@ if [ "x$warning_mode" != "xpedantic" ]; # Both C and C++ warnings warnings="-Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W" warnings="$warnings -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare" - warnings="$warnings -Wwrite-strings -Wunused-function -Wunused-label -Wunused-value -Wunused-variable" + warnings="$warnings -Wwrite-strings -Wunused-function -Wunused-label" + warnings="$warnings -Wunused-value -Wunused-variable" # Make "printf like format specifier warnings" into error #warnings="$warnings -Werror=format" @@ -101,7 +102,7 @@ if [ "x$warning_mode" != "xpedantic" ]; # warnings="$global_warnings -Wshadow" # C warnings - c_warnings="$warnings -Wunused-parameter" + c_warnings="$warnings -Wunused-parameter -Wno-format-zero-length" # C++ warnings cxx_warnings="$warnings" # cxx_warnings="$cxx_warnings -Woverloaded-virtual -Wsign-promo" === modified file 'mysql-test/suite/ndb/t/ndb_dbug_lock.test' --- a/mysql-test/suite/ndb/t/ndb_dbug_lock.test 2008-10-29 22:10:29 +0000 +++ b/mysql-test/suite/ndb/t/ndb_dbug_lock.test 2008-11-07 10:33:31 +0000 @@ -49,6 +49,7 @@ lock tables t1 write; --echo # issue alter in parallell, which should be hanging waiting on --connection another_con --send alter table t1 add column (d int) +--sleep 1 --echo # check thread state which should be: --echo # "Waiting for allowed to take ndbcluster global schema lock" === modified file 'sql/mysqld.cc' --- a/sql/mysqld.cc 2008-10-31 15:25:01 +0000 +++ b/sql/mysqld.cc 2008-11-07 08:52:22 +0000 @@ -380,7 +380,7 @@ bool opt_error_log= IF_WIN(1,0); bool opt_disable_networking=0, opt_skip_show_db=0; my_bool opt_character_set_client_handshake= 1; bool server_id_supplied = 0; -bool opt_endinfo, using_udf_functions; +bool using_udf_functions; my_bool locked_in_memory; bool opt_using_transactions; bool volatile abort_loop; @@ -412,14 +412,10 @@ handlerton *partition_hton; #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE const char *opt_ndbcluster_connectstring= 0; -const char *opt_ndb_connectstring= 0; char opt_ndb_constrbuf[1024]= {0}; -unsigned opt_ndb_constrbuf_len= 0; my_bool opt_ndb_shm; ulong opt_ndb_cache_check_time, opt_ndb_wait_connected; ulong opt_ndb_cluster_connection_pool; -const char *opt_ndb_mgmd; -ulong opt_ndb_nodeid; ulong ndb_extra_logging; ulong ndb_report_thresh_binlog_epoch_slip= 0; ulong ndb_report_thresh_binlog_mem_usage= 0; @@ -427,6 +423,11 @@ my_bool opt_ndb_log_update_as_write= FAL my_bool opt_ndb_log_updated_only= FALSE; my_bool opt_ndb_log_orig= FALSE; +extern bool opt_endinfo; +extern const char *opt_ndb_connectstring; +extern unsigned opt_ndb_constrbuf_len; +extern const char *opt_ndb_mgmd; +extern ulong opt_ndb_nodeid; extern const char *ndb_distribution_names[]; extern TYPELIB ndb_distribution_typelib; extern const char *opt_ndb_distribution; === modified file 'storage/ndb/include/ndbinfo.h' --- a/storage/ndb/include/ndbinfo.h 2008-10-08 10:52:32 +0000 +++ b/storage/ndb/include/ndbinfo.h 2008-11-07 08:52:22 +0000 @@ -39,7 +39,7 @@ struct ndbinfo_column { struct ndbinfo_table { NDBINFO_TABLE_MEMBERS - struct ndbinfo_column col[]; + struct ndbinfo_column col[0]; }; /* because MSVC compiler hates you (or rather, zero length arrays) */ === modified file 'storage/ndb/src/common/debugger/EventLogger.cpp' --- a/storage/ndb/src/common/debugger/EventLogger.cpp 2008-11-06 16:52:59 +0000 +++ b/storage/ndb/src/common/debugger/EventLogger.cpp 2008-11-07 11:00:38 +0000 @@ -897,8 +897,8 @@ void getTextLogFileInitStatus(QQQQ) { if (theData[2]) BaseString::snprintf(m_text, m_text_len, "Local redo log file initialization status:\n" - "#Total files: %lu, Completed: %lu\n" - "#Total MBytes: %lu, Completed: %lu", + "#Total files: %u, Completed: %u\n" + "#Total MBytes: %u, Completed: %u", // refToNode(theData[1]), theData[2], theData[3], theData[4], theData[5]); @@ -910,8 +910,8 @@ void getTextLogFileInitStatus(QQQQ) { void getTextLogFileInitCompStatus(QQQQ) { BaseString::snprintf(m_text, m_text_len, "Local redo log file initialization completed:\n" - "#Total files: %lu, Completed: %lu\n" - "#Total MBytes: %lu, Completed: %lu", + "#Total files: %u, Completed: %u\n" + "#Total MBytes: %u, Completed: %u", // refToNode(theData[1]), theData[2], theData[3], theData[4], theData[5]); === modified file 'storage/ndb/src/common/logger/FileLogHandler.cpp' --- a/storage/ndb/src/common/logger/FileLogHandler.cpp 2008-10-05 07:12:28 +0000 +++ b/storage/ndb/src/common/logger/FileLogHandler.cpp 2008-11-07 11:00:38 +0000 @@ -204,7 +204,7 @@ FileLogHandler::setParam(const BaseStrin bool FileLogHandler::getParams(BaseString &config) { - config.assfmt("FILE:filename=%s,maxsize=%u,maxfiles=%u", + config.assfmt("FILE:filename=%s,maxsize=%lu,maxfiles=%u", m_pLogFile->getName(), m_maxFileSize, m_maxNoFiles); === modified file 'storage/ndb/src/common/transporter/TransporterRegistry.cpp' --- a/storage/ndb/src/common/transporter/TransporterRegistry.cpp 2008-11-06 10:17:49 +0000 +++ b/storage/ndb/src/common/transporter/TransporterRegistry.cpp 2008-11-07 08:52:22 +0000 @@ -1916,7 +1916,7 @@ TransporterRegistry::get_bytes_to_send_i SendBufferPage *page = b->m_first_page; while (page != NULL && count < max) { - dst[count].iov_base = page->m_data+page->m_start; + dst[count].iov_base = (char*)page->m_data+page->m_start; dst[count].iov_len = page->m_bytes; assert(page->m_start + page->m_bytes <= page->max_data_bytes()); page = page->m_next; === modified file 'storage/ndb/src/cw/cpcd/APIService.cpp' --- a/storage/ndb/src/cw/cpcd/APIService.cpp 2008-09-17 13:23:21 +0000 +++ b/storage/ndb/src/cw/cpcd/APIService.cpp 2008-11-07 08:52:22 +0000 @@ -151,7 +151,7 @@ CPCDAPISession::CPCDAPISession(NDB_SOCKE } CPCDAPISession::CPCDAPISession(FILE * f, CPCD & cpcd) - : SocketServer::Session::Session(my_socket_create_invalid()) + : SocketServer::Session(my_socket_create_invalid()) , m_cpcd(cpcd) { m_input = new FileInputStream(f); === modified file 'storage/ndb/src/cw/cpcd/Process.cpp' --- a/storage/ndb/src/cw/cpcd/Process.cpp 2006-12-23 19:20:40 +0000 +++ b/storage/ndb/src/cw/cpcd/Process.cpp 2008-11-07 08:01:33 +0000 @@ -308,7 +308,7 @@ CPCD::Process::do_exec() { } int f = fds[i]= open(redirects[i]->c_str(), flags, mode); if(f == -1){ - logger.error("Cannot redirect %d to/from '%s' : %s\n", i, + logger.error("Cannot redirect %ld to/from '%s' : %s\n", i, redirects[i]->c_str(), strerror(errno)); _exit(1); } === modified file 'storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp' --- a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp 2008-11-03 08:38:27 +0000 +++ b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp 2008-11-07 11:00:38 +0000 @@ -2452,7 +2452,7 @@ void Dbdih::gcpBlockedLab(Signal* signal if (getNodeActiveStatus(nodePtr.i) == Sysfile::NS_NotDefined) { jam(); - infoEvent("Adding node % to sysfile, NS_Configured", + infoEvent("Adding node %d to sysfile, NS_Configured", nodePtr.i); setNodeActiveStatus(nodePtr.i, Sysfile::NS_Configured); Sysfile::setNodeGroup(nodePtr.i, SYSFILE->nodeGroups, === modified file 'storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp' --- a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp 2008-11-06 16:52:59 +0000 +++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp 2008-11-07 11:00:38 +0000 @@ -19352,7 +19352,7 @@ Dblqh::validate_filter(Signal* signal) start += 3; break; default: - infoEvent("Invalid filter op: 0x%x pos: %d", + infoEvent("Invalid filter op: 0x%x pos: %ld", * start, start - (signal->theData + 1)); return false; === modified file 'storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp' --- a/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp 2008-11-06 10:13:37 +0000 +++ b/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp 2008-11-07 11:00:38 +0000 @@ -12255,7 +12255,7 @@ Dbtc::validate_filter(Signal* signal) start += 3; break; default: - infoEvent("Invalid filter op: 0x%x pos: %d", + infoEvent("Invalid filter op: 0x%x pos: %ld", * start, start - (signal->theData + 1)); return false; === modified file 'storage/ndb/src/kernel/main.cpp' --- a/storage/ndb/src/kernel/main.cpp 2008-11-06 10:17:49 +0000 +++ b/storage/ndb/src/kernel/main.cpp 2008-11-07 13:23:15 +0000 @@ -661,7 +661,7 @@ int main(int argc, char** argv) NdbThread *pThis = NdbThread_CreateObject(0); Uint32 inx = globalEmulatorData.theConfiguration->addThread(pThis, MainThread); - globalEmulatorData.theThreadConfig->ipControlLoop(inx); + globalEmulatorData.theThreadConfig->ipControlLoop(pThis, inx); globalEmulatorData.theConfiguration->removeThreadId(inx); } NdbShutdown(NST_Normal); === modified file 'storage/ndb/src/kernel/vm/Configuration.cpp' --- a/storage/ndb/src/kernel/vm/Configuration.cpp 2008-11-06 16:29:57 +0000 +++ b/storage/ndb/src/kernel/vm/Configuration.cpp 2008-11-07 13:23:15 +0000 @@ -471,15 +471,18 @@ Configuration::setupConfiguration(){ "RealtimeScheduler missing"); } - if(iter.get(CFG_DB_EXECUTE_LOCK_CPU, &_executeLockCPU)){ - ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, "Invalid configuration fetched", - "LockExecuteThreadToCPU missing"); + const char * mask; + if(iter.get(CFG_DB_EXECUTE_LOCK_CPU, &mask) == 0) + { + if (_executeLockCPU.parseMask(mask) < 0) + { + _executeLockCPU.clear(); + } } - if(iter.get(CFG_DB_MAINT_LOCK_CPU, &_maintLockCPU)){ - ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, "Invalid configuration fetched", - "LockMaintThreadsToCPU missing"); - } + _maintLockCPU = NO_LOCK_CPU; + iter.get(CFG_DB_MAINT_LOCK_CPU, &_maintLockCPU); + if(iter.get(CFG_DB_WATCHDOG_INTERVAL_INITIAL, &_timeBetweenWatchDogCheckInitial)){ ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, "Invalid configuration fetched", "TimeBetweenWatchDogCheckInitial missing"); @@ -570,16 +573,38 @@ Configuration::realtimeScheduler(bool re Uint32 Configuration::executeLockCPU() const { - return _executeLockCPU; + unsigned res = _executeLockCPU.find(0); + if (res == _executeLockCPU.NotFound) + return NO_LOCK_CPU; + else + return res; } void Configuration::executeLockCPU(Uint32 value) { - Uint32 old_value = _executeLockCPU; - _executeLockCPU = value; - if (value != old_value) + if (value >= NDB_CPU_MASK_SZ) + { + value = NO_LOCK_CPU; + } + + bool changed = false; + if (value == NO_LOCK_CPU) + { + changed = _executeLockCPU.count() > 0; + _executeLockCPU.clear(); + } + else + { + changed = _executeLockCPU.get(value) == false; + _executeLockCPU.clear(); + _executeLockCPU.set(value); + } + + if (changed) + { setAllLockCPU(TRUE); + } } Uint32 @@ -1083,7 +1108,7 @@ Configuration::setLockCPU(NdbThread * pT (!exec_thread && type == MainThread)) return 0; if (type == MainThread) - cpu_id = _executeLockCPU; + cpu_id = executeLockCPU(); else cpu_id = _maintLockCPU; if (!init || @@ -1121,7 +1146,14 @@ Configuration::addThread(struct NdbThrea threadInfo[i].type = type; NdbMutex_Unlock(threadIdMutex); setRealtimeScheduler(pThread, type, _realtimeScheduler, TRUE); - setLockCPU(pThread, type, (type == MainThread), TRUE); + if (type != MainThread) + { + /** + * main threads are set in ThreadConfig::ipControlLoop + * as it's handled differently with mt + */ + setLockCPU(pThread, type, (type == MainThread), TRUE); + } return i; } === modified file 'storage/ndb/src/kernel/vm/Configuration.hpp' --- a/storage/ndb/src/kernel/vm/Configuration.hpp 2008-11-06 10:17:49 +0000 +++ b/storage/ndb/src/kernel/vm/Configuration.hpp 2008-11-07 13:23:15 +0000 @@ -21,6 +21,7 @@ #include #include #include +#include enum ThreadTypes { @@ -34,6 +35,7 @@ enum ThreadTypes #define MAX_NDB_THREADS 256 #define NO_LOCK_CPU 65535 +#define NDB_CPU_MASK_SZ 256 struct ThreadInfo { @@ -72,6 +74,9 @@ public: Uint32 executeLockCPU() const; void executeLockCPU(Uint32 value); + const Bitmask & getExecuteCpuMask() const { + return _executeLockCPU; + } Uint32 maintLockCPU() const; void maintLockCPU(Uint32 value); @@ -140,7 +145,7 @@ private: Uint32 _schedulerExecutionTimer; Uint32 _schedulerSpinTimer; Uint32 _realtimeScheduler; - Uint32 _executeLockCPU; + Bitmask _executeLockCPU; Uint32 _maintLockCPU; Uint32 _timeBetweenWatchDogCheckInitial; === modified file 'storage/ndb/src/kernel/vm/ThreadConfig.cpp' --- a/storage/ndb/src/kernel/vm/ThreadConfig.cpp 2008-01-01 12:45:11 +0000 +++ b/storage/ndb/src/kernel/vm/ThreadConfig.cpp 2008-11-07 13:23:15 +0000 @@ -103,8 +103,10 @@ ThreadConfig::scanTimeQueue() // The timeout value in this call is calculated as (10 ms - laptime) // This would make ndb use less cpu while improving response time. //-------------------------------------------------------------------- -void ThreadConfig::ipControlLoop(Uint32 thread_index) +void ThreadConfig::ipControlLoop(NdbThread*, Uint32 thread_index) { + globalEmulatorData.theConfiguration->setAllLockCPU(true); + Uint32 execute_loop_constant = globalEmulatorData.theConfiguration->schedulerExecutionTimer(); Uint32 min_spin_time = === modified file 'storage/ndb/src/kernel/vm/ThreadConfig.hpp' --- a/storage/ndb/src/kernel/vm/ThreadConfig.hpp 2008-01-01 12:45:11 +0000 +++ b/storage/ndb/src/kernel/vm/ThreadConfig.hpp 2008-11-07 13:23:15 +0000 @@ -29,7 +29,7 @@ public: ~ThreadConfig(); void init(EmulatorData *emulatorData); - void ipControlLoop(Uint32 thread_index); + void ipControlLoop(NdbThread*, Uint32 thread_index); int doStart(NodeState::StartLevel startLevel); private: === modified file 'storage/ndb/src/kernel/vm/mt.cpp' --- a/storage/ndb/src/kernel/vm/mt.cpp 2008-11-03 14:03:15 +0000 +++ b/storage/ndb/src/kernel/vm/mt.cpp 2008-11-07 13:23:15 +0000 @@ -39,6 +39,7 @@ #include #include #include "TransporterCallbackKernel.hpp" +#include #include "mt-asm.h" @@ -724,6 +725,9 @@ struct thr_data BlockNumber m_instance_list[MAX_INSTANCES_PER_THREAD]; SectionSegmentPool::Cache m_sectionPoolCache; + + Uint32 m_cpu; + NdbThread* m_thread; }; struct mt_send_handle : public TransporterSendBufferHandle @@ -2294,48 +2298,40 @@ init_thread(thr_data *selfptr) selfptr->m_waiter.init(); selfptr->m_jam.theEmulatedJamIndex = 0; selfptr->m_jam.theEmulatedJamBlockNumber = 0; - memset(selfptr->m_jam.theEmulatedJam, 0, sizeof(selfptr->m_jam.theEmulatedJam)); + bzero(selfptr->m_jam.theEmulatedJam, sizeof(selfptr->m_jam.theEmulatedJam)); NdbThread_SetTlsKey(NDB_THREAD_TLS_JAM, &selfptr->m_jam); + NdbThread_SetTlsKey(NDB_THREAD_TLS_THREAD, selfptr); unsigned thr_no = selfptr->m_thr_no; globalEmulatorData.theWatchDog->registerWatchedThread(&selfptr->m_watchdog_counter, thr_no); - BaseString tmp; + { + while(selfptr->m_thread == 0) + NdbSleep_MilliSleep(30); + } - NdbThread_SetTlsKey(NDB_THREAD_TLS_THREAD, selfptr); + BaseString tmp; tmp.appfmt("thr: %u ", thr_no); -#ifdef SYS_gettid - tmp.appfmt("tid: %u ", (unsigned)syscall(SYS_gettid)); -#endif -#if 0 -#if defined SYS_gettid && defined HAVE_SCHED_SETAFFINITY - bool lock_to_cpu = false; - if (lock_to_cpu) - { - uint cpu_no = 1; - if (!(thr_no <= 1 || thr_no == num_threads - 1)) - { - cpu_no = (thr_no & 3); - } - tmp.appfmt("cpu: %u ", cpu_no); - { - unsigned tid = (unsigned)syscall(SYS_gettid); - cpu_set_t mask; - CPU_ZERO(&mask); - CPU_SET(cpu_no, &mask); - if (sched_setaffinity(tid, sizeof(mask), &mask) == 0) - { - tmp.appfmt("OK "); - } - else - { - tmp.appfmt("err: %u ", errno); - } + int tid = NdbThread_GetTid(selfptr->m_thread); + if (tid != -1) + { + tmp.appfmt("tid: %u ", (unsigned)syscall(SYS_gettid)); + } + + if (selfptr->m_cpu != NO_LOCK_CPU) + { + tmp.appfmt("cpu: %u ", selfptr->m_cpu); + int res = NdbThread_LockCPU(selfptr->m_thread, selfptr->m_cpu); + if (res == 0) + { + tmp.appfmt("OK "); + } + else + { + tmp.appfmt("err: %u ", res); } } -#endif -#endif for (Uint32 i = 0; i < selfptr->m_instance_count; i++) { @@ -2790,6 +2786,9 @@ thr_init(struct thr_repository* rep, str selfptr->m_instance_list[i] = 0; bzero(&selfptr->m_send_buffers, sizeof(selfptr->m_send_buffers)); + + selfptr->m_thread = 0; + selfptr->m_cpu = NO_LOCK_CPU; } /* Have to do this after init of all m_in_queues is done. */ @@ -2885,11 +2884,106 @@ ThreadConfig::init(EmulatorData *emulato ::rep_init(&g_thr_repository, num_threads, emulatorData->m_mem_manager); } -void ThreadConfig::ipControlLoop(Uint32 thread_index) +static +void +setcpuaffinity(struct thr_repository* rep) +{ + Bitmask mask = + globalEmulatorData.theConfiguration->getExecuteCpuMask(); + + + bool mtlqh = globalData.ndbMtLqhThreads > 0; + unsigned cnt = mask.count(); + if (cnt == 0) + { + return; + } + else if (cnt >= num_threads) + { + unsigned cpu = mask.find(0); + for (unsigned thr_no = 0; thr_no < num_threads; thr_no++) + { + rep->m_thread[thr_no].m_cpu = cpu; + cpu = mask.find(cpu + 1); + } + } + else if (cnt == 1) + { + unsigned cpu = mask.find(0); + for (unsigned thr_no = 0; thr_no < num_threads; thr_no++) + { + rep->m_thread[thr_no].m_cpu = cpu; + } + } + else if (mtlqh) + { + if (cnt > globalData.ndbMtLqhThreads) + { + /** + * let each LQH have it's on CPU and rest share... + */ + // LQH threads start with 2 + unsigned cpu = mask.find(0); + for (unsigned thr_no = 2; thr_no < num_threads - 1; thr_no++) + { + rep->m_thread[thr_no].m_cpu = cpu; + mask.clear(cpu); + cpu = mask.find(cpu + 1); + } + + cpu = mask.find(0); + rep->m_thread[0].m_cpu = cpu; // TC + rep->m_thread[1].m_cpu = cpu; // backup/suma + if ((cpu = mask.find(cpu + 1)) == mask.NotFound) + { + cpu = mask.find(0); + } + rep->m_thread[receiver_thread_no].m_cpu = cpu; // receiver + } + else + { + // put receiver, tc, backup/suma in 1 thread, and round robin LQH for rest + unsigned cpu = mask.find(0); + rep->m_thread[0].m_cpu = cpu; // TC + rep->m_thread[1].m_cpu = cpu; // backup/suma + rep->m_thread[receiver_thread_no].m_cpu = cpu; // receiver + mask.clear(cpu); + cpu = mask.find(0); + for (unsigned thr_no = 2; thr_no < num_threads - 1; thr_no++) + { + rep->m_thread[thr_no].m_cpu = cpu; + cpu = mask.find(cpu + 1); + if (cpu == mask.NotFound) + { + cpu = mask.find(0); + } + } + } + } + else + { + /** + * mt-classic and cnt > 1 + */ + assert(num_threads == 3); + unsigned cpu = mask.find(0); + rep->m_thread[1].m_cpu = cpu; // LQH + cpu = mask.find(cpu + 1); + rep->m_thread[0].m_cpu = cpu; + rep->m_thread[2].m_cpu = cpu; + } +} + +void +ThreadConfig::ipControlLoop(NdbThread* pThis, Uint32 thread_index) { unsigned int thr_no; struct thr_repository* rep = &g_thr_repository; - NdbThread *threads[MAX_THREADS]; + + /** + * assign threads to CPU's + */ + setcpuaffinity(rep); /* * Start threads for all execution threads, except for the receiver @@ -2901,19 +2995,22 @@ void ThreadConfig::ipControlLoop(Uint32 if (thr_no == receiver_thread_no) continue; // Will run in the main thread. + /* * The NdbThread_Create() takes void **, but that is cast to void * when * passed to the thread function. Which is kind of strange ... */ - threads[thr_no] = NdbThread_Create(mt_job_thread_main, - (void **)(rep->m_thread + thr_no), - 1024*1024, - "execute thread", //ToDo add number - NDB_THREAD_PRIO_MEAN); - assert(threads[thr_no] != NULL); + rep->m_thread[thr_no].m_thread = + NdbThread_Create(mt_job_thread_main, + (void **)(rep->m_thread + thr_no), + 1024*1024, + "execute thread", //ToDo add number + NDB_THREAD_PRIO_MEAN); + assert(rep->m_thread[thr_no].m_thread != NULL); } /* Now run the main loop for thread 0 directly. */ + rep->m_thread[receiver_thread_no].m_thread = pThis; mt_receiver_thread_main(&(rep->m_thread[receiver_thread_no])); /* Wait for all threads to shutdown. */ @@ -2922,8 +3019,8 @@ void ThreadConfig::ipControlLoop(Uint32 if (thr_no == receiver_thread_no) continue; void *dummy_return_status; - NdbThread_WaitFor(threads[thr_no], &dummy_return_status); - NdbThread_Destroy(&(threads[thr_no])); + NdbThread_WaitFor(rep->m_thread[thr_no].m_thread, &dummy_return_status); + NdbThread_Destroy(&(rep->m_thread[thr_no].m_thread)); } } === modified file 'storage/ndb/src/kernel/vm/ndbd_malloc_impl.cpp' --- a/storage/ndb/src/kernel/vm/ndbd_malloc_impl.cpp 2008-08-21 06:39:11 +0000 +++ b/storage/ndb/src/kernel/vm/ndbd_malloc_impl.cpp 2008-11-07 11:00:38 +0000 @@ -289,7 +289,7 @@ Ndbd_mem_manager::init(Uint32 *watchCoun m_resource_limit[0].m_min = pages; } - g_eventLogger->info("Ndbd_mem_manager::init(%d) min: %dMb initial: %dMb", + g_eventLogger->info("Ndbd_mem_manager::init(%d) min: %ldMb initial: %ldMb", alloc_less_memory, (sizeof(Alloc_page)*m_resource_limit[0].m_min)>>20, (sizeof(Alloc_page)*pages)>>20); === modified file 'storage/ndb/src/mgmsrv/ConfigInfo.cpp' --- a/storage/ndb/src/mgmsrv/ConfigInfo.cpp 2008-11-03 08:36:33 +0000 +++ b/storage/ndb/src/mgmsrv/ConfigInfo.cpp 2008-11-07 13:23:15 +0000 @@ -622,11 +622,11 @@ const ConfigInfo::ParamInfo ConfigInfo:: CFG_DB_EXECUTE_LOCK_CPU, "LockExecuteThreadToCPU", DB_TOKEN, - "CPU ID indicating which CPU will run the execution thread", + "CPU list indicating which CPU will run the execution thread(s)", ConfigInfo::CI_USED, true, - ConfigInfo::CI_INT, - "65535", + ConfigInfo::CI_STRING, + UNDEFINED, "0", "65535" }, @@ -638,7 +638,7 @@ const ConfigInfo::ParamInfo ConfigInfo:: ConfigInfo::CI_USED, true, ConfigInfo::CI_INT, - "65535", + UNDEFINED, "0", "65535" }, === modified file 'storage/ndb/src/mgmsrv/Services.cpp' --- a/storage/ndb/src/mgmsrv/Services.cpp 2008-11-06 10:56:21 +0000 +++ b/storage/ndb/src/mgmsrv/Services.cpp 2008-11-07 11:00:38 +0000 @@ -542,7 +542,9 @@ MgmApiSession::get_nodeid(Parser_t::Cont int r = my_getpeername(m_socket, (struct sockaddr*)&addr, &addrlen); if (r != 0 ) { m_output->println(cmd); - m_output->println("result: getpeername(%d) failed, err= %d", m_socket, r); + m_output->println("result: getpeername(" MY_SOCKET_FORMAT \ + ") failed, err= %d", + MY_SOCKET_FORMAT_VALUE(m_socket), r); m_output->println(""); return; } @@ -663,7 +665,7 @@ MgmApiSession::getConfig(Parser_t::Conte m_output->println("get config reply"); m_output->println("result: Ok"); - m_output->println("Content-Length: %d", strlen(tmp_str)); + m_output->println("Content-Length: %ld", strlen(tmp_str)); m_output->println("Content-Type: ndbconfig/octet-stream"); SLEEP_ERROR_INSERTED(2); m_output->println("Content-Transfer-Encoding: base64"); @@ -916,7 +918,7 @@ MgmApiSession::setLogLevel(Parser NDB_MGM_MAX_LOGLEVEL) { m_output->println("set loglevel reply"); - m_output->println("result: Invalid loglevel", errorString.c_str()); + m_output->println("result: Invalid loglevel: %s", errorString.c_str()); m_output->println(""); return; } === modified file 'storage/ndb/src/ndbapi/ObjectMap.cpp' --- a/storage/ndb/src/ndbapi/ObjectMap.cpp 2008-04-22 19:36:05 +0000 +++ b/storage/ndb/src/ndbapi/ObjectMap.cpp 2008-11-07 08:01:33 +0000 @@ -53,7 +53,7 @@ int NdbObjectIdMap::expand(Uint32 incSiz else { NdbMutex_Unlock(m_mutex); - g_eventLogger->error("NdbObjectIdMap::expand: realloc(%u*%u) failed", + g_eventLogger->error("NdbObjectIdMap::expand: realloc(%u*%lu) failed", newSize, sizeof(MapEntry)); return -1; } === modified file 'support-files/compiler_warnings.supp' --- a/support-files/compiler_warnings.supp 2008-10-02 06:57:12 +0000 +++ b/support-files/compiler_warnings.supp 2008-11-07 11:00:38 +0000 @@ -69,6 +69,9 @@ db_vrfy.c : .*comparison is always false .*/storage/ndb/.* : .*is used uninitialized in this function.* .*/storage/ndb/.* : .*unused variable.* +# Ignore warning produced by passing "" to a printf like function +.*/ndb/.* : zero-length printf format string + # allow a little moving space for the warning below mi_packrec.c : .*result of 32-bit shift implicitly converted to 64 bits.* : 560-600