]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/alloc_hugepages.2
strip trailing white space
[thirdparty/man-pages.git] / man2 / alloc_hugepages.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright 2003 Andries E. Brouwer (aeb@cwi.nl)
4 .\"
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\"
25 .TH ALLOC_HUGEPAGES 2 2007-05-31 "Linux" "Linux Programmer's Manual"
26 .SH NAME
27 alloc_hugepages, free_hugepages \- allocate or free huge pages
28 .SH SYNOPSIS
29 .nf
30 .BI "void *alloc_hugepages(int " key ", void *" addr ", size_t " len ,
31 .BI " int " prot ", int " flag );
32 .\" asmlinkage unsigned long sys_alloc_hugepages(int key, unsigned long addr,
33 .\" unsigned long len, int prot, int flag);
34 .sp
35 .BI "int free_hugepages(void *" addr );
36 .\" asmlinkage int sys_free_hugepages(unsigned long addr);
37 .fi
38 .SH DESCRIPTION
39 The system calls
40 .BR alloc_hugepages ()
41 and
42 .BR free_hugepages ()
43 were introduced in Linux 2.5.36 and removed again in 2.5.54.
44 They existed only on i386 and ia64 (when built with CONFIG_HUGETLB_PAGE).
45 In Linux 2.4.20 the syscall numbers exist,
46 but the calls fail with the error
47 .BR ENOSYS .
48 .LP
49 On i386 the memory management hardware knows about ordinary pages (4 KiB)
50 and huge pages (2 or 4 MiB).
51 Similarly ia64 knows about huge pages of
52 several sizes.
53 These system calls serve to map huge pages into the
54 process's memory or to free them again.
55 Huge pages are locked into memory, and are not swapped.
56 .LP
57 The
58 .I key
59 parameter is an identifier.
60 When zero the pages are private, and
61 not inherited by children.
62 When positive the pages are shared with other applications using the same
63 .IR key ,
64 and inherited by child processes.
65 .LP
66 The
67 .I addr
68 parameter of
69 .BR free_hugepages ()
70 tells which page is being freed: it was the return value of a
71 call to
72 .BR alloc_hugepages ().
73 (The memory is first actually freed when all users have released it.)
74 The
75 .I addr
76 parameter of
77 .BR alloc_hugepages ()
78 is a hint, that the kernel may or may not follow.
79 Addresses must be properly aligned.
80 .LP
81 The
82 .I len
83 parameter is the length of the required segment.
84 It must be a multiple of the huge page size.
85 .LP
86 The
87 .I prot
88 parameter specifies the memory protection of the segment.
89 It is one of PROT_READ, PROT_WRITE, PROT_EXEC.
90 .LP
91 The
92 .I flag
93 parameter is ignored, unless
94 .I key
95 is positive.
96 In that case, if
97 .I flag
98 is IPC_CREAT, then a new huge page segment is created when none
99 with the given key existed.
100 If this flag is not set, then ENOENT
101 is returned when no segment with the given key exists.
102 .IR
103 .SH "RETURN VALUE"
104 On success,
105 .BR alloc_hugepages ()
106 returns the allocated virtual address, and
107 .BR free_hugepages ()
108 returns zero.
109 On error, \-1 is returned, and
110 .I errno
111 is set appropriately.
112 .SH ERRORS
113 .TP
114 .B ENOSYS
115 The system call is not supported on this kernel.
116 .SH FILES
117 .I /proc/sys/vm/nr_hugepages
118 Number of configured hugetlb pages.
119 This can be read and written.
120 .LP
121 .I /proc/meminfo
122 Gives info on the number of configured hugetlb pages and on their size
123 in the three variables HugePages_Total, HugePages_Free, Hugepagesize.
124 .SH "CONFORMING TO"
125 These calls are specific to Linux on Intel processors, and should not be
126 used in programs intended to be portable.
127 .SH NOTES
128 These system calls are gone;
129 they existed only in Linux 2.5.36 through to 2.5.54.
130 Now the hugetlbfs filesystem can be used instead.
131 Memory backed by huge pages (if the CPU supports them) is obtained by
132 using
133 .BR mmap (2)
134 to map files in this virtual filesystem.
135 .LP
136 The maximal number of huge pages can be specified using the
137 .B hugepages=
138 boot parameter.
139
140 .\" requires CONFIG_HUGETLB_PAGE (under "Processor type and features")
141 .\" and CONFIG_HUGETLBFS (under "Filesystems").
142 .\" mount -t hugetlbfs hugetlbfs /huge
143 .\" SHM_HUGETLB