OSDN Git Service

(split) LDP: Update original to LDP v3.65
[linuxjm/LDP_man-pages.git] / original / man2 / alloc_hugepages.2
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 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
45 .BR CONFIG_HUGETLB_PAGE ).
46 In Linux 2.4.20 the syscall numbers exist,
47 but the calls fail with the error
48 .BR ENOSYS .
49 .LP
50 On i386 the memory management hardware knows about ordinary pages (4 KiB)
51 and huge pages (2 or 4 MiB).
52 Similarly ia64 knows about huge pages of
53 several sizes.
54 These system calls serve to map huge pages into the
55 process's memory or to free them again.
56 Huge pages are locked into memory, and are not swapped.
57 .LP
58 The
59 .I key
60 argument is an identifier.
61 When zero the pages are private, and
62 not inherited by children.
63 When positive the pages are shared with other applications using the same
64 .IR key ,
65 and inherited by child processes.
66 .LP
67 The
68 .I addr
69 argument of
70 .BR free_hugepages ()
71 tells which page is being freed: it was the return value of a
72 call to
73 .BR alloc_hugepages ().
74 (The memory is first actually freed when all users have released it.)
75 The
76 .I addr
77 argument of
78 .BR alloc_hugepages ()
79 is a hint, that the kernel may or may not follow.
80 Addresses must be properly aligned.
81 .LP
82 The
83 .I len
84 argument is the length of the required segment.
85 It must be a multiple of the huge page size.
86 .LP
87 The
88 .I prot
89 argument specifies the memory protection of the segment.
90 It is one of
91 .BR PROT_READ ,
92 .BR PROT_WRITE ,
93 .BR PROT_EXEC .
94 .LP
95 The
96 .I flag
97 argument is ignored, unless
98 .I key
99 is positive.
100 In that case, if
101 .I flag
102 is
103 .BR IPC_CREAT ,
104 then a new huge page segment is created when none
105 with the given key existed.
106 If this flag is not set, then
107 .B ENOENT
108 is returned when no segment with the given key exists.
109 .SH RETURN VALUE
110 On success,
111 .BR alloc_hugepages ()
112 returns the allocated virtual address, and
113 .BR free_hugepages ()
114 returns zero.
115 On error, \-1 is returned, and
116 .I errno
117 is set appropriately.
118 .SH ERRORS
119 .TP
120 .B ENOSYS
121 The system call is not supported on this kernel.
122 .SH FILES
123 .I /proc/sys/vm/nr_hugepages
124 Number of configured hugetlb pages.
125 This can be read and written.
126 .LP
127 .I /proc/meminfo
128 Gives info on the number of configured hugetlb pages and on their size
129 in the three variables HugePages_Total, HugePages_Free, Hugepagesize.
130 .SH CONFORMING TO
131 These calls are specific to Linux on Intel processors, and should not be
132 used in programs intended to be portable.
133 .SH NOTES
134 These system calls are gone;
135 they existed only in Linux 2.5.36 through to 2.5.54.
136 Now the hugetlbfs filesystem can be used instead.
137 Memory backed by huge pages (if the CPU supports them) is obtained by
138 using
139 .BR mmap (2)
140 to map files in this virtual filesystem.
141 .LP
142 The maximal number of huge pages can be specified using the
143 .B hugepages=
144 boot parameter.
145
146 .\" requires CONFIG_HUGETLB_PAGE (under "Processor type and features")
147 .\" and CONFIG_HUGETLBFS (under "Filesystems").
148 .\" mount -t hugetlbfs hugetlbfs /huge
149 .\" SHM_HUGETLB
150 .SH COLOPHON
151 This page is part of release 3.65 of the Linux
152 .I man-pages
153 project.
154 A description of the project,
155 and information about reporting bugs,
156 can be found at
157 \%http://www.kernel.org/doc/man\-pages/.