MySQL 8.0.40
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
os0numa.h File Reference

NUMA API wrapper over various operating system specific APIs. More...

#include "univ.i"
#include <numa.h>

Go to the source code of this file.

Functions

int os_numa_available ()
 Check if NUMA is available. More...
 
int os_numa_num_configured_cpus ()
 Get the number of CPUs in the system, including disabled ones. More...
 
int os_numa_node_of_cpu (int cpu)
 Get the NUMA node of a given CPU. More...
 
void * os_numa_alloc_onnode (size_t size, int node)
 Allocate a memory on a given NUMA node. More...
 
void os_numa_free (void *ptr, size_t size)
 Free a memory allocated by os_numa_alloc_onnode(). More...
 

Detailed Description

NUMA API wrapper over various operating system specific APIs.

The os_numa*() functions in this file mimic the numa*() Linux API that is documented in numa(3). They take the same arguments, have the same return type and behave in the same way. There are two purposes behind this:

  1. Have zero learning curve for developers already familiar with the Linux API.
  2. Linux's numa*() functions are documented in more detail than ours os_numa*(). Should any doubt arise about the behavior, the Linux docs should be referred.

Created Jul 16, 2015 Vasil Dimov

Function Documentation

◆ os_numa_alloc_onnode()

void * os_numa_alloc_onnode ( size_t  size,
int  node 
)
inline

Allocate a memory on a given NUMA node.

Parameters
[in]sizenumber of bytes to allocate
[in]nodeNUMA node on which to allocate the memory
Returns
pointer to allocated memory or NULL if allocation failed

◆ os_numa_available()

int os_numa_available ( )
inline

Check if NUMA is available.

This function must be called before any other os_numa_*() functions and it must return != -1, otherwise the behavior of the rest of the functions is undefined.

Returns
!= -1 if available.

◆ os_numa_free()

void os_numa_free ( void *  ptr,
size_t  size 
)
inline

Free a memory allocated by os_numa_alloc_onnode().

Parameters
[in]ptrpointer to memory to free
[in]sizesize of the memory

◆ os_numa_node_of_cpu()

int os_numa_node_of_cpu ( int  cpu)
inline

Get the NUMA node of a given CPU.

Parameters
[in]cpuCPU whose NUMA node to return, must be obtained using os_getcpu().
Returns
NUMA node id

◆ os_numa_num_configured_cpus()

int os_numa_num_configured_cpus ( )
inline

Get the number of CPUs in the system, including disabled ones.

Returns
number of CPUs