Area Linux Implementation API

group aml_area_linux

Linux Implementation of Areas.

Linux implementation of AML areas. This building block relies on libnuma implementation and linux mmap/munmap to provide mmap/munmap on NUMA host host processor memory. New areas may be created to allocate a specific subset of memories. This building block also include a static declaration of a default initialized area that can be used out of the box with abstract area API.

#include <aml/area/linux.h>

Defines

AML_AREA_LINUX_BINDING_FLAG_BIND

Allowed binding flag for area creation. This flag will apply strict binding to the selected bitmask. If subsequent allocation will failt if they cannot enforce binding on bitmask.

AML_AREA_LINUX_BINDING_FLAG_INTERLEAVE

Allowed binding flag for area creation. This flag will make subsequent allocations to interleave pages on memories of the bitmask.

AML_AREA_LINUX_BINDING_FLAG_PREFERRED

Allowed binding flag for area creation. This flag will make subsequent allocations to bound to the nodes of bitmask if possible, else to some other node.

AML_AREA_LINUX_MMAP_FLAG_PRIVATE

Allowed mapping flag for area creation. This flag will make subsequent allocations to be private to the process making them.

AML_AREA_LINUX_MMAP_FLAG_SHARED

Allowed mapping flag for area creation. This flag will make subsequent allocations to be visible to other processes of the system.

AML_AREA_LINUX_DECL(name)

Static declaration of an aml area with linux ops.

AML_AREA_LINUX_ALLOCSIZE

Static declaration of the size of a linux aml area.

Functions

int aml_area_linux_create(struct aml_area **area, const int mmap_flags, const struct aml_bitmap *nodemask, const int binding_flags)

Linux area creation.

Allocate and initialize a struct aml_area implemented by aml_area_linux operations.

Return

On success, returns 0 and area points to the new aml_area.

Return

On failure, sets area to NULL and returns one of AML error codes:

  • AML_ENOMEM if there wasn’t enough memory available.

  • AML_EINVAL if inputs flags were invalid.

  • AML_EDOM the nodemask provided is out of bounds (allowed nodeset).

Parameters
  • [out] area: pointer to an uninitialized struct aml_area pointer to receive the new area.

  • [in] mmap_flags: flags to use when retrieving virtual memory with mmap

  • [in] binding_flags[in] flags: to use when binding memory.

  • [in] nodemask: list of memory nodes to use. Default to allowed memory nodes if NULL.

void aml_area_linux_destroy(struct aml_area **area)

Linux area destruction.

Destroy (finalize and free resources) a struct aml_area created by aml_area_linux_create().

Parameters
  • area: is NULL after this call.

int aml_area_linux_init(struct aml_area *area, const int mmap_flags, const struct aml_bitmap *nodemask, const int binding_flags)

Initialize a struct aml_area declared using the AML_AREA_LINUX_DECL macro.

See

aml_area_linux_create() for details on arguments.

void aml_area_linux_fini(struct aml_area *area)

Finalize a struct aml_area initialized with aml_area_linux_init.

int aml_area_linux_mbind(struct aml_area_linux_data *bind, void *ptr, size_t size)

Bind memory of size “size” pointed by “ptr” to binding set in “bind”. If mbind call was not successfull, i.e AML_FAILURE is returned, then errno should be inspected for further error checking.

Return

an AML error code.

Parameters
  • bind: The binding settings. mmap_flags is actually unused.

  • ptr: The data to bind.

  • size: The size of the data pointed by ptr.

int aml_area_linux_check_binding(struct aml_area_linux_data *area_data, void *ptr, size_t size)

Function to check whether binding of a ptr obtained with aml_area_linux_mmap() then aml_area_linux_mbind() match area settings.

Return

1 if mapped memory binding in ptr match area_data binding settings, else 0.

Parameters
  • area_data: The expected binding settings.

  • ptr: The data supposely bound.

  • size: The data size.

void *aml_area_linux_mmap(const struct aml_area_data *area_data, void *ptr, size_t size)

mmap block for aml area.

This function is a wrapper on mmap function using arguments set in mmap_flags of area_data. This function does not perform binding, unlike it is done in areas created with aml_area_linux_create().

Return

NULL on failure, else a valid pointer to memory. Upon failure, errno should be checked for further error investigations.

Parameters
  • area_data: The structure containing mmap_flags for mmap call. nodemask and bind_flags fields are ignored.

  • ptr: A hint provided to mmap function.

  • size: The size to allocate.

int aml_area_linux_munmap(const struct aml_area_data *area_data, void *ptr, const size_t size)

munmap hook for aml area.

unmap memory mapped with aml_area_linux_mmap().

Return

AML_FAILURE on error, AML_SUCCESS. Upon failure errno should be checked for further error investigations.

Parameters
  • area_data: unused

  • ptr: The virtual memory to unmap.

  • size: The size of virtual memory to unmap.

Variables

struct aml_area_ops aml_area_linux_ops

This contains area operations implementation for linux area.

struct aml_area aml_area_linux

Default linux area with private mapping and no binding. Can be used out of the box with aml_area_*() functions.

struct aml_area_linux_data
#include <linux.h>

Implementation of aml_area_data for linux areas.