Debian Codegraph @

man/get_hugepage_region.3

raw
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 GET_HUGEPAGE_REGION 3 "November 7, 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 get_hugepage_region, free_hugepage_region \- Allocate and free regions of memory that use hugepages where possible
20 .SH SYNOPSIS
21 .B #include <hugetlbfs.h>
22 .br
23
24 .br
25 .B void *get_hugepage_region(size_t len, ghr_t flags);
26 .br
27 .B void free_hugepage_region(void *ptr);
28 .SH DESCRIPTION
29
30 \fBget_hugepage_region()\fP allocates a memory region \fBlen\fP bytes in size
31 backed by hugepages. Hugepages may be of benefit to applications that use
32 large amounts of address space and suffer a performance hit due to TLB
33 misses. Wall-clock time or oprofile can be used to determine if there is
34 a performance benefit from using hugepages or not.
35
36 Unlike \fBget_huge_pages()\fP, \fBlen\fP does not have to be hugepage-aligned
37 although memory may be wasted due to alignment. The caller may also specify
38 that base pages be used in the event there are no hugepages available.
39
40 The \fBflags\fP argument changes the behaviour of the function. Flags may
41 be or'd together.
42
43 .TP
44 .B GHR_FALLBACK
45 Use base pages if there are an insufficient number of huge pages.
46
47 .TP
48 .B GHR_STRICT
49 Use hugepages or return NULL.
50
51 .TP
52 .B GHR_COLOR
53 When specified, bytes that would be wasted due to alignment are used to
54 color the buffer by offsetting it by a random cacheline within the hugepage.
55 This avoids a performance problem whereby multiple buffers use the same
56 cache lines at the same offsets. If it is not important that the start of the
57 buffer be page-aligned, specify this flag.
58
59 .TP
60 .B GHR_DEFAULT
61 The library chooses a sensible combination of flags for allocating a region of
62 memory. The current default is:
63 GHR_FALLBACK | GHR_COLOR
64
65 .PP
66
67 \fBfree_hugepage_region()\fP frees a region of memory allocated by
68 \fBget_hugepage_region()\fP. The behaviour of the function if another
69 pointer is used, valid or otherwise, is undefined.
70
71 .SH RETURN VALUE
72
73 On success, a pointer is returned for to the allocated memory. On
74 error, NULL is returned. errno will be set based on what the failure of
75 mmap() was due to.
76
77 .SH SEE ALSO
78 .I oprofile(1)
79 ,
80 .I gethugepagesize(3)
81 ,
82 .I get_huge_pages(3)
83 ,
84 .I libhugetlbfs(7)
85 .SH AUTHORS
86 libhugetlbfs was written by various people on the libhugetlbfs-devel
87 mailing list.
88