diff options
author | Jan Lindström <jan.lindstrom@mariadb.com> | 2016-10-24 09:07:49 +0300 |
---|---|---|
committer | Jan Lindström <jan.lindstrom@mariadb.com> | 2016-10-24 09:07:49 +0300 |
commit | f35f61b5a97ed985663c95c0c9eada923a4027f3 (patch) | |
tree | 7d3393ac03800dd216d089e89368990c25a7fb7c | |
parent | 1de147fcefd22678f8f5724cc08e581a11ff04b4 (diff) | |
parent | f05dfbebccf415ab5f9f9ee4253478636baf9b34 (diff) | |
download | mariadb-git-f35f61b5a97ed985663c95c0c9eada923a4027f3.tar.gz |
Merge branch '10.2-numa' of https://github.com/grooverdan/mariadb-server into grooverdan-10.2-numa
-rw-r--r-- | .travis.yml | 1 | ||||
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | cmake/numa.cmake | 38 | ||||
-rw-r--r-- | config.h.cmake | 1 | ||||
-rw-r--r-- | debian/control | 1 | ||||
-rw-r--r-- | mysql-test/include/have_numa.inc | 9 | ||||
-rw-r--r-- | mysql-test/suite/sys_vars/r/innodb_numa_interleave_basic.result | 10 | ||||
-rw-r--r-- | mysql-test/suite/sys_vars/t/innodb_numa_interleave_basic-master.opt | 1 | ||||
-rw-r--r-- | mysql-test/suite/sys_vars/t/innodb_numa_interleave_basic.test | 14 | ||||
-rw-r--r-- | storage/innobase/CMakeLists.txt | 12 | ||||
-rw-r--r-- | storage/innobase/buf/buf0buf.cc | 10 | ||||
-rw-r--r-- | storage/xtradb/CMakeLists.txt | 12 | ||||
-rw-r--r-- | storage/xtradb/buf/buf0buf.cc | 11 |
13 files changed, 111 insertions, 10 deletions
diff --git a/.travis.yml b/.travis.yml index d850a0d681e..24ccd522868 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,6 +28,7 @@ addons: - libpam0g-dev - libreadline-gplv2-dev - libssl-dev + - libnuma-dev - lsb-release - perl - po-debconf diff --git a/CMakeLists.txt b/CMakeLists.txt index 4272699cb4e..d0e5cf87475 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -162,6 +162,7 @@ INCLUDE(install_macros) INCLUDE(systemd) INCLUDE(mysql_add_executable) INCLUDE(crc32-vpmsum) +INCLUDE(numa) # Handle options OPTION(DISABLE_SHARED diff --git a/cmake/numa.cmake b/cmake/numa.cmake new file mode 100644 index 00000000000..d5234a5ef4f --- /dev/null +++ b/cmake/numa.cmake @@ -0,0 +1,38 @@ +MACRO (MYSQL_CHECK_NUMA) + + CHECK_INCLUDE_FILES(numa.h HAVE_NUMA_H) + CHECK_INCLUDE_FILES(numaif.h HAVE_NUMAIF_H) + + IF(HAVE_NUMA_H AND HAVE_NUMAIF_H) + OPTION(WITH_NUMA "Explicitly set NUMA memory allocation policy" ON) + ELSE() + OPTION(WITH_NUMA "Explicitly set NUMA memory allocation policy" OFF) + ENDIF() + + IF(WITH_NUMA AND HAVE_NUMA_H AND HAVE_NUMAIF_H) + SET(SAVE_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) + SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} numa) + CHECK_C_SOURCE_COMPILES( + " + #include <numa.h> + #include <numaif.h> + int main() + { + struct bitmask *all_nodes= numa_all_nodes_ptr; + set_mempolicy(MPOL_DEFAULT, 0, 0); + return all_nodes != NULL; + }" + HAVE_LIBNUMA) + SET(CMAKE_REQUIRED_LIBRARIES ${SAVE_CMAKE_REQUIRED_LIBRARIES}) + ELSE() + SET(HAVE_LIBNUMA 0) + ENDIF() + + IF(WITH_NUMA AND NOT HAVE_LIBNUMA) + # Forget it in cache, abort the build. + UNSET(WITH_NUMA CACHE) + MESSAGE(FATAL_ERROR "Could not find numa headers/libraries") + ENDIF() + +ENDMACRO() + diff --git a/config.h.cmake b/config.h.cmake index 00aa03483ee..08b0422a520 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -106,6 +106,7 @@ #cmakedefine HAVE_LIBWRAP 1 #cmakedefine HAVE_SYSTEMD 1 #cmakedefine HAVE_CRC32_VPMSUM 1 +#cmakedefine HAVE_LIBNUMA 1 /* Does "struct timespec" have a "sec" and "nsec" field? */ #cmakedefine HAVE_TIMESPEC_TS_SEC 1 diff --git a/debian/control b/debian/control index 0c34ae61b7e..1941b84c148 100644 --- a/debian/control +++ b/debian/control @@ -19,6 +19,7 @@ Build-Depends: bison, libreadline-gplv2-dev, libssl-dev, libxml2-dev, + libnuma-dev, lsb-release, perl (>= 5.6.0), po-debconf, diff --git a/mysql-test/include/have_numa.inc b/mysql-test/include/have_numa.inc new file mode 100644 index 00000000000..18bca99e04d --- /dev/null +++ b/mysql-test/include/have_numa.inc @@ -0,0 +1,9 @@ +let $numa_support = `SELECT COUNT(VARIABLE_VALUE) = 1 FROM + INFORMATION_SCHEMA.GLOBAL_VARIABLES + WHERE VARIABLE_NAME='innodb_numa_interleave'`; + +if ( $numa_support == 0 ) +{ + --skip Test requires: Binary must be built with NUMA support. +} + diff --git a/mysql-test/suite/sys_vars/r/innodb_numa_interleave_basic.result b/mysql-test/suite/sys_vars/r/innodb_numa_interleave_basic.result new file mode 100644 index 00000000000..21ed16c1dab --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_numa_interleave_basic.result @@ -0,0 +1,10 @@ +SELECT @@GLOBAL.innodb_numa_interleave; +@@GLOBAL.innodb_numa_interleave +1 +SET @@GLOBAL.innodb_numa_interleave=off; +ERROR HY000: Variable 'innodb_numa_interleave' is a read only variable +SELECT @@GLOBAL.innodb_numa_interleave; +@@GLOBAL.innodb_numa_interleave +1 +SELECT @@SESSION.innodb_numa_interleave; +ERROR HY000: Variable 'innodb_numa_interleave' is a GLOBAL variable diff --git a/mysql-test/suite/sys_vars/t/innodb_numa_interleave_basic-master.opt b/mysql-test/suite/sys_vars/t/innodb_numa_interleave_basic-master.opt new file mode 100644 index 00000000000..c1c2bb26b8a --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_numa_interleave_basic-master.opt @@ -0,0 +1 @@ +--loose-innodb_numa_interleave=1 diff --git a/mysql-test/suite/sys_vars/t/innodb_numa_interleave_basic.test b/mysql-test/suite/sys_vars/t/innodb_numa_interleave_basic.test new file mode 100644 index 00000000000..518b5ebba17 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_numa_interleave_basic.test @@ -0,0 +1,14 @@ +--source include/have_innodb.inc +--source include/have_numa.inc +--source include/have_64bit.inc + +SELECT @@GLOBAL.innodb_numa_interleave; + +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@GLOBAL.innodb_numa_interleave=off; + +SELECT @@GLOBAL.innodb_numa_interleave; + +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@SESSION.innodb_numa_interleave; + diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index 446e971aacf..d9b50935d27 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -30,6 +30,7 @@ MYSQL_CHECK_LZO() MYSQL_CHECK_LZMA() MYSQL_CHECK_BZIP2() MYSQL_CHECK_SNAPPY() +MYSQL_CHECK_NUMA() INCLUDE(innodb.cmake) @@ -173,11 +174,20 @@ IF(WITH_INNODB) SET(WITH_INNOBASE_STORAGE_ENGINE TRUE) ENDIF() +UNSET(NUMA_LIBRARY) +IF(HAVE_LIBNUMA) + SET(NUMA_LIBRARY "numa") +ENDIF() + MYSQL_ADD_PLUGIN(innobase ${INNOBASE_SOURCES} STORAGE_ENGINE # MODULE_ONLY # MODULE_OUTPUT_NAME ha_innodb DEFAULT RECOMPILE_FOR_EMBEDDED - LINK_LIBRARIES ${ZLIB_LIBRARY} ${CRC32_VPMSUM_LIBRARY} ${LINKER_SCRIPT}) + LINK_LIBRARIES + ${ZLIB_LIBRARY} + ${CRC32_VPMSUM_LIBRARY} + ${NUMA_LIBRARY} + ${LINKER_SCRIPT}) IF(WITH_INNOBASE_STORAGE_ENGINE) ADD_DEPENDENCIES(innobase GenError) diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index e187297b231..12d073bf10f 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -96,11 +96,12 @@ struct set_numa_interleave_t { if (srv_numa_interleave) { + struct bitmask *numa_mems_allowed = numa_get_mems_allowed(); ib::info() << "Setting NUMA memory policy to" " MPOL_INTERLEAVE"; if (set_mempolicy(MPOL_INTERLEAVE, - numa_all_nodes_ptr->maskp, - numa_all_nodes_ptr->size) != 0) { + numa_mems_allowed->maskp, + numa_mems_allowed->size) != 0) { ib::warn() << "Failed to set NUMA memory" " policy to MPOL_INTERLEAVE: " @@ -1555,10 +1556,11 @@ buf_chunk_init( #if defined(HAVE_LIBNUMA) && defined(WITH_NUMA) if (srv_numa_interleave) { + struct bitmask *numa_mems_allowed = numa_get_mems_allowed(); int st = mbind(chunk->mem, chunk->mem_size(), MPOL_INTERLEAVE, - numa_all_nodes_ptr->maskp, - numa_all_nodes_ptr->size, + numa_mems_allowed->maskp, + numa_mems_allowed->size, MPOL_MF_MOVE); if (st != 0) { ib::warn() << "Failed to set NUMA memory policy of" diff --git a/storage/xtradb/CMakeLists.txt b/storage/xtradb/CMakeLists.txt index 22897a3b315..7e0bb9103d2 100644 --- a/storage/xtradb/CMakeLists.txt +++ b/storage/xtradb/CMakeLists.txt @@ -29,6 +29,7 @@ MYSQL_CHECK_LZO() MYSQL_CHECK_LZMA() MYSQL_CHECK_BZIP2() MYSQL_CHECK_SNAPPY() +MYSQL_CHECK_NUMA() IF(CMAKE_CROSSCOMPILING) # Use CHECK_C_SOURCE_COMPILES instead of CHECK_C_SOURCE_RUNS when @@ -496,10 +497,19 @@ SET(INNOBASE_SOURCES ut/ut0wqueue.cc ut/ut0timer.cc) +UNSET(NUMA_LIBRARY) +IF(HAVE_LIBNUMA) + SET(NUMA_LIBRARY "numa") +ENDIF() + MYSQL_ADD_PLUGIN(xtradb ${INNOBASE_SOURCES} STORAGE_ENGINE DISABLED # until upgraded to 5.7, see also mysql-test/include/have_xtradb.combinations RECOMPILE_FOR_EMBEDDED - LINK_LIBRARIES ${ZLIB_LIBRARY} ${CRC32_VPMSUM_LIBRARY} ${LINKER_SCRIPT}) + LINK_LIBRARIES + ${ZLIB_LIBRARY} + ${CRC32_VPMSUM_LIBRARY} + ${NUMA_LIBRARY} + ${LINKER_SCRIPT}) IF(TARGET xtradb AND NOT XTRADB_OK) MESSAGE(FATAL_ERROR "Percona XtraDB is not supported on this platform") diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc index 37b9eaac9c2..6e7f0e44c79 100644 --- a/storage/xtradb/buf/buf0buf.cc +++ b/storage/xtradb/buf/buf0buf.cc @@ -1235,10 +1235,11 @@ buf_chunk_init( #ifdef HAVE_LIBNUMA if (srv_numa_interleave) { + struct bitmask *numa_mems_allowed = numa_get_mems_allowed(); int st = mbind(chunk->mem, chunk->mem_size, MPOL_INTERLEAVE, - numa_all_nodes_ptr->maskp, - numa_all_nodes_ptr->size, + numa_mems_allowed->maskp, + numa_mems_allowed->size, MPOL_MF_MOVE); if (st != 0) { ib_logf(IB_LOG_LEVEL_WARN, @@ -1645,11 +1646,13 @@ buf_pool_init( #ifdef HAVE_LIBNUMA if (srv_numa_interleave) { + struct bitmask *numa_mems_allowed = numa_get_mems_allowed(); + ib_logf(IB_LOG_LEVEL_INFO, "Setting NUMA memory policy to MPOL_INTERLEAVE"); if (set_mempolicy(MPOL_INTERLEAVE, - numa_all_nodes_ptr->maskp, - numa_all_nodes_ptr->size) != 0) { + numa_mems_allowed->maskp, + numa_mems_allowed->size) != 0) { ib_logf(IB_LOG_LEVEL_WARN, "Failed to set NUMA memory policy to" " MPOL_INTERLEAVE (error: %s).", |