memkind_default - default implementations for memkind operations.
Contents
Copyright
Copyright (C) 2014 - 2020 Intel Corporation. All rights reserved.
Description
Default implementations for memkind operations which include a several useful methods that are not part
of the MEMKIND_DEFAULT kind which is a fall through to the jemalloc implementation.
memkind_default_create() implements the required start up for every kind. If a kind does not point to
this function directly for its ops.create() operation, then the function that it points to must call
memkind_default_create() at its start.
memkind_default_destroy() implements the required shutdown for every kind. If a kind does not point to
this function directly for its ops.destroy() operation, then the function that it points to must call
memkind_default_destroy() at its end.
memkind_default_malloc() is a direct call through the jemalloc's malloc().
memkind_default_calloc() is a direct call through the jemalloc's calloc().
memkind_default_posix_memalign() is a direct call through the jemalloc's posix_memalign().
memkind_default_realloc() is a direct call through the jemalloc's realloc().
memkind_default_free() is a direct call through the jemalloc's free(). Note that this method can be
called on any pointer returned by a jemalloc allocation, and in particular, all of the arena allocations
described in memkind_arena(3) can use this function for freeing.
memkind_default_mmap() This calls the ops->get_mmap_flags() operations for the kind, or falls back on the
default implementations if the function pointers are NULL. The results of these calls are passed to the
mmap(2) call to allocate pages from the operating system. The addr is the hint passed through to mmap(2)
and size is the size of the buffer to be allocated. The return value is the allocated buffer or
MAP_FAILED in the case of an error.
memkind_default_mbind() makes calls the kind's ops.get_mbind_nodemask() and ops.get_mbind_mode()
operations to gather inputs and then calls the mbind(2) system call using the results along with and user
input ptr and len.
memkind_default_get_mmap_flags() sets flags to MAP_PRIVATE|MAP_ANONYMOUS. See mmap(2) for more
information about these flags.
memkind_default_get_mbind_mode() sets mode to MPOL_BIND. See mbind(2) for more information about this
flag.
memkind_default_malloc_usable_size() is a direct call through the jemalloc's malloc_usable_size().
memkind_preferred_get_mbind_mode() sets mode to MPOL_PREFERRED. See mbind(2) for more information about
this flag.
memkind_interleave_get_mbind_mode() sets mode to MPOL_INTERLEAVE. See mbind(2) for more information
about this flag.
memkind_nohugepage_madvise() calls madvise(2) with the MADV_NOHUGEPAGE advice. See madvise(2) for more
information about this option.
memkind_posix_check_alignment() can be used to check the alignment value for memkind_posix_memalign() to
ensure that is abides by the POSIX requirements: alignment must be a power of 2 at least as large as
sizeof(void*).
memkind_default_get_mbind_nodemask() wraps jemalloc's copy_bitmask_to_bitmask. This function copies body
of the bitmask structure into passed pointer.
memkind_default_init_once() initializes heap manager.
size_out_of_bounds() returns true if given size is out of bounds, otherwise will return false.
Name
memkind_default - default implementations for memkind operations.
Note: This is EXPERIMENTAL API. The functionality and the header file itself can be changed (including
non-backward compatible changes), or removed.
See Also
memkind(3), memkind_arena(3), memkind_hbw(3), memkind_hugetlb(3), memkind_pmem(3), jemalloc(3), mbind(2), mmap(2) Intel Corporation 2015-04-21 MEMKIND_DEFAULT(3)
Synopsis
intmemkind_default_create(structmemkind*kind,structmemkind_ops*ops,constchar*name);intmemkind_default_destroy(structmemkind*kind);void*memkind_default_malloc(structmemkind*kind,size_tsize);void*memkind_default_calloc(structmemkind*kind,size_tnum,size_tsize);intmemkind_default_posix_memalign(structmemkind*kind,void**memptr,size_talignment,size_tsize);void*memkind_default_realloc(structmemkind*kind,void*ptr,size_tsize);voidmemkind_default_free(structmemkind*kind,void*ptr);void*memkind_default_mmap(structmemkind*kind,void*addr,size_tsize);intmemkind_default_mbind(structmemkind*kind,void*ptr,size_tlen);intmemkind_default_get_mmap_flags(structmemkind*kind,int*flags);intmemkind_default_get_mbind_mode(structmemkind*kind,int*mode);size_tmemkind_default_malloc_usable_size(structmemkind*kind,void*ptr);intmemkind_preferred_get_mbind_mode(structmemkind*kind,int*mode);intmemkind_interleave_get_mbind_mode(structmemkind*kind,int*mode);intmemkind_nohugepage_madvise(structmemkind*kind,void*addr,size_tsize);intmemkind_posix_check_alignment(structmemkind*kind,size_talignment);intmemkind_default_get_mbind_nodemask(structmemkind*kind,unsignedlong*nodemask,unsignedlongmaxnode);voidmemkind_default_init_once(void);boolsize_out_of_bounds(size_tsize);
