| 1 |
.\" Hey, EMACS: -*- nroff -*- |
| 2 |
.\" First parameter, NAME, should be all caps |
| 3 |
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection |
| 4 |
.\" other parameters are allowed: see man(7), man(1) |
| 5 |
.TH LIBHUGETLBFS 7 "September 27, 2008" |
| 6 |
.\" Please adjust this date whenever revising the manpage. |
| 7 |
.\" |
| 8 |
.\" Some roff macros, for reference: |
| 9 |
.\" .nh disable hyphenation |
| 10 |
.\" .hy enable hyphenation |
| 11 |
.\" .ad l left justify |
| 12 |
.\" .ad b justify to both left and right margins |
| 13 |
.\" .nf disable filling |
| 14 |
.\" .fi enable filling |
| 15 |
.\" .br insert line break |
| 16 |
.\" .sp <n> insert n+1 empty lines |
| 17 |
.\" for manpage-specific macros, see man(7) |
| 18 |
.SH NAME |
| 19 |
libhugetlbfs \- preload library to back text, data, malloc() or shared memory with hugepages |
| 20 |
.SH SYNOPSIS |
| 21 |
.B export [environment options] |
| 22 |
.br |
| 23 |
.B [LD_PRELOAD=libhugetlbfs.so] target_application |
| 24 |
.SH DESCRIPTION |
| 25 |
|
| 26 |
\fBlibhugetlbfs\fP is a library that can back application text, data, malloc() |
| 27 |
and shared memory with hugepages. This is of benefit to applications that |
| 28 |
use large amounts of address space and suffer a performance hit due to TLB |
| 29 |
misses. Wall-clock time or oprofile can be used to determine if there is |
| 30 |
a performance benefit from using \fBlibhugetlbfs\fP or not. In all cases |
| 31 |
but shared memory, a hugetlbfs mount must exist and a hugepage pool defined |
| 32 |
for hugepages to be used. |
| 33 |
|
| 34 |
Some limited functionality is available for unmodified dynamically linked |
| 35 |
applications. By preloading the library, the library can back malloc() |
| 36 |
and shared memory, and text and data segments can be partially backed if |
| 37 |
they are large enough. |
| 38 |
|
| 39 |
For the effective backing of text and data with huge pages, the application |
| 40 |
must be linked to the library and the ELF segments correctly aligned using |
| 41 |
the ld helpers. Once linked, malloc or shared memory can still be backed |
| 42 |
but no pre-loading is required. See /usr/share/doc/libhugetlbfs/HOWTO and |
| 43 |
ld.hugetlbfs(1) for detailed instructions on relinking applications. |
| 44 |
|
| 45 |
For applications that are hugepage-aware and linked to the library |
| 46 |
\fBget_huge_pages()\fP can be used for the direct allocation of |
| 47 |
hugepage-backed regions. |
| 48 |
|
| 49 |
Unless otherwise specified, \fBlibhugetlbfs\fP will use the default hugepage |
| 50 |
size to back memory regions. The default size is the value of Hugepagesize |
| 51 |
displayed in /proc/meminfo. The size can be specified in bytes or in |
| 52 |
kilobytes, megabytes, or gigabytes by appending K, M, or G respectively. It |
| 53 |
is an error to specify a invalid, unsupported, or otherwise unconfigured |
| 54 |
huge page size. Kernel 2.6.27 or later is required to specify any pagesize |
| 55 |
other than the default. |
| 56 |
|
| 57 |
See /usr/share/docs/libhugetlbfs/HOWTO for detailed instructions on how |
| 58 |
the library should be used, particularly when relinking the application. |
| 59 |
This manual page provides a brief synopsis of the environment variables |
| 60 |
as a quick reference. |
| 61 |
|
| 62 |
The following variables affect what memory regions are backed by hugepages. In |
| 63 |
all cases, the environment being unset implies the feature should remain |
| 64 |
disabled. |
| 65 |
|
| 66 |
.TP |
| 67 |
.B HUGETLB_DEFAULT_PAGE_SIZE=<pagesize> |
| 68 |
This sets the default hugepage size to be used by libhugetlbfs. If not |
| 69 |
set, libhugetlbfs will use the kernel's default hugepage size. |
| 70 |
|
| 71 |
.TP |
| 72 |
.B HUGETLB_MORECORE=[yes|<pagesize>] |
| 73 |
This enables the hugepage malloc() feature, instructing libhugetlbfs to |
| 74 |
override glibc's normal morecore() function with a hugepage version and use |
| 75 |
it for malloc(). All application malloc() memory should come from hugepage |
| 76 |
memory until it runs out, it will then fallback to base pages. Note that |
| 77 |
applications that use custom allocators may not be able to back their heaps |
| 78 |
using hugepages and this environment variable. It may be necessary to modify |
| 79 |
the custom allocator to use \fBget_huge_pages()\fP. |
| 80 |
|
| 81 |
.TP |
| 82 |
.B HUGETLB_SHM=yes |
| 83 |
When this environment variable is set, the SHM_HUGETLB flag is added to |
| 84 |
the shmget() call and the size parameter is aligned to back the shared |
| 85 |
memory segment with hugepages. In the event hugepages cannot be used, base |
| 86 |
pages will be used instead and a warning will be printed to explain the |
| 87 |
failure. The pagesize cannot be specified with this parameter. To change |
| 88 |
the kernels default hugepage size, use the pagesize= kernel boot parameter |
| 89 |
(2.6.26 or later required). |
| 90 |
|
| 91 |
.TP |
| 92 |
.B HUGETLB_ELFMAP=[no|[R[<=pagesize>]:[W[<=pagesize>]]] |
| 93 |
If the application has been relinked (see the HOWTO for instructions), |
| 94 |
this environment variable determines whether read-only, read-write, both |
| 95 |
or no segments are backed by hugepages and what pagesize should be used. If |
| 96 |
the recommended relinking method has been used, then \fBhugeedit\fP can be |
| 97 |
used to automatically back the text or data by default. |
| 98 |
|
| 99 |
.TP |
| 100 |
.B HUGETLB_FORCE_ELFMAP=yes |
| 101 |
Force the use of hugepages for text and data segments even if the application |
| 102 |
has not been relinked to align the ELF segments on a hugepage boundary. |
| 103 |
Partial segment remapping is not guaranteed to work and the segments must be |
| 104 |
large enough to contain at least one hugepage for the remapping to occur. |
| 105 |
|
| 106 |
.PP |
| 107 |
The following options affect how libhugetlbfs behaves. |
| 108 |
|
| 109 |
.TP |
| 110 |
.B HUGETLB_RESTRICT_EXE=e1:e2:...:eN |
| 111 |
By default, libhugetlbfs will act on any program that it |
| 112 |
is loaded with, either via LD_PRELOAD or by explicitly |
| 113 |
linking with -lhugetlbfs. |
| 114 |
|
| 115 |
There are situations in which it is desirable to restrict |
| 116 |
libhugetlbfs' actions to specific programs. For example, |
| 117 |
some ISV applications are wrapped in a series of scripts |
| 118 |
that invoke bash, python, and/or perl. It is more |
| 119 |
convenient to set the environment variables related |
| 120 |
to libhugetlbfs before invoking the wrapper scripts, |
| 121 |
yet this has the unintended and undesirable consequence |
| 122 |
of causing the script interpreters to use and consume |
| 123 |
hugepages. There is no obvious benefit to causing the |
| 124 |
script interpreters to use hugepages, and there is a |
| 125 |
clear disadvantage: fewer hugepages are available to |
| 126 |
the actual application. |
| 127 |
|
| 128 |
To address this scenario, set HUGETLB_RESTRICT_EXE to a |
| 129 |
colon-separated list of programs to which the other |
| 130 |
libhugetlbfs environment variables should apply. (If |
| 131 |
not set, libhugetlbfs will attempt to apply the requested |
| 132 |
actions to all programs.) For example, |
| 133 |
|
| 134 |
HUGETLB_RESTRICT_EXE=hpcc:long_hpcc |
| 135 |
|
| 136 |
will restrict libhugetlbfs' actions to programs named |
| 137 |
/home/fred/hpcc and /bench/long_hpcc but not /bin/hpcc_no. |
| 138 |
|
| 139 |
|
| 140 |
.TP |
| 141 |
.B HUGETLB_MORECORE_SHRINK=yes |
| 142 |
By default, the hugepage heap does not shrink. Shrinking is enabled by |
| 143 |
setting this environment variable. It is disabled by default as glibc |
| 144 |
occasionally exhibits strange behaviour if it mistakes the heap returned |
| 145 |
by \fBlibhugetlbfs\fP as a foreign brk(). |
| 146 |
|
| 147 |
.TP |
| 148 |
.B HUGETLB_NO_PREFAULT |
| 149 |
By default \fBlibhugetlbfs\fP will prefault regions it creates to ensure they |
| 150 |
can be referenced without receiving a SIGKILL. On kernels older than 2.6.27, |
| 151 |
this was necessary as the system did not guarantee that future faults would |
| 152 |
succeed on regions mapped MAP_PRIVATE. Prefaulting impacts the performance |
| 153 |
of malloc() and can result in poor placement on NUMA systems. If it is known |
| 154 |
the hugepage pool is large enough to run the application or the kernel is |
| 155 |
2.6.27 or later, this environment variable should be set. |
| 156 |
|
| 157 |
.TP |
| 158 |
.B HUGETLB_NO_RESERVE=yes |
| 159 |
|
| 160 |
By default, the kernel will reserve huge pages at mmap() time to ensure that |
| 161 |
future faults will succeed. This avoids unexpected application failure at |
| 162 |
fault time but some applications depend on memory overcommit to create |
| 163 |
large sparse mappings. For this type of application, setting this environment |
| 164 |
variable will create huge page backed mappings without a reservation. Use |
| 165 |
this option with extreme care as in the event huge pages are not available |
| 166 |
when the mapping is used, the application will be killed. On older kernels, |
| 167 |
the use of this feature can trigger the OOM killer. Hence, even with this |
| 168 |
variable set, reservations may still be used for safety. |
| 169 |
|
| 170 |
.TP |
| 171 |
.B HUGETLB_MORECORE_HEAPBASE=address |
| 172 |
\fBlibhugetlbfs\fP normally picks an address to use as the base of the heap for |
| 173 |
malloc() automatically. This environment variable fixes which address is used. |
| 174 |
|
| 175 |
.TP |
| 176 |
.B HUGETLB_PATH=<path> |
| 177 |
The path to the hugetlbfs mount is automatically determined at run-time. In the |
| 178 |
event there are multiple mounts and the wrong one is being selected, use this |
| 179 |
option to select the correct one. This may be the case if an |
| 180 |
application-specific mount with a fixed quota has been created for example. |
| 181 |
|
| 182 |
.TP |
| 183 |
.B HUGETLB_SHARE=1 |
| 184 |
By default, \fBlibhugetlbfs\fP uses unlinked hugetlbfs files to store remapped |
| 185 |
program segment data. If the same program is started multiple times using |
| 186 |
hugepage segments, multiple hugepages will be used to store the same program |
| 187 |
data. The reduce this wastage, setting this environment variable will share |
| 188 |
read-only segments between multiple invocations of a program at the cost of |
| 189 |
the memory being used whether the applications are running or not. It is |
| 190 |
also possible that a malicious application inferfere with other applications |
| 191 |
executable code. See the HOWTO for more detailed information on this topic. |
| 192 |
|
| 193 |
.PP |
| 194 |
The following options control the verbosity of \fBlibhugetlbfs\fP. |
| 195 |
|
| 196 |
.TP |
| 197 |
.B HUGETLB_VERBOSE=<level> |
| 198 |
The default value for this is 1 and the range of the value is from 0 to |
| 199 |
99. The higher the value, the more verbose the output is. 0 is quiet and |
| 200 |
3 will output much debugging information. |
| 201 |
|
| 202 |
.TP |
| 203 |
.B HUGETLB_DEBUG |
| 204 |
Once set, this will give very detailed output on what is happening in the |
| 205 |
library and run extra diagnostics. |
| 206 |
|
| 207 |
.SH FILES |
| 208 |
[DESTDIR|/usr/share]/doc/libhugetlbfs/HOWTO |
| 209 |
|
| 210 |
.SH SEE ALSO |
| 211 |
.I oprofile(1), |
| 212 |
.I ld.hugetlbfs(1), |
| 213 |
.I hugectl(8), |
| 214 |
.I hugeedit(8), |
| 215 |
.I gethugepagesize(3), |
| 216 |
.I gethugepagesizes(3), |
| 217 |
.I getpagesizes(3), |
| 218 |
.I hugetlbfs_test_path(3), |
| 219 |
.I hugetlbfs_find_path(3), |
| 220 |
.I hugetlbfs_find_path_for_size(3), |
| 221 |
.I hugetlbfs_test_path(3), |
| 222 |
.I hugetlbfs_test_path_for_size(3), |
| 223 |
.I hugetlbfs_unlinked_fd(3), |
| 224 |
.I hugetlbfs_unlinked_fd_for_size(3), |
| 225 |
.I get_huge_pages(3), |
| 226 |
.I free_huge_pages(3) |
| 227 |
.br |
| 228 |
.SH AUTHORS |
| 229 |
libhugetlbfs was written by various people on the libhugetlbfs-devel |
| 230 |
mailing list. |