1GET_HUGEPAGE_REGION(3) Library Functions Manual GET_HUGEPAGE_REGION(3)
2
3
4
6 get_hugepage_region, free_hugepage_region - Allocate and free regions
7 of memory that use hugepages where possible
8
10 #include <hugetlbfs.h>
11
12 void *get_hugepage_region(size_t len, ghr_t flags);
13 void free_hugepage_region(void *ptr);
14
16 get_hugepage_region() allocates a memory region len bytes in size
17 backed by hugepages. Hugepages may be of benefit to applications that
18 use large amounts of address space and suffer a performance hit due to
19 TLB misses. Wall-clock time or oprofile can be used to determine if
20 there is a performance benefit from using hugepages or not.
21
22 Unlike get_huge_pages(), len does not have to be hugepage-aligned
23 although memory may be wasted due to alignment. The caller may also
24 specify that base pages be used in the event there are no hugepages
25 available.
26
27 The flags argument changes the behaviour of the function. Flags may be
28 or'd together.
29
30
31 GHR_FALLBACK
32 Use base pages if there are an insufficient number of huge
33 pages.
34
35
36 GHR_STRICT
37 Use hugepages or return NULL.
38
39
40 GHR_COLOR
41 When specified, bytes that would be wasted due to alignment are
42 used to color the buffer by offsetting it by a random cacheline
43 within the hugepage. This avoids a performance problem whereby
44 multiple buffers use the same cache lines at the same offsets.
45 If it is not important that the start of the buffer be page-
46 aligned, specify this flag.
47
48
49 GHR_DEFAULT
50 The library chooses a sensible combination of flags for allocat‐
51 ing a region of memory. The current default is: GHR_FALL‐
52 BACK | GHR_COLOR
53
54
55 free_hugepage_region() frees a region of memory allocated by
56 get_hugepage_region(). The behaviour of the function if another pointer
57 is used, valid or otherwise, is undefined.
58
59
61 On success, a pointer is returned for to the allocated memory. On
62 error, NULL is returned. errno will be set based on what the failure of
63 mmap() was due to.
64
65
67 oprofile(1) , gethugepagesize(3) , get_huge_pages(3) , libhugetlbfs(7)
68
70 libhugetlbfs was written by various people on the libhugetlbfs-devel
71 mailing list.
72
73
74
75
76 November 7, 2008 GET_HUGEPAGE_REGION(3)