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