MySQL 9.0.0
Source Code Documentation
ut::detail::Page_alloc_metadata Struct Reference

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...
 

Detailed Description

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:


| DATALEN | PAGE-TYPE | VARLEN |

\ \ 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.

Member Typedef Documentation

◆ datalen_t

These are the types representing our memory fields.

◆ page_type_t

Member Function Documentation

◆ datalen() [1/2]

static datalen_t ut::detail::Page_alloc_metadata::datalen ( void *  data)
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.

Parameters
[in]dataPointer to the DATA segment.
Returns
Value held by datalen_t field.

◆ datalen() [2/2]

static void ut::detail::Page_alloc_metadata::datalen ( void *  mem,
size_t  length 
)
inlinestatic

Accessor to the datalen_t field.

Sets its value.

Parameters
[in]memPointer to the memory, usually allocated through large_page_alloc or page_alloc.
[in]lengthNew value to be set into the field.

◆ page_type() [1/2]

static Page_type ut::detail::Page_alloc_metadata::page_type ( void *  data)
inlinestatic

Accessor to the page_type_t field.

Returns its value.

Parameters
[in]dataPointer to the DATA segment.
Returns
Value held by page_type_t field, in particular Page_type.

◆ page_type() [2/2]

static void ut::detail::Page_alloc_metadata::page_type ( void *  mem,
Page_type  type 
)
inlinestatic

Accessor to the page_type_t field.

Sets its value.

Parameters
[in]memPointer to the memory, usually allocated through large_page_alloc or page_alloc.
[in]typeNew value to be set into the field.

Member Data Documentation

◆ len

constexpr auto ut::detail::Page_alloc_metadata::len = CPU_PAGE_SIZE
staticconstexpr

This is how much tise metadata segment will be big.


The documentation for this struct was generated from the following file: