LIBHUGETLBFS(7) | Miscellaneous Information Manual | LIBHUGETLBFS(7) |
libhugetlbfs - preload library to back text, data, malloc() or shared memory with hugepages
export [environment options]
[LD_PRELOAD=libhugetlbfs.so] target_application
libhugetlbfs is a library that can back application text, data, malloc() and shared memory with hugepages. This is of benefit to applications that use large amounts of address space and suffer a performance hit due to TLB misses. Wall-clock time or oprofile can be used to determine if there is a performance benefit from using libhugetlbfs or not. In all cases but shared memory, a hugetlbfs mount must exist and a hugepage pool defined for hugepages to be used.
Some limited functionality is available for unmodified dynamically linked applications. By preloading the library, the library can back malloc() and shared memory, and text and data segments can be partially backed if they are large enough.
For the effective backing of text and data with huge pages, the application must be linked to the library and the ELF segments correctly aligned using the ld helpers. Once linked, malloc or shared memory can still be backed but no pre-loading is required. See /usr/share/doc/libhugetlbfs/HOWTO and ld.hugetlbfs(1) for detailed instructions on relinking applications.
For applications that are hugepage-aware and linked to the library get_huge_pages() can be used for the direct allocation of hugepage-backed regions.
Unless otherwise specified, libhugetlbfs will use the default hugepage size to back memory regions. The default size is the value of Hugepagesize displayed in /proc/meminfo. The size can be specified in bytes or in kilobytes, megabytes, or gigabytes by appending K, M, or G respectively. It is an error to specify a invalid, unsupported, or otherwise unconfigured huge page size. Kernel 2.6.27 or later is required to specify any pagesize other than the default.
See /usr/share/docs/libhugetlbfs/HOWTO for detailed instructions on how the library should be used, particularly when relinking the application. This manual page provides a brief synopsis of the environment variables as a quick reference.
The following variables affect what memory regions are backed by hugepages. In all cases, the environment being unset implies the feature should remain disabled.
The following options affect how libhugetlbfs behaves.
There are situations in which it is desirable to restrict libhugetlbfs' actions to specific programs. For example, some ISV applications are wrapped in a series of scripts that invoke bash, python, and/or perl. It is more convenient to set the environment variables related to libhugetlbfs before invoking the wrapper scripts, yet this has the unintended and undesirable consequence of causing the script interpreters to use and consume hugepages. There is no obvious benefit to causing the script interpreters to use hugepages, and there is a clear disadvantage: fewer hugepages are available to the actual application.
To address this scenario, set HUGETLB_RESTRICT_EXE to a colon-separated list of programs to which the other libhugetlbfs environment variables should apply. (If not set, libhugetlbfs will attempt to apply the requested actions to all programs.) For example,
HUGETLB_RESTRICT_EXE=hpcc:long_hpcc
will restrict libhugetlbfs' actions to programs named /home/fred/hpcc and /bench/long_hpcc but not /bin/hpcc_no.
By default, the kernel will reserve huge pages at mmap() time to ensure that future faults will succeed. This avoids unexpected application failure at fault time but some applications depend on memory overcommit to create large sparse mappings. For this type of application, setting this environment variable will create huge page backed mappings without a reservation. Use this option with extreme care as in the event huge pages are not available when the mapping is used, the application will be killed. On older kernels, the use of this feature can trigger the OOM killer. Hence, even with this variable set, reservations may still be used for safety.
The following options control the verbosity of libhugetlbfs.
[DESTDIR|/usr/share]/doc/libhugetlbfs/HOWTO
oprofile(1), ld.hugetlbfs(1), hugectl(8), hugeedit(8), gethugepagesize(3), gethugepagesizes(3), getpagesizes(3), hugetlbfs_test_path(3), hugetlbfs_find_path(3), hugetlbfs_find_path_for_size(3), hugetlbfs_test_path(3), hugetlbfs_test_path_for_size(3), hugetlbfs_unlinked_fd(3), hugetlbfs_unlinked_fd_for_size(3), get_huge_pages(3), free_huge_pages(3)
libhugetlbfs was written by various people on the libhugetlbfs-devel mailing list.
September 27, 2008 |