libvmmalloc
original source: http://pmem.io/nvml/libvmmalloc/libvmmalloc.3.html
libvmmalloc
INTRO.
NAME
libvmmalloc − general purpose volatile memory allocation library |
SYNOPSIS
$ LD_PRELOAD=libvmmalloc.so command [ args... ] or #include <stdlib.h> #include <malloc.h> #include <libvmmalloc.h> $ cc [ flag... ] file... -lvmmalloc [ library... ] void *malloc(size_t size); void free(void *ptr); void *calloc(size_t number, size_t size); void *realloc(void *ptr, size_t size); int posix_memalign(void **memptr, size_t alignment, size_t size); void *aligned_alloc(size_t alignment, size_t size); void *memalign(size_t alignment, size_t size); void *valloc(size_t size); void *pvalloc(size_t size); size_t malloc_usable_size(const void *ptr); void cfree(void *ptr); |
DESCRIPTION
libvmmalloc transparently converts all the dynamic memory allocations into Persistent Memory allocations. The typical usage of libvmmalloc does not require any modification of the target program. It is enough to load libvmmalloc before all other libraries by setting the environment variable LD_PRELOAD. When used in that way,libvmmalloc interposes the standard system memory allocation routines, as defined in malloc(3), posix_memalign(3) and malloc_usable_size(3), and provides that all dynamic memory allocations are made from a memory poolbuilt on memory-mapped file, instead of a system heap. The memory managed by libvmmalloc may have different attributes, depending on the file system containing the memory-mapped file. In particular, libvmmalloc is part of the Non-Volatile Memory Library because it is sometimes useful to use non-volatile memory as a volatile memory pool, leveraging its capacity, cost, or performance characteristics. libvmmalloc은 동적 메모리 할당을 영속 메모리 할당으로 투명하게 변환한다. libvmalloc 사용은 해당 프로그램의 수정을 요구하지 않는다. 환경변수 LD_PRELOAD를 세팅하기 전에 libvmmaloc을 로드하여 libvmmalloc을 표준 시스템 메모리 할당 루틴에 끼워넣는다. malloc(3), posix_memalign(3), malloc_usable_size(3) 등은 시스템 힙 대신 MMFIO를 통해 메모리 풀에서 동적메모리 할당을 지원한다. libvmmaloc의 메모리 관리는 MMFIO를 포함하는 파일 시스템에 의존한다. 특히 NVM을 일반 메모리 풀로 사용이 가능하다. libvmmalloc may be also linked to the program, by providing the vmmalloc argument to the linker. Then it becomes the default memory allocator for given program. NOTE: Due to the fact the library operates on a memory-mapped file, it may not work properly with the programs that perform fork(3) not followed by exec(3). There are two variants of experimental fork() support available in libvmmalloc. The desired library behavior may be selected by setting VMMALLOC_FORK environment variable. By default variant #1 is enabled. See ENVIRONMENT section for more details. libvmmalloc 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 traditional malloc interfaces on top of those pools. libvmmalloc은 mmap(2) 시스템 콜을 통해 일반 메모리 풀을 생성한다. 라이브러리는 DAX에 가장 효과가 좋다. PMFS는 보통 L/S를 지원한다. PMFS를 통한 MMFIO는 저수준 메모리 풀을 지원하고, 이 라이브러리는 malloc 인터페이스를 해당 풀의 상위에서 지원한다. The memory pool acting as a system heap replacement is created automatically at the library initialization time. User may control its location and size by setting the environment variables described in ENVIRONMENT section. The allocated file space is reclaimed when process terminates or in case of system crash. 시스템 힙 대체로서 메모리풀은 라이브러리 초기화 과정에서 자동으로 생성된다. 사용자는 위치와 크기를 ENVIRONMENT 섹션에서 소개되는 환경변수 세팅을 통해 조정된다. Under normal usage, libvmmalloc will never print messages or intentionally cause the process to exit. The library uses pthreads(7) 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() or poll(). |
ENVIRONMENT
There are two configuration variables that must be set to make libvmmalloc work properly. If any of them is not specified, or if their values are not valid, the library prints the appropriate error message and terminates the process. 다음 2개의 환경 변수는 libvmmalloc에 반드시 필요하다. 아닐 경우, 에러 메시지와 함께 해당 프로세스를 종료 시킨다. |
VMMALLOC_POOL_DIR |
Specifies a path to directory where the memory pool file should be created. The directory must exist and be writable. 메모리 풀에 생성되어야 하는 패스를 나타내며, 해당 디렉토리는 쓰기가능하도록 존재해야 한다. |
VMMALLOC_POOL_SIZE |
Defines the desired size (in bytes) of the memory pool file. It must be not less than the minimum allowed size VMMALLOC_MIN_POOL as defined in <libvmmalloc.h>. Note that due to the fact the library adds some metadata to the memory pool, the amount of actual usable space is typically less than the size of the memory pool file. 메모리 풀 파일의 크기를 명시한다. VMMALLOC_MIN_POOL 보다는 반드시 커야한다. |
'NVM' 카테고리의 다른 글
libvmmalloc initialization analysis (0) | 2016.08.30 |
---|---|
LD_PRELOAD rootkits (0) | 2016.08.26 |
libpmem library (0) | 2016.08.09 |
libnvdimm (0) | 2016.08.05 |
PCMSIM (0) | 2016.08.05 |