]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/alloc_hugepages.2
sched_setattr.2: tfix
[thirdparty/man-pages.git] / man2 / alloc_hugepages.2
CommitLineData
fea681da
MK
1.\" Copyright 2003 Andries E. Brouwer (aeb@cwi.nl)
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
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.
c13182ef 12.\"
fea681da
MK
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.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da 24.\"
4b8c67d9 25.TH ALLOC_HUGEPAGES 2 2017-09-15 "Linux" "Linux Programmer's Manual"
fea681da
MK
26.SH NAME
27alloc_hugepages, free_hugepages \- allocate or free huge pages
28.SH SYNOPSIS
616c0fd3 29.nf
c13182ef 30.BI "void *alloc_hugepages(int " key ", void *" addr ", size_t " len ,
616c0fd3 31.BI " int " prot ", int " flag );
fea681da
MK
32.\" asmlinkage unsigned long sys_alloc_hugepages(int key, unsigned long addr,
33.\" unsigned long len, int prot, int flag);
558b6205 34.PP
fea681da
MK
35.BI "int free_hugepages(void *" addr );
36.\" asmlinkage int sys_free_hugepages(unsigned long addr);
616c0fd3 37.fi
fea681da
MK
38.SH DESCRIPTION
39The system calls
e511ffb6 40.BR alloc_hugepages ()
fea681da 41and
e511ffb6 42.BR free_hugepages ()
fea681da 43were introduced in Linux 2.5.36 and removed again in 2.5.54.
682edefb
MK
44They existed only on i386 and ia64 (when built with
45.BR CONFIG_HUGETLB_PAGE ).
11b520ed 46In Linux 2.4.20, the syscall numbers exist,
988db661 47but the calls fail with the error
d1dcf598 48.BR ENOSYS .
dd3568a1 49.PP
c4b7e5ac
MK
50On i386 the memory management hardware knows about ordinary pages (4\ KiB)
51and huge pages (2 or 4\ MiB).
c13182ef
MK
52Similarly ia64 knows about huge pages of
53several sizes.
54These system calls serve to map huge pages into the
fc7ba057 55process's memory or to free them again.
fea681da 56Huge pages are locked into memory, and are not swapped.
dd3568a1 57.PP
fea681da
MK
58The
59.I key
c4bb193f 60argument is an identifier.
c13182ef 61When zero the pages are private, and
fea681da
MK
62not inherited by children.
63When positive the pages are shared with other applications using the same
64.IR key ,
65and inherited by child processes.
dd3568a1 66.PP
fea681da
MK
67The
68.I addr
c4bb193f 69argument of
63aa9df0 70.BR free_hugepages ()
e9496f74 71tells which page is being freed: it was the return value of a
fea681da 72call to
63aa9df0 73.BR alloc_hugepages ().
fea681da
MK
74(The memory is first actually freed when all users have released it.)
75The
76.I addr
c4bb193f 77argument of
63aa9df0 78.BR alloc_hugepages ()
fea681da
MK
79is a hint, that the kernel may or may not follow.
80Addresses must be properly aligned.
dd3568a1 81.PP
fea681da
MK
82The
83.I len
c4bb193f 84argument is the length of the required segment.
c13182ef 85It must be a multiple of the huge page size.
dd3568a1 86.PP
fea681da
MK
87The
88.I prot
c4bb193f 89argument specifies the memory protection of the segment.
682edefb
MK
90It is one of
91.BR PROT_READ ,
92.BR PROT_WRITE ,
93.BR PROT_EXEC .
dd3568a1 94.PP
fea681da
MK
95The
96.I flag
c4bb193f 97argument is ignored, unless
fea681da 98.I key
c13182ef
MK
99is positive.
100In that case, if
fea681da 101.I flag
682edefb
MK
102is
103.BR IPC_CREAT ,
104then a new huge page segment is created when none
c13182ef 105with the given key existed.
682edefb 106If this flag is not set, then
0daa9e92 107.B ENOENT
fea681da 108is returned when no segment with the given key exists.
47297adb 109.SH RETURN VALUE
fea681da 110On success,
e511ffb6 111.BR alloc_hugepages ()
fea681da 112returns the allocated virtual address, and
e511ffb6 113.BR free_hugepages ()
c13182ef
MK
114returns zero.
115On error, \-1 is returned, and
fea681da
MK
116.I errno
117is set appropriately.
118.SH ERRORS
119.TP
120.B ENOSYS
121The system call is not supported on this kernel.
fea681da 122.SH FILES
09bf2ec8 123.TP
fea681da
MK
124.I /proc/sys/vm/nr_hugepages
125Number of configured hugetlb pages.
126This can be read and written.
09bf2ec8 127.TP
fea681da
MK
128.I /proc/meminfo
129Gives info on the number of configured hugetlb pages and on their size
130in the three variables HugePages_Total, HugePages_Free, Hugepagesize.
47297adb 131.SH CONFORMING TO
2b2581ee
MK
132These calls are specific to Linux on Intel processors, and should not be
133used in programs intended to be portable.
fea681da 134.SH NOTES
d1dcf598
MK
135These system calls are gone;
136they existed only in Linux 2.5.36 through to 2.5.54.
9ee4a2b6 137Now the hugetlbfs filesystem can be used instead.
fea681da 138Memory backed by huge pages (if the CPU supports them) is obtained by
1e321034 139using
0bfa087b 140.BR mmap (2)
9ee4a2b6 141to map files in this virtual filesystem.
dd3568a1 142.PP
fea681da
MK
143The maximal number of huge pages can be specified using the
144.B hugepages=
145boot parameter.
558b6205 146.PP
fea681da
MK
147.\" requires CONFIG_HUGETLB_PAGE (under "Processor type and features")
148.\" and CONFIG_HUGETLBFS (under "Filesystems").
149.\" mount -t hugetlbfs hugetlbfs /huge
150.\" SHM_HUGETLB