libvmem uses the mmap(2) system call to create a pool of volatile memory. The library is most useful when used with Direct Access storage (DAX), which is memory-addressable persistent storage that supports load/store access without being paged via the system page cache. A Persistent Memory-aware file system is typically used to provide this type of access. Memory-mapping a file from a Persistent Memory-aware file system provides the raw memory pools, and this library supplies the more familiar malloc-like interfaces on top of those pools.
Under normal usage, libvmem will never print messages or intentionally cause the process to exit. Exceptions to this are prints caused by calls to vmem_stats_print(3), or by enabling debugging as described under DEBUGGING AND ERROR HANDLING below. The library uses pthreads to be fully MT-safe, but never creates or destroys threads itself. The library does not make use of any signals, networking, and never calls select(2) or poll(2). The system memory allocation routines like malloc(3) and free(3) are used by libvmem for managing a small amount of run-time state, but applications are allowed to override these calls if necessary (see the description of vmem_set_funcs() below).
libvmem interfaces are grouped into three categories: those that manage memory pools, those providing the basic memory allocation functions, and those interfaces less commonly used for managing the overall library behavior.
Any mismatch in the major version number is considered a failure, but a library with a newer minor version number will pass this check since increasing minor versions imply backwards compatibility.
An application can also check specifically for the existence of an interface by checking for the version where that interface was introduced. These versions are documented in this man page as follows: unless otherwise specified, all interfaces described here are available in version 1.0 of the library. Interfaces added after version 1.0 will contain the text introduced in version x.y in the section of this manual describing the feature.
When the version check is successful, vmem_check_version() returns NULL. Otherwise, vmem_check_version() returns a static string describing the reason for failing the version check. The returned string must not be modified or freed.
The vmem_set_funcs() function allows an application to override some interfaces used internally by libvmem. Passing NULL for any of the handlers will cause the libvmem default function to be used. The only functions in the malloc family used by the library are represented by the first four arguments to vmem_set_funcs(). While the library does not make heavy use of the system malloc functions, it does allocate approximately 4-8 kilobytes for each memory pool in use. The print_func function is called by libvmem when the vmem_stats_print() entry point is used, or when additional tracing is enabled in the debug version of the library as described in DEBUGGING AND ERROR HANDLING, below. The default print_func used by the library prints to the file specified by the VMEM_LOG_FILE environment variable, or to stderr if that variable is not set.
Two versions of libvmem are typically available on a development system. The normal version is optimized for performance. That version skips checks that impact performance and never logs any trace information or performs any run-time assertions. A second version, accessed when using libraries from /usr/lib/pmdk_debug, contains run-time assertions and trace points. The typical way to access the debug version is to set the LD_LIBRARY_PATH environment variable to /usr/lib/pmdk_debug or /usr/lib64/pmdk_debug, as appropriate. Debugging output is controlled using the following environment variables. These variables have no effect on the non-debug version of the library.
The value of VMEM_LOG_LEVEL enables trace points in the debug version of the library, as follows:
Unless VMEM_LOG_FILE is set, debugging output is written to stderr.
Specifies the name of a file where all logging information should be written. If the last character in the name is “-”, the PID of the current process will be appended to the file name when the log file is created. If VMEM_LOG_FILE is not set, output is written to stderr.
See <http://pmem.io/pmdk/libvmem> for more examples using the libvmem API.
libvmem builds on the persistent memory programming model recommended by the SNIA NVM Programming Technical Work Group: <http://snia.org/nvmp>