diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2022-06-22 08:34:29 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2022-06-22 08:34:29 +0300 |
commit | 8ebff3bcb02e4185328542a2755e2f44e79465ec (patch) | |
tree | e1bb0e30d8aa66545c2a2fb3e05ca0483c9a7964 | |
parent | 6680fd8d4b1f5fa8488608ca9e528e56f338dba4 (diff) | |
parent | 0fa19fdebf0925be6ec5503938d541332f259cb5 (diff) | |
download | mariadb-git-8ebff3bcb02e4185328542a2755e2f44e79465ec.tar.gz |
Merge 10.6 into 10.7
-rw-r--r-- | configure.cmake | 9 | ||||
-rw-r--r-- | include/aligned.h | 7 | ||||
-rw-r--r-- | storage/innobase/buf/buf0flu.cc | 12 | ||||
-rw-r--r-- | storage/perfschema/unittest/stub_pfs_global.h | 4 |
4 files changed, 29 insertions, 3 deletions
diff --git a/configure.cmake b/configure.cmake index 6db53ba6e8f..5b5f2f911c0 100644 --- a/configure.cmake +++ b/configure.cmake @@ -324,7 +324,14 @@ ENDIF() CHECK_FUNCTION_EXISTS (accept4 HAVE_ACCEPT4) CHECK_FUNCTION_EXISTS (access HAVE_ACCESS) CHECK_FUNCTION_EXISTS (alarm HAVE_ALARM) -CHECK_FUNCTION_EXISTS (aligned_alloc HAVE_ALIGNED_ALLOC) +IF (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT WITH_ASAN) + # When an old custom memory allocator library is used, aligned_alloc() + # could invoke the built-in allocator in libc, not matching + # the overriden free() in the custom memory allocator. + SET(HAVE_ALIGNED_ALLOC 0) +ELSE() + CHECK_FUNCTION_EXISTS (aligned_alloc HAVE_ALIGNED_ALLOC) +ENDIF() SET(HAVE_ALLOCA 1) CHECK_FUNCTION_EXISTS (backtrace HAVE_BACKTRACE) CHECK_FUNCTION_EXISTS (backtrace_symbols HAVE_BACKTRACE_SYMBOLS) diff --git a/include/aligned.h b/include/aligned.h index ad2c7532b26..0ae1f0d0848 100644 --- a/include/aligned.h +++ b/include/aligned.h @@ -14,12 +14,19 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ +#ifdef HAVE_ALIGNED_ALLOC +#elif defined __linux__ +# include <malloc.h> +#endif + inline void *aligned_malloc(size_t size, size_t alignment) { #ifdef _WIN32 return _aligned_malloc(size, alignment); #elif defined HAVE_ALIGNED_ALLOC return aligned_alloc(alignment, size); +#elif defined __linux__ + return memalign(alignment, size); #else void *result; if (posix_memalign(&result, alignment, size)) diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index a9b1a359f0e..d205b78e6b8 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -573,9 +573,19 @@ static void buf_tmp_reserve_compression_buf(buf_tmp_buffer_t* slot) buffer be bigger than input buffer. Adjust the allocated size. */ ulint size= srv_page_size; if (provider_service_lzo->is_loaded) - size+= LZO1X_1_15_MEM_COMPRESS; + { + size= LZO1X_1_15_MEM_COMPRESS; +#ifdef HAVE_ALIGNED_ALLOC + size= MY_ALIGN(size, srv_page_size); +#endif + } else if (provider_service_snappy->is_loaded) + { size= snappy_max_compressed_length(size); +#ifdef HAVE_ALIGNED_ALLOC + size= MY_ALIGN(size, srv_page_size); +#endif + } slot->comp_buf= static_cast<byte*>(aligned_malloc(size, srv_page_size)); } diff --git a/storage/perfschema/unittest/stub_pfs_global.h b/storage/perfschema/unittest/stub_pfs_global.h index 3a3aedb537e..450633ad466 100644 --- a/storage/perfschema/unittest/stub_pfs_global.h +++ b/storage/perfschema/unittest/stub_pfs_global.h @@ -26,6 +26,7 @@ #include <pfs_global.h> #include <string.h> #include "aligned.h" +#include "assume_aligned.h" bool pfs_initialized= false; size_t pfs_allocated_memory_size= 0; @@ -47,9 +48,10 @@ void *pfs_malloc(PFS_builtin_memory_class *klass, size_t size, myf) if (--stub_alloc_fails_after_count <= 0) return NULL; + size= MY_ALIGN(size, CPU_LEVEL1_DCACHE_LINESIZE); void *ptr= aligned_malloc(size, CPU_LEVEL1_DCACHE_LINESIZE); if (ptr != NULL) - memset(ptr, 0, size); + memset_aligned<CPU_LEVEL1_DCACHE_LINESIZE>(ptr, 0, size); return ptr; } |