Commit a1f0a339 authored by Jan Lindström's avatar Jan Lindström

Merge branch 'grooverdan-10.2-numa' into 10.2

parents 1de147fc f35f61b5
...@@ -28,6 +28,7 @@ addons: ...@@ -28,6 +28,7 @@ addons:
- libpam0g-dev - libpam0g-dev
- libreadline-gplv2-dev - libreadline-gplv2-dev
- libssl-dev - libssl-dev
- libnuma-dev
- lsb-release - lsb-release
- perl - perl
- po-debconf - po-debconf
......
...@@ -162,6 +162,7 @@ INCLUDE(install_macros) ...@@ -162,6 +162,7 @@ INCLUDE(install_macros)
INCLUDE(systemd) INCLUDE(systemd)
INCLUDE(mysql_add_executable) INCLUDE(mysql_add_executable)
INCLUDE(crc32-vpmsum) INCLUDE(crc32-vpmsum)
INCLUDE(numa)
# Handle options # Handle options
OPTION(DISABLE_SHARED OPTION(DISABLE_SHARED
......
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()
...@@ -106,6 +106,7 @@ ...@@ -106,6 +106,7 @@
#cmakedefine HAVE_LIBWRAP 1 #cmakedefine HAVE_LIBWRAP 1
#cmakedefine HAVE_SYSTEMD 1 #cmakedefine HAVE_SYSTEMD 1
#cmakedefine HAVE_CRC32_VPMSUM 1 #cmakedefine HAVE_CRC32_VPMSUM 1
#cmakedefine HAVE_LIBNUMA 1
/* Does "struct timespec" have a "sec" and "nsec" field? */ /* Does "struct timespec" have a "sec" and "nsec" field? */
#cmakedefine HAVE_TIMESPEC_TS_SEC 1 #cmakedefine HAVE_TIMESPEC_TS_SEC 1
......
...@@ -19,6 +19,7 @@ Build-Depends: bison, ...@@ -19,6 +19,7 @@ Build-Depends: bison,
libreadline-gplv2-dev, libreadline-gplv2-dev,
libssl-dev, libssl-dev,
libxml2-dev, libxml2-dev,
libnuma-dev,
lsb-release, lsb-release,
perl (>= 5.6.0), perl (>= 5.6.0),
po-debconf, po-debconf,
......
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.
}
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
--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;
...@@ -30,6 +30,7 @@ MYSQL_CHECK_LZO() ...@@ -30,6 +30,7 @@ MYSQL_CHECK_LZO()
MYSQL_CHECK_LZMA() MYSQL_CHECK_LZMA()
MYSQL_CHECK_BZIP2() MYSQL_CHECK_BZIP2()
MYSQL_CHECK_SNAPPY() MYSQL_CHECK_SNAPPY()
MYSQL_CHECK_NUMA()
INCLUDE(innodb.cmake) INCLUDE(innodb.cmake)
...@@ -173,11 +174,20 @@ IF(WITH_INNODB) ...@@ -173,11 +174,20 @@ IF(WITH_INNODB)
SET(WITH_INNOBASE_STORAGE_ENGINE TRUE) SET(WITH_INNOBASE_STORAGE_ENGINE TRUE)
ENDIF() ENDIF()
UNSET(NUMA_LIBRARY)
IF(HAVE_LIBNUMA)
SET(NUMA_LIBRARY "numa")
ENDIF()
MYSQL_ADD_PLUGIN(innobase ${INNOBASE_SOURCES} STORAGE_ENGINE MYSQL_ADD_PLUGIN(innobase ${INNOBASE_SOURCES} STORAGE_ENGINE
# MODULE_ONLY # MODULE_ONLY
# MODULE_OUTPUT_NAME ha_innodb # MODULE_OUTPUT_NAME ha_innodb
DEFAULT RECOMPILE_FOR_EMBEDDED 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) IF(WITH_INNOBASE_STORAGE_ENGINE)
ADD_DEPENDENCIES(innobase GenError) ADD_DEPENDENCIES(innobase GenError)
......
...@@ -96,11 +96,12 @@ struct set_numa_interleave_t ...@@ -96,11 +96,12 @@ struct set_numa_interleave_t
{ {
if (srv_numa_interleave) { if (srv_numa_interleave) {
struct bitmask *numa_mems_allowed = numa_get_mems_allowed();
ib::info() << "Setting NUMA memory policy to" ib::info() << "Setting NUMA memory policy to"
" MPOL_INTERLEAVE"; " MPOL_INTERLEAVE";
if (set_mempolicy(MPOL_INTERLEAVE, if (set_mempolicy(MPOL_INTERLEAVE,
numa_all_nodes_ptr->maskp, numa_mems_allowed->maskp,
numa_all_nodes_ptr->size) != 0) { numa_mems_allowed->size) != 0) {
ib::warn() << "Failed to set NUMA memory" ib::warn() << "Failed to set NUMA memory"
" policy to MPOL_INTERLEAVE: " " policy to MPOL_INTERLEAVE: "
...@@ -1555,10 +1556,11 @@ buf_chunk_init( ...@@ -1555,10 +1556,11 @@ buf_chunk_init(
#if defined(HAVE_LIBNUMA) && defined(WITH_NUMA) #if defined(HAVE_LIBNUMA) && defined(WITH_NUMA)
if (srv_numa_interleave) { if (srv_numa_interleave) {
struct bitmask *numa_mems_allowed = numa_get_mems_allowed();
int st = mbind(chunk->mem, chunk->mem_size(), int st = mbind(chunk->mem, chunk->mem_size(),
MPOL_INTERLEAVE, MPOL_INTERLEAVE,
numa_all_nodes_ptr->maskp, numa_mems_allowed->maskp,
numa_all_nodes_ptr->size, numa_mems_allowed->size,
MPOL_MF_MOVE); MPOL_MF_MOVE);
if (st != 0) { if (st != 0) {
ib::warn() << "Failed to set NUMA memory policy of" ib::warn() << "Failed to set NUMA memory policy of"
......
...@@ -29,6 +29,7 @@ MYSQL_CHECK_LZO() ...@@ -29,6 +29,7 @@ MYSQL_CHECK_LZO()
MYSQL_CHECK_LZMA() MYSQL_CHECK_LZMA()
MYSQL_CHECK_BZIP2() MYSQL_CHECK_BZIP2()
MYSQL_CHECK_SNAPPY() MYSQL_CHECK_SNAPPY()
MYSQL_CHECK_NUMA()
IF(CMAKE_CROSSCOMPILING) IF(CMAKE_CROSSCOMPILING)
# Use CHECK_C_SOURCE_COMPILES instead of CHECK_C_SOURCE_RUNS when # Use CHECK_C_SOURCE_COMPILES instead of CHECK_C_SOURCE_RUNS when
...@@ -496,10 +497,19 @@ SET(INNOBASE_SOURCES ...@@ -496,10 +497,19 @@ SET(INNOBASE_SOURCES
ut/ut0wqueue.cc ut/ut0wqueue.cc
ut/ut0timer.cc) ut/ut0timer.cc)
UNSET(NUMA_LIBRARY)
IF(HAVE_LIBNUMA)
SET(NUMA_LIBRARY "numa")
ENDIF()
MYSQL_ADD_PLUGIN(xtradb ${INNOBASE_SOURCES} STORAGE_ENGINE MYSQL_ADD_PLUGIN(xtradb ${INNOBASE_SOURCES} STORAGE_ENGINE
DISABLED # until upgraded to 5.7, see also mysql-test/include/have_xtradb.combinations DISABLED # until upgraded to 5.7, see also mysql-test/include/have_xtradb.combinations
RECOMPILE_FOR_EMBEDDED 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) IF(TARGET xtradb AND NOT XTRADB_OK)
MESSAGE(FATAL_ERROR "Percona XtraDB is not supported on this platform") MESSAGE(FATAL_ERROR "Percona XtraDB is not supported on this platform")
......
...@@ -1235,10 +1235,11 @@ buf_chunk_init( ...@@ -1235,10 +1235,11 @@ buf_chunk_init(
#ifdef HAVE_LIBNUMA #ifdef HAVE_LIBNUMA
if (srv_numa_interleave) { if (srv_numa_interleave) {
struct bitmask *numa_mems_allowed = numa_get_mems_allowed();
int st = mbind(chunk->mem, chunk->mem_size, int st = mbind(chunk->mem, chunk->mem_size,
MPOL_INTERLEAVE, MPOL_INTERLEAVE,
numa_all_nodes_ptr->maskp, numa_mems_allowed->maskp,
numa_all_nodes_ptr->size, numa_mems_allowed->size,
MPOL_MF_MOVE); MPOL_MF_MOVE);
if (st != 0) { if (st != 0) {
ib_logf(IB_LOG_LEVEL_WARN, ib_logf(IB_LOG_LEVEL_WARN,
...@@ -1645,11 +1646,13 @@ buf_pool_init( ...@@ -1645,11 +1646,13 @@ buf_pool_init(
#ifdef HAVE_LIBNUMA #ifdef HAVE_LIBNUMA
if (srv_numa_interleave) { if (srv_numa_interleave) {
struct bitmask *numa_mems_allowed = numa_get_mems_allowed();
ib_logf(IB_LOG_LEVEL_INFO, ib_logf(IB_LOG_LEVEL_INFO,
"Setting NUMA memory policy to MPOL_INTERLEAVE"); "Setting NUMA memory policy to MPOL_INTERLEAVE");
if (set_mempolicy(MPOL_INTERLEAVE, if (set_mempolicy(MPOL_INTERLEAVE,
numa_all_nodes_ptr->maskp, numa_mems_allowed->maskp,
numa_all_nodes_ptr->size) != 0) { numa_mems_allowed->size) != 0) {
ib_logf(IB_LOG_LEVEL_WARN, ib_logf(IB_LOG_LEVEL_WARN,
"Failed to set NUMA memory policy to" "Failed to set NUMA memory policy to"
" MPOL_INTERLEAVE (error: %s).", " MPOL_INTERLEAVE (error: %s).",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment