mirror of
https://github.com/MariaDB/server.git
synced 2026-10-23 18:49:29 +03:00
my_large_malloc() attempted large pages whenever --large-pages was enabled, silently rounding the size up and reporting it back via an in/out parameter. ut_malloc_dontdump() never passed that adjusted size on to its own callers (the InnoDB redo log buffer and recv_sys_t::tmp_buf), so freeing later used the original, smaller size, causing the reported "faux memory leak". Only the buffer pool and the MyISAM/Aria key caches are documented to benefit from large pages. Everything else that ended up calling my_large_malloc() only wanted its "do not dump to core" property and picked up large pages as an undocumented side effect; those buffers are also small and sequentially accessed, so they would have gained little from large pages anyway. Add MY_TRY_LARGE_PAGES: my_large_malloc() and my_large_virtual_alloc() now only attempt large pages when a caller passes this flag, instead of always trying whenever the global option is set. Only the buffer pool and the key caches pass it. The redo log buffer, tmp_buf, and row0log.cc's crypt buffers no longer request large pages at all, which removes the size-rounding bug for them without touching that code. my_large_virtual_alloc()'s fallback (no usable large page size) must also return read-write memory right away, like the Windows large-pages fallback already does, since my_virtual_mem_commit() is a no-op for MY_TRY_LARGE_PAGES. my_large_pages_flag is now set once, in my_init_large_pages(), and never changed thereafter, on any platform. Both my_virtual_mem_commit() and my_virtual_mem_decommit() are now no-ops, aside from accounting, whenever large pages are requested. Also fix a broken mtr suppression regex in main.large_pages that would fail the test on Windows.
40 lines
1.3 KiB
C
40 lines
1.3 KiB
C
/* Copyright (c) 2025, 2026, MariaDB plc.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
|
|
|
|
#pragma once
|
|
/*
|
|
Functionality for handling virtual memory
|
|
(reserve, commit, decommit, release)
|
|
*/
|
|
#include <stddef.h> /*size_t*/
|
|
#include <my_global.h> /*myf*/
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
enum my_vmem_prot { MY_VMEM_READONLY= 0, MY_VMEM_READWRITE };
|
|
|
|
char *my_virtual_mem_reserve(size_t *size, myf my_flags);
|
|
char *my_virtual_mem_commit(char *ptr, size_t size, myf my_flags);
|
|
void my_virtual_mem_decommit(char *ptr, size_t size, myf my_flags);
|
|
void my_virtual_mem_release(char *ptr, size_t size);
|
|
void my_virtual_mem_protect(void *ptr, size_t size, enum my_vmem_prot prot);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|