MySQL 8.0.39
Source Code Documentation
|
Helper struct implementing the type which represents the metadata for all types of page-aligned allocations, be it regular pages or huge-pages. More...
#include <page_metadata.h>
Public Types | |
using | datalen_t = size_t |
These are the types representing our memory fields. More... | |
using | page_type_t = size_t |
Static Public Member Functions | |
static datalen_t | datalen (void *data) |
Sanity check so that we can be sure that the size of our metadata segment is such so that the next segment coming after it (DATA) is always suitably aligned (multiple of alignof(max_align_t). More... | |
static Page_type | page_type (void *data) |
Accessor to the page_type_t field. More... | |
static void | datalen (void *mem, size_t length) |
Accessor to the datalen_t field. More... | |
static void | page_type (void *mem, Page_type type) |
Accessor to the page_type_t field. More... | |
Static Public Attributes | |
static constexpr auto | len = CPU_PAGE_SIZE |
This is how much tise metadata segment will be big. More... | |
Helper struct implementing the type which represents the metadata for all types of page-aligned allocations, be it regular pages or huge-pages.
Concrete implementations such as Page_alloc or Large_page_alloc are both implemented in terms of this basic building block. This is one way which enables an easier implementation of higher-kinded convenience library functions, e.g. huge-page allocation with fallback to regular pages.
Memory layout representation looks like the following:
\ \ 0 \ CPU_PAGE_SIZE - 1
DATALEN field encodes total size of memory consumed and not only the size of the DATA segment.
PAGE-TYPE field encodes the type of page this memory is backed up with.
VARLEN is the leftover variable-length segment that specialized implementations can further make use of by deducing its size from the following formulae: abs(CPU_PAGE_SIZE - sizeof(DATALEN) - sizeof(PAGE-TYPE)). In code that would be std::abs(CPU_PAGE_SIZE - sizeof(Page_alloc_metadata::datalen_t) - sizeof(Page_alloc_metadata::page_type_t)). Not used by this implementation.
using ut::detail::Page_alloc_metadata::datalen_t = size_t |
These are the types representing our memory fields.
using ut::detail::Page_alloc_metadata::page_type_t = size_t |
|
inlinestatic |
Sanity check so that we can be sure that the size of our metadata segment is such so that the next segment coming after it (DATA) is always suitably aligned (multiple of alignof(max_align_t).
Sanity check so that we can be sure that our metadata segment can fit all our fields (datalen_t and page_type_t). Accessor to the datalen_t field. Returns its value.
[in] | data | Pointer to the DATA segment. |
|
inlinestatic |
Accessor to the datalen_t field.
Sets its value.
[in] | mem | Pointer to the memory, usually allocated through large_page_alloc or page_alloc. |
[in] | length | New value to be set into the field. |
|
inlinestatic |
Accessor to the page_type_t field.
Returns its value.
[in] | data | Pointer to the DATA segment. |
|
inlinestatic |
Accessor to the page_type_t field.
Sets its value.
[in] | mem | Pointer to the memory, usually allocated through large_page_alloc or page_alloc. |
[in] | type | New value to be set into the field. |
|
staticconstexpr |
This is how much tise metadata segment will be big.