1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
Backport MariaDB 10.2 support into 10.1
diff --git a/cmake/numa.cmake b/cmake/numa.cmake
new file mode 100644
index 000000000000..d5234a5ef4f6
--- /dev/null
+++ b/cmake/numa.cmake
@@ -0,0 +1,43 @@
+MACRO (MYSQL_CHECK_NUMA)
+
+ IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
+ 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})
+ IF(HAVE_LIBNUMA)
+ ADD_DEFINITIONS(-DHAVE_LIBNUMA=1)
+ SET(NUMA_LIBRARY "numa")
+ ENDIF()
+ ENDIF()
+
+ IF(WITH_NUMA AND NOT HAVE_LIBNUMA)
+ # Forget it in cache, abort the build.
+ UNSET(WITH_NUMA CACHE)
+ UNSET(NUMA_LIBRARY CACHE)
+ MESSAGE(FATAL_ERROR "Could not find numa headers/libraries")
+ ENDIF()
+ ENDIF()
+
+ENDMACRO()
+
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 000000000000..c1c2bb26b8ac
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/innodb_numa_interleave_basic-master.opt
@@ -0,0 +1,1 @@
+--loose-innodb_numa_interleave=1
diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt
index 7e667d5ebb29..c80ef6f09937 100644
--- a/storage/innobase/CMakeLists.txt
+++ b/storage/innobase/CMakeLists.txt
@@ -23,12 +23,14 @@ INCLUDE(lzo)
INCLUDE(lzma)
INCLUDE(bzip2)
INCLUDE(snappy)
+INCLUDE(numa)
MYSQL_CHECK_LZ4()
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
@@ -63,5 +63,2 @@
ENDIF()
ADD_DEFINITIONS("-DUNIV_LINUX -D_GNU_SOURCE=1")
- IF(HAVE_LIBNUMA)
- LINK_LIBRARIES(numa)
- ENDIF()
@@ -517,6 +517,10 @@
MYSQL_ADD_PLUGIN(innobase ${INNOBASE_SOURCES} STORAGE_ENGINE
MODULE_ONLY
MODULE_OUTPUT_NAME ha_innodb
- LINK_LIBRARIES ${ZLIB_LIBRARY} ${LIBSYSTEMD} ${LINKER_SCRIPT})
+ LINK_LIBRARIES
+ ${ZLIB_LIBRARY}
+ ${NUMA_LIBRARY}
+ ${LIBSYSTEMD}
+ ${LINKER_SCRIPT})
ADD_DEPENDENCIES(innobase GenError)
diff --git a/storage/xtradb/CMakeLists.txt b/storage/xtradb/CMakeLists.txt
index 7d2a3fad56dc..51e24b3cd8a2 100644
--- a/storage/xtradb/CMakeLists.txt
+++ b/storage/xtradb/CMakeLists.txt
@@ -23,12 +23,14 @@ INCLUDE(lzo)
INCLUDE(lzma)
INCLUDE(bzip2)
INCLUDE(snappy)
+INCLUDE(numa)
MYSQL_CHECK_LZ4()
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
@@ -63,5 +63,2 @@
ENDIF()
ADD_DEFINITIONS("-DUNIV_LINUX -D_GNU_SOURCE=1")
- IF(HAVE_LIBNUMA)
- LINK_LIBRARIES(numa)
- ENDIF()
@@ -507,6 +507,9 @@
MYSQL_ADD_PLUGIN(xtradb ${INNOBASE_SOURCES} STORAGE_ENGINE
DEFAULT RECOMPILE_FOR_EMBEDDED
- LINK_LIBRARIES ${ZLIB_LIBRARY} ${LINKER_SCRIPT})
+ LINK_LIBRARIES
+ ${ZLIB_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/mysql-test/include/have_numa.inc b/mysql-test/include/have_numa.inc
new file mode 100644
index 000000000000..18bca99e04d7
--- /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 000000000000..21ed16c1dab8
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/innodb_numa_interleave_basic.result
@@ -0,0 +1,11 @@
+call mtr.add_suppression("InnoDB: Failed to set NUMA memory policy");
+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.test b/mysql-test/suite/sys_vars/t/innodb_numa_interleave_basic.test
new file mode 100644
index 000000000000..518b5ebba177
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/innodb_numa_interleave_basic.test
@@ -0,0 +1,15 @@
+--source include/have_innodb.inc
+--source include/have_numa.inc
+
+call mtr.add_suppression("InnoDB: Failed to set NUMA memory policy");
+
+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/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result
index 87e000faf025..ad6dcc1bb643 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result
+++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result
@@ -2,6 +2,7 @@ select * from information_schema.system_variables
where variable_name like 'innodb%' and
variable_name not in (
'innodb_disallow_writes', # only available WITH_WSREP
+'innodb_numa_interleave', # only available WITH_NUMA
'innodb_sched_priority_cleaner', # linux only
'innodb_use_native_aio') # default value depends on OS
order by variable_name;
diff --git a/mysql-test/suite/sys_vars/t/sysvars_innodb.test b/mysql-test/suite/sys_vars/t/sysvars_innodb.test
index bd8442b6a443..38f248cb6113 100644
--- a/mysql-test/suite/sys_vars/t/sysvars_innodb.test
+++ b/mysql-test/suite/sys_vars/t/sysvars_innodb.test
@@ -9,6 +9,7 @@ select * from information_schema.system_variables
where variable_name like 'innodb%' and
variable_name not in (
'innodb_disallow_writes', # only available WITH_WSREP
+ 'innodb_numa_interleave', # only available WITH_NUMA
'innodb_sched_priority_cleaner', # linux only
'innodb_use_native_aio') # default value depends on OS
order by variable_name;
|