MySQL 8.0.40
Source Code Documentation
|
Allocation routines which are purposed for allocating system page-aligned memory. More...
#include <page_alloc.h>
Public Types | |
using | page_allocation_metadata = Page_alloc_metadata |
Static Public Member Functions | |
static void * | alloc (std::size_t size) |
Allocates memory through large-page support. More... | |
static bool | free (void *data) noexcept |
Releases storage allocated through Page_alloc::alloc(). More... | |
static page_allocation_metadata::datalen_t | datalen (void *data) |
Returns the number of bytes that have been allocated. More... | |
static Page_type | page_type (void *data) |
Returns the the type of the page. More... | |
static allocation_low_level_info | low_level_info (void *data) |
Retrieves the pointer and size of the allocation provided by the OS. More... | |
Static Private Member Functions | |
static void * | deduce (void *data) noexcept |
Helper function which deduces the original pointer returned by Page_alloc from a pointer which is passed to us by the call-site. More... | |
Additional Inherited Members | |
Static Public Attributes inherited from ut::detail::allocator_traits< false > | |
static constexpr auto | is_pfs_instrumented_v |
Allocation routines which are purposed for allocating system page-aligned memory.
page_aligned_alloc() and page_aligned_free() are taking care of OS specific details and Page_alloc is a convenience wrapper which only makes the use of system page-aligned memory more ergonomic so that it serializes the actual size being allocated into the raw memory. This size is then automagically deduced when system page-aligned memory is being freed. Otherwise, client code would have been responsible to store and keep that value somewhere until the memory segment is freed. Additionally, information on type of page used to back up requested allocation is also serialized into the memory allowing to build higher-kinded abstractions more easily. See ut::malloc_large_page with option to fallback to regular pages through ut::malloc_page.
Cost associated with this abstraction is the size of a single CPU page. In terms of virtual memory, especially in 64-bit address space, this cost is negligible. In practice this means that for each N pages allocation request there will be N+1 pages allocated beneath.
Memory layout representation looks like the following:
^ ^ | | | | | ptr (system-page) to be | returned to call-site
^ | | ptr returned by page_aligned_alloc
For details on DATALEN, PAGE-TYPE and VARLEN fields see Page_alloc_metadata.
DATA is an actual page-aligned segment that will be returned to the call-site and which the client code will be able to use for the application data.
|
inlinestatic |
Allocates memory through large-page support.
[in] | size | Size of storage (in bytes) requested to be allocated. |
|
inlinestatic |
Returns the number of bytes that have been allocated.
[in] | data | Pointer to storage allocated through Page_alloc::alloc() |
|
inlinestaticprivatenoexcept |
Helper function which deduces the original pointer returned by Page_alloc from a pointer which is passed to us by the call-site.
|
inlinestaticnoexcept |
Releases storage allocated through Page_alloc::alloc().
[in] | data | Pointer to storage allocated through Page_alloc::alloc() |
|
inlinestatic |
Retrieves the pointer and size of the allocation provided by the OS.
It is a low level information, and is needed only to call low level memory-related OS functions.
[in] | data | Pointer to storage allocated through Page_alloc::alloc() |
|
inlinestatic |
Returns the the type of the page.
[in] | data | Pointer to storage allocated through Page_alloc::alloc() |