1 # SOME DESCRIPTIVE TITLE
2 # Copyright (C) YEAR Free Software Foundation, Inc.
3 # This file is distributed under the same license as the PACKAGE package.
4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
9 "Project-Id-Version: PACKAGE VERSION\n"
10 "POT-Creation-Date: 2012-05-10 20:03+0900\n"
11 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13 "Language-Team: LANGUAGE <LL@li.org>\n"
16 "Content-Type: text/plain; charset=UTF-8\n"
17 "Content-Transfer-Encoding: 8bit\n"
20 #: build/C/man2/alloc_hugepages.2:25
22 msgid "ALLOC_HUGEPAGES"
26 #: build/C/man2/alloc_hugepages.2:25
32 #: build/C/man2/alloc_hugepages.2:25 build/C/man2/cacheflush.2:24 build/C/man2/fallocate.2:8 build/C/man2/madvise.2:35 build/C/man3/malloc_trim.3:24 build/C/man3/mallopt.3:24 build/C/man2/mlock.2:27 build/C/man2/mmap.2:40 build/C/man2/mmap2.2:29 build/C/man2/mprotect.2:32 build/C/man2/mremap.2:31 build/C/man2/msync.2:25 build/C/man2/posix_fadvise.2:27 build/C/man2/readahead.2:28 build/C/man2/remap_file_pages.2:26 build/C/man3/shm_open.3:26 build/C/man7/shm_overview.7:27 build/C/man2/shmctl.2:43 build/C/man2/shmget.2:36 build/C/man2/shmop.2:39 build/C/man2/subpage_prot.2:28 build/C/man2/sync_file_range.2:30
38 #: build/C/man2/alloc_hugepages.2:25 build/C/man3/alloca.3:41 build/C/man2/cacheflush.2:24 build/C/man2/fallocate.2:8 build/C/man2/madvise.2:35 build/C/man3/malloc_get_state.3:23 build/C/man3/malloc_hook.3:6 build/C/man3/malloc_trim.3:24 build/C/man3/malloc_usable_size.3:23 build/C/man3/mallopt.3:24 build/C/man3/mcheck.3:23 build/C/man2/mlock.2:27 build/C/man2/mmap.2:40 build/C/man2/mmap2.2:29 build/C/man2/mprotect.2:32 build/C/man2/mremap.2:31 build/C/man2/msync.2:25 build/C/man3/mtrace.3:23 build/C/man2/posix_fadvise.2:27 build/C/man3/posix_fallocate.3:23 build/C/man3/posix_memalign.3:28 build/C/man2/readahead.2:28 build/C/man2/remap_file_pages.2:26 build/C/man3/shm_open.3:26 build/C/man7/shm_overview.7:27 build/C/man2/shmctl.2:43 build/C/man2/shmget.2:36 build/C/man2/shmop.2:39 build/C/man2/subpage_prot.2:28 build/C/man2/sync_file_range.2:30
40 msgid "Linux Programmer's Manual"
44 #: build/C/man2/alloc_hugepages.2:26 build/C/man3/alloca.3:42 build/C/man2/cacheflush.2:25 build/C/man2/fallocate.2:9 build/C/man2/madvise.2:36 build/C/man3/malloc_get_state.3:24 build/C/man3/malloc_hook.3:7 build/C/man3/malloc_trim.3:25 build/C/man3/malloc_usable_size.3:24 build/C/man3/mallopt.3:25 build/C/man3/mcheck.3:24 build/C/man2/mlock.2:28 build/C/man2/mmap.2:41 build/C/man2/mmap2.2:30 build/C/man2/mprotect.2:33 build/C/man2/mremap.2:32 build/C/man2/msync.2:26 build/C/man3/mtrace.3:24 build/C/man2/posix_fadvise.2:28 build/C/man3/posix_fallocate.3:24 build/C/man3/posix_memalign.3:29 build/C/man2/readahead.2:29 build/C/man2/remap_file_pages.2:27 build/C/man3/shm_open.3:27 build/C/man7/shm_overview.7:28 build/C/man2/shmctl.2:44 build/C/man2/shmget.2:37 build/C/man2/shmop.2:40 build/C/man2/subpage_prot.2:29 build/C/man2/sync_file_range.2:31
50 #: build/C/man2/alloc_hugepages.2:28
51 msgid "alloc_hugepages, free_hugepages - allocate or free huge pages"
55 #: build/C/man2/alloc_hugepages.2:28 build/C/man3/alloca.3:44 build/C/man2/cacheflush.2:27 build/C/man2/fallocate.2:11 build/C/man2/madvise.2:38 build/C/man3/malloc_get_state.3:26 build/C/man3/malloc_hook.3:11 build/C/man3/malloc_trim.3:27 build/C/man3/malloc_usable_size.3:26 build/C/man3/mallopt.3:27 build/C/man3/mcheck.3:26 build/C/man2/mlock.2:30 build/C/man2/mmap.2:43 build/C/man2/mmap2.2:32 build/C/man2/mprotect.2:35 build/C/man2/mremap.2:34 build/C/man2/msync.2:28 build/C/man3/mtrace.3:26 build/C/man2/posix_fadvise.2:30 build/C/man3/posix_fallocate.3:26 build/C/man3/posix_memalign.3:31 build/C/man2/readahead.2:31 build/C/man2/remap_file_pages.2:29 build/C/man3/shm_open.3:29 build/C/man2/shmctl.2:46 build/C/man2/shmget.2:39 build/C/man2/shmop.2:42 build/C/man2/subpage_prot.2:31 build/C/man2/sync_file_range.2:33
60 #. asmlinkage unsigned long sys_alloc_hugepages(int key, unsigned long addr,
61 #. unsigned long len, int prot, int flag);
63 #: build/C/man2/alloc_hugepages.2:34
66 "B<void *alloc_hugepages(int >I<key>B<, void *>I<addr>B<, size_t "
68 "B< int >I<prot>B<, int >I<flag>B<);>\n"
71 #. asmlinkage int sys_free_hugepages(unsigned long addr);
73 #: build/C/man2/alloc_hugepages.2:37
75 msgid "B<int free_hugepages(void *>I<addr>B<);>\n"
79 #: build/C/man2/alloc_hugepages.2:38 build/C/man3/alloca.3:48 build/C/man2/cacheflush.2:33 build/C/man2/fallocate.2:19 build/C/man2/madvise.2:50 build/C/man3/malloc_get_state.3:34 build/C/man3/malloc_hook.3:29 build/C/man3/malloc_trim.3:31 build/C/man3/malloc_usable_size.3:30 build/C/man3/mallopt.3:31 build/C/man3/mcheck.3:39 build/C/man2/mlock.2:40 build/C/man2/mmap.2:52 build/C/man2/mmap2.2:39 build/C/man2/mprotect.2:41 build/C/man2/mremap.2:43 build/C/man2/msync.2:32 build/C/man3/mtrace.3:32 build/C/man2/posix_fadvise.2:49 build/C/man3/posix_fallocate.3:44 build/C/man3/posix_memalign.3:83 build/C/man2/readahead.2:38 build/C/man2/remap_file_pages.2:37 build/C/man3/shm_open.3:41 build/C/man7/shm_overview.7:30 build/C/man2/shmctl.2:54 build/C/man2/shmget.2:47 build/C/man2/shmop.2:51 build/C/man2/subpage_prot.2:36 build/C/man2/sync_file_range.2:41
85 #: build/C/man2/alloc_hugepages.2:49
87 "The system calls B<alloc_hugepages>() and B<free_hugepages>() were "
88 "introduced in Linux 2.5.36 and removed again in 2.5.54. They existed only "
89 "on i386 and ia64 (when built with B<CONFIG_HUGETLB_PAGE>). In Linux 2.4.20 "
90 "the syscall numbers exist, but the calls fail with the error B<ENOSYS>."
94 #: build/C/man2/alloc_hugepages.2:57
96 "On i386 the memory management hardware knows about ordinary pages (4 KiB) "
97 "and huge pages (2 or 4 MiB). Similarly ia64 knows about huge pages of "
98 "several sizes. These system calls serve to map huge pages into the "
99 "process's memory or to free them again. Huge pages are locked into memory, "
100 "and are not swapped."
104 #: build/C/man2/alloc_hugepages.2:66
106 "The I<key> argument is an identifier. When zero the pages are private, and "
107 "not inherited by children. When positive the pages are shared with other "
108 "applications using the same I<key>, and inherited by child processes."
112 #: build/C/man2/alloc_hugepages.2:81
114 "The I<addr> argument of B<free_hugepages>() tells which page is being "
115 "freed: it was the return value of a call to B<alloc_hugepages>(). (The "
116 "memory is first actually freed when all users have released it.) The "
117 "I<addr> argument of B<alloc_hugepages>() is a hint, that the kernel may or "
118 "may not follow. Addresses must be properly aligned."
122 #: build/C/man2/alloc_hugepages.2:86
124 "The I<len> argument is the length of the required segment. It must be a "
125 "multiple of the huge page size."
129 #: build/C/man2/alloc_hugepages.2:94
131 "The I<prot> argument specifies the memory protection of the segment. It is "
132 "one of B<PROT_READ>, B<PROT_WRITE>, B<PROT_EXEC>."
136 #: build/C/man2/alloc_hugepages.2:109
138 "The I<flag> argument is ignored, unless I<key> is positive. In that case, "
139 "if I<flag> is B<IPC_CREAT>, then a new huge page segment is created when "
140 "none with the given key existed. If this flag is not set, then B<ENOENT> is "
141 "returned when no segment with the given key exists."
145 #: build/C/man2/alloc_hugepages.2:109 build/C/man3/alloca.3:58 build/C/man2/cacheflush.2:52 build/C/man2/fallocate.2:109 build/C/man2/madvise.2:250 build/C/man3/malloc_get_state.3:59 build/C/man3/malloc_trim.3:49 build/C/man3/malloc_usable_size.3:38 build/C/man3/mallopt.3:377 build/C/man3/mcheck.3:128 build/C/man2/mlock.2:117 build/C/man2/mmap.2:373 build/C/man2/mmap2.2:54 build/C/man2/mprotect.2:72 build/C/man2/mremap.2:128 build/C/man2/msync.2:68 build/C/man2/posix_fadvise.2:86 build/C/man3/posix_fallocate.3:64 build/C/man3/posix_memalign.3:141 build/C/man2/readahead.2:65 build/C/man2/remap_file_pages.2:122 build/C/man3/shm_open.3:169 build/C/man2/shmctl.2:272 build/C/man2/shmget.2:178 build/C/man2/shmop.2:169 build/C/man2/subpage_prot.2:61 build/C/man2/sync_file_range.2:141
151 #: build/C/man2/alloc_hugepages.2:118
153 "On success, B<alloc_hugepages>() returns the allocated virtual address, and "
154 "B<free_hugepages>() returns zero. On error, -1 is returned, and I<errno> "
155 "is set appropriately."
159 #: build/C/man2/alloc_hugepages.2:118 build/C/man2/cacheflush.2:58 build/C/man2/fallocate.2:112 build/C/man2/madvise.2:257 build/C/man3/malloc_trim.3:54 build/C/man3/mallopt.3:382 build/C/man2/mlock.2:123 build/C/man2/mmap.2:390 build/C/man2/mmap2.2:61 build/C/man2/mprotect.2:79 build/C/man2/mremap.2:136 build/C/man2/msync.2:73 build/C/man2/posix_fadvise.2:89 build/C/man3/posix_fallocate.3:70 build/C/man3/posix_memalign.3:155 build/C/man2/readahead.2:71 build/C/man2/remap_file_pages.2:129 build/C/man3/shm_open.3:178 build/C/man2/shmctl.2:294 build/C/man2/shmget.2:182 build/C/man2/shmop.2:183 build/C/man2/subpage_prot.2:66 build/C/man2/sync_file_range.2:147
165 #: build/C/man2/alloc_hugepages.2:119 build/C/man2/fallocate.2:151
171 #: build/C/man2/alloc_hugepages.2:122
172 msgid "The system call is not supported on this kernel."
176 #: build/C/man2/alloc_hugepages.2:122
182 #: build/C/man2/alloc_hugepages.2:126
184 "I</proc/sys/vm/nr_hugepages> Number of configured hugetlb pages. This can "
185 "be read and written."
189 #: build/C/man2/alloc_hugepages.2:130
191 "I</proc/meminfo> Gives info on the number of configured hugetlb pages and on "
192 "their size in the three variables HugePages_Total, HugePages_Free, "
197 #: build/C/man2/alloc_hugepages.2:130 build/C/man3/alloca.3:63 build/C/man2/cacheflush.2:74 build/C/man2/fallocate.2:188 build/C/man2/madvise.2:307 build/C/man3/malloc_get_state.3:84 build/C/man3/malloc_hook.3:76 build/C/man3/malloc_trim.3:58 build/C/man3/malloc_usable_size.3:46 build/C/man3/mallopt.3:390 build/C/man3/mcheck.3:144 build/C/man2/mlock.2:187 build/C/man2/mmap.2:483 build/C/man2/mmap2.2:77 build/C/man2/mprotect.2:107 build/C/man2/mremap.2:186 build/C/man2/msync.2:96 build/C/man3/mtrace.3:76 build/C/man2/posix_fadvise.2:111 build/C/man3/posix_fallocate.3:101 build/C/man3/posix_memalign.3:180 build/C/man2/readahead.2:87 build/C/man2/remap_file_pages.2:151 build/C/man3/shm_open.3:249 build/C/man7/shm_overview.7:101 build/C/man2/shmctl.2:366 build/C/man2/shmget.2:229 build/C/man2/shmop.2:226 build/C/man2/subpage_prot.2:91 build/C/man2/sync_file_range.2:180
199 msgid "CONFORMING TO"
203 #: build/C/man2/alloc_hugepages.2:133
205 "These calls are specific to Linux on Intel processors, and should not be "
206 "used in programs intended to be portable."
210 #: build/C/man2/alloc_hugepages.2:133 build/C/man3/alloca.3:71 build/C/man2/madvise.2:328 build/C/man3/malloc_get_state.3:86 build/C/man3/malloc_hook.3:78 build/C/man3/malloc_trim.3:60 build/C/man3/malloc_trim.3:72 build/C/man3/malloc_usable_size.3:48 build/C/man3/mcheck.3:146 build/C/man2/mlock.2:214 build/C/man2/mmap.2:501 build/C/man2/mmap2.2:79 build/C/man2/mprotect.2:116 build/C/man2/mremap.2:192 build/C/man3/mtrace.3:78 build/C/man2/posix_fadvise.2:120 build/C/man3/posix_memalign.3:219 build/C/man3/shm_open.3:255 build/C/man7/shm_overview.7:103 build/C/man2/shmctl.2:371 build/C/man2/shmget.2:235 build/C/man2/shmop.2:245 build/C/man2/subpage_prot.2:93 build/C/man2/sync_file_range.2:183
216 #: build/C/man2/alloc_hugepages.2:141
218 "These system calls are gone; they existed only in Linux 2.5.36 through to "
219 "2.5.54. Now the hugetlbfs file system can be used instead. Memory backed "
220 "by huge pages (if the CPU supports them) is obtained by using B<mmap>(2) to "
221 "map files in this virtual file system."
225 #: build/C/man2/alloc_hugepages.2:145
227 "The maximal number of huge pages can be specified using the B<hugepages=> "
232 #: build/C/man2/alloc_hugepages.2:150 build/C/man3/alloca.3:153 build/C/man2/cacheflush.2:88 build/C/man2/fallocate.2:195 build/C/man2/madvise.2:360 build/C/man3/malloc_get_state.3:112 build/C/man3/malloc_hook.3:138 build/C/man3/malloc_trim.3:80 build/C/man3/malloc_usable_size.3:62 build/C/man3/mallopt.3:580 build/C/man3/mcheck.3:211 build/C/man2/mlock.2:337 build/C/man2/mmap.2:671 build/C/man2/mmap2.2:98 build/C/man2/mprotect.2:223 build/C/man2/mremap.2:214 build/C/man2/msync.2:122 build/C/man3/mtrace.3:170 build/C/man2/posix_fadvise.2:188 build/C/man3/posix_fallocate.3:130 build/C/man3/posix_memalign.3:275 build/C/man2/readahead.2:98 build/C/man2/remap_file_pages.2:162 build/C/man3/shm_open.3:280 build/C/man7/shm_overview.7:127 build/C/man2/shmctl.2:410 build/C/man2/shmget.2:298 build/C/man2/shmop.2:290 build/C/man2/subpage_prot.2:126 build/C/man2/sync_file_range.2:222
238 #: build/C/man2/alloc_hugepages.2:157 build/C/man3/alloca.3:160 build/C/man2/cacheflush.2:95 build/C/man2/fallocate.2:202 build/C/man2/madvise.2:367 build/C/man3/malloc_get_state.3:119 build/C/man3/malloc_hook.3:145 build/C/man3/malloc_trim.3:87 build/C/man3/malloc_usable_size.3:69 build/C/man3/mallopt.3:587 build/C/man3/mcheck.3:218 build/C/man2/mlock.2:344 build/C/man2/mmap.2:678 build/C/man2/mmap2.2:105 build/C/man2/mprotect.2:230 build/C/man2/mremap.2:221 build/C/man2/msync.2:129 build/C/man3/mtrace.3:177 build/C/man2/posix_fadvise.2:195 build/C/man3/posix_fallocate.3:137 build/C/man3/posix_memalign.3:282 build/C/man2/readahead.2:105 build/C/man2/remap_file_pages.2:169 build/C/man3/shm_open.3:287 build/C/man7/shm_overview.7:134 build/C/man2/shmctl.2:417 build/C/man2/shmget.2:305 build/C/man2/shmop.2:297 build/C/man2/subpage_prot.2:133 build/C/man2/sync_file_range.2:229
240 "This page is part of release 3.40 of the Linux I<man-pages> project. A "
241 "description of the project, and information about reporting bugs, can be "
242 "found at http://www.kernel.org/doc/man-pages/."
246 #: build/C/man3/alloca.3:41
252 #: build/C/man3/alloca.3:41
258 #: build/C/man3/alloca.3:41 build/C/man3/malloc_get_state.3:23 build/C/man3/malloc_hook.3:6 build/C/man3/malloc_usable_size.3:23 build/C/man3/mcheck.3:23 build/C/man3/mtrace.3:23 build/C/man3/posix_fallocate.3:23 build/C/man3/posix_memalign.3:28
264 #: build/C/man3/alloca.3:44
265 msgid "alloca - allocate memory that is automatically freed"
269 #: build/C/man3/alloca.3:46
270 msgid "B<#include E<lt>alloca.hE<gt>>"
274 #: build/C/man3/alloca.3:48
275 msgid "B<void *alloca(size_t >I<size>B<);>"
279 #: build/C/man3/alloca.3:58
281 "The B<alloca>() function allocates I<size> bytes of space in the stack "
282 "frame of the caller. This temporary space is automatically freed when the "
283 "function that called B<alloca>() returns to its caller."
287 #: build/C/man3/alloca.3:63
289 "The B<alloca>() function returns a pointer to the beginning of the "
290 "allocated space. If the allocation causes stack overflow, program behavior "
295 #: build/C/man3/alloca.3:65
296 msgid "This function is not in POSIX.1-2001."
300 #: build/C/man3/alloca.3:71
302 "There is evidence that the B<alloca>() function appeared in 32V, PWB, "
303 "PWB.2, 3BSD, and 4BSD. There is a man page for it in 4.3BSD. Linux uses "
308 #: build/C/man3/alloca.3:86
310 "The B<alloca>() function is machine- and compiler-dependent. For certain "
311 "applications, its use can improve efficiency compared to the use of "
312 "B<malloc>(3) plus B<free>(3). In certain cases, it can also simplify "
313 "memory deallocation in applications that use B<longjmp>(3) or "
314 "B<siglongjmp>(3). Otherwise, its use is discouraged."
318 #: build/C/man3/alloca.3:95
320 "Because the space allocated by B<alloca>() is allocated within the stack "
321 "frame, that space is automatically freed if the function return is jumped "
322 "over by a call to B<longjmp>(3) or B<siglongjmp>(3)."
326 #: build/C/man3/alloca.3:100
327 msgid "Do not attempt to B<free>(3) space allocated by B<alloca>()!"
331 #: build/C/man3/alloca.3:100
333 msgid "Notes on the GNU Version"
337 #: build/C/man3/alloca.3:122
339 "Normally, B<gcc>(1) translates calls to B<alloca>() with inlined code. "
340 "This is not done when either the I<-ansi>, I<-std=c89>, I<-std=c99>, or the "
341 "I<-fno-builtin> option is given (and the header I<E<lt>alloca.hE<gt>> is not "
342 "included). But beware! By default the glibc version of "
343 "I<E<lt>stdlib.hE<gt>> includes I<E<lt>alloca.hE<gt>> and that contains the "
348 #: build/C/man3/alloca.3:125
350 msgid " #define alloca(size) __builtin_alloca (size)\n"
354 #: build/C/man3/alloca.3:128
355 msgid "with messy consequences if one has a private version of this function."
359 #: build/C/man3/alloca.3:132
361 "The fact that the code is inlined means that it is impossible to take the "
362 "address of this function, or to change its behavior by linking with a "
367 #: build/C/man3/alloca.3:136
369 "The inlined code often consists of a single instruction adjusting the stack "
370 "pointer, and does not check for stack overflow. Thus, there is no NULL "
375 #: build/C/man3/alloca.3:136 build/C/man2/cacheflush.2:81 build/C/man3/mallopt.3:404 build/C/man2/mlock.2:305 build/C/man2/mmap.2:544 build/C/man3/mtrace.3:100 build/C/man2/posix_fadvise.2:177 build/C/man2/shmget.2:284
381 #: build/C/man3/alloca.3:141
383 "There is no error indication if the stack frame cannot be extended. "
384 "(However, after a failed allocation, the program is likely to receive a "
385 "B<SIGSEGV> signal if it attempts to access the unallocated space.)"
389 #: build/C/man3/alloca.3:149
391 "On many systems B<alloca>() cannot be used inside the list of arguments of "
392 "a function call, because the stack space reserved by B<alloca>() would "
393 "appear on the stack in the middle of the space for the function arguments."
397 #: build/C/man3/alloca.3:149 build/C/man2/fallocate.2:191 build/C/man2/madvise.2:353 build/C/man3/malloc_get_state.3:109 build/C/man3/malloc_hook.3:133 build/C/man3/malloc_trim.3:76 build/C/man3/malloc_usable_size.3:60 build/C/man3/mallopt.3:568 build/C/man3/mcheck.3:204 build/C/man2/mlock.2:330 build/C/man2/mmap.2:653 build/C/man2/mmap2.2:92 build/C/man2/mprotect.2:220 build/C/man2/mremap.2:200 build/C/man2/msync.2:118 build/C/man3/mtrace.3:165 build/C/man2/posix_fadvise.2:182 build/C/man3/posix_fallocate.3:126 build/C/man3/posix_memalign.3:270 build/C/man2/readahead.2:92 build/C/man2/remap_file_pages.2:155 build/C/man3/shm_open.3:269 build/C/man7/shm_overview.7:114 build/C/man2/shmctl.2:403 build/C/man2/shmget.2:290 build/C/man2/shmop.2:282 build/C/man2/subpage_prot.2:120 build/C/man2/sync_file_range.2:217
403 #: build/C/man3/alloca.3:153
404 msgid "B<brk>(2), B<longjmp>(3), B<malloc>(3)"
408 #: build/C/man2/cacheflush.2:24
414 #: build/C/man2/cacheflush.2:24
420 #: build/C/man2/cacheflush.2:27
421 msgid "cacheflush - flush contents of instruction and/or data cache"
425 #: build/C/man2/cacheflush.2:30
427 msgid "B<#include E<lt>asm/cachectl.hE<gt>>\n"
431 #: build/C/man2/cacheflush.2:32
433 msgid "B<int cacheflush(char *>I<addr>B<, int >I<nbytes>B<, int >I<cache>B<);>\n"
437 #: build/C/man2/cacheflush.2:42
439 "B<cacheflush>() flushes the contents of the indicated cache(s) for the user "
440 "addresses in the range I<addr> to I<(addr+nbytes-1)>. I<cache> may be one "
445 #: build/C/man2/cacheflush.2:42
451 #: build/C/man2/cacheflush.2:45
452 msgid "Flush the instruction cache."
456 #: build/C/man2/cacheflush.2:45
462 #: build/C/man2/cacheflush.2:48
463 msgid "Write back to memory and invalidate the affected valid cache lines."
467 #: build/C/man2/cacheflush.2:48
473 #: build/C/man2/cacheflush.2:52
474 msgid "Same as B<(ICACHE|DCACHE)>."
478 #: build/C/man2/cacheflush.2:58
480 "B<cacheflush>() returns 0 on success or -1 on error. If errors are "
481 "detected, I<errno> will indicate the error."
485 #: build/C/man2/cacheflush.2:59 build/C/man2/mmap2.2:62 build/C/man2/mremap.2:143 build/C/man2/shmctl.2:303 build/C/man2/subpage_prot.2:67
491 #: build/C/man2/cacheflush.2:66
493 "Some or all of the address range I<addr> to I<(addr+nbytes-1)> is not "
498 #: build/C/man2/cacheflush.2:66 build/C/man2/fallocate.2:124 build/C/man2/madvise.2:264 build/C/man2/mlock.2:158 build/C/man2/mlock.2:165 build/C/man2/mlock.2:177 build/C/man2/mmap.2:421 build/C/man2/mmap.2:429 build/C/man2/mmap.2:434 build/C/man2/mmap2.2:65 build/C/man2/mprotect.2:89 build/C/man2/mremap.2:152 build/C/man2/msync.2:80 build/C/man2/posix_fadvise.2:93 build/C/man3/posix_fallocate.3:79 build/C/man3/posix_memalign.3:156 build/C/man2/readahead.2:76 build/C/man2/remap_file_pages.2:130 build/C/man2/remap_file_pages.2:137 build/C/man3/shm_open.3:211 build/C/man2/shmctl.2:317 build/C/man2/shmget.2:196 build/C/man2/shmop.2:195 build/C/man2/shmop.2:218 build/C/man2/subpage_prot.2:72 build/C/man2/sync_file_range.2:152
504 #: build/C/man2/cacheflush.2:74
505 msgid "I<cache> is not one of B<ICACHE>, B<DCACHE>, or B<BCACHE>."
508 #. FIXME This system call was only on MIPS back in 1.2 days, but
509 #. by now it is on a number of other architectures (but not i386).
510 #. Investigate the details and update this page.
511 #. Irix 6.5 appears to have a cacheflush() syscall -- mtk
513 #: build/C/man2/cacheflush.2:81
515 "This Linux-specific system call is only available on MIPS-based systems. It "
516 "should not be used in programs intended to be portable."
520 #: build/C/man2/cacheflush.2:88
522 "The current implementation ignores the I<addr> and I<nbytes> arguments. "
523 "Therefore, the whole cache is always flushed."
527 #: build/C/man2/fallocate.2:8
533 #: build/C/man2/fallocate.2:8
539 #: build/C/man2/fallocate.2:11
540 msgid "fallocate - manipulate file space"
544 #: build/C/man2/fallocate.2:15 build/C/man2/readahead.2:35
547 "B<#define _GNU_SOURCE> /* See feature_test_macros(7) */\n"
548 "B<#include E<lt>fcntl.hE<gt>>\n"
552 #: build/C/man2/fallocate.2:18
555 "B<int fallocate(int >I<fd>B<, int >I<mode>B<, off_t >I<offset>B<, off_t "
560 #: build/C/man2/fallocate.2:24
562 "This is a nonportable, Linux-specific system call. For the portable, "
563 "POSIX.1-specified method of ensuring that space is allocated for a file, see "
564 "B<posix_fallocate>(3)."
568 #: build/C/man2/fallocate.2:34
570 "B<fallocate>() allows the caller to directly manipulate the allocated disk "
571 "space for the file referred to by I<fd> for the byte range starting at "
572 "I<offset> and continuing for I<len> bytes."
576 #: build/C/man2/fallocate.2:39
578 "The I<mode> argument determines the operation to be performed on the given "
579 "range. Details of the supported operations are given in the subsections "
584 #: build/C/man2/fallocate.2:39
586 msgid "Allocating disk space"
590 #: build/C/man2/fallocate.2:58
592 "The default operation (i.e., I<mode> is zero) of B<fallocate>() allocates "
593 "and initializes to zero the disk space within the range specified by "
594 "I<offset> and I<len>. The file size (as reported by B<stat>(2)) will be "
595 "changed if I<offset>+I<len> is greater than the file size. This default "
596 "behavior closely resembles the behavior of the B<posix_fallocate>(3) "
597 "library function, and is intended as a method of optimally implementing that "
602 #: build/C/man2/fallocate.2:64
604 "After a successful call, subsequent writes into the range specified by "
605 "I<offset> and I<len> are guaranteed not to fail because of lack of disk "
610 #: build/C/man2/fallocate.2:75
612 "If the B<FALLOC_FL_KEEP_SIZE> flag is specified in I<mode>, the behavior of "
613 "the call is similar, but the file size will not be changed even if "
614 "I<offset>+I<len> is greater than the file size. Preallocating zeroed blocks "
615 "beyond the end of the file in this manner is useful for optimizing append "
620 #: build/C/man2/fallocate.2:79
622 "Because allocation is done in block size chunks, B<fallocate>() may "
623 "allocate a larger range of disk space than was specified."
627 #: build/C/man2/fallocate.2:79
629 msgid "Deallocating file space"
633 #: build/C/man2/fallocate.2:94
635 "Specifying the B<FALLOC_FL_PUNCH_HOLE> flag (available since Linux 2.6.38) "
636 "in I<mode> deallocates space (i.e., creates a hole) in the byte range "
637 "starting at I<offset> and continuing for I<len> bytes. Within the specified "
638 "range, partial file system blocks are zeroed, and whole file system blocks "
639 "are removed from the file. After a successful call, subsequent reads from "
640 "this range will return zeroes."
644 #: build/C/man2/fallocate.2:105
646 "The B<FALLOC_FL_PUNCH_HOLE> flag must be ORed with B<FALLOC_FL_KEEP_SIZE> in "
647 "I<mode>; in other words, even when punching off the end of the file, the "
648 "file size (as reported by B<stat>(2)) does not change."
652 #: build/C/man2/fallocate.2:109
654 "Not all file systems support B<FALLOC_FL_PUNCH_HOLE>; if a file system "
655 "doesn't support the operation, an error is returned."
659 #: build/C/man2/fallocate.2:112
660 msgid "B<fallocate>() returns zero on success, and -1 on failure."
664 #: build/C/man2/fallocate.2:113 build/C/man2/madvise.2:261 build/C/man2/mmap.2:415 build/C/man2/posix_fadvise.2:90 build/C/man3/posix_fallocate.3:71 build/C/man2/readahead.2:72 build/C/man2/sync_file_range.2:148
670 #: build/C/man2/fallocate.2:117 build/C/man3/posix_fallocate.3:75
671 msgid "I<fd> is not a valid file descriptor, or is not opened for writing."
675 #: build/C/man2/fallocate.2:117 build/C/man3/posix_fallocate.3:75
681 #: build/C/man2/fallocate.2:121
682 msgid "I<offset>+I<len> exceeds the maximum file size."
686 #: build/C/man2/fallocate.2:121
692 #: build/C/man2/fallocate.2:124
693 msgid "A signal was caught during execution."
697 #: build/C/man2/fallocate.2:136 build/C/man3/posix_fallocate.3:85
698 msgid "I<offset> was less than 0, or I<len> was less than or equal to 0."
702 #: build/C/man2/fallocate.2:136 build/C/man2/madvise.2:292 build/C/man2/sync_file_range.2:160
708 #: build/C/man2/fallocate.2:139
709 msgid "An I/O error occurred while reading from or writing to a file system."
713 #: build/C/man2/fallocate.2:139 build/C/man2/mmap.2:450 build/C/man3/posix_fallocate.3:85
719 #: build/C/man2/fallocate.2:146
721 "I<fd> does not refer to a regular file or a directory. (If I<fd> is a pipe "
722 "or FIFO, a different error results.)"
726 #: build/C/man2/fallocate.2:146 build/C/man3/posix_fallocate.3:89 build/C/man2/shmget.2:214 build/C/man2/sync_file_range.2:166
732 #: build/C/man2/fallocate.2:151 build/C/man3/posix_fallocate.3:94
734 "There is not enough space left on the device containing the file referred to "
739 #: build/C/man2/fallocate.2:155
740 msgid "This kernel does not implement B<fallocate>()."
744 #: build/C/man2/fallocate.2:155
746 msgid "B<EOPNOTSUPP>"
750 #: build/C/man2/fallocate.2:164
752 "The file system containing the file referred to by I<fd> does not support "
753 "this operation; or the I<mode> is not supported by the file system "
754 "containing the file referred to by I<fd>."
758 #: build/C/man2/fallocate.2:164 build/C/man2/mlock.2:144 build/C/man2/mlock.2:183 build/C/man2/mmap.2:458 build/C/man2/shmctl.2:342 build/C/man2/shmget.2:222
764 #: build/C/man2/fallocate.2:180
766 "The file referred to by I<fd> is marked immutable (see B<chattr>(1)). Or: "
767 "I<mode> specifies B<FALLOC_FL_PUNCH_HOLE> and the file referred to by I<fd> "
768 "is marked append-only (see B<chattr>(1))."
772 #: build/C/man2/fallocate.2:180 build/C/man2/posix_fadvise.2:96 build/C/man3/posix_fallocate.3:94 build/C/man2/sync_file_range.2:169
778 #: build/C/man2/fallocate.2:184
779 msgid "I<fd> refers to a pipe or FIFO."
783 #: build/C/man2/fallocate.2:184 build/C/man3/mcheck.3:133 build/C/man2/mmap2.2:74 build/C/man2/posix_fadvise.2:103 build/C/man3/posix_fallocate.3:98 build/C/man3/posix_memalign.3:165 build/C/man2/readahead.2:82 build/C/man2/remap_file_pages.2:146 build/C/man3/shm_open.3:247 build/C/man2/subpage_prot.2:85 build/C/man2/sync_file_range.2:177
789 #: build/C/man2/fallocate.2:188
791 "B<fallocate>() is available on Linux since kernel 2.6.23. Support is "
792 "provided by glibc since version 2.10."
796 #: build/C/man2/fallocate.2:191
797 msgid "B<fallocate>() is Linux-specific."
801 #: build/C/man2/fallocate.2:195
802 msgid "B<ftruncate>(2), B<posix_fadvise>(3), B<posix_fallocate>(3)"
806 #: build/C/man2/madvise.2:35
812 #: build/C/man2/madvise.2:35
818 #: build/C/man2/madvise.2:38
819 msgid "madvise - give advice about use of memory"
823 #: build/C/man2/madvise.2:40 build/C/man2/msync.2:30 build/C/man3/shm_open.3:31
824 msgid "B<#include E<lt>sys/mman.hE<gt>>"
828 #: build/C/man2/madvise.2:42
829 msgid "B<int madvise(void *>I<addr>B<, size_t >I<length>B<, int >I<advice>B<);>"
833 #: build/C/man2/madvise.2:46 build/C/man2/posix_fadvise.2:42 build/C/man3/posix_fallocate.3:37 build/C/man3/posix_memalign.3:48
834 msgid "Feature Test Macro Requirements for glibc (see B<feature_test_macros>(7)):"
838 #: build/C/man2/madvise.2:50
839 msgid "B<madvise>(): _BSD_SOURCE"
843 #: build/C/man2/madvise.2:68
845 "The B<madvise>() system call advises the kernel about how to handle paging "
846 "input/output in the address range beginning at address I<addr> and with size "
847 "I<length> bytes. It allows an application to tell the kernel how it expects "
848 "to use some mapped or shared memory areas, so that the kernel can choose "
849 "appropriate read-ahead and caching techniques. This call does not influence "
850 "the semantics of the application (except in the case of B<MADV_DONTNEED>), "
851 "but may influence its performance. The kernel is free to ignore the advice."
855 #: build/C/man2/madvise.2:72
856 msgid "The advice is indicated in the I<advice> argument which can be"
860 #: build/C/man2/madvise.2:72
862 msgid "B<MADV_NORMAL>"
866 #: build/C/man2/madvise.2:76
867 msgid "No special treatment. This is the default."
871 #: build/C/man2/madvise.2:76
873 msgid "B<MADV_RANDOM>"
877 #: build/C/man2/madvise.2:80
879 "Expect page references in random order. (Hence, read ahead may be less "
880 "useful than normally.)"
884 #: build/C/man2/madvise.2:80
886 msgid "B<MADV_SEQUENTIAL>"
890 #: build/C/man2/madvise.2:85
892 "Expect page references in sequential order. (Hence, pages in the given "
893 "range can be aggressively read ahead, and may be freed soon after they are "
898 #: build/C/man2/madvise.2:85
900 msgid "B<MADV_WILLNEED>"
904 #: build/C/man2/madvise.2:89
906 "Expect access in the near future. (Hence, it might be a good idea to read "
911 #: build/C/man2/madvise.2:89
913 msgid "B<MADV_DONTNEED>"
917 #: build/C/man2/madvise.2:100
919 "Do not expect access in the near future. (For the time being, the "
920 "application is finished with the given range, so the kernel can free "
921 "resources associated with it.) Subsequent accesses of pages in this range "
922 "will succeed, but will result either in reloading of the memory contents "
923 "from the underlying mapped file (see B<mmap>(2)) or zero-fill-on-demand "
924 "pages for mappings without an underlying file."
928 #: build/C/man2/madvise.2:100
930 msgid "B<MADV_REMOVE> (Since Linux 2.6.16)"
934 #. Databases want to use this feature to drop a section of their
935 #. bufferpool (shared memory segments) - without writing back to
936 #. disk/swap space. This feature is also useful for supporting
937 #. hot-plug memory on UML.
939 #: build/C/man2/madvise.2:113
941 "Free up a given range of pages and its associated backing store. Currently, "
942 "only shmfs/tmpfs supports this; other file systems return with the error "
947 #: build/C/man2/madvise.2:113
949 msgid "B<MADV_DONTFORK> (Since Linux 2.6.16)"
952 #. See http://lwn.net/Articles/171941/
953 #. [PATCH] madvise MADV_DONTFORK/MADV_DOFORK
954 #. Currently, copy-on-write may change the physical address of
955 #. a page even if the user requested that the page is pinned in
956 #. memory (either by mlock or by get_user_pages). This happens
957 #. if the process forks meanwhile, and the parent writes to that
958 #. page. As a result, the page is orphaned: in case of
959 #. get_user_pages, the application will never see any data hardware
960 #. DMA's into this page after the COW. In case of mlock'd memory,
961 #. the parent is not getting the realtime/security benefits of mlock.
963 #. In particular, this affects the Infiniband modules which do DMA from
964 #. and into user pages all the time.
966 #. This patch adds madvise options to control whether memory range is
967 #. inherited across fork. Useful e.g. for when hardware is doing DMA
968 #. from/into these pages. Could also be useful to an application
969 #. wanting to speed up its forks by cutting large areas out of
972 #. SEE ALSO: http://lwn.net/Articles/171941/
973 #. "Tweaks to madvise() and posix_fadvise()", 14 Feb 2006
975 #: build/C/man2/madvise.2:144
977 "Do not make the pages in this range available to the child after a "
978 "B<fork>(2). This is useful to prevent copy-on-write semantics from changing "
979 "the physical location of a page(s) if the parent writes to it after a "
980 "B<fork>(2). (Such page relocations cause problems for hardware that DMAs "
985 #: build/C/man2/madvise.2:144
987 msgid "B<MADV_DOFORK> (Since Linux 2.6.16)"
991 #: build/C/man2/madvise.2:150
993 "Undo the effect of B<MADV_DONTFORK>, restoring the default behavior, whereby "
994 "a mapping is inherited across B<fork>(2)."
998 #: build/C/man2/madvise.2:150
1000 msgid "B<MADV_HWPOISON> (Since Linux 2.6.32)"
1004 #: build/C/man2/madvise.2:162
1006 "Poison a page and handle it like a hardware memory corruption. This "
1007 "operation is only available for privileged (B<CAP_SYS_ADMIN>) processes. "
1008 "This operation may result in the calling process receiving a B<SIGBUS> and "
1009 "the page being unmapped. This feature is intended for testing of memory "
1010 "error-handling code; it is only available if the kernel was configured with "
1011 "B<CONFIG_MEMORY_FAILURE>."
1015 #: build/C/man2/madvise.2:162
1017 msgid "B<MADV_SOFT_OFFLINE> (Since Linux 2.6.33)"
1021 #: build/C/man2/madvise.2:180
1023 "Soft offline the pages in the range specified by I<addr> and I<length>. The "
1024 "memory of each page in the specified range is preserved (i.e., when next "
1025 "accessed, the same content will be visible, but in a new physical page "
1026 "frame), and the original page is offlined (i.e., no longer used, and taken "
1027 "out of normal memory management). The effect of the B<MADV_SOFT_OFFLINE> "
1028 "operation is invisible to (i.e., does not change the semantics of) the "
1029 "calling process. This feature is intended for testing of memory "
1030 "error-handling code; it is only available if the kernel was configured with "
1031 "B<CONFIG_MEMORY_FAILURE>."
1035 #: build/C/man2/madvise.2:180
1037 msgid "B<MADV_MERGEABLE> (since Linux 2.6.32)"
1041 #: build/C/man2/madvise.2:205
1043 "Enable Kernel Samepage Merging (KSM) for the pages in the range specified by "
1044 "I<addr> and I<length>. The kernel regularly scans those areas of user "
1045 "memory that have been marked as mergeable, looking for pages with identical "
1046 "content. These are replaced by a single write-protected page (which is "
1047 "automatically copied if a process later wants to update the content of the "
1048 "page). KSM only merges private anonymous pages (see B<mmap>(2)). The KSM "
1049 "feature is intended for applications that generate many instances of the "
1050 "same data (e.g., virtualization systems such as KVM). It can consume a lot "
1051 "of processing power; use with care. See the kernel source file "
1052 "I<Documentation/vm/ksm.txt> for more details. The B<MADV_MERGEABLE> and "
1053 "B<MADV_UNMERGEABLE> operations are only available if the kernel was "
1054 "configured with B<CONFIG_KSM>."
1058 #: build/C/man2/madvise.2:205
1060 msgid "B<MADV_UNMERGEABLE> (since Linux 2.6.32)"
1064 #: build/C/man2/madvise.2:214
1066 "Undo the effect of an earlier B<MADV_MERGEABLE> operation on the specified "
1067 "address range; KSM unmerges whatever pages it had merged in the address "
1068 "range specified by I<addr> and I<length>."
1072 #: build/C/man2/madvise.2:214
1074 msgid "B<MADV_HUGEPAGE> (since Linux 2.6.38)"
1077 #. http://lwn.net/Articles/358904/
1078 #. https://lwn.net/Articles/423584/
1080 #: build/C/man2/madvise.2:243
1082 "Enables Transparent Huge Pages (THP) for pages in the range specified by "
1083 "I<addr> and I<length>. Currently, Transparent Huge Pages only work with "
1084 "private anonymous pages (see B<mmap>(2)). The kernel will regularly scan "
1085 "the areas marked as huge page candidates to replace them with huge pages. "
1086 "The kernel will also allocate huge pages directly when the region is "
1087 "naturally aligned to the huge page size (see B<posix_memalign>(2)). This "
1088 "feature is primarily aimed at applications that use large mappings of data "
1089 "and access large regions of that memory at a time (e.g. virtualization "
1090 "systems such as QEMU). It can very easily waste memory (e.g. a 2MB mapping "
1091 "that only ever accesses 1 byte will result in 2MB of wired memory instead of "
1092 "one 4KB page). See the kernel source file I<Documentation/vm/transhuge.txt> "
1093 "for more details. The B<MADV_HUGEPAGE> and B<MADV_NOHUGEPAGE> operations "
1094 "are only available if the kernel was configured with "
1095 "B<CONFIG_TRANSPARENT_HUGEPAGE>."
1099 #: build/C/man2/madvise.2:243
1101 msgid "B<MADV_NOHUGEPAGE> (since Linux 2.6.38)"
1105 #: build/C/man2/madvise.2:250
1107 "Ensures that memory in the address range specified by I<addr> and I<length> "
1108 "will not be collapsed into huge pages."
1112 #: build/C/man2/madvise.2:257
1114 "On success B<madvise>() returns zero. On error, it returns -1 and I<errno> "
1115 "is set appropriately."
1119 #: build/C/man2/madvise.2:258 build/C/man2/mlock.2:155 build/C/man2/mmap.2:411 build/C/man2/mremap.2:137
1125 #: build/C/man2/madvise.2:261
1126 msgid "A kernel resource was temporarily unavailable."
1130 #: build/C/man2/madvise.2:264
1131 msgid "The map exists, but the area maps something that isn't a file."
1135 #: build/C/man2/madvise.2:267
1136 msgid "This error can occur for the following reasons:"
1140 #: build/C/man2/madvise.2:268 build/C/man2/madvise.2:274 build/C/man2/madvise.2:277 build/C/man2/madvise.2:280 build/C/man2/madvise.2:283 build/C/man3/mallopt.3:233 build/C/man3/mallopt.3:239
1148 #: build/C/man2/madvise.2:274
1149 msgid "The value I<len> is negative."
1153 #: build/C/man2/madvise.2:277
1154 msgid "I<addr> is not page-aligned."
1158 #: build/C/man2/madvise.2:280
1159 msgid "I<advice> is not a valid value"
1163 #: build/C/man2/madvise.2:283
1165 "The application is attempting to release locked or shared pages (with "
1166 "B<MADV_DONTNEED>)."
1170 #: build/C/man2/madvise.2:291
1172 "B<MADV_MERGEABLE> or B<MADV_UNMERGEABLE> was specified in I<advice>, but the "
1173 "kernel was not configured with B<CONFIG_KSM>."
1177 #: build/C/man2/madvise.2:298
1179 "(for B<MADV_WILLNEED>) Paging in this area would exceed the process's "
1180 "maximum resident set size."
1184 #: build/C/man2/madvise.2:298 build/C/man2/madvise.2:303 build/C/man2/mlock.2:124 build/C/man2/mlock.2:132 build/C/man2/mlock.2:170 build/C/man2/mmap.2:454 build/C/man2/mprotect.2:94 build/C/man2/mprotect.2:97 build/C/man2/mremap.2:180 build/C/man2/msync.2:93 build/C/man3/posix_memalign.3:162 build/C/man2/shmctl.2:326 build/C/man2/shmget.2:211 build/C/man2/shmop.2:209 build/C/man2/subpage_prot.2:82 build/C/man2/sync_file_range.2:163
1190 #: build/C/man2/madvise.2:303
1191 msgid "(for B<MADV_WILLNEED>) Not enough memory: paging in failed."
1195 #: build/C/man2/madvise.2:307
1197 "Addresses in the specified range are not currently mapped, or are outside "
1198 "the address space of the process."
1201 #. FIXME . Write a posix_fadvise(3) page.
1203 #: build/C/man2/madvise.2:319
1205 "POSIX.1b. POSIX.1-2001 describes B<posix_madvise>(3) with constants "
1206 "B<POSIX_MADV_NORMAL>, etc., with a behavior close to that described here. "
1207 "There is a similar B<posix_fadvise>(2) for file access."
1211 #: build/C/man2/madvise.2:328
1213 "B<MADV_REMOVE>, B<MADV_DONTFORK>, B<MADV_DOFORK>, B<MADV_HWPOISON>, "
1214 "B<MADV_MERGEABLE>, and B<MADV_UNMERGEABLE> are Linux-specific."
1218 #: build/C/man2/madvise.2:329 build/C/man2/mlock.2:268 build/C/man2/shmget.2:278
1224 #: build/C/man2/madvise.2:337
1226 "The current Linux implementation (2.4.0) views this system call more as a "
1227 "command than as advice and hence may return an error when it cannot do what "
1228 "it usually would do in response to this advice. (See the ERRORS description "
1229 "above.) This is nonstandard behavior."
1235 #. function first appeared in 4.4BSD.
1237 #: build/C/man2/madvise.2:353
1239 "The Linux implementation requires that the address I<addr> be page-aligned, "
1240 "and allows I<length> to be zero. If there are some parts of the specified "
1241 "address range that are not mapped, the Linux version of B<madvise>() "
1242 "ignores them and applies the call to the rest (but returns B<ENOMEM> from "
1243 "the system call, as it should)."
1247 #: build/C/man2/madvise.2:360
1249 "B<getrlimit>(2), B<mincore>(2), B<mmap>(2), B<mprotect>(2), B<msync>(2), "
1254 #: build/C/man3/malloc_get_state.3:23
1256 msgid "MALLOC_GET_STATE"
1260 #: build/C/man3/malloc_get_state.3:23
1266 #: build/C/man3/malloc_get_state.3:26
1268 "get_malloc_state, set_malloc_state - record and restore state of malloc "
1273 #: build/C/man3/malloc_get_state.3:29 build/C/man3/posix_memalign.3:34
1275 msgid "B<#include E<lt>stdlib.hE<gt>>\n"
1279 #: build/C/man3/malloc_get_state.3:31
1281 msgid "B<void* malloc_get_state(void);>\n"
1285 #: build/C/man3/malloc_get_state.3:33
1287 msgid "B<int malloc_set_state(void *>I<state>B<);>\n"
1291 #: build/C/man3/malloc_get_state.3:51
1293 "The B<malloc_get_state>() function records the current state of all "
1294 "B<malloc>(3) internal bookkeeping variables (but not the actual contents of "
1295 "the heap or the state of B<malloc_hook>(3) functions pointers). The state "
1296 "is recorded in a system-dependent opaque data structure dynamically "
1297 "allocated via B<malloc>(3), and a pointer to that data structure is returned "
1298 "as the function result. (It is the caller's responsibility to B<free>(3) "
1303 #: build/C/man3/malloc_get_state.3:59
1305 "The B<malloc_set_state>() function restores the state of all B<malloc>(3) "
1306 "internal bookkeeping variables to the values recorded in the opaque data "
1307 "structure pointed to by I<state>."
1311 #: build/C/man3/malloc_get_state.3:66
1313 "On success, B<malloc_get_state>() returns a pointer to a newly allocated "
1314 "opaque data structure. On error (for example, memory could not be allocated "
1315 "for the data structure), B<malloc_get_state>() returns NULL."
1318 #. if(ms->magic != MALLOC_STATE_MAGIC) return -1;
1319 #. /* Must fail if the major version is too high. */
1320 #. if((ms->version & ~0xffl) > (MALLOC_STATE_VERSION & ~0xffl)) return -2;
1322 #: build/C/man3/malloc_get_state.3:84
1324 "On success, B<malloc_set_state>() returns 0. If the implementation detects "
1325 "that I<state> does not point to a correctly formed data structure, "
1326 "B<malloc_set_state>() returns -1. If the implementation detects that the "
1327 "version of the data structure referred to by I<state> is a more recent "
1328 "version than this implementation knows about, B<malloc_set_state>() returns "
1333 #: build/C/man3/malloc_get_state.3:86 build/C/man3/malloc_hook.3:78 build/C/man3/mcheck.3:146 build/C/man3/mtrace.3:78
1334 msgid "These functions are GNU extensions."
1338 #: build/C/man3/malloc_get_state.3:92
1340 "These functions are especially useful when using this B<malloc>(3) "
1341 "implementation as part of a shared library, and the heap contents are "
1342 "saved/restored via some other method. This technique is used by the GNU "
1343 "Emacs to implement its \"dumping\" function."
1346 #. i.e., calls __malloc_check_init()
1347 #. i.e., malloc checking is not already in use
1348 #. and the caller requested malloc checking
1350 #: build/C/man3/malloc_get_state.3:109
1352 "Hook function pointers are never saved or restored by these functions, with "
1353 "two exceptions: if malloc checking (see B<mallopt>(3)) was in use when "
1354 "B<malloc_get_state>() was called, then B<malloc_set_state>() resets malloc "
1355 "checking hooks if possible; if malloc checking was not in use in the "
1356 "recorded state, but the caller has requested malloc checking, then the hooks "
1361 #: build/C/man3/malloc_get_state.3:112
1362 msgid "B<malloc>(3), B<mallopt>(3)"
1366 #: build/C/man3/malloc_hook.3:6
1372 #: build/C/man3/malloc_hook.3:6
1378 #: build/C/man3/malloc_hook.3:11
1380 "__malloc_hook, __malloc_initialize_hook, __memalign_hook, __free_hook, "
1381 "__realloc_hook, __after_morecore_hook - malloc debugging variables"
1385 #: build/C/man3/malloc_hook.3:14 build/C/man3/posix_memalign.3:40
1387 msgid "B<#include E<lt>malloc.hE<gt>>\n"
1391 #: build/C/man3/malloc_hook.3:16
1393 msgid "B<void *(*__malloc_hook)(size_t >I<size>B<, const void *>I<caller>B<);>\n"
1397 #: build/C/man3/malloc_hook.3:19
1400 "B<void *(*__realloc_hook)(void *>I<ptr>B<, size_t >I<size>B<, const void "
1401 "*>I<caller>B<);>\n"
1405 #: build/C/man3/malloc_hook.3:22
1408 "B<void *(*__memalign_hook)(size_t >I<alignment>B<, size_t >I<size>B<,>\n"
1409 "B< const void *>I<caller>B<);>\n"
1413 #: build/C/man3/malloc_hook.3:24
1415 msgid "B<void (*__free_hook)(void *>I<ptr>B<, const void *>I<caller>B<);>\n"
1419 #: build/C/man3/malloc_hook.3:26
1421 msgid "B<void (*__malloc_initialize_hook)(void);>\n"
1425 #: build/C/man3/malloc_hook.3:28
1427 msgid "B<void (*__after_morecore_hook)(void);>\n"
1431 #: build/C/man3/malloc_hook.3:39
1433 "The GNU C library lets you modify the behavior of B<malloc>(3), "
1434 "B<realloc>(3), and B<free>(3) by specifying appropriate hook functions. "
1435 "You can use these hooks to help you debug programs that use dynamic memory "
1436 "allocation, for example."
1440 #: build/C/man3/malloc_hook.3:46
1442 "The variable B<__malloc_initialize_hook> points at a function that is called "
1443 "once when the malloc implementation is initialized. This is a weak "
1444 "variable, so it can be overridden in the application with a definition like "
1449 #: build/C/man3/malloc_hook.3:49
1451 msgid " void (*__malloc_initialize_hook)(void) = my_init_hook;\n"
1455 #: build/C/man3/malloc_hook.3:54
1456 msgid "Now the function I<my_init_hook>() can do the initialization of all hooks."
1460 #: build/C/man3/malloc_hook.3:70
1462 "The four functions pointed to by B<__malloc_hook>, B<__realloc_hook>, "
1463 "B<__memalign_hook>, B<__free_hook> have a prototype like the functions "
1464 "B<malloc>(3), B<realloc>(3), B<memalign>(3), B<free>(3), respectively, "
1465 "except that they have a final argument I<caller> that gives the address of "
1466 "the caller of B<malloc>(3), etc."
1470 #: build/C/man3/malloc_hook.3:76
1472 "The variable B<__after_morecore_hook> points at a function that is called "
1473 "each time after B<sbrk>(2) was asked for more memory."
1476 #. https://bugzilla.redhat.com/show_bug.cgi?id=450187
1477 #. http://sourceware.org/bugzilla/show_bug.cgi?id=9957
1479 #: build/C/man3/malloc_hook.3:85
1481 "The use of these hook functions is not safe in multithreaded programs, and "
1482 "they are now deprecated. Programmers should instead preempt calls to the "
1483 "relevant functions by defining and exporting functions such as \"malloc\" "
1488 #: build/C/man3/malloc_hook.3:85 build/C/man3/mallopt.3:464 build/C/man3/mcheck.3:159 build/C/man2/mmap.2:571 build/C/man2/mprotect.2:142 build/C/man3/mtrace.3:106
1494 #: build/C/man3/malloc_hook.3:87
1495 msgid "Here is a short example of how to use these variables."
1499 #: build/C/man3/malloc_hook.3:91
1502 "#include E<lt>stdio.hE<gt>\n"
1503 "#include E<lt>malloc.hE<gt>\n"
1507 #: build/C/man3/malloc_hook.3:95
1510 "/* Prototypes for our hooks. */\n"
1511 "static void my_init_hook(void);\n"
1512 "static void *my_malloc_hook(size_t, const void *);\n"
1516 #: build/C/man3/malloc_hook.3:98
1519 "/* Variables to save original hooks. */\n"
1520 "static void *(*old_malloc_hook)(size_t, const void *);\n"
1524 #: build/C/man3/malloc_hook.3:101
1527 "/* Override initializing hook from the C library. */\n"
1528 "void (*__malloc_initialize_hook) (void) = my_init_hook;\n"
1532 #: build/C/man3/malloc_hook.3:108
1536 "my_init_hook(void)\n"
1538 " old_malloc_hook = __malloc_hook;\n"
1539 " __malloc_hook = my_malloc_hook;\n"
1544 #: build/C/man3/malloc_hook.3:113
1548 "my_malloc_hook(size_t size, const void *caller)\n"
1554 #: build/C/man3/malloc_hook.3:116
1557 " /* Restore all old hooks */\n"
1558 " __malloc_hook = old_malloc_hook;\n"
1562 #: build/C/man3/malloc_hook.3:119
1565 " /* Call recursively */\n"
1566 " result = malloc(size);\n"
1570 #: build/C/man3/malloc_hook.3:122
1573 " /* Save underlying hooks */\n"
1574 " old_malloc_hook = __malloc_hook;\n"
1578 #: build/C/man3/malloc_hook.3:126
1581 " /* printf() might call malloc(), so protect it too. */\n"
1582 " printf(\"malloc(%u) called from %p returns %p\\en\",\n"
1583 " (unsigned int) size, caller, result);\n"
1587 #: build/C/man3/malloc_hook.3:129
1590 " /* Restore our own hooks */\n"
1591 " __malloc_hook = my_malloc_hook;\n"
1595 #: build/C/man3/malloc_hook.3:132
1603 #: build/C/man3/malloc_hook.3:138
1604 msgid "B<mallinfo>(3), B<malloc>(3), B<mcheck>(3), B<mtrace>(3)"
1608 #: build/C/man3/malloc_trim.3:24
1614 #: build/C/man3/malloc_trim.3:24 build/C/man3/malloc_usable_size.3:23
1620 #: build/C/man3/malloc_trim.3:27
1621 msgid "malloc_trim - release free memory from the top of the heap"
1625 #: build/C/man3/malloc_trim.3:29 build/C/man3/malloc_usable_size.3:28 build/C/man3/mallopt.3:29
1626 msgid "B<#include E<lt>malloc.hE<gt>>"
1630 #: build/C/man3/malloc_trim.3:31
1631 msgid "B<void malloc_trim(size_t >I<pad>B<);>"
1635 #: build/C/man3/malloc_trim.3:38
1637 "The B<malloc_trim>() function attempts to release free memory at the top of "
1638 "the heap (by calling B<sbrk>(2) with a suitable argument)."
1642 #: build/C/man3/malloc_trim.3:49
1644 "The I<pad> argument specifies the amount of free space to leave untrimmed at "
1645 "the top of the heap. If this argument is 0, only the minimum amount of "
1646 "memory is maintained at the top of the heap (i.e., one page or less). A "
1647 "nonzero argument can be used to maintain some trailing space at the top of "
1648 "the heap in order to allow future allocations to be made without having to "
1649 "extend the heap with B<sbrk>(2)."
1653 #: build/C/man3/malloc_trim.3:54
1655 "The B<malloc_trim>() function returns 1 if memory was actually released "
1656 "back to the system, or 0 if it was not possible to release any memory."
1660 #. Available already in glibc 2.0, possibly earlier
1662 #: build/C/man3/malloc_trim.3:58
1663 msgid "No errors are defined."
1667 #: build/C/man3/malloc_trim.3:60 build/C/man3/malloc_usable_size.3:48
1668 msgid "This function is a GNU extension."
1672 #: build/C/man3/malloc_trim.3:69
1674 "This function is automatically called by B<free>(3) in certain "
1675 "circumstances; see the discussion of B<M_TOP_PAD> and B<M_TRIM_THRESHOLD> in "
1680 #: build/C/man3/malloc_trim.3:72
1682 "This function cannot release free memory located at places other than the "
1686 #. malloc/malloc.c::mTRIm():
1687 #. return result | (av == &main_arena ? sYSTRIm (pad, av) : 0);
1689 #: build/C/man3/malloc_trim.3:76
1690 msgid "This function only releases memory in the main arena."
1694 #: build/C/man3/malloc_trim.3:80
1695 msgid "B<sbrk>(2), B<malloc>(3), B<mallopt>(3)"
1699 #: build/C/man3/malloc_usable_size.3:23
1701 msgid "MALLOC_USABLE_SIZE"
1705 #: build/C/man3/malloc_usable_size.3:26
1706 msgid "malloc_usable_size - obtain size of block of memory allocated from heap"
1710 #: build/C/man3/malloc_usable_size.3:30
1711 msgid "B<size_t malloc_usable_size (void *>I<ptr>B<);>"
1715 #: build/C/man3/malloc_usable_size.3:38
1717 "The B<malloc_usable_size>() function returns the number of usable bytes in "
1718 "the block pointed to by I<ptr>, a pointer to a block of memory allocated by "
1719 "B<malloc>(3) or a related function."
1723 #: build/C/man3/malloc_usable_size.3:46
1725 "B<malloc_usable_size>() returns the number of usable bytes in the block of "
1726 "allocated memory pointed to by I<ptr>. If I<ptr> is NULL, 0 is returned."
1730 #: build/C/man3/malloc_usable_size.3:58
1732 "The value returned by B<malloc_usable_size>() may be greater than the "
1733 "requested size of the allocation because of alignment and minimum size "
1734 "constraints. Although the excess bytes can be overwritten by the "
1735 "application without ill effects, this is not good programming practice: the "
1736 "number of excess bytes in an allocation depends on the underlying "
1741 #: build/C/man3/malloc_usable_size.3:60
1742 msgid "The main use of this function is for debugging and introspection."
1746 #: build/C/man3/malloc_usable_size.3:62
1747 msgid "B<malloc>(3)"
1751 #: build/C/man3/mallopt.3:24
1757 #: build/C/man3/mallopt.3:24 build/C/man3/mcheck.3:23 build/C/man3/mtrace.3:23
1763 #: build/C/man3/mallopt.3:27
1764 msgid "mallopt - set memory allocation parameters"
1768 #: build/C/man3/mallopt.3:31
1769 msgid "B<int mallopt(int >I<param>B<, int >I<value>B<);>"
1773 #: build/C/man3/mallopt.3:42
1775 "The B<mallopt>() function adjusts parameters that control the behavior of "
1776 "the memory-allocation functions (see B<malloc>(3)). The I<param> argument "
1777 "specifies the parameter to be modified, and I<value> specifies the new value "
1778 "for that parameter."
1782 #: build/C/man3/mallopt.3:45
1783 msgid "The following values can be specified for I<param>:"
1787 #: build/C/man3/mallopt.3:45
1789 msgid "B<M_CHECK_ACTION>"
1793 #: build/C/man3/mallopt.3:51
1795 "Setting this parameter controls how glibc responds when various kinds of "
1796 "programming errors are detected (e.g., freeing the same pointer twice). The "
1797 "3 least significant bits (2, 1, and 0) of the value assigned to this "
1798 "parameter determine the glibc behavior, as follows:"
1802 #: build/C/man3/mallopt.3:52
1808 #: build/C/man3/mallopt.3:62
1810 "If this bit is set, then print a one-line message on I<stderr> that provides "
1811 "details about the error. The message starts with the string \"***\\ glibc "
1812 "detected\\ ***\", followed by the program name, the name of the "
1813 "memory-allocation function in which the error was detected, a brief "
1814 "description of the error, and the memory address where the error was "
1819 #: build/C/man3/mallopt.3:62
1825 #: build/C/man3/mallopt.3:77
1827 "If this bit is set, then, after printing any error message specified by bit "
1828 "0, the program is terminated by calling B<abort>(3). In glibc versions "
1829 "since 2.4, if bit 0 is also set, then, between printing the error message "
1830 "and aborting, the program also prints a stack trace in the manner of "
1831 "B<backtrace>(3), and prints the process's memory mapping in the style of "
1832 "I</proc/[pid]/maps> (see B<proc>(5))."
1836 #: build/C/man3/mallopt.3:77
1838 msgid "Bit 2 (since glibc 2.4)"
1842 #: build/C/man3/mallopt.3:84
1844 "This bit has an effect only if bit 0 is also set. If this bit is set, then "
1845 "the one-line message describing the error is simplified to contain just the "
1846 "name of the function where the error was detected and the brief description "
1851 #: build/C/man3/mallopt.3:89
1852 msgid "The remaining bits in I<value> are ignored."
1856 #: build/C/man3/mallopt.3:93
1858 "Combining the above details, the following numeric values are meaningful for "
1859 "B<M_CHECK_ACTION>:"
1863 #: build/C/man3/mallopt.3:94
1869 #: build/C/man3/mallopt.3:96
1870 msgid "Ignore error conditions; continue execution (with undefined results)."
1874 #: build/C/man3/mallopt.3:96
1880 #: build/C/man3/mallopt.3:98
1881 msgid "Print a detailed error message and continue execution."
1885 #: build/C/man3/mallopt.3:98
1891 #: build/C/man3/mallopt.3:100
1892 msgid "Abort the program."
1896 #: build/C/man3/mallopt.3:100
1902 #: build/C/man3/mallopt.3:103
1904 "Print detailed error message, stack trace, and memory mappings, and abort "
1909 #: build/C/man3/mallopt.3:103
1915 #: build/C/man3/mallopt.3:105
1916 msgid "Print a simple error message and continue execution."
1920 #: build/C/man3/mallopt.3:105
1926 #: build/C/man3/mallopt.3:108
1928 "Print simple error message, stack trace, and memory mappings, and abort the "
1933 #: build/C/man3/mallopt.3:114
1935 "Since glibc 2.3.4, the default value for the B<M_CHECK_ACTION> parameter is "
1936 "3. In glibc version 2.3.3 and earlier, the default value is 1."
1940 #: build/C/man3/mallopt.3:119
1942 "Using a nonzero B<M_CHECK_ACTION> value can be useful because otherwise a "
1943 "crash may happen much later, and the true cause of the problem is then very "
1944 "hard to track down."
1948 #: build/C/man3/mallopt.3:119
1950 msgid "B<M_MMAP_MAX>"
1953 #. The following text adapted from comments in the glibc source:
1955 #: build/C/man3/mallopt.3:129
1957 "This parameter specifies the maximum number of allocation requests that may "
1958 "be simultaneously serviced using B<mmap>(2). This parameter exists because "
1959 "some systems have a limited number of internal tables for use by B<mmap>(2), "
1960 "and using more than a few of them may degrade performance."
1964 #: build/C/man3/mallopt.3:136
1966 "The default value is 65,536, a value which has no special significance and "
1967 "which servers only as a safeguard. Setting this parameter to 0 disables the "
1968 "use of B<mmap>(2) for servicing large allocation requests."
1972 #: build/C/man3/mallopt.3:136
1974 msgid "B<M_MMAP_THRESHOLD>"
1978 #: build/C/man3/mallopt.3:145
1980 "For allocations greater than or equal to the limit specified (in bytes) by "
1981 "B<M_MMAP_THRESHOLD> that can't be satisfied from the free list, the "
1982 "memory-allocation functions employ B<mmap>(2) instead of increasing the "
1983 "program break using B<sbrk>(2)."
1987 #: build/C/man3/mallopt.3:165
1989 "Allocating memory using B<mmap>(2) has the significant advantage that the "
1990 "allocated memory blocks can always be independently released back to the "
1991 "system. (By contrast, the heap can be trimmed only if memory is freed at "
1992 "the top end.) On the other hand, there are some disadvantages to the use of "
1993 "B<mmap>(2): deallocated space is not placed on the free list for reuse by "
1994 "later allocations; memory may be wasted because B<mmap>(2) allocations must "
1995 "be page-aligned; and the kernel must perform the expensive task of zeroing "
1996 "out memory allocated via B<mmap>(2). Balancing these factors leads to a "
1997 "default setting of 128*1024 for the B<M_MMAP_THRESHOLD> parameter."
2001 #: build/C/man3/mallopt.3:172
2003 "The lower limit for this parameter is 0. The upper limit is "
2004 "B<DEFAULT_MMAP_THRESHOLD_MAX>: 512*1024 on 32-bit systems or "
2005 "I<4*1024*1024*sizeof(long)> on 64-bit systems."
2009 #: build/C/man3/mallopt.3:190
2011 "I<Note:> Nowadays, glibc uses a dynamic mmap threshold by default. The "
2012 "initial value of the threshold is 128*1024, but when blocks larger than the "
2013 "current threshold and less than or equal to B<DEFAULT_MMAP_THRESHOLD_MAX> "
2014 "are freed, the threshold is adjusted upwards to the size of the freed "
2015 "block. When dynamic mmap thresholding is in effect, the threshold for "
2016 "trimming the heap is also dynamically adjusted to be twice the dynamic mmap "
2017 "threshold. Dynamic adjustment of the mmap threshold is disabled if any of "
2018 "the B<M_TRIM_THRESHOLD>, B<M_TOP_PAD>, B<M_MMAP_THRESHOLD>, or B<M_MMAP_MAX> "
2019 "parameters is set."
2023 #: build/C/man3/mallopt.3:190
2025 msgid "B<M_MXFAST> (since glibc 2.3)"
2028 #. The following text adapted from comments in the glibc sources:
2030 #: build/C/man3/mallopt.3:210
2032 "Set the upper limit for memory allocation requests that are satisfied using "
2033 "\"fastbins\". (The measurement unit for this parameter is bytes.) Fastbins "
2034 "are storage areas that hold deallocated blocks of memory of the same size "
2035 "without merging adjacent free blocks. Subsequent reallocation of blocks of "
2036 "the same size can be handled very quickly by allocating from the fastbin, "
2037 "although memory fragmentation and the overall memory footprint of the "
2038 "program can increase. The default value for this parameter is "
2039 "I<64*sizeof(size_t)/4> (i.e., 64 on 32-bit architectures). The range for "
2040 "this parameter is 0 to I<80*sizeof(size_t)/4>. Setting B<M_MXFAST> to 0 "
2041 "disables the use of fastbins."
2045 #: build/C/man3/mallopt.3:210
2047 msgid "B<M_PERTURB> (since glibc 2.4)"
2051 #: build/C/man3/mallopt.3:225
2053 "If this parameter is set to a nonzero value, then bytes of allocated memory "
2054 "(other than allocations via B<calloc>(3)) are initialized to the complement "
2055 "of the value in the least significant byte of I<value>, and when allocated "
2056 "memory is released using B<free>(3), the freed bytes are set to the least "
2057 "significant byte of I<value>. This can be useful for detecting errors where "
2058 "programs incorrectly rely on allocated memory being initialized to zero, or "
2059 "reuse values in memory that has already been freed."
2063 #: build/C/man3/mallopt.3:225
2065 msgid "B<M_TOP_PAD>"
2069 #: build/C/man3/mallopt.3:232
2071 "This parameter defines the amount of padding to employ when calling "
2072 "B<sbrk>(2) to modify the program break. (The measurement unit for this "
2073 "parameter is bytes.) This parameter has an effect in the following "
2078 #: build/C/man3/mallopt.3:239
2080 "When the program break is increased, then B<M_TOP_PAD> bytes are added to "
2081 "the B<sbrk>(2) request."
2085 #: build/C/man3/mallopt.3:245
2087 "When the heap is trimmed as a consequence of calling B<free>(3) (see the "
2088 "discussion of B<M_TRIM_THRESHOLD>) this much free space is preserved at the "
2093 #: build/C/man3/mallopt.3:249
2095 "In either case, the amount of padding is always rounded to a system page "
2100 #: build/C/man3/mallopt.3:256
2102 "Modifying B<M_TOP_PAD> is a trade-off between increasing the number of "
2103 "system calls (when the parameter is set low) and wasting unused memory at "
2104 "the top of the heap (when the parameter is set high)."
2107 #. DEFAULT_TOP_PAD in glibc source
2109 #: build/C/man3/mallopt.3:259
2110 msgid "The default value for this parameter is 128*1024."
2114 #: build/C/man3/mallopt.3:259
2116 msgid "B<M_TRIM_THRESHOLD>"
2120 #: build/C/man3/mallopt.3:275
2122 "When the amount of contiguous free memory at the top of the heap grows "
2123 "sufficiently large, B<free>(3) employs B<sbrk>(2) to release this memory "
2124 "back to the system. (This can be useful in programs that continue to "
2125 "execute for a long period after freeing a significant amount of memory.) "
2126 "The B<M_TRIM_THRESHOLD> parameter specifies the minimum size (in bytes) that "
2127 "this block of memory must reach before B<sbrk>(2) is used to trim the heap."
2131 #: build/C/man3/mallopt.3:280
2133 "The default value for this parameter is 128*1024. Setting "
2134 "B<M_TRIM_THRESHOLD> to -1 disables trimming completely."
2137 #. FIXME Do the arena parameters need to be documented?
2139 #. .BR M_ARENA_TEST " (since glibc 2.10)"
2141 #. .BR M_ARENA_MAX " (since glibc 2.10)"
2143 #. Environment variables
2144 #. MALLOC_ARENA_MAX_
2145 #. MALLOC_ARENA_TEST_
2147 #. http://udrepper.livejournal.com/20948.html describes some details
2148 #. of the MALLOC_ARENA_* environment variables.
2150 #. These macros aren't enabled in production releases until 2.15?
2151 #. (see glibc malloc/Makefile)
2153 #: build/C/man3/mallopt.3:303
2155 "Modifying B<M_TRIM_THRESHOLD> is a trade-off between increasing the number "
2156 "of system calls (when the parameter is set low) and wasting unused memory "
2157 "at the top of the heap (when the parameter is set high)."
2161 #: build/C/man3/mallopt.3:303
2163 msgid "Environment Variables"
2167 #: build/C/man3/mallopt.3:318
2169 "A number of environment variables can be defined to modify some of the same "
2170 "parameters as are controlled by B<mallopt>(). Using these variables has the "
2171 "advantage that the source code of the program need not be changed. To be "
2172 "effective, these variables must be defined before the first call to a "
2173 "memory-allocation function. (If the same parameters are adjusted via "
2174 "B<mallopt>() then the B<mallopt>() settings take precedence.) For "
2175 "security reasons, these variables are ignored in set-user-ID and "
2176 "set-group-ID programs."
2180 #: build/C/man3/mallopt.3:321
2182 "The environment variables are as follows (note the trailing underscore at "
2183 "the end of the name of each variable):"
2187 #: build/C/man3/mallopt.3:321
2189 msgid "B<MALLOC_CHECK_>"
2192 #. On glibc 2.12/x86, a simple malloc()+free() loop is about 70% slower
2193 #. when MALLOC_CHECK_ was set.
2195 #: build/C/man3/mallopt.3:338
2197 "This environment variable controls the same parameter as B<mallopt>() "
2198 "B<M_CHECK_ACTION>. If this variable is set to a nonzero value, then a "
2199 "special implementation of the memory-allocation functions is used. (This is "
2200 "accomplished using the B<malloc_hook>(3) feature.) This implementation "
2201 "performs additional error checking, but is slower than the standard set of "
2202 "memory-allocation functions. (This implementation does not detect all "
2203 "possible errors; memory leaks can still occur.)"
2207 #: build/C/man3/mallopt.3:343
2209 "The value assigned to this environment variable should be a single digit, "
2210 "whose meaning is as described for B<M_CHECK_ACTION>. Any characters beyond "
2211 "the initial digit are ignored."
2215 #: build/C/man3/mallopt.3:352
2217 "For security reasons, the effect of B<MALLOC_CHECK_> is disabled by default "
2218 "for set-user-ID and set-group-ID programs. However, if the file "
2219 "I</etc/suid-debug> exists (the content of the file is irrelevant), then "
2220 "B<MALLOC_CHECK_> also has an effect for set-user-ID and set-group-ID "
2225 #: build/C/man3/mallopt.3:352
2227 msgid "B<MALLOC_MMAP_MAX_>"
2231 #: build/C/man3/mallopt.3:357
2232 msgid "Controls the same parameter as B<mallopt>() B<M_MMAP_MAX>."
2236 #: build/C/man3/mallopt.3:357
2238 msgid "B<MALLOC_MMAP_THRESHOLD_>"
2242 #: build/C/man3/mallopt.3:362
2243 msgid "Controls the same parameter as B<mallopt>() B<M_MMAP_THRESHOLD>."
2247 #: build/C/man3/mallopt.3:362
2249 msgid "B<MALLOC_PERTURB_>"
2253 #: build/C/man3/mallopt.3:367
2254 msgid "Controls the same parameter as B<mallopt>() B<M_PERTURB>."
2258 #: build/C/man3/mallopt.3:367
2260 msgid "B<MALLOC_TRIM_THRESHOLD_>"
2264 #: build/C/man3/mallopt.3:372
2265 msgid "Controls the same parameter as B<mallopt>() B<M_TRIM_THRESHOLD>."
2269 #: build/C/man3/mallopt.3:372
2271 msgid "B<MALLOC_TOP_PAD_>"
2275 #: build/C/man3/mallopt.3:377
2276 msgid "Controls the same parameter as B<mallopt>() B<M_TOP_PAD>."
2280 #: build/C/man3/mallopt.3:382
2281 msgid "On success, B<mallopt>() returns 1. On error, it returns 0."
2285 #. Available already in glibc 2.0, possibly earlier
2287 #: build/C/man3/mallopt.3:390
2288 msgid "On error, I<errno> is I<not> set."
2293 #: build/C/man3/mallopt.3:404
2295 "This function is not specified by POSIX or the C standards. A similar "
2296 "function exists on many System V derivatives, but the range of values for "
2297 "I<param> varies across systems. The SVID defined options B<M_MXFAST>, "
2298 "B<M_NLBLKS>, B<M_GRAIN>, and B<M_KEEP>, but only the first of these is "
2299 "implemented in glibc."
2303 #: build/C/man3/mallopt.3:408
2304 msgid "Specifying an invalid value for I<param> does not generate an error."
2307 #. FIXME This looks buggy:
2308 #. setting the M_MXFAST limit rounds up: (s + SIZE_SZ) & ~MALLOC_ALIGN_MASK)
2309 #. malloc requests are rounded up:
2310 #. (req) + SIZE_SZ + MALLOC_ALIGN_MASK) & ~MALLOC_ALIGN_MASK
2311 #. http://sources.redhat.com/bugzilla/show_bug.cgi?id=12129
2313 #: build/C/man3/mallopt.3:416
2315 "A calculation error within the glibc implementation means that a call of the "
2320 #: build/C/man3/mallopt.3:419
2322 msgid " mallopt(M_MXFAST, n)\n"
2325 #. Bins are multiples of 2 * sizeof(size_t) + sizeof(size_t)
2327 #: build/C/man3/mallopt.3:431
2329 "does not result in fastbins being employed for all allocations of size up to "
2330 "I<n>. To ensure desired results, I<n> should be rounded up to the next "
2331 "multiple greater than or equal to I<(2k+1)*sizeof(size_t)>, where I<k> is an "
2335 #. FIXME MALLOC_MMAP_THRESHOLD_ and MALLOC_MMAP_MAX_
2336 #. do have an effect for set-user-ID programs (but not
2337 #. set-group-ID programs).
2338 #. http://sources.redhat.com/bugzilla/show_bug.cgi?id=12155
2340 #: build/C/man3/mallopt.3:443
2342 "The B<MALLOC_MMAP_THRESHOLD_> and B<MALLOC_MMAP_MAX_> variables are I<not> "
2343 "ignored in set-group-ID programs."
2346 #. FIXME http://sources.redhat.com/bugzilla/show_bug.cgi?id=12140
2348 #: build/C/man3/mallopt.3:464
2350 "If B<mallopt>() is used to set B<M_PERTURB>, then, as expected, the bytes "
2351 "of allocated memory are initialized to the complement of the byte in "
2352 "I<value>, and when that memory is freed, the bytes of the region are "
2353 "initialized to the byte specified in I<value>. However, there is an "
2354 "off-by-I<sizeof(size_t)> error in the implementation: instead of "
2355 "initializing precisely the block of memory being freed by the call "
2356 "I<free(p)>, the block starting at I<p+sizeof(size_t)> is initialized."
2360 #: build/C/man3/mallopt.3:473
2362 "The program below demonstrates the use of B<M_CHECK_ACTION>. If the program "
2363 "is supplied with an (integer) command-line argument, then that argument is "
2364 "used to set the B<M_CHECK_ACTION> parameter. The program then allocates a "
2365 "block of memory, and frees it twice (an error)."
2369 #: build/C/man3/mallopt.3:477
2371 "The following shell session shows what happens when we run this program "
2372 "under glibc, with the default value for B<M_CHECK_ACTION>:"
2376 #: build/C/man3/mallopt.3:496
2380 "*** glibc detected *** ./a.out: double free or corruption (top): 0x09d30008 "
2382 "======= Backtrace: =========\n"
2383 "/lib/libc.so.6(+0x6c501)[0x523501]\n"
2384 "/lib/libc.so.6(+0x6dd70)[0x524d70]\n"
2385 "/lib/libc.so.6(cfree+0x6d)[0x527e5d]\n"
2386 "\\&./a.out[0x80485db]\n"
2387 "/lib/libc.so.6(__libc_start_main+0xe7)[0x4cdce7]\n"
2388 "\\&./a.out[0x8048471]\n"
2389 "======= Memory map: ========\n"
2390 "001e4000-001fe000 r-xp 00000000 08:06 1083555 /lib/libgcc_s.so.1\n"
2391 "001fe000-001ff000 r--p 00019000 08:06 1083555 /lib/libgcc_s.so.1\n"
2392 "[some lines omitted]\n"
2393 "b7814000-b7817000 rw-p 00000000 00:00 0\n"
2394 "bff53000-bff74000 rw-p 00000000 00:00 0 [stack]\n"
2395 "Aborted (core dumped)\n"
2399 #: build/C/man3/mallopt.3:501
2401 "The following runs show the results when employing other values for "
2402 "B<M_CHECK_ACTION>:"
2406 #: build/C/man3/mallopt.3:514
2409 "$ B<./a.out 1> # Diagnose error and continue\n"
2410 "main(): returned from first free() call\n"
2411 "*** glibc detected *** ./a.out: double free or corruption (top): 0x09cbe008 "
2413 "main(): returned from second free() call\n"
2414 "$ B<./a.out 2> # Abort without error message\n"
2415 "main(): returned from first free() call\n"
2416 "Aborted (core dumped)\n"
2417 "$ B<./a.out 0> # Ignore error and continue\n"
2418 "main(): returned from first free() call\n"
2419 "main(): returned from second free() call\n"
2423 #: build/C/man3/mallopt.3:520
2425 "The next run shows how to set the same parameter using the B<MALLOC_CHECK_> "
2426 "environment variable:"
2430 #: build/C/man3/mallopt.3:527
2433 "$ B<MALLOC_CHECK_=1 ./a.out>\n"
2434 "main(): returned from first free() call\n"
2435 "*** glibc detected *** ./a.out: free(): invalid pointer: 0x092c2008 ***\n"
2436 "main(): returned from second free() call\n"
2440 #: build/C/man3/mallopt.3:529 build/C/man3/mcheck.3:176 build/C/man2/mprotect.2:159
2442 msgid "Program source"
2446 #: build/C/man3/mallopt.3:535
2449 "#include E<lt>malloc.hE<gt>\n"
2450 "#include E<lt>stdio.hE<gt>\n"
2451 "#include E<lt>stdlib.hE<gt>\n"
2455 #: build/C/man3/mallopt.3:540 build/C/man3/mcheck.3:187
2459 "main(int argc, char *argv[])\n"
2465 #: build/C/man3/mallopt.3:547
2468 " if (argc E<gt> 1) {\n"
2469 " if (argc != 2) {\n"
2470 " fprintf(stderr, \"%s E<lt>M_CHECK_ACTION-valueE<gt>\\en\", "
2472 " exit(EXIT_FAILURE);\n"
2478 #: build/C/man3/mallopt.3:552
2481 " if (mallopt(M_CHECK_ACTION, atoi(argv[1])) != 1) {\n"
2482 " fprintf(stderr, \"mallopt() failed\");\n"
2483 " exit(EXIT_FAILURE);\n"
2488 #: build/C/man3/mallopt.3:558
2491 " p = malloc(1000);\n"
2492 " if (p == NULL) {\n"
2493 " fprintf(stderr, \"malloc() failed\");\n"
2494 " exit(EXIT_FAILURE);\n"
2499 #: build/C/man3/mallopt.3:561
2503 " printf(\"main(): returned from first free() call\\en\");\n"
2507 #: build/C/man3/mallopt.3:564
2511 " printf(\"main(): returned from second free() call\\en\");\n"
2515 #: build/C/man3/mallopt.3:567 build/C/man3/mcheck.3:203 build/C/man2/mmap.2:652
2518 " exit(EXIT_SUCCESS);\n"
2523 #: build/C/man3/mallopt.3:580
2525 "B<mmap>(2) B<sbrk>(2), B<mallinfo>(3), B<malloc>(3), B<malloc_hook>(3), "
2526 "B<malloc_trim>(3), B<mcheck>(3), B<mtrace>(3), B<posix_memalign>(3)"
2530 #: build/C/man3/mcheck.3:23
2536 #: build/C/man3/mcheck.3:26
2538 "mcheck, mcheck_check_all, mcheck_pedantic, mprobe - heap consistency "
2543 #: build/C/man3/mcheck.3:29
2545 msgid "B<#include E<lt>mcheck.hE<gt>>\n"
2549 #: build/C/man3/mcheck.3:31
2551 msgid "B<int mcheck(void (*>I<abortfunc>B<)(enum mcheck_status >I<mstatus>B<));>\n"
2555 #: build/C/man3/mcheck.3:33
2558 "B<int mcheck_pedantic(void (*>I<abortfunc>B<)(enum mcheck_status "
2559 ">I<mstatus>B<));>\n"
2563 #: build/C/man3/mcheck.3:35
2565 msgid "B<void mcheck_check_all(void);>\n"
2569 #: build/C/man3/mcheck.3:37
2571 msgid "B<enum mcheck_status mprobe(void *>I<ptr>B<);>\n"
2575 #: build/C/man3/mcheck.3:50
2577 "The B<mcheck>() function installs a set of debugging hooks for the "
2578 "B<malloc>(3) family of memory-allocation functions. These hooks cause "
2579 "certain consistency checks to be performed on the state of the heap. The "
2580 "checks can detect application errors such as freeing a block of memory more "
2581 "than once or corrupting the bookkeeping data structures that immediately "
2582 "precede a block of allocated memory."
2586 #: build/C/man3/mcheck.3:62
2588 "To be effective, the B<mcheck>() function must be called before the first "
2589 "call to B<malloc>(3) or a related function. In cases where this is "
2590 "difficult to ensure, linking the program with I<-mcheck> inserts an implicit "
2591 "call to B<mcheck>() (with a NULL argument) before the first call to a "
2592 "memory-allocation function."
2596 #: build/C/man3/mcheck.3:70
2598 "The B<mcheck_pedantic>() function is similar to B<mcheck>(), but performs "
2599 "checks on all allocated blocks whenever one of the memory-allocation "
2600 "functions is called. This can be very slow!"
2604 #: build/C/man3/mcheck.3:77
2606 "The B<mcheck_check_all>() function causes an immediate check on all "
2607 "allocated blocks. This call is only effective if B<mcheck>() is called "
2612 #: build/C/man3/mcheck.3:90
2614 "If the system detects an inconsistency in the heap, the caller-supplied "
2615 "function pointed to by I<abortfunc> is invoked with a single argument "
2616 "argument, I<mstatus>, that indicates what type of inconsistency was "
2617 "detected. If I<abortfunc> is NULL, a default function prints an error "
2618 "message on I<stderr> and calls B<abort>(3)."
2622 #: build/C/man3/mcheck.3:102
2624 "The B<mprobe>() function performs a consistency check on the block of "
2625 "allocated memory pointed to by I<ptr>. The B<mcheck>() function should be "
2626 "called beforehand (otherwise B<mprobe>() returns B<MCHECK_DISABLED>)."
2630 #: build/C/man3/mcheck.3:110
2632 "The following list describes the values returned by B<mprobe>() or passed "
2633 "as the I<mstatus> argument when I<abortfunc> is invoked:"
2637 #: build/C/man3/mcheck.3:110
2639 msgid "B<MCHECK_DISABLED> (B<mprobe>() only)"
2643 #: build/C/man3/mcheck.3:115
2645 "B<mcheck>() was not called before the first memory allocation function was "
2646 "called. Consistency checking is not possible."
2650 #: build/C/man3/mcheck.3:115
2652 msgid "B<MCHECK_OK> (B<mprobe>() only)"
2656 #: build/C/man3/mcheck.3:118
2657 msgid "No inconsistency detected."
2661 #: build/C/man3/mcheck.3:118
2663 msgid "B<MCHECK_HEAD>"
2667 #: build/C/man3/mcheck.3:121
2668 msgid "Memory preceding an allocated block was clobbered."
2672 #: build/C/man3/mcheck.3:121
2674 msgid "B<MCHECK_TAIL>"
2678 #: build/C/man3/mcheck.3:124
2679 msgid "Memory following an allocated block was clobbered."
2683 #: build/C/man3/mcheck.3:124
2685 msgid "B<MCHECK_FREE>"
2689 #: build/C/man3/mcheck.3:128
2690 msgid "A block of memory was freed twice."
2694 #: build/C/man3/mcheck.3:133
2695 msgid "B<mcheck>() and B<mcheck_pedantic>() return 0 on success, or -1 on error."
2699 #: build/C/man3/mcheck.3:144
2701 "The B<mcheck_pedantic>() and B<mcheck_check_all>() functions are available "
2702 "since glibc 2.2. The B<mcheck()> and B<mprobe()> functions are present "
2703 "since at least glibc 2.0"
2706 #. But is MALLOC_CHECK_ slower?
2708 #: build/C/man3/mcheck.3:158
2710 "Linking a program with I<-lmcheck> and using the B<MALLOC_CHECK_> "
2711 "environment variable (described in B<mallopt>(3)) cause the same kinds of "
2712 "errors to be detected. But, using B<MALLOC_CHECK_> does not require the "
2713 "application to be relinked."
2717 #: build/C/man3/mcheck.3:165
2719 "The program below calls B<mcheck>() with a NULL argument and then frees the "
2720 "same block of memory twice. The following shell session demonstrates what "
2721 "happens when running the program:"
2725 #: build/C/man3/mcheck.3:170
2733 #: build/C/man3/mcheck.3:174
2736 "About to free a second time\n"
2737 "block freed twice\n"
2738 "Aborted (core dumped)\n"
2742 #: build/C/man3/mcheck.3:182
2745 "#include E<lt>stdlib.hE<gt>\n"
2746 "#include E<lt>stdio.hE<gt>\n"
2747 "#include E<lt>mcheck.hE<gt>\n"
2751 #: build/C/man3/mcheck.3:190
2754 " if (mcheck(NULL) != 0) {\n"
2755 " fprintf(stderr, \"mcheck() failed\\en\");\n"
2759 #: build/C/man3/mcheck.3:193
2762 " exit(EXIT_FAILURE);\n"
2767 #: build/C/man3/mcheck.3:195
2769 msgid " p = malloc(1000);\n"
2773 #: build/C/man3/mcheck.3:200
2776 " fprintf(stderr, \"About to free\\en\");\n"
2778 " fprintf(stderr, \"\\enAbout to free a second time\\en\");\n"
2782 #. FIXME add SEE ALSO pointer from malloc(3) to here
2783 #. FIXME add SEE ALSO pointer from mallopt(3) to here
2784 #. FIXME add SEE ALSO pointer from mtrace(3) to here
2786 #: build/C/man3/mcheck.3:211
2787 msgid "B<malloc>(3), B<mallopt>(3), B<mtrace>(3)"
2791 #: build/C/man2/mlock.2:27
2797 #: build/C/man2/mlock.2:27
2803 #: build/C/man2/mlock.2:30
2804 msgid "mlock, munlock, mlockall, munlockall - lock and unlock memory"
2808 #: build/C/man2/mlock.2:33 build/C/man2/mmap.2:46 build/C/man2/mmap2.2:35 build/C/man2/mprotect.2:38 build/C/man2/mremap.2:39
2810 msgid "B<#include E<lt>sys/mman.hE<gt>>\n"
2814 #: build/C/man2/mlock.2:36
2817 "B<int mlock(const void *>I<addr>B<, size_t >I<len>B<);>\n"
2818 "B<int munlock(const void *>I<addr>B<, size_t >I<len>B<);>\n"
2822 #: build/C/man2/mlock.2:39
2825 "B<int mlockall(int >I<flags>B<);>\n"
2826 "B<int munlockall(void);>\n"
2830 #: build/C/man2/mlock.2:55
2832 "B<mlock>() and B<mlockall>() respectively lock part or all of the calling "
2833 "process's virtual address space into RAM, preventing that memory from being "
2834 "paged to the swap area. B<munlock>() and B<munlockall>() perform the "
2835 "converse operation, respectively unlocking part or all of the calling "
2836 "process's virtual address space, so that pages in the specified virtual "
2837 "address range may once more to be swapped out if required by the kernel "
2838 "memory manager. Memory locking and unlocking are performed in units of "
2843 #: build/C/man2/mlock.2:55
2845 msgid "mlock() and munlock()"
2849 #: build/C/man2/mlock.2:65
2851 "B<mlock>() locks pages in the address range starting at I<addr> and "
2852 "continuing for I<len> bytes. All pages that contain a part of the specified "
2853 "address range are guaranteed to be resident in RAM when the call returns "
2854 "successfully; the pages are guaranteed to stay in RAM until later unlocked."
2858 #: build/C/man2/mlock.2:74
2860 "B<munlock>() unlocks pages in the address range starting at I<addr> and "
2861 "continuing for I<len> bytes. After this call, all pages that contain a part "
2862 "of the specified memory range can be moved to external swap space again by "
2867 #: build/C/man2/mlock.2:74
2869 msgid "mlockall() and munlockall()"
2873 #: build/C/man2/mlock.2:84
2875 "B<mlockall>() locks all pages mapped into the address space of the calling "
2876 "process. This includes the pages of the code, data and stack segment, as "
2877 "well as shared libraries, user space kernel data, shared memory, and "
2878 "memory-mapped files. All mapped pages are guaranteed to be resident in RAM "
2879 "when the call returns successfully; the pages are guaranteed to stay in RAM "
2880 "until later unlocked."
2884 #: build/C/man2/mlock.2:89
2886 "The I<flags> argument is constructed as the bitwise OR of one or more of the "
2887 "following constants:"
2891 #: build/C/man2/mlock.2:89
2893 msgid "B<MCL_CURRENT>"
2897 #: build/C/man2/mlock.2:93
2899 "Lock all pages which are currently mapped into the address space of the "
2904 #: build/C/man2/mlock.2:93
2906 msgid "B<MCL_FUTURE>"
2910 #: build/C/man2/mlock.2:100
2912 "Lock all pages which will become mapped into the address space of the "
2913 "process in the future. These could be for instance new pages required by a "
2914 "growing heap and stack as well as new memory mapped files or shared memory "
2919 #: build/C/man2/mlock.2:113
2921 "If B<MCL_FUTURE> has been specified, then a later system call (e.g., "
2922 "B<mmap>(2), B<sbrk>(2), B<malloc>(3)), may fail if it would cause the number "
2923 "of locked bytes to exceed the permitted maximum (see below). In the same "
2924 "circumstances, stack growth may likewise fail: the kernel will deny stack "
2925 "expansion and deliver a B<SIGSEGV> signal to the process."
2929 #: build/C/man2/mlock.2:117
2931 "B<munlockall>() unlocks all pages mapped into the address space of the "
2936 #: build/C/man2/mlock.2:123
2938 "On success these system calls return 0. On error, -1 is returned, I<errno> "
2939 "is set appropriately, and no changes are made to any locks in the address "
2940 "space of the process."
2944 #: build/C/man2/mlock.2:132
2946 "(Linux 2.6.9 and later) the caller had a nonzero B<RLIMIT_MEMLOCK> soft "
2947 "resource limit, but tried to lock more memory than the limit permitted. "
2948 "This limit is not enforced if the process is privileged (B<CAP_IPC_LOCK>)."
2951 #. In the case of mlock(), this check is somewhat buggy: it doesn't
2952 #. take into account whether the to-be-locked range overlaps with
2953 #. already locked pages. Thus, suppose we allocate
2954 #. (num_physpages / 4 + 1) of memory, and lock those pages once using
2955 #. mlock(), and then lock the *same* page range a second time.
2956 #. In the case, the second mlock() call will fail, since the check
2957 #. calculates that the process is trying to lock (num_physpages / 2 + 2)
2958 #. pages, which of course is not true. (MTK, Nov 04, kernel 2.4.28)
2960 #: build/C/man2/mlock.2:144
2962 "(Linux 2.4 and earlier) the calling process tried to lock more than half of "
2966 #. SVr4 documents an additional EAGAIN error code.
2968 #: build/C/man2/mlock.2:150
2970 "The caller is not privileged, but needs privilege (B<CAP_IPC_LOCK>) to "
2971 "perform the requested operation."
2975 #: build/C/man2/mlock.2:155
2976 msgid "For B<mlock>() and B<munlock>():"
2980 #: build/C/man2/mlock.2:158
2981 msgid "Some or all of the specified address range could not be locked."
2985 #: build/C/man2/mlock.2:165
2987 "The result of the addition I<start>+I<len> was less than I<start> (e.g., the "
2988 "addition may have resulted in an overflow)."
2992 #: build/C/man2/mlock.2:170
2993 msgid "(Not on Linux) I<addr> was not a multiple of the page size."
2997 #: build/C/man2/mlock.2:174
2999 "Some of the specified address range does not correspond to mapped pages in "
3000 "the address space of the process."
3004 #: build/C/man2/mlock.2:177
3005 msgid "For B<mlockall>():"
3009 #: build/C/man2/mlock.2:180
3010 msgid "Unknown I<flags> were specified."
3014 #: build/C/man2/mlock.2:183
3015 msgid "For B<munlockall>():"
3019 #: build/C/man2/mlock.2:187
3020 msgid "(Linux 2.6.8 and earlier) The caller was not privileged (B<CAP_IPC_LOCK>)."
3024 #: build/C/man2/mlock.2:189
3025 msgid "POSIX.1-2001, SVr4."
3029 #: build/C/man2/mlock.2:189 build/C/man2/mmap.2:487 build/C/man2/msync.2:105
3031 msgid "AVAILABILITY"
3035 #: build/C/man2/mlock.2:201
3037 "On POSIX systems on which B<mlock>() and B<munlock>() are available, "
3038 "B<_POSIX_MEMLOCK_RANGE> is defined in I<E<lt>unistd.hE<gt>> and the number "
3039 "of bytes in a page can be determined from the constant B<PAGESIZE> (if "
3040 "defined) in I<E<lt>limits.hE<gt>> or by calling I<sysconf(_SC_PAGESIZE)>."
3043 #. POSIX.1-2001: It shall be defined to -1 or 0 or 200112L.
3044 #. -1: unavailable, 0: ask using sysconf().
3045 #. glibc defines it to 1.
3047 #: build/C/man2/mlock.2:214
3049 "On POSIX systems on which B<mlockall>() and B<munlockall>() are available, "
3050 "B<_POSIX_MEMLOCK> is defined in I<E<lt>unistd.hE<gt>> to a value greater "
3051 "than 0. (See also B<sysconf>(3).)"
3055 #: build/C/man2/mlock.2:232
3057 "Memory locking has two main applications: real-time algorithms and "
3058 "high-security data processing. Real-time applications require deterministic "
3059 "timing, and, like scheduling, paging is one major cause of unexpected "
3060 "program execution delays. Real-time applications will usually also switch "
3061 "to a real-time scheduler with B<sched_setscheduler>(2). Cryptographic "
3062 "security software often handles critical bytes like passwords or secret keys "
3063 "as data structures. As a result of paging, these secrets could be "
3064 "transferred onto a persistent swap store medium, where they might be "
3065 "accessible to the enemy long after the security software has erased the "
3066 "secrets in RAM and terminated. (But be aware that the suspend mode on "
3067 "laptops and some desktop computers will save a copy of the system's RAM to "
3068 "disk, regardless of memory locks.)"
3072 #: build/C/man2/mlock.2:245
3074 "Real-time processes that are using B<mlockall>() to prevent delays on page "
3075 "faults should reserve enough locked stack pages before entering the "
3076 "time-critical section, so that no page fault can be caused by function "
3077 "calls. This can be achieved by calling a function that allocates a "
3078 "sufficiently large automatic variable (an array) and writes to the memory "
3079 "occupied by this array in order to touch these stack pages. This way, "
3080 "enough pages will be mapped for the stack and can be locked into RAM. The "
3081 "dummy writes ensure that not even copy-on-write page faults can occur in the "
3086 #: build/C/man2/mlock.2:251
3088 "Memory locks are not inherited by a child created via B<fork>(2) and are "
3089 "automatically removed (unlocked) during an B<execve>(2) or when the process "
3094 #: build/C/man2/mlock.2:255
3096 "The memory lock on an address range is automatically removed if the address "
3097 "range is unmapped via B<munmap>(2)."
3101 #: build/C/man2/mlock.2:268
3103 "Memory locks do not stack, that is, pages which have been locked several "
3104 "times by calls to B<mlock>() or B<mlockall>() will be unlocked by a single "
3105 "call to B<munlock>() for the corresponding range or by B<munlockall>(). "
3106 "Pages which are mapped to several locations or by several processes stay "
3107 "locked into RAM as long as they are locked at least at one location or by at "
3108 "least one process."
3112 #: build/C/man2/mlock.2:279
3114 "Under Linux, B<mlock>() and B<munlock>() automatically round I<addr> down "
3115 "to the nearest page boundary. However, POSIX.1-2001 allows an "
3116 "implementation to require that I<addr> is page aligned, so portable "
3117 "applications should ensure this."
3121 #: build/C/man2/mlock.2:292
3123 "The I<VmLck> field of the Linux-specific I</proc/PID/status> file shows how "
3124 "many kilobytes of memory the process with ID I<PID> has locked using "
3125 "B<mlock>(), B<mlockall>(), and B<mmap>(2) B<MAP_LOCKED>."
3129 #: build/C/man2/mlock.2:292
3131 msgid "Limits and permissions"
3135 #: build/C/man2/mlock.2:299
3137 "In Linux 2.6.8 and earlier, a process must be privileged (B<CAP_IPC_LOCK>) "
3138 "in order to lock memory and the B<RLIMIT_MEMLOCK> soft resource limit "
3139 "defines a limit on how much memory the process may lock."
3143 #: build/C/man2/mlock.2:305
3145 "Since Linux 2.6.9, no limits are placed on the amount of memory that a "
3146 "privileged process can lock and the B<RLIMIT_MEMLOCK> soft resource limit "
3147 "instead defines a limit on how much memory an unprivileged process may lock."
3151 #: build/C/man2/mlock.2:313
3153 "In the 2.4 series Linux kernels up to and including 2.4.17, a bug caused the "
3154 "B<mlockall>() B<MCL_FUTURE> flag to be inherited across a B<fork>(2). This "
3155 "was rectified in kernel 2.4.18."
3158 #. See the following LKML thread:
3159 #. http://marc.theaimsgroup.com/?l=linux-kernel&m=113801392825023&w=2
3160 #. "Rationale for RLIMIT_MEMLOCK"
3163 #: build/C/man2/mlock.2:330
3165 "Since kernel 2.6.9, if a privileged process calls I<mlockall(MCL_FUTURE)> "
3166 "and later drops privileges (loses the B<CAP_IPC_LOCK> capability by, for "
3167 "example, setting its effective UID to a nonzero value), then subsequent "
3168 "memory allocations (e.g., B<mmap>(2), B<brk>(2)) will fail if the "
3169 "B<RLIMIT_MEMLOCK> resource limit is encountered."
3173 #: build/C/man2/mlock.2:337
3175 "B<mmap>(2), B<setrlimit>(2), B<shmctl>(2), B<sysconf>(3), B<proc>(5), "
3176 "B<capabilities>(7)"
3180 #: build/C/man2/mmap.2:40
3186 #: build/C/man2/mmap.2:40 build/C/man2/mmap2.2:29
3192 #: build/C/man2/mmap.2:43
3193 msgid "mmap, munmap - map or unmap files or devices into memory"
3197 #: build/C/man2/mmap.2:51
3200 "B<void *mmap(void *>I<addr>B<, size_t >I<length>B<, int >I<prot>B<, int "
3202 "B< int >I<fd>B<, off_t >I<offset>B<);>\n"
3203 "B<int munmap(void *>I<addr>B<, size_t >I<length>B<);>\n"
3207 #: build/C/man2/mmap.2:61
3209 "B<mmap>() creates a new mapping in the virtual address space of the calling "
3210 "process. The starting address for the new mapping is specified in I<addr>. "
3211 "The I<length> argument specifies the length of the mapping."
3214 #. Before Linux 2.6.24, the address was rounded up to the next page
3215 #. boundary; since 2.6.24, it is rounded down!
3217 #: build/C/man2/mmap.2:75
3219 "If I<addr> is NULL, then the kernel chooses the address at which to create "
3220 "the mapping; this is the most portable method of creating a new mapping. If "
3221 "I<addr> is not NULL, then the kernel takes it as a hint about where to place "
3222 "the mapping; on Linux, the mapping will be created at a nearby page "
3223 "boundary. The address of the new mapping is returned as the result of the "
3228 #: build/C/man2/mmap.2:87
3230 "The contents of a file mapping (as opposed to an anonymous mapping; see "
3231 "B<MAP_ANONYMOUS> below), are initialized using I<length> bytes starting at "
3232 "offset I<offset> in the file (or other object) referred to by the file "
3233 "descriptor I<fd>. I<offset> must be a multiple of the page size as returned "
3234 "by I<sysconf(_SC_PAGE_SIZE)>."
3238 #: build/C/man2/mmap.2:95
3240 "The I<prot> argument describes the desired memory protection of the mapping "
3241 "(and must not conflict with the open mode of the file). It is either "
3242 "B<PROT_NONE> or the bitwise OR of one or more of the following flags:"
3246 #: build/C/man2/mmap.2:95 build/C/man2/mprotect.2:67
3248 msgid "B<PROT_EXEC>"
3252 #: build/C/man2/mmap.2:98
3253 msgid "Pages may be executed."
3257 #: build/C/man2/mmap.2:98 build/C/man2/mprotect.2:61
3259 msgid "B<PROT_READ>"
3263 #: build/C/man2/mmap.2:101
3264 msgid "Pages may be read."
3268 #: build/C/man2/mmap.2:101 build/C/man2/mprotect.2:64
3270 msgid "B<PROT_WRITE>"
3274 #: build/C/man2/mmap.2:104
3275 msgid "Pages may be written."
3279 #: build/C/man2/mmap.2:104 build/C/man2/mprotect.2:58
3281 msgid "B<PROT_NONE>"
3285 #: build/C/man2/mmap.2:107
3286 msgid "Pages may not be accessed."
3290 #: build/C/man2/mmap.2:116
3292 "The I<flags> argument determines whether updates to the mapping are visible "
3293 "to other processes mapping the same region, and whether updates are carried "
3294 "through to the underlying file. This behavior is determined by including "
3295 "exactly one of the following values in I<flags>:"
3299 #: build/C/man2/mmap.2:116
3301 msgid "B<MAP_SHARED>"
3305 #: build/C/man2/mmap.2:126
3307 "Share this mapping. Updates to the mapping are visible to other processes "
3308 "that map this file, and are carried through to the underlying file. The "
3309 "file may not actually be updated until B<msync>(2) or B<munmap>() is "
3314 #: build/C/man2/mmap.2:126
3316 msgid "B<MAP_PRIVATE>"
3320 #: build/C/man2/mmap.2:135
3322 "Create a private copy-on-write mapping. Updates to the mapping are not "
3323 "visible to other processes mapping the same file, and are not carried "
3324 "through to the underlying file. It is unspecified whether changes made to "
3325 "the file after the B<mmap>() call are visible in the mapped region."
3329 #: build/C/man2/mmap.2:137
3330 msgid "Both of these flags are described in POSIX.1-2001."
3334 #: build/C/man2/mmap.2:140
3335 msgid "In addition, zero or more of the following values can be ORed in I<flags>:"
3339 #: build/C/man2/mmap.2:140
3341 msgid "B<MAP_32BIT> (since Linux 2.4.20, 2.6)"
3344 #. See http://lwn.net/Articles/294642 "Tangled up in threads", 19 Aug 08
3346 #: build/C/man2/mmap.2:156
3348 "Put the mapping into the first 2 Gigabytes of the process address space. "
3349 "This flag is only supported on x86-64, for 64-bit programs. It was added to "
3350 "allow thread stacks to be allocated somewhere in the first 2GB of memory, so "
3351 "as to improve context-switch performance on some early 64-bit processors. "
3352 "Modern x86-64 processors no longer have this performance problem, so use of "
3353 "this flag is not required on those systems. The B<MAP_32BIT> flag is "
3354 "ignored when B<MAP_FIXED> is set."
3358 #: build/C/man2/mmap.2:156
3364 #: build/C/man2/mmap.2:161
3365 msgid "Synonym for B<MAP_ANONYMOUS>. Deprecated."
3369 #: build/C/man2/mmap.2:161
3371 msgid "B<MAP_ANONYMOUS>"
3375 #: build/C/man2/mmap.2:183
3377 "The mapping is not backed by any file; its contents are initialized to "
3378 "zero. The I<fd> and I<offset> arguments are ignored; however, some "
3379 "implementations require I<fd> to be -1 if B<MAP_ANONYMOUS> (or B<MAP_ANON>) "
3380 "is specified, and portable applications should ensure this. The use of "
3381 "B<MAP_ANONYMOUS> in conjunction with B<MAP_SHARED> is only supported on "
3382 "Linux since kernel 2.4."
3386 #: build/C/man2/mmap.2:183
3388 msgid "B<MAP_DENYWRITE>"
3391 #. Introduced in 1.1.36, removed in 1.3.24.
3393 #: build/C/man2/mmap.2:191
3395 "This flag is ignored. (Long ago, it signaled that attempts to write to the "
3396 "underlying file should fail with B<ETXTBUSY>. But this was a source of "
3397 "denial-of-service attacks.)"
3401 #: build/C/man2/mmap.2:191
3403 msgid "B<MAP_EXECUTABLE>"
3406 #. Introduced in 1.1.38, removed in 1.3.24. Flag tested in proc_follow_link.
3407 #. (Long ago, it signaled that the underlying file is an executable.
3408 #. However, that information was not really used anywhere.)
3409 #. Linus talked about DOS related to MAP_EXECUTABLE, but he was thinking of
3412 #: build/C/man2/mmap.2:199
3413 msgid "This flag is ignored."
3417 #: build/C/man2/mmap.2:199
3422 #. On some systems, this was required as the opposite of
3423 #. MAP_ANONYMOUS -- mtk, 1 May 2007
3425 #: build/C/man2/mmap.2:205
3426 msgid "Compatibility flag. Ignored."
3430 #: build/C/man2/mmap.2:205
3432 msgid "B<MAP_FIXED>"
3436 #: build/C/man2/mmap.2:223
3438 "Don't interpret I<addr> as a hint: place the mapping at exactly that "
3439 "address. I<addr> must be a multiple of the page size. If the memory region "
3440 "specified by I<addr> and I<len> overlaps pages of any existing mapping(s), "
3441 "then the overlapped part of the existing mapping(s) will be discarded. If "
3442 "the specified address cannot be used, B<mmap>() will fail. Because "
3443 "requiring a fixed address for a mapping is less portable, the use of this "
3444 "option is discouraged."
3448 #: build/C/man2/mmap.2:223
3450 msgid "B<MAP_GROWSDOWN>"
3454 #: build/C/man2/mmap.2:228
3456 "Used for stacks. Indicates to the kernel virtual memory system that the "
3457 "mapping should extend downward in memory."
3461 #: build/C/man2/mmap.2:228
3463 msgid "B<MAP_HUGETLB> (since Linux 2.6.32)"
3467 #: build/C/man2/mmap.2:234
3469 "Allocate the mapping using \"huge pages.\" See the kernel source file "
3470 "I<Documentation/vm/hugetlbpage.txt> for further information."
3474 #: build/C/man2/mmap.2:234
3476 msgid "B<MAP_LOCKED> (since Linux 2.5.37)"
3479 #. If set, the mapped pages will not be swapped out.
3481 #: build/C/man2/mmap.2:240
3483 "Lock the pages of the mapped region into memory in the manner of "
3484 "B<mlock>(2). This flag is ignored in older kernels."
3488 #: build/C/man2/mmap.2:240
3490 msgid "B<MAP_NONBLOCK> (since Linux 2.5.46)"
3494 #: build/C/man2/mmap.2:255
3496 "Only meaningful in conjunction with B<MAP_POPULATE>. Don't perform "
3497 "read-ahead: only create page tables entries for pages that are already "
3498 "present in RAM. Since Linux 2.6.23, this flag causes B<MAP_POPULATE> to do "
3499 "nothing. One day the combination of B<MAP_POPULATE> and B<MAP_NONBLOCK> may "
3504 #: build/C/man2/mmap.2:255
3506 msgid "B<MAP_NORESERVE>"
3510 #: build/C/man2/mmap.2:270
3512 "Do not reserve swap space for this mapping. When swap space is reserved, "
3513 "one has the guarantee that it is possible to modify the mapping. When swap "
3514 "space is not reserved one might get B<SIGSEGV> upon a write if no physical "
3515 "memory is available. See also the discussion of the file "
3516 "I</proc/sys/vm/overcommit_memory> in B<proc>(5). In kernels before 2.6, "
3517 "this flag only had effect for private writable mappings."
3521 #: build/C/man2/mmap.2:270
3523 msgid "B<MAP_POPULATE> (since Linux 2.5.46)"
3527 #: build/C/man2/mmap.2:277
3529 "Populate (prefault) page tables for a mapping. For a file mapping, this "
3530 "causes read-ahead on the file. Later accesses to the mapping will not be "
3531 "blocked by page faults. B<MAP_POPULATE> is only supported for private "
3532 "mappings since Linux 2.6.23."
3536 #: build/C/man2/mmap.2:277
3538 msgid "B<MAP_STACK> (since Linux 2.6.27)"
3541 #. See http://lwn.net/Articles/294642 "Tangled up in threads", 19 Aug 08
3542 #. commit cd98a04a59e2f94fa64d5bf1e26498d27427d5e7
3543 #. http://thread.gmane.org/gmane.linux.kernel/720412
3544 #. "pthread_create() slow for many threads; also time to revisit 64b
3545 #. context switch optimization?"
3547 #: build/C/man2/mmap.2:290
3549 "Allocate the mapping at an address suitable for a process or thread stack. "
3550 "This flag is currently a no-op, but is used in the glibc threading "
3551 "implementation so that if some architectures require special treatment for "
3552 "stack allocations, support can later be transparently implemented for glibc."
3556 #: build/C/man2/mmap.2:290
3558 msgid "B<MAP_UNINITIALIZED> (since Linux 2.6.33)"
3562 #: build/C/man2/mmap.2:300
3564 "Don't clear anonymous pages. This flag is intended to improve performance "
3565 "on embedded devices. This flag is only honored if the kernel was configured "
3566 "with the B<CONFIG_MMAP_ALLOW_UNINITIALIZED> option. Because of the security "
3567 "implications, that option is normally enabled only on embedded devices "
3568 "(i.e., devices where one has complete control of the contents of user "
3573 #: build/C/man2/mmap.2:308
3575 "Of the above flags, only B<MAP_FIXED> is specified in POSIX.1-2001. "
3576 "However, most systems also support B<MAP_ANONYMOUS> (or its synonym "
3581 #: build/C/man2/mmap.2:315
3583 "Some systems document the additional flags B<MAP_AUTOGROW>, "
3584 "B<MAP_AUTORESRV>, B<MAP_COPY>, and B<MAP_LOCAL>."
3588 #: build/C/man2/mmap.2:321
3590 "Memory mapped by B<mmap>() is preserved across B<fork>(2), with the same "
3595 #: build/C/man2/mmap.2:329
3597 "A file is mapped in multiples of the page size. For a file that is not a "
3598 "multiple of the page size, the remaining memory is zeroed when mapped, and "
3599 "writes to that region are not written out to the file. The effect of "
3600 "changing the size of the underlying file of a mapping on the pages that "
3601 "correspond to added or removed regions of the file is unspecified."
3605 #: build/C/man2/mmap.2:329
3611 #: build/C/man2/mmap.2:339
3613 "The B<munmap>() system call deletes the mappings for the specified address "
3614 "range, and causes further references to addresses within the range to "
3615 "generate invalid memory references. The region is also automatically "
3616 "unmapped when the process is terminated. On the other hand, closing the "
3617 "file descriptor does not unmap the region."
3621 #: build/C/man2/mmap.2:349
3623 "The address I<addr> must be a multiple of the page size. All pages "
3624 "containing a part of the indicated range are unmapped, and subsequent "
3625 "references to these pages will generate B<SIGSEGV>. It is not an error if "
3626 "the indicated range does not contain any mapped pages."
3630 #: build/C/man2/mmap.2:349
3632 msgid "Timestamps changes for file-backed mappings"
3636 #: build/C/man2/mmap.2:356
3638 "For file-backed mappings, the I<st_atime> field for the mapped file may be "
3639 "updated at any time between the B<mmap>() and the corresponding unmapping; "
3640 "the first reference to a mapped page will update the field if it has not "
3645 #: build/C/man2/mmap.2:373
3647 "The I<st_ctime> and I<st_mtime> field for a file mapped with B<PROT_WRITE> "
3648 "and B<MAP_SHARED> will be updated after a write to the mapped region, and "
3649 "before a subsequent B<msync>(2) with the B<MS_SYNC> or B<MS_ASYNC> flag, if "
3654 #: build/C/man2/mmap.2:390
3656 "On success, B<mmap>() returns a pointer to the mapped area. On error, the "
3657 "value B<MAP_FAILED> (that is, I<(void\\ *)\\ -1>) is returned, and I<errno> "
3658 "is set appropriately. On success, B<munmap>() returns 0, on failure -1, "
3659 "and I<errno> is set (probably to B<EINVAL>)."
3663 #: build/C/man2/mmap.2:391 build/C/man2/mprotect.2:80 build/C/man3/shm_open.3:185 build/C/man3/shm_open.3:190 build/C/man2/shmctl.2:295 build/C/man2/shmget.2:186 build/C/man2/shmop.2:189
3669 #: build/C/man2/mmap.2:411
3671 "A file descriptor refers to a non-regular file. Or B<MAP_PRIVATE> was "
3672 "requested, but I<fd> is not open for reading. Or B<MAP_SHARED> was "
3673 "requested and B<PROT_WRITE> is set, but I<fd> is not open in read/write "
3674 "(B<O_RDWR>) mode. Or B<PROT_WRITE> is set, but the file is append-only."
3678 #: build/C/man2/mmap.2:415
3680 "The file has been locked, or too much memory has been locked (see "
3685 #: build/C/man2/mmap.2:421
3686 msgid "I<fd> is not a valid file descriptor (and B<MAP_ANONYMOUS> was not set)."
3690 #: build/C/man2/mmap.2:429
3692 "We don't like I<addr>, I<length>, or I<offset> (e.g., they are too large, or "
3693 "not aligned on a page boundary)."
3697 #: build/C/man2/mmap.2:434
3698 msgid "(since Linux 2.6.12) I<length> was 0."
3702 #: build/C/man2/mmap.2:442
3704 "I<flags> contained neither B<MAP_PRIVATE> or B<MAP_SHARED>, or contained "
3705 "both of these values."
3709 #: build/C/man2/mmap.2:442 build/C/man3/shm_open.3:227 build/C/man2/shmget.2:202
3714 #. [2.6.7] shmem_zero_setup()-->shmem_file_setup()-->get_empty_filp()
3716 #: build/C/man2/mmap.2:450 build/C/man2/shmget.2:206
3717 msgid "The system limit on the total number of open files has been reached."
3721 #: build/C/man2/mmap.2:454
3723 "The underlying file system of the specified file does not support memory "
3728 #: build/C/man2/mmap.2:458
3730 "No memory is available, or the process's maximum number of mappings would "
3731 "have been exceeded."
3734 #. (Since 2.4.25 / 2.6.0.)
3736 #: build/C/man2/mmap.2:467
3738 "The I<prot> argument asks for B<PROT_EXEC> but the mapped area belongs to a "
3739 "file on a file system that was mounted no-exec."
3743 #: build/C/man2/mmap.2:467
3749 #: build/C/man2/mmap.2:473
3751 "B<MAP_DENYWRITE> was set but the object specified by I<fd> is open for "
3756 #: build/C/man2/mmap.2:475
3757 msgid "Use of a mapped region can result in these signals:"
3761 #: build/C/man2/mmap.2:475
3767 #: build/C/man2/mmap.2:478
3768 msgid "Attempted write into a region mapped as read-only."
3772 #: build/C/man2/mmap.2:478
3778 #: build/C/man2/mmap.2:483
3780 "Attempted access to a portion of the buffer that does not correspond to the "
3781 "file (for example, beyond the end of the file, including the case where "
3782 "another process has truncated the file)."
3785 #. SVr4 documents additional error codes ENXIO and ENODEV.
3786 #. SUSv2 documents additional error codes EMFILE and EOVERFLOW.
3788 #: build/C/man2/mmap.2:487
3789 msgid "SVr4, 4.4BSD, POSIX.1-2001."
3792 #. POSIX.1-2001: It shall be defined to -1 or 0 or 200112L.
3793 #. -1: unavailable, 0: ask using sysconf().
3794 #. glibc defines it to 1.
3796 #: build/C/man2/mmap.2:501
3798 "On POSIX systems on which B<mmap>(), B<msync>(2) and B<munmap>() are "
3799 "available, B<_POSIX_MAPPED_FILES> is defined in I<E<lt>unistd.hE<gt>> to a "
3800 "value greater than 0. (See also B<sysconf>(3).)"
3803 #. Since around glibc 2.1/2.2, depending on the platform.
3805 #: build/C/man2/mmap.2:516
3807 "This page describes the interface provided by the glibc B<mmap>() wrapper "
3808 "function. Originally, this function invoked a system call of the same "
3809 "name. Since kernel 2.4, that system call has been superseded by "
3810 "B<mmap2>(2), and nowadays the glibc B<mmap>() wrapper function invokes "
3811 "B<mmap2>(2) with a suitably adjusted value for I<offset>."
3815 #: build/C/man2/mmap.2:529
3817 "On some hardware architectures (e.g., i386), B<PROT_WRITE> implies "
3818 "B<PROT_READ>. It is architecture dependent whether B<PROT_READ> implies "
3819 "B<PROT_EXEC> or not. Portable programs should always set B<PROT_EXEC> if "
3820 "they intend to execute code in the new mapping."
3824 #: build/C/man2/mmap.2:544
3826 "The portable way to create a mapping is to specify I<addr> as 0 (NULL), and "
3827 "omit B<MAP_FIXED> from I<flags>. In this case, the system chooses the "
3828 "address for the mapping; the address is chosen so as not to conflict with "
3829 "any existing mapping, and will not be 0. If the B<MAP_FIXED> flag is "
3830 "specified, and I<addr> is 0 (NULL), then the mapped address will be 0 "
3835 #: build/C/man2/mmap.2:549
3837 "On Linux there are no guarantees like those suggested above under "
3838 "B<MAP_NORESERVE>. By default, any process can be killed at any moment when "
3839 "the system runs out of memory."
3843 #: build/C/man2/mmap.2:556
3845 "In kernels before 2.6.7, the B<MAP_POPULATE> flag only has effect if I<prot> "
3846 "is specified as B<PROT_NONE>."
3850 #: build/C/man2/mmap.2:571
3852 "SUSv3 specifies that B<mmap>() should fail if I<length> is 0. However, in "
3853 "kernels before 2.6.12, B<mmap>() succeeded in this case: no mapping was "
3854 "created and the call returned I<addr>. Since kernel 2.6.12, B<mmap>() "
3855 "fails with the error B<EINVAL> for this case."
3859 #: build/C/man2/mmap.2:583
3861 "The following program prints part of the file specified in its first "
3862 "command-line argument to standard output. The range of bytes to be printed "
3863 "is specified via offset and length values in the second and third "
3864 "command-line arguments. The program creates a memory mapping of the "
3865 "required pages of the file and then uses B<write>(2) to output the desired "
3870 #: build/C/man2/mmap.2:591
3873 "#include E<lt>sys/mman.hE<gt>\n"
3874 "#include E<lt>sys/stat.hE<gt>\n"
3875 "#include E<lt>fcntl.hE<gt>\n"
3876 "#include E<lt>stdio.hE<gt>\n"
3877 "#include E<lt>stdlib.hE<gt>\n"
3878 "#include E<lt>unistd.hE<gt>\n"
3882 #: build/C/man2/mmap.2:594 build/C/man2/mprotect.2:172
3885 "#define handle_error(msg) \\e\n"
3886 " do { perror(msg); exit(EXIT_FAILURE); } while (0)\n"
3890 #: build/C/man2/mmap.2:604
3894 "main(int argc, char *argv[])\n"
3898 " struct stat sb;\n"
3899 " off_t offset, pa_offset;\n"
3905 #: build/C/man2/mmap.2:609
3908 " if (argc E<lt> 3 || argc E<gt> 4) {\n"
3909 " fprintf(stderr, \"%s file offset [length]\\en\", argv[0]);\n"
3910 " exit(EXIT_FAILURE);\n"
3915 #: build/C/man2/mmap.2:613
3918 " fd = open(argv[1], O_RDONLY);\n"
3920 " handle_error(\"open\");\n"
3924 #: build/C/man2/mmap.2:616
3927 " if (fstat(fd, &sb) == -1) /* To obtain file size */\n"
3928 " handle_error(\"fstat\");\n"
3932 #: build/C/man2/mmap.2:620
3935 " offset = atoi(argv[2]);\n"
3936 " pa_offset = offset & ~(sysconf(_SC_PAGE_SIZE) - 1);\n"
3937 " /* offset for mmap() must be page aligned */\n"
3941 #: build/C/man2/mmap.2:625
3944 " if (offset E<gt>= sb.st_size) {\n"
3945 " fprintf(stderr, \"offset is past end of file\\en\");\n"
3946 " exit(EXIT_FAILURE);\n"
3951 #: build/C/man2/mmap.2:631
3954 " if (argc == 4) {\n"
3955 " length = atoi(argv[3]);\n"
3956 " if (offset + length E<gt> sb.st_size)\n"
3957 " length = sb.st_size - offset;\n"
3958 " /* Can\\(aqt display bytes past end of file */\n"
3962 #: build/C/man2/mmap.2:635
3965 " } else { /* No length arg ==E<gt> display to end of file */\n"
3966 " length = sb.st_size - offset;\n"
3971 #: build/C/man2/mmap.2:640
3974 " addr = mmap(NULL, length + offset - pa_offset, PROT_READ,\n"
3975 " MAP_PRIVATE, fd, pa_offset);\n"
3976 " if (addr == MAP_FAILED)\n"
3977 " handle_error(\"mmap\");\n"
3981 #: build/C/man2/mmap.2:645
3984 " s = write(STDOUT_FILENO, addr + offset - pa_offset, length);\n"
3985 " if (s != length) {\n"
3987 " handle_error(\"write\");\n"
3991 #: build/C/man2/mmap.2:649
3994 " fprintf(stderr, \"partial write\");\n"
3995 " exit(EXIT_FAILURE);\n"
4000 #: build/C/man2/mmap.2:666
4002 "B<getpagesize>(2), B<mincore>(2), B<mlock>(2), B<mmap2>(2), B<mprotect>(2), "
4003 "B<mremap>(2), B<msync>(2), B<remap_file_pages>(2), B<setrlimit>(2), "
4004 "B<shmat>(2), B<shm_open>(3), B<shm_overview>(7)"
4008 #: build/C/man2/mmap.2:671 build/C/man2/msync.2:122
4009 msgid "B.O. Gallmeister, POSIX.4, O'Reilly, pp. 128-129 and 389-391."
4013 #: build/C/man2/mmap2.2:29
4019 #: build/C/man2/mmap2.2:32
4020 msgid "mmap2 - map files or devices into memory"
4024 #: build/C/man2/mmap2.2:38
4027 "B<void *mmap2(void *>I<addr>B<, size_t >I<length>B<, int >I<prot>B<,>\n"
4028 "B< int >I<flags>B<, int >I<fd>B<, off_t >I<pgoffset>B<);>\n"
4032 #: build/C/man2/mmap2.2:43
4034 "This is probably not the system call you are interested; instead, see "
4035 "B<mmap>(2), which describes the glibc wrapper function that invokes this "
4040 #: build/C/man2/mmap2.2:54
4042 "The B<mmap2>() system call provides the same interface as B<mmap>(2), "
4043 "except that the final argument specifies the offset into the file in "
4044 "4096-byte units (instead of bytes, as is done by B<mmap>(2)). This enables "
4045 "applications that use a 32-bit I<off_t> to map large files (up to 2^44 "
4050 #: build/C/man2/mmap2.2:61
4052 "On success, B<mmap2>() returns a pointer to the mapped area. On error -1 "
4053 "is returned and I<errno> is set appropriately."
4057 #: build/C/man2/mmap2.2:65
4058 msgid "Problem with getting the data from userspace."
4062 #: build/C/man2/mmap2.2:70
4064 "(Various platforms where the page size is not 4096 bytes.) I<offset * 4096> "
4065 "is not a multiple of the system page size."
4069 #: build/C/man2/mmap2.2:74
4070 msgid "B<mmap2>() can also return any of the errors described in B<mmap>(2)."
4074 #: build/C/man2/mmap2.2:77
4075 msgid "B<mmap2>() is available since Linux 2.3.31."
4079 #: build/C/man2/mmap2.2:79 build/C/man2/subpage_prot.2:93
4080 msgid "This system call is Linux-specific."
4084 #: build/C/man2/mmap2.2:85
4086 "Nowadays, the glibc B<mmap>() wrapper function invokes this system call "
4087 "rather than the B<mmap>(2) system call."
4090 #. ia64 can have page sizes ranging from 4kB to 64kB.
4091 #. On cris, it looks like the unit might also be the page size,
4092 #. which is 8192 bytes. -- mtk, June 2007
4094 #: build/C/man2/mmap2.2:92
4096 "On ia64, the unit for I<offset> is actually the system page size, rather "
4101 #: build/C/man2/mmap2.2:98
4102 msgid "B<getpagesize>(2), B<mmap>(2), B<mremap>(2), B<msync>(2), B<shm_open>(3)"
4106 #: build/C/man2/mprotect.2:32
4112 #: build/C/man2/mprotect.2:32
4118 #: build/C/man2/mprotect.2:35
4119 msgid "mprotect - set protection on a region of memory"
4123 #: build/C/man2/mprotect.2:40
4125 msgid "B<int mprotect(const void *>I<addr>B<, size_t >I<len>B<, int >I<prot>B<);>\n"
4129 #: build/C/man2/mprotect.2:48
4131 "B<mprotect>() changes protection for the calling process's memory page(s) "
4132 "containing any part of the address range in the interval [I<addr>,\\ "
4133 "I<addr>+I<len>-1]. I<addr> must be aligned to a page boundary."
4137 #: build/C/man2/mprotect.2:53
4139 "If the calling process tries to access memory in a manner that violates the "
4140 "protection, then the kernel generates a B<SIGSEGV> signal for the process."
4144 #: build/C/man2/mprotect.2:58
4146 "I<prot> is either B<PROT_NONE> or a bitwise-or of the other values in the "
4151 #: build/C/man2/mprotect.2:61
4152 msgid "The memory cannot be accessed at all."
4156 #: build/C/man2/mprotect.2:64
4157 msgid "The memory can be read."
4161 #: build/C/man2/mprotect.2:67
4162 msgid "The memory can be modified."
4166 #. Document PROT_GROWSUP and PROT_GROWSDOWN
4168 #: build/C/man2/mprotect.2:72
4169 msgid "The memory can be executed."
4173 #: build/C/man2/mprotect.2:79
4175 "On success, B<mprotect>() returns zero. On error, -1 is returned, and "
4176 "I<errno> is set appropriately."
4180 #: build/C/man2/mprotect.2:89
4182 "The memory cannot be given the specified access. This can happen, for "
4183 "example, if you B<mmap>(2) a file to which you have read-only access, then "
4184 "ask B<mprotect>() to mark it B<PROT_WRITE>."
4187 #. Or: both PROT_GROWSUP and PROT_GROWSDOWN were specified in 'prot'.
4189 #: build/C/man2/mprotect.2:94
4190 msgid "I<addr> is not a valid pointer, or not a multiple of the system page size."
4194 #: build/C/man2/mprotect.2:97
4195 msgid "Internal kernel structures could not be allocated."
4199 #: build/C/man2/mprotect.2:107
4201 "Addresses in the range [I<addr>, I<addr>+I<len>-1] are invalid for the "
4202 "address space of the process, or specify one or more pages that are not "
4203 "mapped. (Before kernel 2.4.19, the error B<EFAULT> was incorrectly produced "
4207 #. SVr4 defines an additional error
4208 #. code EAGAIN. The SVr4 error conditions don't map neatly onto Linux's.
4210 #: build/C/man2/mprotect.2:116
4212 "SVr4, POSIX.1-2001. POSIX says that the behavior of B<mprotect>() is "
4213 "unspecified if it is applied to a region of memory that was not obtained via "
4218 #: build/C/man2/mprotect.2:123
4220 "On Linux it is always permissible to call B<mprotect>() on any address in a "
4221 "process's address space (except for the kernel vsyscall area). In "
4222 "particular it can be used to change existing code mappings to be writable."
4226 #: build/C/man2/mprotect.2:133
4228 "Whether B<PROT_EXEC> has any effect different from B<PROT_READ> is "
4229 "architecture- and kernel version-dependent. On some hardware architectures "
4230 "(e.g., i386), B<PROT_WRITE> implies B<PROT_READ>."
4234 #: build/C/man2/mprotect.2:142
4236 "POSIX.1-2001 says that an implementation may permit access other than that "
4237 "specified in I<prot>, but at a minimum can only allow write access if "
4238 "B<PROT_WRITE> has been set, and must not allow any access if B<PROT_NONE> "
4243 #: build/C/man2/mprotect.2:148
4245 "The program below allocates four pages of memory, makes the third of these "
4246 "pages read-only, and then executes a loop that walks upward through the "
4247 "allocated region modifying bytes."
4251 #: build/C/man2/mprotect.2:151
4252 msgid "An example of what we might see when running the program is the following:"
4256 #: build/C/man2/mprotect.2:157
4260 "Start of region: 0x804c000\n"
4261 "Got SIGSEGV at address: 0x804e000\n"
4265 #: build/C/man2/mprotect.2:169
4268 "#include E<lt>unistd.hE<gt>\n"
4269 "#include E<lt>signal.hE<gt>\n"
4270 "#include E<lt>stdio.hE<gt>\n"
4271 "#include E<lt>malloc.hE<gt>\n"
4272 "#include E<lt>stdlib.hE<gt>\n"
4273 "#include E<lt>errno.hE<gt>\n"
4274 "#include E<lt>sys/mman.hE<gt>\n"
4278 #: build/C/man2/mprotect.2:174
4280 msgid "char *buffer;\n"
4284 #: build/C/man2/mprotect.2:182
4288 "handler(int sig, siginfo_t *si, void *unused)\n"
4290 " printf(\"Got SIGSEGV at address: 0x%lx\\en\",\n"
4291 " (long) si-E<gt>si_addr);\n"
4292 " exit(EXIT_FAILURE);\n"
4297 #: build/C/man2/mprotect.2:189
4301 "main(int argc, char *argv[])\n"
4305 " struct sigaction sa;\n"
4309 #: build/C/man2/mprotect.2:195
4312 " sa.sa_flags = SA_SIGINFO;\n"
4313 " sigemptyset(&sa.sa_mask);\n"
4314 " sa.sa_sigaction = handler;\n"
4315 " if (sigaction(SIGSEGV, &sa, NULL) == -1)\n"
4316 " handle_error(\"sigaction\");\n"
4320 #: build/C/man2/mprotect.2:199
4323 " pagesize = sysconf(_SC_PAGE_SIZE);\n"
4324 " if (pagesize == -1)\n"
4325 " handle_error(\"sysconf\");\n"
4329 #: build/C/man2/mprotect.2:202
4332 " /* Allocate a buffer aligned on a page boundary;\n"
4333 " initial protection is PROT_READ | PROT_WRITE */\n"
4337 #: build/C/man2/mprotect.2:206
4340 " buffer = memalign(pagesize, 4 * pagesize);\n"
4341 " if (buffer == NULL)\n"
4342 " handle_error(\"memalign\");\n"
4346 #: build/C/man2/mprotect.2:208
4348 msgid " printf(\"Start of region: 0x%lx\\en\", (long) buffer);\n"
4352 #: build/C/man2/mprotect.2:212
4355 " if (mprotect(buffer + pagesize * 2, pagesize,\n"
4356 " PROT_READ) == -1)\n"
4357 " handle_error(\"mprotect\");\n"
4361 #: build/C/man2/mprotect.2:215
4364 " for (p = buffer ; ; )\n"
4365 " *(p++) = \\(aqa\\(aq;\n"
4369 #: build/C/man2/mprotect.2:219
4372 " printf(\"Loop completed\\en\"); /* Should never happen */\n"
4373 " exit(EXIT_SUCCESS);\n"
4378 #: build/C/man2/mprotect.2:223
4379 msgid "B<mmap>(2), B<sysconf>(3)"
4383 #: build/C/man2/mremap.2:31
4389 #: build/C/man2/mremap.2:31
4395 #: build/C/man2/mremap.2:34
4396 msgid "mremap - remap a virtual memory address"
4400 #: build/C/man2/mremap.2:37
4402 msgid "B<#define _GNU_SOURCE> /* See feature_test_macros(7) */\n"
4406 #: build/C/man2/mremap.2:42
4409 "B<void *mremap(void *>I<old_address>B<, size_t >I<old_size>B<,>\n"
4410 "B< size_t >I<new_size>B<, int >I<flags>B<, ... /* void "
4411 "*>I<new_address>B< */);>\n"
4415 #: build/C/man2/mremap.2:48
4417 "B<mremap>() expands (or shrinks) an existing memory mapping, potentially "
4418 "moving it at the same time (controlled by the I<flags> argument and the "
4419 "available virtual address space)."
4423 #: build/C/man2/mremap.2:62
4425 "I<old_address> is the old address of the virtual memory block that you want "
4426 "to expand (or shrink). Note that I<old_address> has to be page aligned. "
4427 "I<old_size> is the old size of the virtual memory block. I<new_size> is the "
4428 "requested size of the virtual memory block after the resize. An optional "
4429 "fifth argument, I<new_address>, may be provided; see the description of "
4430 "B<MREMAP_FIXED> below."
4434 #: build/C/man2/mremap.2:74
4436 "In Linux the memory is divided into pages. A user process has (one or) "
4437 "several linear virtual memory segments. Each virtual memory segment has one "
4438 "or more mappings to real memory pages (in the page table). Each virtual "
4439 "memory segment has its own protection (access rights), which may cause a "
4440 "segmentation violation if the memory is accessed incorrectly (e.g., writing "
4441 "to a read-only segment). Accessing virtual memory outside of the segments "
4442 "will also cause a segmentation violation."
4446 #: build/C/man2/mremap.2:82
4448 "B<mremap>() uses the Linux page table scheme. B<mremap>() changes the "
4449 "mapping between virtual addresses and memory pages. This can be used to "
4450 "implement a very efficient B<realloc>(3)."
4454 #: build/C/man2/mremap.2:84
4455 msgid "The I<flags> bit-mask argument may be 0, or include the following flag:"
4459 #: build/C/man2/mremap.2:84
4461 msgid "B<MREMAP_MAYMOVE>"
4465 #: build/C/man2/mremap.2:96
4467 "By default, if there is not sufficient space to expand a mapping at its "
4468 "current location, then B<mremap>() fails. If this flag is specified, then "
4469 "the kernel is permitted to relocate the mapping to a new virtual address, if "
4470 "necessary. If the mapping is relocated, then absolute pointers into the old "
4471 "mapping location become invalid (offsets relative to the starting address of "
4472 "the mapping should be employed)."
4476 #: build/C/man2/mremap.2:96
4478 msgid "B<MREMAP_FIXED> (since Linux 2.3.31)"
4482 #: build/C/man2/mremap.2:118
4484 "This flag serves a similar purpose to the B<MAP_FIXED> flag of B<mmap>(2). "
4485 "If this flag is specified, then B<mremap>() accepts a fifth argument, "
4486 "I<void *new_address>, which specifies a page-aligned address to which the "
4487 "mapping must be moved. Any previous mapping at the address range specified "
4488 "by I<new_address> and I<new_size> is unmapped. If B<MREMAP_FIXED> is "
4489 "specified, then B<MREMAP_MAYMOVE> must also be specified."
4493 #: build/C/man2/mremap.2:128
4495 "If the memory segment specified by I<old_address> and I<old_size> is locked "
4496 "(using B<mlock>(2) or similar), then this lock is maintained when the "
4497 "segment is resized and/or relocated. As a consequence, the amount of memory "
4498 "locked by the process may change."
4502 #: build/C/man2/mremap.2:136
4504 "On success B<mremap>() returns a pointer to the new virtual memory area. "
4505 "On error, the value B<MAP_FAILED> (that is, I<(void\\ *)\\ -1>) is returned, "
4506 "and I<errno> is set appropriately."
4510 #: build/C/man2/mremap.2:143
4512 "The caller tried to expand a memory segment that is locked, but this was not "
4513 "possible without exceeding the B<RLIMIT_MEMLOCK> resource limit."
4517 #: build/C/man2/mremap.2:152
4519 "\"Segmentation fault.\" Some address in the range I<old_address> to "
4520 "I<old_address>+I<old_size> is an invalid virtual memory address for this "
4521 "process. You can also get B<EFAULT> even if there exist mappings that cover "
4522 "the whole address space requested, but those mappings are of different "
4527 #: build/C/man2/mremap.2:180
4529 "An invalid argument was given. Possible causes are: I<old_address> was not "
4530 "page aligned; a value other than B<MREMAP_MAYMOVE> or B<MREMAP_FIXED> was "
4531 "specified in I<flags>; I<new_size> was zero; I<new_size> or I<new_address> "
4532 "was invalid; or the new address range specified by I<new_address> and "
4533 "I<new_size> overlapped the old address range specified by I<old_address> and "
4534 "I<old_size>; or B<MREMAP_FIXED> was specified without also specifying "
4535 "B<MREMAP_MAYMOVE>."
4539 #: build/C/man2/mremap.2:186
4541 "The memory area cannot be expanded at the current virtual address, and the "
4542 "B<MREMAP_MAYMOVE> flag is not set in I<flags>. Or, there is not enough "
4543 "(virtual) memory available."
4546 #. 4.2BSD had a (never actually implemented)
4548 #. call with completely different semantics.
4550 #: build/C/man2/mremap.2:192
4552 "This call is Linux-specific, and should not be used in programs intended to "
4557 #: build/C/man2/mremap.2:200
4559 "Prior to version 2.4, glibc did not expose the definition of "
4560 "B<MREMAP_FIXED>, and the prototype for B<mremap>() did not allow for the "
4561 "I<new_address> argument."
4565 #: build/C/man2/mremap.2:209
4567 "B<brk>(2), B<getpagesize>(2), B<getrlimit>(2), B<mlock>(2), B<mmap>(2), "
4568 "B<sbrk>(2), B<malloc>(3), B<realloc>(3)"
4572 #: build/C/man2/mremap.2:214
4574 "Your favorite OS text book for more information on paged memory. (I<Modern "
4575 "Operating Systems> by Andrew S. Tanenbaum, I<Inside Linux> by Randolf "
4576 "Bentson, I<The Design of the UNIX Operating System> by Maurice J. Bach.)"
4580 #: build/C/man2/msync.2:25
4586 #: build/C/man2/msync.2:25 build/C/man2/remap_file_pages.2:26
4592 #: build/C/man2/msync.2:28
4593 msgid "msync - synchronize a file with a memory map"
4597 #: build/C/man2/msync.2:32
4598 msgid "B<int msync(void *>I<addr>B<, size_t >I<length>B<, int >I<flags>B<);>"
4602 #: build/C/man2/msync.2:48
4604 "B<msync>() flushes changes made to the in-core copy of a file that was "
4605 "mapped into memory using B<mmap>(2) back to disk. Without use of this call "
4606 "there is no guarantee that changes are written back before B<munmap>(2) is "
4607 "called. To be more precise, the part of the file that corresponds to the "
4608 "memory area starting at I<addr> and having length I<length> is updated."
4612 #: build/C/man2/msync.2:68
4614 "The I<flags> argument may have the bits B<MS_ASYNC>, B<MS_SYNC>, and "
4615 "B<MS_INVALIDATE> set, but not both B<MS_ASYNC> and B<MS_SYNC>. B<MS_ASYNC> "
4616 "specifies that an update be scheduled, but the call returns immediately. "
4617 "B<MS_SYNC> asks for an update and waits for it to complete. "
4618 "B<MS_INVALIDATE> asks to invalidate other mappings of the same file (so that "
4619 "they can be updated with the fresh values just written)."
4623 #: build/C/man2/msync.2:73
4625 "On success, zero is returned. On error, -1 is returned, and I<errno> is set "
4630 #: build/C/man2/msync.2:74
4636 #: build/C/man2/msync.2:80
4638 "B<MS_INVALIDATE> was specified in I<flags>, and a memory lock exists for the "
4639 "specified address range."
4643 #: build/C/man2/msync.2:93
4645 "I<addr> is not a multiple of PAGESIZE; or any bit other than B<MS_ASYNC> | "
4646 "B<MS_INVALIDATE> | B<MS_SYNC> is set in I<flags>; or both B<MS_SYNC> and "
4647 "B<MS_ASYNC> are set in I<flags>."
4651 #: build/C/man2/msync.2:96
4652 msgid "The indicated memory (or part of it) was not mapped."
4656 #: build/C/man2/msync.2:98 build/C/man3/posix_fallocate.3:103 build/C/man3/shm_open.3:251 build/C/man7/shm_overview.7:103
4657 msgid "POSIX.1-2001."
4661 #: build/C/man2/msync.2:105
4663 "This call was introduced in Linux 1.3.21, and then used B<EFAULT> instead of "
4664 "B<ENOMEM>. In Linux 2.4.19 this was changed to the POSIX value B<ENOMEM>."
4667 #. POSIX.1-2001: It shall be defined to -1 or 0 or 200112L.
4668 #. -1: unavailable, 0: ask using sysconf().
4669 #. glibc defines them to 1.
4671 #: build/C/man2/msync.2:118
4673 "On POSIX systems on which B<msync>() is available, both "
4674 "B<_POSIX_MAPPED_FILES> and B<_POSIX_SYNCHRONIZED_IO> are defined in "
4675 "I<E<lt>unistd.hE<gt>> to a value greater than 0. (See also B<sysconf>(3).)"
4679 #: build/C/man2/msync.2:120 build/C/man7/shm_overview.7:46
4685 #: build/C/man3/mtrace.3:23
4691 #: build/C/man3/mtrace.3:26
4692 msgid "mtrace, muntrace - malloc tracing"
4696 #: build/C/man3/mtrace.3:28
4697 msgid "B<#include E<lt>mcheck.hE<gt>>"
4701 #: build/C/man3/mtrace.3:30
4702 msgid "B<void mtrace(void);>"
4706 #: build/C/man3/mtrace.3:32
4707 msgid "B<void muntrace(void);>"
4711 #: build/C/man3/mtrace.3:44
4713 "The B<mtrace>() function installs hook functions for the memory-allocation "
4714 "functions (B<malloc>(3), B<realloc>(3) B<memalign>(3), B<free>(3)). These "
4715 "hook functions record tracing information about memory allocation and "
4716 "deallocation. The tracing information can be used to discover memory leaks "
4717 "and attempts to free nonallocated memory in a program."
4721 #: build/C/man3/mtrace.3:55
4723 "The B<muntrace>() function disables the hook functions installed by "
4724 "B<mtrace>(), so that tracing information is no longer recorded for the "
4725 "memory-allocation functions. If no hook functions were successfully "
4726 "installed by B<mtrace>(), B<muntrace>() does nothing."
4730 #: build/C/man3/mtrace.3:63
4732 "When B<mtrace>(3) is called, it checks the value of the environment "
4733 "variable B<MALLOC_TRACE>, which should contain the pathname of a file in "
4734 "which the tracing information is to be recorded. If the pathname is "
4735 "successfully opened, it is truncated to zero length."
4739 #: build/C/man3/mtrace.3:76
4741 "If B<MALLOC_TRACE> is not set, or the pathname it specifies is invalid or "
4742 "not writable, then no hook functions are installed, and B<mtrace>() has no "
4743 "effect. In set-user-ID and set-group-ID programs, B<MALLOC_TRACE> is "
4744 "ignored, and B<mtrace>() has no effect."
4748 #: build/C/man3/mtrace.3:84
4750 "In normal usage, B<mtrace>() is called once at the start of execution of a "
4751 "program, and B<muntrace>() is never called."
4755 #: build/C/man3/mtrace.3:94
4757 "The tracing output produced after a call to B<mtrace>() is textual, but not "
4758 "designed to be human readable. The GNU C library provides a Perl script, "
4759 "B<mtrace>(1), that interprets the trace log and produces human-readable "
4760 "output. For best results, the traced program should be compiled with "
4761 "debugging enabled, so that line-number information is recorded in the "
4766 #: build/C/man3/mtrace.3:100
4768 "The tracing performed by B<mtrace>() incurs a performance penalty (if "
4769 "B<MALLOC_TRACE> points to a valid, writable pathname)."
4773 #: build/C/man3/mtrace.3:106
4775 "The line-number information produced by B<mtrace>(1) is not always precise: "
4776 "the line number references may refer to the previous or following "
4777 "(non-blank) line of the source code."
4781 #: build/C/man3/mtrace.3:113
4783 "The shell session below demonstrates the use of the B<mtrace>() function "
4784 "and the B<mtrace>(1) command in a program that has memory leaks at two "
4785 "different locations. The demonstration uses the following program:"
4789 #: build/C/man3/mtrace.3:120
4792 "$ B<cat t_mtrace.c>\n"
4793 "#include E<lt>mcheck.hE<gt>\n"
4794 "#include E<lt>stdlib.hE<gt>\n"
4795 "#include E<lt>stdio.hE<gt>\n"
4799 #: build/C/man3/mtrace.3:125
4803 "main(int argc, char *argv[])\n"
4809 #: build/C/man3/mtrace.3:127
4811 msgid " mtrace();\n"
4815 #: build/C/man3/mtrace.3:130
4818 " for (j = 0; j E<lt> 2; j++)\n"
4819 " malloc(100); /* Never freed--a memory leak */\n"
4823 #: build/C/man3/mtrace.3:134
4826 " calloc(16, 16); /* Never freed--a memory leak */\n"
4827 " exit(EXIT_SUCCESS);\n"
4832 #: build/C/man3/mtrace.3:140
4834 "When we run the program as follows, we see that B<mtrace>() diagnosed "
4835 "memory leaks at two different locations in the program:"
4839 #: build/C/man3/mtrace.3:153
4842 "$ B<cc -g t_mtrace.c -o t_mtrace>\n"
4843 "$ B<export MALLOC_TRACE=/tmp/t>\n"
4845 "$ B<mtrace ./t_mtrace $MALLOC_TRACE>\n"
4846 "Memory not freed:\n"
4847 "-----------------\n"
4848 " Address Size Caller\n"
4849 "0x084c9378 0x64 at /home/cecilia/t_mtrace.c:12\n"
4850 "0x084c93e0 0x64 at /home/cecilia/t_mtrace.c:12\n"
4851 "0x084c9448 0x100 at /home/cecilia/t_mtrace.c:16\n"
4855 #: build/C/man3/mtrace.3:165
4857 "The first two messages about unfreed memory correspond to the two "
4858 "B<malloc>(3) calls inside the I<for> loop. The final message corresponds "
4859 "to the call to B<calloc>(3) (which in turn calls B<malloc>(3))."
4863 #: build/C/man3/mtrace.3:170
4864 msgid "B<mtrace>(1), B<malloc>(3), B<malloc_hook>(3), B<mcheck>(3)"
4868 #: build/C/man2/posix_fadvise.2:27
4870 msgid "POSIX_FADVISE"
4874 #: build/C/man2/posix_fadvise.2:27 build/C/man2/sync_file_range.2:30
4880 #: build/C/man2/posix_fadvise.2:30
4881 msgid "posix_fadvise - predeclare an access pattern for file data"
4885 #: build/C/man2/posix_fadvise.2:33 build/C/man3/posix_fallocate.3:29
4887 msgid "B<#include E<lt>fcntl.hE<gt>>\n"
4891 #: build/C/man2/posix_fadvise.2:36
4894 "B<int posix_fadvise(int >I<fd>B<, off_t >I<offset>B<, off_t >I<len>B<, int "
4899 #: build/C/man2/posix_fadvise.2:45
4900 msgid "B<posix_fadvise>():"
4904 #: build/C/man2/posix_fadvise.2:47 build/C/man3/posix_fallocate.3:42
4905 msgid "_XOPEN_SOURCE\\ E<gt>=\\ 600 || _POSIX_C_SOURCE\\ E<gt>=\\ 200112L"
4909 #: build/C/man2/posix_fadvise.2:55
4911 "Programs can use B<posix_fadvise>() to announce an intention to access file "
4912 "data in a specific pattern in the future, thus allowing the kernel to "
4913 "perform appropriate optimizations."
4917 #: build/C/man2/posix_fadvise.2:62
4919 "The I<advice> applies to a (not necessarily existent) region starting at "
4920 "I<offset> and extending for I<len> bytes (or until the end of the file if "
4921 "I<len> is 0) within the file referred to by I<fd>. The I<advice> is not "
4922 "binding; it merely constitutes an expectation on behalf of the application."
4926 #: build/C/man2/posix_fadvise.2:64
4927 msgid "Permissible values for I<advice> include:"
4931 #: build/C/man2/posix_fadvise.2:64
4933 msgid "B<POSIX_FADV_NORMAL>"
4937 #: build/C/man2/posix_fadvise.2:70
4939 "Indicates that the application has no advice to give about its access "
4940 "pattern for the specified data. If no advice is given for an open file, "
4941 "this is the default assumption."
4945 #: build/C/man2/posix_fadvise.2:70
4947 msgid "B<POSIX_FADV_SEQUENTIAL>"
4951 #: build/C/man2/posix_fadvise.2:74
4953 "The application expects to access the specified data sequentially (with "
4954 "lower offsets read before higher ones)."
4958 #: build/C/man2/posix_fadvise.2:74
4960 msgid "B<POSIX_FADV_RANDOM>"
4964 #: build/C/man2/posix_fadvise.2:77
4965 msgid "The specified data will be accessed in random order."
4969 #: build/C/man2/posix_fadvise.2:77
4971 msgid "B<POSIX_FADV_NOREUSE>"
4975 #: build/C/man2/posix_fadvise.2:80
4976 msgid "The specified data will be accessed only once."
4980 #: build/C/man2/posix_fadvise.2:80
4982 msgid "B<POSIX_FADV_WILLNEED>"
4986 #: build/C/man2/posix_fadvise.2:83
4987 msgid "The specified data will be accessed in the near future."
4991 #: build/C/man2/posix_fadvise.2:83
4993 msgid "B<POSIX_FADV_DONTNEED>"
4997 #: build/C/man2/posix_fadvise.2:86
4998 msgid "The specified data will not be accessed in the near future."
5002 #: build/C/man2/posix_fadvise.2:89
5003 msgid "On success, zero is returned. On error, an error number is returned."
5007 #: build/C/man2/posix_fadvise.2:93
5008 msgid "The I<fd> argument was not a valid file descriptor."
5012 #: build/C/man2/posix_fadvise.2:96
5013 msgid "An invalid value was specified for I<advice>."
5017 #: build/C/man2/posix_fadvise.2:103
5019 "The specified file descriptor refers to a pipe or FIFO. (Linux actually "
5020 "returns B<EINVAL> in this case.)"
5023 #. of fadvise64_64()
5025 #: build/C/man2/posix_fadvise.2:111
5027 "Kernel support first appeared in Linux 2.5.60; the underlying system call is "
5028 "called B<fadvise64>(). Library support has been provided since glibc "
5029 "version 2.2, via the wrapper function B<posix_fadvise>()."
5033 #: build/C/man2/posix_fadvise.2:120
5035 "POSIX.1-2001. Note that the type of the I<len> argument was changed from "
5036 "I<size_t> to I<off_t> in POSIX.1-2003 TC1."
5040 #: build/C/man2/posix_fadvise.2:126
5042 "Under Linux, B<POSIX_FADV_NORMAL> sets the readahead window to the default "
5043 "size for the backing device; B<POSIX_FADV_SEQUENTIAL> doubles this size, and "
5044 "B<POSIX_FADV_RANDOM> disables file readahead entirely. These changes affect "
5045 "the entire file, not just the specified region (but other open file handles "
5046 "to the same file are unaffected)."
5050 #: build/C/man2/posix_fadvise.2:133
5052 "B<POSIX_FADV_WILLNEED> initiates a nonblocking read of the specified region "
5053 "into the page cache. The amount of data read may be decreased by the kernel "
5054 "depending on virtual memory load. (A few megabytes will usually be fully "
5055 "satisfied, and more is rarely useful.)"
5059 #: build/C/man2/posix_fadvise.2:137
5061 "In kernels before 2.6.18, B<POSIX_FADV_NOREUSE> had the same semantics as "
5062 "B<POSIX_FADV_WILLNEED>. This was probably a bug; since kernel 2.6.18, this "
5067 #: build/C/man2/posix_fadvise.2:145
5069 "B<POSIX_FADV_DONTNEED> attempts to free cached pages associated with the "
5070 "specified region. This is useful, for example, while streaming large "
5071 "files. A program may periodically request the kernel to free cached data "
5072 "that has already been used, so that more useful cached pages are not "
5073 "discarded instead."
5077 #: build/C/man2/posix_fadvise.2:153
5079 "Pages that have not yet been written out will be unaffected, so if the "
5080 "application wishes to guarantee that pages will be released, it should call "
5081 "B<fsync>(2) or B<fdatasync>(2) first."
5085 #: build/C/man2/posix_fadvise.2:153
5087 msgid "arm_fadvise()"
5091 #: build/C/man2/posix_fadvise.2:165
5093 "The ARM architecture needs 64-bit arguments to be aligned in a suitable pair "
5094 "of registers. On this architecture, the call signature of "
5095 "B<posix_fadvise>() is flawed, since it forces a register to be wasted as "
5096 "padding between the I<fd> and I<len> arguments. Therefore, since Linux "
5097 "2.6.14, ARM defines a different system call that orders the arguments "
5102 #: build/C/man2/posix_fadvise.2:170
5105 "B<long arm_fadvise64_64(int >I<fd>B<, int >I<advice>B<,>\n"
5106 "B< loff_t >I<offset>B<, loff_t >I<len>B<);>\n"
5109 #. No ARM support in glibc.
5111 #: build/C/man2/posix_fadvise.2:177
5113 "The behavior of this system call is otherwise exactly the same as "
5114 "B<posix_fadvise>(). No library support is provided for this system call in "
5119 #: build/C/man2/posix_fadvise.2:182
5121 "In kernels before 2.6.6, if I<len> was specified as 0, then this was "
5122 "interpreted literally as \"zero bytes\", rather than as meaning \"all bytes "
5123 "through to the end of the file\"."
5126 #. FIXME . Write a posix_fadvise(3) page.
5128 #: build/C/man2/posix_fadvise.2:188
5130 "B<readahead>(2), B<sync_file_range>(2), B<posix_fallocate>(3), "
5131 "B<posix_madvise>(3)"
5135 #: build/C/man3/posix_fallocate.3:23
5137 msgid "POSIX_FALLOCATE"
5141 #: build/C/man3/posix_fallocate.3:23
5147 #: build/C/man3/posix_fallocate.3:26
5148 msgid "posix_fallocate - allocate file space"
5152 #: build/C/man3/posix_fallocate.3:31
5154 msgid "B<int posix_fallocate(int >I<fd>B<, off_t >I<offset>B<, off_t >I<len>B<);>\n"
5158 #: build/C/man3/posix_fallocate.3:40
5159 msgid "B<posix_fallocate>():"
5163 #: build/C/man3/posix_fallocate.3:59
5165 "The function B<posix_fallocate>() ensures that disk space is allocated for "
5166 "the file referred to by the descriptor I<fd> for the bytes in the range "
5167 "starting at I<offset> and continuing for I<len> bytes. After a successful "
5168 "call to B<posix_fallocate>(), subsequent writes to bytes in the specified "
5169 "range are guaranteed not to fail because of lack of disk space."
5173 #: build/C/man3/posix_fallocate.3:64
5175 "If the size of the file is less than I<offset>+I<len>, then the file is "
5176 "increased to this size; otherwise the file size is left unchanged."
5180 #: build/C/man3/posix_fallocate.3:70
5182 "B<posix_fallocate>() returns zero on success, or an error number on "
5183 "failure. Note that I<errno> is not set."
5187 #: build/C/man3/posix_fallocate.3:79
5188 msgid "I<offset+len> exceeds the maximum file size."
5192 #: build/C/man3/posix_fallocate.3:89
5193 msgid "I<fd> does not refer to a regular file."
5197 #: build/C/man3/posix_fallocate.3:98
5198 msgid "I<fd> refers to a pipe."
5202 #: build/C/man3/posix_fallocate.3:101
5203 msgid "B<posix_fallocate>() is available since glibc 2.1.94."
5207 #: build/C/man3/posix_fallocate.3:126
5209 "POSIX.1-2008 says that an implementation I<shall> give the B<EINVAL> error "
5210 "if I<len> was 0, or I<offset> was less than 0. POSIX.1-2001 says that an "
5211 "implementation I<shall> give the B<EINVAL> error if I<len> is less than 0, "
5212 "or I<offset> was less than 0, and I<may> give the error if I<len> equals "
5217 #: build/C/man3/posix_fallocate.3:130
5218 msgid "B<fallocate>(2), B<lseek>(2), B<posix_fadvise>(2)"
5222 #: build/C/man3/posix_memalign.3:28
5224 msgid "POSIX_MEMALIGN"
5228 #: build/C/man3/posix_memalign.3:28
5234 #: build/C/man3/posix_memalign.3:31
5236 "posix_memalign, aligned_alloc, memalign, valloc, pvalloc - Allocate aligned "
5241 #: build/C/man3/posix_memalign.3:38
5244 "B<int posix_memalign(void **>I<memptr>B<, size_t >I<alignment>B<, size_t "
5246 "B<void *aligned_alloc(size_t >I<alignment>B<, size_t >I<size>B<);>\n"
5247 "B<void *valloc(size_t >I<size>B<);>\n"
5251 #: build/C/man3/posix_memalign.3:43
5254 "B<void *memalign(size_t >I<alignment>B<, size_t >I<size>B<);>\n"
5255 "B<void *pvalloc(size_t >I<size>B<);>\n"
5259 #: build/C/man3/posix_memalign.3:53
5261 "B<posix_memalign>(): _POSIX_C_SOURCE\\ E<gt>=\\ 200112L || _XOPEN_SOURCE\\ "
5266 #: build/C/man3/posix_memalign.3:56
5267 msgid "B<aligned_alloc>(): _ISOC11_SOURCE"
5271 #: build/C/man3/posix_memalign.3:58
5272 msgid "B<valloc>():"
5276 #: build/C/man3/posix_memalign.3:61
5278 msgid "Since glibc 2.12:"
5282 #: build/C/man3/posix_memalign.3:68
5286 " (_XOPEN_SOURCE\\ E<gt>=\\ 500 ||\n"
5287 " _XOPEN_SOURCE\\ &&\\ _XOPEN_SOURCE_EXTENDED) &&\n"
5288 " !(_POSIX_C_SOURCE\\ E<gt>=\\ 200112L || _XOPEN_SOURCE\\ E<gt>=\\ 600)\n"
5292 #: build/C/man3/posix_memalign.3:70
5294 msgid "Before glibc 2.12:"
5298 #: build/C/man3/posix_memalign.3:74
5300 "_BSD_SOURCE || _XOPEN_SOURCE\\ E<gt>=\\ 500 || _XOPEN_SOURCE\\ &&\\ "
5301 "_XOPEN_SOURCE_EXTENDED"
5305 #: build/C/man3/posix_memalign.3:81
5307 "(The (nonstandard) header file I<E<lt>malloc.hE<gt>> also exposes the "
5308 "declaration of B<valloc>(); no feature test macros are required.)"
5313 #: build/C/man3/posix_memalign.3:102
5315 "The function B<posix_memalign>() allocates I<size> bytes and places the "
5316 "address of the allocated memory in I<*memptr>. The address of the allocated "
5317 "memory will be a multiple of I<alignment>, which must be a power of two and "
5318 "a multiple of I<sizeof(void *)>. If I<size> is 0, then B<posix_memalign>() "
5319 "returns either NULL, or a unique pointer value that can later be "
5320 "successfully passed to B<free>(3)."
5323 #. The behavior of memalign() for size==0 is as for posix_memalign()
5324 #. but no standards govern this.
5326 #: build/C/man3/posix_memalign.3:113
5328 "The obsolete function B<memalign>() allocates I<size> bytes and returns a "
5329 "pointer to the allocated memory. The memory address will be a multiple of "
5330 "I<alignment>, which must be a power of two."
5334 #: build/C/man3/posix_memalign.3:122
5336 "The function B<aligned_alloc>() is the same as B<memalign>(), except for "
5337 "the added restriction that I<size> should be a multiple of I<alignment>."
5341 #: build/C/man3/posix_memalign.3:132
5343 "The obsolete function B<valloc>() allocates I<size> bytes and returns a "
5344 "pointer to the allocated memory. The memory address will be a multiple of "
5345 "the page size. It is equivalent to I<memalign(sysconf(_SC_PAGESIZE),size)>."
5349 #: build/C/man3/posix_memalign.3:139
5351 "The obsolete function B<pvalloc>() is similar to B<valloc>(), but rounds "
5352 "the size of the allocation up to the next multiple of the system page size."
5356 #: build/C/man3/posix_memalign.3:141
5357 msgid "For all of these functions, the memory is not zeroed."
5361 #: build/C/man3/posix_memalign.3:148
5363 "B<aligned_alloc>(), B<memalign>(), B<valloc>(), and B<pvalloc>() return a "
5364 "pointer to the allocated memory, or NULL if the request fails."
5368 #: build/C/man3/posix_memalign.3:155
5370 "B<posix_memalign>() returns zero on success, or one of the error values "
5371 "listed in the next section on failure. Note that I<errno> is not set."
5375 #: build/C/man3/posix_memalign.3:162
5377 "The I<alignment> argument was not a power of two, or was not a multiple of "
5378 "I<sizeof(void *)>."
5382 #: build/C/man3/posix_memalign.3:165
5383 msgid "There was insufficient memory to fulfill the allocation request."
5387 #: build/C/man3/posix_memalign.3:172
5389 "The functions B<memalign>(), B<valloc>(), and B<pvalloc>() have been "
5390 "available in all Linux libc libraries."
5394 #: build/C/man3/posix_memalign.3:176
5395 msgid "The function B<aligned_alloc>() was added to glibc in version 2.16."
5399 #: build/C/man3/posix_memalign.3:180
5400 msgid "The function B<posix_memalign>() is available since glibc 2.1.91."
5404 #: build/C/man3/posix_memalign.3:187
5406 "The function B<valloc>() appeared in 3.0BSD. It is documented as being "
5407 "obsolete in 4.3BSD, and as legacy in SUSv2. It does not appear in "
5412 #: build/C/man3/posix_memalign.3:191
5413 msgid "The function B<pvalloc>() is a GNU extension."
5417 #: build/C/man3/posix_memalign.3:195
5418 msgid "The function B<memalign>() appears in SunOS 4.1.3 but not in 4.4BSD."
5422 #: build/C/man3/posix_memalign.3:199
5423 msgid "The function B<posix_memalign>() comes from POSIX.1d."
5427 #: build/C/man3/posix_memalign.3:204
5428 msgid "The function B<aligned_alloc>() is specified in the C11 standard."
5432 #: build/C/man3/posix_memalign.3:204
5438 #: build/C/man3/posix_memalign.3:208
5440 "Everybody agrees that B<posix_memalign>() is declared in "
5441 "I<E<lt>stdlib.hE<gt>>."
5445 #: build/C/man3/posix_memalign.3:212
5447 "On some systems B<memalign>() is declared in I<E<lt>stdlib.hE<gt>> instead "
5448 "of I<E<lt>malloc.hE<gt>>."
5452 #: build/C/man3/posix_memalign.3:219
5454 "According to SUSv2, B<valloc>() is declared in I<E<lt>stdlib.hE<gt>>. "
5455 "Libc4,5 and glibc declare it in I<E<lt>malloc.hE<gt>>, and also in "
5456 "I<E<lt>stdlib.hE<gt>> if suitable feature test macros are defined (see "
5461 #: build/C/man3/posix_memalign.3:228
5463 "On many systems there are alignment restrictions, for example, on buffers "
5464 "used for direct block device I/O. POSIX specifies the "
5465 "I<pathconf(path,_PC_REC_XFER_ALIGN)> call that tells what alignment is "
5466 "needed. Now one can use B<posix_memalign>() to satisfy this requirement."
5470 #: build/C/man3/posix_memalign.3:237
5472 "B<posix_memalign>() verifies that I<alignment> matches the requirements "
5473 "detailed above. B<memalign>() may not check that the I<alignment> argument "
5477 #. Other systems allow passing the result of
5484 #: build/C/man3/posix_memalign.3:265
5486 "POSIX requires that memory obtained from B<posix_memalign>() can be freed "
5487 "using B<free>(3). Some systems provide no way to reclaim memory allocated "
5488 "with B<memalign>() or B<valloc>() (because one can only pass to B<free>(3) "
5489 "a pointer gotten from B<malloc>(3), while, for example, B<memalign>() would "
5490 "call B<malloc>(3) and then align the obtained value). The glibc "
5491 "implementation allows memory obtained from any of these functions to be "
5492 "reclaimed with B<free>(3)."
5496 #: build/C/man3/posix_memalign.3:270
5498 "The glibc B<malloc>(3) always returns 8-byte aligned memory addresses, so "
5499 "these functions are only needed if you require larger alignment values."
5503 #: build/C/man3/posix_memalign.3:275
5504 msgid "B<brk>(2), B<getpagesize>(2), B<free>(3), B<malloc>(3)"
5508 #: build/C/man2/readahead.2:28
5514 #: build/C/man2/readahead.2:28 build/C/man7/shm_overview.7:27
5520 #: build/C/man2/readahead.2:31
5521 msgid "readahead - perform file readahead into page cache"
5525 #: build/C/man2/readahead.2:37
5528 "B<ssize_t readahead(int >I<fd>B<, off64_t >I<offset>B<, size_t "
5533 #: build/C/man2/readahead.2:65
5535 "B<readahead>() populates the page cache with data from a file so that "
5536 "subsequent reads from that file will not block on disk I/O. The I<fd> "
5537 "argument is a file descriptor identifying the file which is to be read. The "
5538 "I<offset> argument specifies the starting point from which data is to be "
5539 "read and I<count> specifies the number of bytes to be read. I/O is "
5540 "performed in whole pages, so that I<offset> is effectively rounded down to a "
5541 "page boundary and bytes are read up to the next page boundary greater than "
5542 "or equal to I<(offset+count)>. B<readahead>() does not read beyond the end "
5543 "of the file. B<readahead>() blocks until the specified data has been "
5544 "read. The current file offset of the open file referred to by I<fd> is left "
5549 #: build/C/man2/readahead.2:71
5551 "On success, B<readahead>() returns 0; on failure, -1 is returned, with "
5552 "I<errno> set to indicate the cause of the error."
5556 #: build/C/man2/readahead.2:76
5557 msgid "I<fd> is not a valid file descriptor or is not open for reading."
5561 #: build/C/man2/readahead.2:82
5562 msgid "I<fd> does not refer to a file type to which B<readahead>() can be applied."
5566 #: build/C/man2/readahead.2:87
5568 "The B<readahead>() system call appeared in Linux 2.4.13; glibc support has "
5569 "been provided since version 2.3."
5573 #: build/C/man2/readahead.2:92
5575 "The B<readahead>() system call is Linux-specific, and its use should be "
5576 "avoided in portable applications."
5580 #: build/C/man2/readahead.2:98
5581 msgid "B<lseek>(2), B<madvise>(2), B<mmap>(2), B<posix_fadvise>(2), B<read>(2)"
5585 #: build/C/man2/remap_file_pages.2:26
5587 msgid "REMAP_FILE_PAGES"
5591 #: build/C/man2/remap_file_pages.2:29
5592 msgid "remap_file_pages - create a nonlinear file mapping"
5596 #: build/C/man2/remap_file_pages.2:33
5599 "B<#define _GNU_SOURCE> /* See feature_test_macros(7) */\n"
5600 "B<#include E<lt>sys/mman.hE<gt>>\n"
5604 #: build/C/man2/remap_file_pages.2:36
5607 "B<int remap_file_pages(void *>I<addr>B<, size_t >I<size>B<, int "
5609 "B< ssize_t >I<pgoff>B<, int >I<flags>B<);>\n"
5613 #: build/C/man2/remap_file_pages.2:49
5615 "The B<remap_file_pages>() system call is used to create a nonlinear "
5616 "mapping, that is, a mapping in which the pages of the file are mapped into a "
5617 "nonsequential order in memory. The advantage of using B<remap_file_pages>() "
5618 "over using repeated calls to B<mmap>(2) is that the former approach does "
5619 "not require the kernel to create additional VMA (Virtual Memory Area) data "
5624 #: build/C/man2/remap_file_pages.2:51
5625 msgid "To create a nonlinear mapping we perform the following steps:"
5629 #: build/C/man2/remap_file_pages.2:51
5635 #: build/C/man2/remap_file_pages.2:59
5637 "Use B<mmap>(2) to create a mapping (which is initially linear). This "
5638 "mapping must be created with the B<MAP_SHARED> flag."
5642 #: build/C/man2/remap_file_pages.2:59
5648 #: build/C/man2/remap_file_pages.2:67
5650 "Use one or more calls to B<remap_file_pages>() to rearrange the "
5651 "correspondence between the pages of the mapping and the pages of the file. "
5652 "It is possible to map the same page of a file into multiple locations within "
5653 "the mapped region."
5657 #: build/C/man2/remap_file_pages.2:78
5659 "The I<pgoff> and I<size> arguments specify the region of the file that is to "
5660 "be relocated within the mapping: I<pgoff> is a file offset in units of the "
5661 "system page size; I<size> is the length of the region in bytes."
5665 #: build/C/man2/remap_file_pages.2:96
5667 "The I<addr> argument serves two purposes. First, it identifies the mapping "
5668 "whose pages we want to rearrange. Thus, I<addr> must be an address that "
5669 "falls within a region previously mapped by a call to B<mmap>(2). Second, "
5670 "I<addr> specifies the address at which the file pages identified by I<pgoff> "
5671 "and I<size> will be placed."
5674 #. This rounding is weird, and not consistent with the treatment of
5675 #. the analogous arguments for munmap()/mprotect() and for mlock().
5678 #: build/C/man2/remap_file_pages.2:110
5680 "The values specified in I<addr> and I<size> should be multiples of the "
5681 "system page size. If they are not, then the kernel rounds I<both> values "
5682 "I<down> to the nearest multiple of the page size."
5686 #: build/C/man2/remap_file_pages.2:114
5687 msgid "The I<prot> argument must be specified as 0."
5691 #: build/C/man2/remap_file_pages.2:122
5693 "The I<flags> argument has the same meaning as for B<mmap>(2), but all flags "
5694 "other than B<MAP_NONBLOCK> are ignored."
5698 #: build/C/man2/remap_file_pages.2:129
5700 "On success, B<remap_file_pages>() returns 0. On error, -1 is returned, and "
5701 "I<errno> is set appropriately."
5705 #: build/C/man2/remap_file_pages.2:137
5707 "I<addr> does not refer to a valid mapping created with the B<MAP_SHARED> "
5711 #. And possibly others from vma->vm_ops->populate()
5713 #: build/C/man2/remap_file_pages.2:146
5714 msgid "I<addr>, I<size>, I<prot>, or I<pgoff> is invalid."
5718 #: build/C/man2/remap_file_pages.2:151
5720 "The B<remap_file_pages>() system call appeared in Linux 2.5.46; glibc "
5721 "support was added in version 2.3.3."
5725 #: build/C/man2/remap_file_pages.2:155
5726 msgid "The B<remap_file_pages>() system call is Linux-specific."
5730 #: build/C/man2/remap_file_pages.2:162
5732 "B<getpagesize>(2), B<mmap>(2), B<mmap2>(2), B<mprotect>(2), B<mremap>(2), "
5737 #: build/C/man3/shm_open.3:26
5743 #: build/C/man3/shm_open.3:26
5749 #: build/C/man3/shm_open.3:29
5750 msgid "shm_open, shm_unlink - Create/open or unlink POSIX shared memory objects"
5754 #: build/C/man3/shm_open.3:33
5755 msgid "B<#include E<lt>sys/stat.hE<gt>> /* For mode constants */"
5759 #: build/C/man3/shm_open.3:35
5760 msgid "B<#include E<lt>fcntl.hE<gt>> /* For O_* constants */"
5764 #: build/C/man3/shm_open.3:37
5765 msgid "B<int shm_open(const char *>I<name>B<, int >I<oflag>B<, mode_t >I<mode>B<);>"
5769 #: build/C/man3/shm_open.3:39
5770 msgid "B<int shm_unlink(const char *>I<name>B<);>"
5774 #: build/C/man3/shm_open.3:41
5775 msgid "Link with I<-lrt>."
5779 #: build/C/man3/shm_open.3:53
5781 "B<shm_open>() creates and opens a new, or opens an existing, POSIX shared "
5782 "memory object. A POSIX shared memory object is in effect a handle which can "
5783 "be used by unrelated processes to B<mmap>(2) the same region of shared "
5784 "memory. The B<shm_unlink>() function performs the converse operation, "
5785 "removing an object previously created by B<shm_open>()."
5788 #. glibc allows the initial slash to be omitted, and makes
5789 #. multiple initial slashes equivalent to a single slash.
5790 #. This differs from the implementation of POSIX message queues.
5791 #. glibc allows subdirectory components in the name, in which
5792 #. case the subdirectory must exist under /dev/shm, and allow the
5793 #. required permissions if a user wants to create a shared memory
5794 #. object in that subdirectory.
5796 #: build/C/man3/shm_open.3:74
5798 "The operation of B<shm_open>() is analogous to that of B<open>(2). I<name> "
5799 "specifies the shared memory object to be created or opened. For portable "
5800 "use, a shared memory object should be identified by a name of the form "
5801 "I</somename>; that is, a null-terminated string of up to B<NAME_MAX> (i.e., "
5802 "255) characters consisting of an initial slash, followed by one or more "
5803 "characters, none of which are slashes."
5807 #: build/C/man3/shm_open.3:81
5809 "I<oflag> is a bit mask created by ORing together exactly one of B<O_RDONLY> "
5810 "or B<O_RDWR> and any of the other flags listed here:"
5814 #: build/C/man3/shm_open.3:81
5820 #: build/C/man3/shm_open.3:87
5822 "Open the object for read access. A shared memory object opened in this way "
5823 "can only be B<mmap>(2)ed for read (B<PROT_READ>) access."
5827 #: build/C/man3/shm_open.3:87
5833 #: build/C/man3/shm_open.3:90
5834 msgid "Open the object for read-write access."
5838 #: build/C/man3/shm_open.3:90
5843 #. In truth it is actually the file system IDs on Linux, but these
5844 #. are nearly always the same as the effective IDs. (MTK, Jul 05)
5846 #: build/C/man3/shm_open.3:110
5848 "Create the shared memory object if it does not exist. The user and group "
5849 "ownership of the object are taken from the corresponding effective IDs of "
5850 "the calling process, and the object's permission bits are set according to "
5851 "the low-order 9 bits of I<mode>, except that those bits set in the process "
5852 "file mode creation mask (see B<umask>(2)) are cleared for the new object. "
5853 "A set of macro constants which can be used to define I<mode> is listed in "
5854 "B<open>(2). (Symbolic definitions of these constants can be obtained by "
5855 "including I<E<lt>sys/stat.hE<gt>>.)"
5859 #: build/C/man3/shm_open.3:116
5861 "A new shared memory object initially has zero length\\(emthe size of the "
5862 "object can be set using B<ftruncate>(2). The newly allocated bytes of a "
5863 "shared memory object are automatically initialized to 0."
5867 #: build/C/man3/shm_open.3:116
5873 #: build/C/man3/shm_open.3:125
5875 "If B<O_CREAT> was also specified, and a shared memory object with the given "
5876 "I<name> already exists, return an error. The check for the existence of the "
5877 "object, and its creation if it does not exist, are performed atomically."
5881 #: build/C/man3/shm_open.3:125
5887 #: build/C/man3/shm_open.3:128
5888 msgid "If the shared memory object already exists, truncate it to zero bytes."
5892 #: build/C/man3/shm_open.3:131
5894 "Definitions of these flag values can be obtained by including "
5895 "I<E<lt>fcntl.hE<gt>>."
5899 #: build/C/man3/shm_open.3:142
5901 "On successful completion B<shm_open>() returns a new file descriptor "
5902 "referring to the shared memory object. This file descriptor is guaranteed "
5903 "to be the lowest-numbered file descriptor not previously opened within the "
5904 "process. The B<FD_CLOEXEC> flag (see B<fcntl>(2)) is set for the file "
5909 #: build/C/man3/shm_open.3:151
5911 "The file descriptor is normally used in subsequent calls to B<ftruncate>(2) "
5912 "(for a newly created object) and B<mmap>(2). After a call to B<mmap>(2) "
5913 "the file descriptor may be closed without affecting the memory mapping."
5917 #: build/C/man3/shm_open.3:169
5919 "The operation of B<shm_unlink>() is analogous to B<unlink>(2): it removes a "
5920 "shared memory object name, and, once all processes have unmapped the object, "
5921 "de-allocates and destroys the contents of the associated memory region. "
5922 "After a successful B<shm_unlink>(), attempts to B<shm_open>() an object "
5923 "with the same I<name> will fail (unless B<O_CREAT> was specified, in which "
5924 "case a new, distinct object is created)."
5928 #: build/C/man3/shm_open.3:178
5930 "On success, B<shm_open>() returns a nonnegative file descriptor. On "
5931 "failure, B<shm_open>() returns -1. B<shm_unlink>() returns 0 on success, "
5936 #: build/C/man3/shm_open.3:185
5938 "On failure, I<errno> is set to indicate the cause of the error. Values "
5939 "which may appear in I<errno> include the following:"
5943 #: build/C/man3/shm_open.3:190
5944 msgid "Permission to B<shm_unlink>() the shared memory object was denied."
5948 #: build/C/man3/shm_open.3:200
5950 "Permission was denied to B<shm_open>() I<name> in the specified I<mode>, or "
5951 "B<O_TRUNC> was specified and the caller does not have write permission on "
5956 #: build/C/man3/shm_open.3:200 build/C/man2/shmget.2:192
5962 #: build/C/man3/shm_open.3:211
5964 "Both B<O_CREAT> and B<O_EXCL> were specified to B<shm_open>() and the "
5965 "shared memory object specified by I<name> already exists."
5969 #: build/C/man3/shm_open.3:218
5970 msgid "The I<name> argument to B<shm_open>() was invalid."
5974 #: build/C/man3/shm_open.3:218
5980 #: build/C/man3/shm_open.3:221
5981 msgid "The process already has the maximum number of files open."
5985 #: build/C/man3/shm_open.3:221
5987 msgid "B<ENAMETOOLONG>"
5991 #: build/C/man3/shm_open.3:227
5992 msgid "The length of I<name> exceeds B<PATH_MAX>."
5996 #: build/C/man3/shm_open.3:231
5997 msgid "The limit on the total number of files open on the system has been reached."
6001 #: build/C/man3/shm_open.3:231 build/C/man3/shm_open.3:240 build/C/man2/shmget.2:206
6007 #: build/C/man3/shm_open.3:240
6009 "An attempt was made to B<shm_open>() a I<name> that did not exist, and "
6010 "B<O_CREAT> was not specified."
6014 #: build/C/man3/shm_open.3:247
6015 msgid "An attempt was to made to B<shm_unlink>() a I<name> that does not exist."
6019 #: build/C/man3/shm_open.3:249
6020 msgid "These functions are provided in glibc 2.2 and later."
6024 #: build/C/man3/shm_open.3:255
6026 "POSIX.1-2001 says that the group ownership of a newly created shared memory "
6027 "object is set to either the calling process's effective group ID or \"a "
6028 "system default group ID\"."
6032 #: build/C/man3/shm_open.3:264
6034 "POSIX leaves the behavior of the combination of B<O_RDONLY> and B<O_TRUNC> "
6035 "unspecified. On Linux, this will successfully truncate an existing shared "
6036 "memory object\\(emthis may not be so on other UNIX systems."
6040 #: build/C/man3/shm_open.3:269
6042 "The POSIX shared memory object implementation on Linux 2.4 makes use of a "
6043 "dedicated file system, which is normally mounted under I</dev/shm>."
6047 #: build/C/man3/shm_open.3:280
6049 "B<close>(2), B<fchmod>(2), B<fchown>(2), B<fcntl>(2), B<fstat>(2), "
6050 "B<ftruncate>(2), B<mmap>(2), B<open>(2), B<umask>(2), B<shm_overview>(7)"
6054 #: build/C/man7/shm_overview.7:27
6056 msgid "SHM_OVERVIEW"
6060 #: build/C/man7/shm_overview.7:30
6061 msgid "shm_overview - Overview of POSIX shared memory"
6065 #: build/C/man7/shm_overview.7:33
6067 "The POSIX shared memory API allows processes to communicate information by "
6068 "sharing a region of memory."
6072 #: build/C/man7/shm_overview.7:35
6073 msgid "The interfaces employed in the API are:"
6077 #: build/C/man7/shm_overview.7:35
6079 msgid "B<shm_open>(3)"
6083 #: build/C/man7/shm_overview.7:42
6085 "Create and open a new object, or open an existing object. This is analogous "
6086 "to B<open>(2). The call returns a file descriptor for use by the other "
6087 "interfaces listed below."
6091 #: build/C/man7/shm_overview.7:42
6093 msgid "B<ftruncate>(2)"
6097 #: build/C/man7/shm_overview.7:46
6099 "Set the size of the shared memory object. (A newly created shared memory "
6100 "object has a length of zero.)"
6104 #: build/C/man7/shm_overview.7:50
6106 "Map the shared memory object into the virtual address space of the calling "
6111 #: build/C/man7/shm_overview.7:50
6113 msgid "B<munmap>(2)"
6117 #: build/C/man7/shm_overview.7:54
6119 "Unmap the shared memory object from the virtual address space of the calling "
6124 #: build/C/man7/shm_overview.7:54
6126 msgid "B<shm_unlink>(3)"
6130 #: build/C/man7/shm_overview.7:57
6131 msgid "Remove a shared memory object name."
6135 #: build/C/man7/shm_overview.7:57
6141 #: build/C/man7/shm_overview.7:62
6143 "Close the file descriptor allocated by B<shm_open>(3) when it is no longer "
6148 #: build/C/man7/shm_overview.7:62
6154 #: build/C/man7/shm_overview.7:76
6156 "Obtain a I<stat> structure that describes the shared memory object. Among "
6157 "the information returned by this call are the object's size (I<st_size>), "
6158 "permissions (I<st_mode>), owner (I<st_uid>), and group (I<st_gid>)."
6162 #: build/C/man7/shm_overview.7:76
6164 msgid "B<fchown>(2)"
6168 #: build/C/man7/shm_overview.7:79
6169 msgid "To change the ownership of a shared memory object."
6173 #: build/C/man7/shm_overview.7:79
6175 msgid "B<fchmod>(2)"
6179 #: build/C/man7/shm_overview.7:82
6180 msgid "To change the permissions of a shared memory object."
6184 #: build/C/man7/shm_overview.7:82
6190 #: build/C/man7/shm_overview.7:84
6191 msgid "POSIX shared memory is supported since Linux 2.4 and glibc 2.2."
6195 #: build/C/man7/shm_overview.7:84
6201 #: build/C/man7/shm_overview.7:89
6203 "POSIX shared memory objects have kernel persistence: a shared memory object "
6204 "will exist until the system is shut down, or until all processes have "
6205 "unmapped the object and it has been deleted with B<shm_unlink>(3)"
6209 #: build/C/man7/shm_overview.7:89
6215 #: build/C/man7/shm_overview.7:94
6217 "Programs using the POSIX shared memory API must be compiled with I<cc -lrt> "
6218 "to link against the real-time library, I<librt>."
6222 #: build/C/man7/shm_overview.7:94
6224 msgid "Accessing shared memory objects via the file system"
6228 #: build/C/man7/shm_overview.7:101
6230 "On Linux, shared memory objects are created in a (I<tmpfs>) virtual file "
6231 "system, normally mounted under I</dev/shm>. Since kernel 2.6.19, Linux "
6232 "supports the use of access control lists (ACLs) to control the permissions "
6233 "of objects in the virtual file system."
6237 #: build/C/man7/shm_overview.7:106
6239 "Typically, processes must synchronize their access to a shared memory "
6240 "object, using, for example, POSIX semaphores."
6244 #: build/C/man7/shm_overview.7:114
6246 "System V shared memory (B<shmget>(2), B<shmop>(2), etc.) is an older shared "
6247 "memory API. POSIX shared memory provides a simpler, and better designed "
6248 "interface; on the other hand POSIX shared memory is somewhat less widely "
6249 "available (especially on older systems) than System V shared memory."
6253 #: build/C/man7/shm_overview.7:127
6255 "B<fchmod>(2), B<fchown>(2), B<fstat>(2), B<ftruncate>(2), B<mmap>(2), "
6256 "B<mprotect>(2), B<munmap>(2), B<shmget>(2), B<shmop>(2), B<shm_open>(3), "
6257 "B<shm_unlink>(3), B<sem_overview>(7)"
6261 #: build/C/man2/shmctl.2:43
6267 #: build/C/man2/shmctl.2:43
6273 #: build/C/man2/shmctl.2:46
6274 msgid "shmctl - shared memory control"
6278 #: build/C/man2/shmctl.2:49 build/C/man2/shmget.2:42
6279 msgid "B<#include E<lt>sys/ipc.hE<gt>>"
6283 #: build/C/man2/shmctl.2:51 build/C/man2/shmget.2:44
6284 msgid "B<#include E<lt>sys/shm.hE<gt>>"
6288 #: build/C/man2/shmctl.2:53
6289 msgid "B<int shmctl(int >I<shmid>B<, int >I<cmd>B<, struct shmid_ds *>I<buf>B<);>"
6293 #: build/C/man2/shmctl.2:60
6295 "B<shmctl>() performs the control operation specified by I<cmd> on the "
6296 "shared memory segment whose identifier is given in I<shmid>."
6300 #: build/C/man2/shmctl.2:65
6302 "The I<buf> argument is a pointer to a I<shmid_ds> structure, defined in "
6303 "I<E<lt>sys/shm.hE<gt>> as follows:"
6307 #: build/C/man2/shmctl.2:79
6310 "struct shmid_ds {\n"
6311 " struct ipc_perm shm_perm; /* Ownership and permissions */\n"
6312 " size_t shm_segsz; /* Size of segment (bytes) */\n"
6313 " time_t shm_atime; /* Last attach time */\n"
6314 " time_t shm_dtime; /* Last detach time */\n"
6315 " time_t shm_ctime; /* Last change time */\n"
6316 " pid_t shm_cpid; /* PID of creator */\n"
6317 " pid_t shm_lpid; /* PID of last shmat(2)/shmdt(2) */\n"
6318 " shmatt_t shm_nattch; /* No. of current attaches */\n"
6324 #: build/C/man2/shmctl.2:87
6326 "The I<ipc_perm> structure is defined in I<E<lt>sys/ipc.hE<gt>> as follows "
6327 "(the highlighted fields are settable using B<IPC_SET>):"
6331 #: build/C/man2/shmctl.2:100
6334 "struct ipc_perm {\n"
6335 " key_t __key; /* Key supplied to shmget(2) */\n"
6336 " uid_t B<uid>; /* Effective UID of owner */\n"
6337 " gid_t B<gid>; /* Effective GID of owner */\n"
6338 " uid_t cuid; /* Effective UID of creator */\n"
6339 " gid_t cgid; /* Effective GID of creator */\n"
6340 " unsigned short B<mode>; /* B<Permissions> + SHM_DEST and\n"
6341 " SHM_LOCKED flags */\n"
6342 " unsigned short __seq; /* Sequence number */\n"
6347 #: build/C/man2/shmctl.2:106
6348 msgid "Valid values for I<cmd> are:"
6352 #: build/C/man2/shmctl.2:107
6358 #: build/C/man2/shmctl.2:116
6360 "Copy information from the kernel data structure associated with I<shmid> "
6361 "into the I<shmid_ds> structure pointed to by I<buf>. The caller must have "
6362 "read permission on the shared memory segment."
6366 #: build/C/man2/shmctl.2:116
6372 #: build/C/man2/shmctl.2:134
6374 "Write the values of some members of the I<shmid_ds> structure pointed to by "
6375 "I<buf> to the kernel data structure associated with this shared memory "
6376 "segment, updating also its I<shm_ctime> member. The following fields can be "
6377 "changed: I<shm_perm.uid>, I<shm_perm.gid>, and (the least significant 9 bits "
6378 "of) I<shm_perm.mode>. The effective UID of the calling process must match "
6379 "the owner (I<shm_perm.uid>) or creator (I<shm_perm.cuid>) of the shared "
6380 "memory segment, or the caller must be privileged."
6384 #: build/C/man2/shmctl.2:134
6390 #: build/C/man2/shmctl.2:151
6392 "Mark the segment to be destroyed. The segment will only actually be "
6393 "destroyed after the last process detaches it (i.e., when the I<shm_nattch> "
6394 "member of the associated structure I<shmid_ds> is zero). The caller must be "
6395 "the owner or creator, or be privileged. If a segment has been marked for "
6396 "destruction, then the (nonstandard) B<SHM_DEST> flag of the "
6397 "I<shm_perm.mode> field in the associated data structure retrieved by "
6398 "B<IPC_STAT> will be set."
6402 #: build/C/man2/shmctl.2:154
6404 "The caller I<must> ensure that a segment is eventually destroyed; otherwise "
6405 "its pages that were faulted in will remain in memory or swap."
6409 #: build/C/man2/shmctl.2:154
6411 msgid "B<IPC_INFO> (Linux-specific)"
6415 #: build/C/man2/shmctl.2:167
6417 "Returns information about system-wide shared memory limits and parameters in "
6418 "the structure pointed to by I<buf>. This structure is of type I<shminfo> "
6419 "(thus, a cast is required), defined in I<E<lt>sys/shm.hE<gt>> if the "
6420 "B<_GNU_SOURCE> feature test macro is defined:"
6424 #: build/C/man2/shmctl.2:181
6427 "struct shminfo {\n"
6428 " unsigned long shmmax; /* Maximum segment size */\n"
6429 " unsigned long shmmin; /* Minimum segment size;\n"
6431 " unsigned long shmmni; /* Maximum number of segments */\n"
6432 " unsigned long shmseg; /* Maximum number of segments\n"
6433 " that a process can attach;\n"
6434 " unused within kernel */\n"
6435 " unsigned long shmall; /* Maximum number of pages of\n"
6436 " shared memory, system-wide */\n"
6441 #: build/C/man2/shmctl.2:194
6443 "The I<shmmni>, I<shmmax>, and I<shmall> settings can be changed via I</proc> "
6444 "files of the same name; see B<proc>(5) for details."
6448 #: build/C/man2/shmctl.2:194
6450 msgid "B<SHM_INFO> (Linux-specific)"
6454 #: build/C/man2/shmctl.2:205
6456 "Returns a I<shm_info> structure whose fields contain information about "
6457 "system resources consumed by shared memory. This structure is defined in "
6458 "I<E<lt>sys/shm.hE<gt>> if the B<_GNU_SOURCE> feature test macro is defined:"
6462 #: build/C/man2/shmctl.2:222
6465 "struct shm_info {\n"
6466 " int used_ids; /* # of currently existing\n"
6468 " unsigned long shm_tot; /* Total number of shared\n"
6469 " memory pages */\n"
6470 " unsigned long shm_rss; /* # of resident shared\n"
6471 " memory pages */\n"
6472 " unsigned long shm_swp; /* # of swapped shared\n"
6473 " memory pages */\n"
6474 " unsigned long swap_attempts;\n"
6475 " /* Unused since Linux 2.4 */\n"
6476 " unsigned long swap_successes;\n"
6477 " /* Unused since Linux 2.4 */\n"
6482 #: build/C/man2/shmctl.2:224
6484 msgid "B<SHM_STAT> (Linux-specific)"
6488 #: build/C/man2/shmctl.2:235
6490 "Returns a I<shmid_ds> structure as for B<IPC_STAT>. However, the I<shmid> "
6491 "argument is not a segment identifier, but instead an index into the kernel's "
6492 "internal array that maintains information about all shared memory segments "
6497 #: build/C/man2/shmctl.2:238
6499 "The caller can prevent or allow swapping of a shared memory segment with the "
6500 "following I<cmd> values:"
6504 #: build/C/man2/shmctl.2:239
6506 msgid "B<SHM_LOCK> (Linux-specific)"
6510 #: build/C/man2/shmctl.2:251
6512 "Prevent swapping of the shared memory segment. The caller must fault in any "
6513 "pages that are required to be present after locking is enabled. If a "
6514 "segment has been locked, then the (nonstandard) B<SHM_LOCKED> flag of the "
6515 "I<shm_perm.mode> field in the associated data structure retrieved by "
6516 "B<IPC_STAT> will be set."
6520 #: build/C/man2/shmctl.2:251
6522 msgid "B<SHM_UNLOCK> (Linux-specific)"
6526 #: build/C/man2/shmctl.2:254
6527 msgid "Unlock the segment, allowing it to be swapped out."
6530 #. There was some weirdness in 2.6.9: SHM_LOCK and SHM_UNLOCK could
6531 #. be applied to a segment, regardless of ownership of the segment.
6532 #. This was a botch-up in the move to RLIMIT_MEMLOCK, and was fixed
6533 #. in 2.6.10. MTK, May 2005
6535 #: build/C/man2/shmctl.2:272
6537 "In kernels before 2.6.10, only a privileged process could employ B<SHM_LOCK> "
6538 "and B<SHM_UNLOCK>. Since kernel 2.6.10, an unprivileged process can employ "
6539 "these operations if its effective UID matches the owner or creator UID of "
6540 "the segment, and (for B<SHM_LOCK>) the amount of memory to be locked falls "
6541 "within the B<RLIMIT_MEMLOCK> resource limit (see B<setrlimit>(2))."
6545 #: build/C/man2/shmctl.2:290
6547 "A successful B<IPC_INFO> or B<SHM_INFO> operation returns the index of the "
6548 "highest used entry in the kernel's internal array recording information "
6549 "about all shared memory segments. (This information can be used with "
6550 "repeated B<SHM_STAT> operations to obtain information about all shared "
6551 "memory segments on the system.) A successful B<SHM_STAT> operation returns "
6552 "the identifier of the shared memory segment whose index was given in "
6553 "I<shmid>. Other operations return 0 on success."
6557 #: build/C/man2/shmctl.2:294
6558 msgid "On error, -1 is returned, and I<errno> is set appropriately."
6562 #: build/C/man2/shmctl.2:303
6564 "B<IPC_STAT> or B<SHM_STAT> is requested and I<shm_perm.mode> does not allow "
6565 "read access for I<shmid>, and the calling process does not have the "
6566 "B<CAP_IPC_OWNER> capability."
6570 #: build/C/man2/shmctl.2:314
6572 "The argument I<cmd> has value B<IPC_SET> or B<IPC_STAT> but the address "
6573 "pointed to by I<buf> isn't accessible."
6577 #: build/C/man2/shmctl.2:314
6583 #: build/C/man2/shmctl.2:317
6584 msgid "I<shmid> points to a removed identifier."
6588 #: build/C/man2/shmctl.2:326
6590 "I<shmid> is not a valid identifier, or I<cmd> is not a valid command. Or: "
6591 "for a B<SHM_STAT> operation, the index value specified in I<shmid> referred "
6592 "to an array slot that is currently unused."
6596 #: build/C/man2/shmctl.2:337
6598 "(In kernels since 2.6.9), B<SHM_LOCK> was specified and the size of the "
6599 "to-be-locked segment would mean that the total bytes in locked shared memory "
6600 "segments would exceed the limit for the real user ID of the calling "
6601 "process. This limit is defined by the B<RLIMIT_MEMLOCK> soft resource limit "
6602 "(see B<setrlimit>(2))."
6606 #: build/C/man2/shmctl.2:337
6608 msgid "B<EOVERFLOW>"
6612 #: build/C/man2/shmctl.2:342
6614 "B<IPC_STAT> is attempted, and the GID or UID value is too large to be stored "
6615 "in the structure pointed to by I<buf>."
6619 #: build/C/man2/shmctl.2:354
6621 "B<IPC_SET> or B<IPC_RMID> is attempted, and the effective user ID of the "
6622 "calling process is not that of the creator (found in I<shm_perm.cuid>), or "
6623 "the owner (found in I<shm_perm.uid>), and the process was not privileged "
6624 "(Linux: did not have the B<CAP_SYS_ADMIN> capability)."
6628 #: build/C/man2/shmctl.2:366
6630 "Or (in kernels before 2.6.9), B<SHM_LOCK> or B<SHM_UNLOCK> was specified, "
6631 "but the process was not privileged (Linux: did not have the B<CAP_IPC_LOCK> "
6632 "capability). (Since Linux 2.6.9, this error can also occur if the "
6633 "B<RLIMIT_MEMLOCK> is 0 and the caller is not privileged.)"
6636 #. SVr4 documents an additional error condition EMFILE.
6638 #: build/C/man2/shmctl.2:371 build/C/man2/shmget.2:232 build/C/man2/shmop.2:229
6639 msgid "SVr4, POSIX.1-2001."
6643 #: build/C/man2/shmctl.2:382
6645 "The B<IPC_INFO>, B<SHM_STAT> and B<SHM_INFO> operations are used by the "
6646 "B<ipcs>(1) program to provide information on allocated resources. In the "
6647 "future these may modified or moved to a /proc file system interface."
6651 #: build/C/man2/shmctl.2:390
6653 "Linux permits a process to attach (B<shmat>(2)) a shared memory segment "
6654 "that has already been marked for deletion using I<shmctl(IPC_RMID)>. This "
6655 "feature is not available on other UNIX implementations; portable "
6656 "applications should avoid relying on it."
6660 #: build/C/man2/shmctl.2:403
6662 "Various fields in a I<struct shmid_ds> were typed as I<short> under Linux "
6663 "2.2 and have become I<long> under Linux 2.4. To take advantage of this, a "
6664 "recompilation under glibc-2.1.91 or later should suffice. (The kernel "
6665 "distinguishes old and new calls by an B<IPC_64> flag in I<cmd>.)"
6669 #: build/C/man2/shmctl.2:410
6671 "B<mlock>(2), B<setrlimit>(2), B<shmget>(2), B<shmop>(2), B<capabilities>(7), "
6676 #: build/C/man2/shmget.2:36
6682 #: build/C/man2/shmget.2:36
6688 #: build/C/man2/shmget.2:39
6689 msgid "shmget - allocates a shared memory segment"
6693 #: build/C/man2/shmget.2:46
6694 msgid "B<int shmget(key_t >I<key>B<, size_t >I<size>B<, int >I<shmflg>B<);>"
6698 #: build/C/man2/shmget.2:70
6700 "B<shmget>() returns the identifier of the shared memory segment associated "
6701 "with the value of the argument I<key>. A new shared memory segment, with "
6702 "size equal to the value of I<size> rounded up to a multiple of B<PAGE_SIZE>, "
6703 "is created if I<key> has the value B<IPC_PRIVATE> or I<key> isn't "
6704 "B<IPC_PRIVATE>, no shared memory segment corresponding to I<key> exists, and "
6705 "B<IPC_CREAT> is specified in I<shmflg>."
6709 #: build/C/man2/shmget.2:89
6711 "If I<shmflg> specifies both B<IPC_CREAT> and B<IPC_EXCL> and a shared memory "
6712 "segment already exists for I<key>, then B<shmget>() fails with I<errno> set "
6713 "to B<EEXIST>. (This is analogous to the effect of the combination B<O_CREAT "
6714 "| O_EXCL> for B<open>(2).)"
6718 #: build/C/man2/shmget.2:93
6719 msgid "The value I<shmflg> is composed of:"
6723 #: build/C/man2/shmget.2:93
6725 msgid "B<IPC_CREAT>"
6729 #: build/C/man2/shmget.2:100
6731 "to create a new segment. If this flag is not used, then B<shmget>() will "
6732 "find the segment associated with I<key> and check to see if the user has "
6733 "permission to access the segment."
6737 #: build/C/man2/shmget.2:100
6743 #: build/C/man2/shmget.2:103
6744 msgid "used with B<IPC_CREAT> to ensure failure if the segment already exists."
6748 #: build/C/man2/shmget.2:103
6750 msgid "I<mode_flags>"
6754 #: build/C/man2/shmget.2:113
6756 "(least significant 9 bits) specifying the permissions granted to the owner, "
6757 "group, and world. These bits have the same format, and the same meaning, as "
6758 "the I<mode> argument of B<open>(2). Presently, the execute permissions are "
6759 "not used by the system."
6763 #: build/C/man2/shmget.2:113
6765 msgid "B<SHM_HUGETLB> (since Linux 2.6)"
6769 #: build/C/man2/shmget.2:119
6771 "Allocate the segment using \"huge pages.\" See the kernel source file "
6772 "I<Documentation/vm/hugetlbpage.txt> for further information."
6776 #: build/C/man2/shmget.2:119
6778 msgid "B<SHM_NORESERVE> (since Linux 2.6.15)"
6781 #. As at 2.6.17-rc2, this flag has no effect if SHM_HUGETLB was also
6784 #: build/C/man2/shmget.2:138
6786 "This flag serves the same purpose as the B<mmap>(2) B<MAP_NORESERVE> flag. "
6787 "Do not reserve swap space for this segment. When swap space is reserved, "
6788 "one has the guarantee that it is possible to modify the segment. When swap "
6789 "space is not reserved one might get B<SIGSEGV> upon a write if no physical "
6790 "memory is available. See also the discussion of the file "
6791 "I</proc/sys/vm/overcommit_memory> in B<proc>(5)."
6795 #: build/C/man2/shmget.2:146
6797 "When a new shared memory segment is created, its contents are initialized to "
6798 "zero values, and its associated data structure, I<shmid_ds> (see "
6799 "B<shmctl>(2)), is initialized as follows:"
6803 #: build/C/man2/shmget.2:151
6805 "I<shm_perm.cuid> and I<shm_perm.uid> are set to the effective user ID of the "
6810 #: build/C/man2/shmget.2:156
6812 "I<shm_perm.cgid> and I<shm_perm.gid> are set to the effective group ID of "
6813 "the calling process."
6817 #: build/C/man2/shmget.2:161
6819 "The least significant 9 bits of I<shm_perm.mode> are set to the least "
6820 "significant 9 bit of I<shmflg>."
6824 #: build/C/man2/shmget.2:165
6825 msgid "I<shm_segsz> is set to the value of I<size>."
6829 #: build/C/man2/shmget.2:172
6830 msgid "I<shm_lpid>, I<shm_nattch>, I<shm_atime> and I<shm_dtime> are set to 0."
6834 #: build/C/man2/shmget.2:175
6835 msgid "I<shm_ctime> is set to the current time."
6839 #: build/C/man2/shmget.2:178
6841 "If the shared memory segment already exists, the permissions are verified, "
6842 "and a check is made to see if it is marked for destruction."
6846 #: build/C/man2/shmget.2:182
6847 msgid "A valid segment identifier, I<shmid>, is returned on success, -1 on error."
6851 #: build/C/man2/shmget.2:186
6852 msgid "On failure, I<errno> is set to one of the following:"
6856 #: build/C/man2/shmget.2:192
6858 "The user does not have permission to access the shared memory segment, and "
6859 "does not have the B<CAP_IPC_OWNER> capability."
6863 #: build/C/man2/shmget.2:196
6864 msgid "B<IPC_CREAT | IPC_EXCL> was specified and the segment exists."
6868 #: build/C/man2/shmget.2:202
6870 "A new segment was to be created and I<size> E<lt> B<SHMMIN> or I<size> E<gt> "
6871 "B<SHMMAX>, or no new segment was to be created, a segment with given key "
6872 "existed, but I<size> is greater than the size of that segment."
6876 #: build/C/man2/shmget.2:211
6877 msgid "No segment exists for the given I<key>, and B<IPC_CREAT> was not specified."
6881 #: build/C/man2/shmget.2:214
6882 msgid "No memory could be allocated for segment overhead."
6886 #: build/C/man2/shmget.2:222
6888 "All possible shared memory IDs have been taken (B<SHMMNI>), or allocating a "
6889 "segment of the requested I<size> would cause the system to exceed the "
6890 "system-wide limit on shared memory (B<SHMALL>)."
6894 #: build/C/man2/shmget.2:229
6896 "The B<SHM_HUGETLB> flag was specified, but the caller was not privileged "
6897 "(did not have the B<CAP_IPC_LOCK> capability)."
6901 #: build/C/man2/shmget.2:235
6902 msgid "B<SHM_HUGETLB> is a nonportable Linux extension."
6906 #: build/C/man2/shmget.2:245
6908 "B<IPC_PRIVATE> isn't a flag field but a I<key_t> type. If this special "
6909 "value is used for I<key>, the system call ignores everything but the least "
6910 "significant 9 bits of I<shmflg> and creates a new shared memory segment (on "
6915 #: build/C/man2/shmget.2:249
6917 "The following limits on shared memory segment resources affect the "
6922 #: build/C/man2/shmget.2:249
6928 #: build/C/man2/shmget.2:254
6930 "System wide maximum of shared memory pages (on Linux, this limit can be read "
6931 "and modified via I</proc/sys/kernel/shmall>)."
6935 #: build/C/man2/shmget.2:254
6941 #: build/C/man2/shmget.2:259
6943 "Maximum size in bytes for a shared memory segment: policy dependent (on "
6944 "Linux, this limit can be read and modified via I</proc/sys/kernel/shmmax>)."
6948 #: build/C/man2/shmget.2:259
6954 #: build/C/man2/shmget.2:265
6956 "Minimum size in bytes for a shared memory segment: implementation dependent "
6957 "(currently 1 byte, though B<PAGE_SIZE> is the effective minimum size)."
6961 #: build/C/man2/shmget.2:265
6966 #. Kernels between 2.4.x and 2.6.8 had an off-by-one error that meant
6967 #. that we could create one more segment than SHMMNI -- MTK
6968 #. This /proc file is not available in Linux 2.2 and earlier -- MTK
6970 #: build/C/man2/shmget.2:274
6972 "System wide maximum number of shared memory segments: implementation "
6973 "dependent (currently 4096, was 128 before Linux 2.3.99; on Linux, this limit "
6974 "can be read and modified via I</proc/sys/kernel/shmmni>)."
6978 #: build/C/man2/shmget.2:278
6980 "The implementation has no specific limits for the per-process maximum number "
6981 "of shared memory segments (B<SHMSEG>)."
6985 #: build/C/man2/shmget.2:284
6987 "Until version 2.3.30 Linux would return B<EIDRM> for a B<shmget>() on a "
6988 "shared memory segment scheduled for deletion."
6992 #: build/C/man2/shmget.2:290
6994 "The name choice B<IPC_PRIVATE> was perhaps unfortunate, B<IPC_NEW> would "
6995 "more clearly show its function."
6999 #: build/C/man2/shmget.2:298
7001 "B<shmat>(2), B<shmctl>(2), B<shmdt>(2), B<ftok>(3), B<capabilities>(7), "
7002 "B<shm_overview>(7), B<svipc>(7)"
7006 #: build/C/man2/shmop.2:39
7012 #: build/C/man2/shmop.2:39
7018 #: build/C/man2/shmop.2:42
7019 msgid "shmat, shmdt - shared memory operations"
7023 #: build/C/man2/shmop.2:46
7026 "B<#include E<lt>sys/types.hE<gt>>\n"
7027 "B<#include E<lt>sys/shm.hE<gt>>\n"
7031 #: build/C/man2/shmop.2:48
7034 "B<void *shmat(int >I<shmid>B<, const void *>I<shmaddr>B<, int "
7039 #: build/C/man2/shmop.2:50
7041 msgid "B<int shmdt(const void *>I<shmaddr>B<);>\n"
7045 #: build/C/man2/shmop.2:59
7047 "B<shmat>() attaches the shared memory segment identified by I<shmid> to the "
7048 "address space of the calling process. The attaching address is specified by "
7049 "I<shmaddr> with one of the following criteria:"
7053 #: build/C/man2/shmop.2:65
7055 "If I<shmaddr> is NULL, the system chooses a suitable (unused) address at "
7056 "which to attach the segment."
7060 #: build/C/man2/shmop.2:80
7062 "If I<shmaddr> isn't NULL and B<SHM_RND> is specified in I<shmflg>, the "
7063 "attach occurs at the address equal to I<shmaddr> rounded down to the nearest "
7064 "multiple of B<SHMLBA>. Otherwise I<shmaddr> must be a page-aligned address "
7065 "at which the attach occurs."
7069 #: build/C/man2/shmop.2:90
7071 "If B<SHM_RDONLY> is specified in I<shmflg>, the segment is attached for "
7072 "reading and the process must have read permission for the segment. "
7073 "Otherwise the segment is attached for read and write and the process must "
7074 "have read and write permission for the segment. There is no notion of a "
7075 "write-only shared memory segment."
7079 #: build/C/man2/shmop.2:105
7081 "The (Linux-specific) B<SHM_REMAP> flag may be specified in I<shmflg> to "
7082 "indicate that the mapping of the segment should replace any existing mapping "
7083 "in the range starting at I<shmaddr> and continuing for the size of the "
7084 "segment. (Normally an B<EINVAL> error would result if a mapping already "
7085 "exists in this address range.) In this case, I<shmaddr> must not be NULL."
7089 #: build/C/man2/shmop.2:112
7091 "The B<brk>(2) value of the calling process is not altered by the attach. "
7092 "The segment will automatically be detached at process exit. The same "
7093 "segment may be attached as a read and as a read-write one, and more than "
7094 "once, in the process's address space."
7098 #: build/C/man2/shmop.2:120
7100 "A successful B<shmat>() call updates the members of the I<shmid_ds> "
7101 "structure (see B<shmctl>(2)) associated with the shared memory segment as "
7106 #: build/C/man2/shmop.2:123
7107 msgid "I<shm_atime> is set to the current time."
7111 #: build/C/man2/shmop.2:126 build/C/man2/shmop.2:152
7112 msgid "I<shm_lpid> is set to the process-ID of the calling process."
7116 #: build/C/man2/shmop.2:129
7117 msgid "I<shm_nattch> is incremented by one."
7121 #: build/C/man2/shmop.2:140
7123 "B<shmdt>() detaches the shared memory segment located at the address "
7124 "specified by I<shmaddr> from the address space of the calling process. The "
7125 "to-be-detached segment must be currently attached with I<shmaddr> equal to "
7126 "the value returned by the attaching B<shmat>() call."
7130 #: build/C/man2/shmop.2:146
7132 "On a successful B<shmdt>() call the system updates the members of the "
7133 "I<shmid_ds> structure associated with the shared memory segment as follows:"
7137 #: build/C/man2/shmop.2:149
7138 msgid "I<shm_dtime> is set to the current time."
7142 #: build/C/man2/shmop.2:157
7144 "I<shm_nattch> is decremented by one. If it becomes 0 and the segment is "
7145 "marked for deletion, the segment is deleted."
7149 #: build/C/man2/shmop.2:161
7150 msgid "After a B<fork>(2) the child inherits the attached shared memory segments."
7154 #: build/C/man2/shmop.2:165
7156 "After an B<execve>(2) all attached shared memory segments are detached from "
7161 #: build/C/man2/shmop.2:169
7163 "Upon B<_exit>(2) all attached shared memory segments are detached from the "
7168 #: build/C/man2/shmop.2:177
7170 "On success B<shmat>() returns the address of the attached shared memory "
7171 "segment; on error I<(void\\ *)\\ -1> is returned, and I<errno> is set to "
7172 "indicate the cause of the error."
7176 #: build/C/man2/shmop.2:183
7178 "On success B<shmdt>() returns 0; on error -1 is returned, and I<errno> is "
7179 "set to indicate the cause of the error."
7183 #: build/C/man2/shmop.2:189
7184 msgid "When B<shmat>() fails, I<errno> is set to one of the following:"
7188 #: build/C/man2/shmop.2:195
7190 "The calling process does not have the required permissions for the requested "
7191 "attach type, and does not have the B<CAP_IPC_OWNER> capability."
7195 #: build/C/man2/shmop.2:209
7197 "Invalid I<shmid> value, unaligned (i.e., not page-aligned and B<SHM_RND> was "
7198 "not specified) or invalid I<shmaddr> value, or can't attach segment at "
7199 "I<shmaddr>, or B<SHM_REMAP> was specified and I<shmaddr> was NULL."
7203 #: build/C/man2/shmop.2:212
7204 msgid "Could not allocate memory for the descriptor or for the page tables."
7208 #: build/C/man2/shmop.2:218
7209 msgid "When B<shmdt>() fails, I<errno> is set as follows:"
7212 #. The following since 2.6.17-rc1:
7214 #: build/C/man2/shmop.2:226
7216 "There is no shared memory segment attached at I<shmaddr>; or, I<shmaddr> is "
7217 "not aligned on a page boundary."
7221 #: build/C/man2/shmop.2:245
7223 "In SVID 3 (or perhaps earlier) the type of the I<shmaddr> argument was "
7224 "changed from I<char *> into I<const void *>, and the returned type of "
7225 "B<shmat>() from I<char *> into I<void *>. (Linux libc4 and libc5 have the "
7226 "I<char *> prototypes; glibc2 has I<void *>.)"
7230 #: build/C/man2/shmop.2:257
7232 "Using B<shmat>() with I<shmaddr> equal to NULL is the preferred, portable "
7233 "way of attaching a shared memory segment. Be aware that the shared memory "
7234 "segment attached in this way may be attached at different addresses in "
7235 "different processes. Therefore, any pointers maintained within the shared "
7236 "memory must be made relative (typically to the starting address of the "
7237 "segment), rather than absolute."
7241 #: build/C/man2/shmop.2:262
7243 "On Linux, it is possible to attach a shared memory segment even if it is "
7244 "already marked to be deleted. However, POSIX.1-2001 does not specify this "
7245 "behavior and many other implementations do not support it."
7249 #: build/C/man2/shmop.2:265
7250 msgid "The following system parameter affects B<shmat>():"
7253 #. FIXME A good explanation of the rationale for the existence
7254 #. of SHMLBA would be useful here
7256 #: build/C/man2/shmop.2:265
7261 #. FIXME That last sentence isn't true for all Linux
7262 #. architectures (i.e., SHMLBA != PAGE_SIZE for some architectures)
7265 #: build/C/man2/shmop.2:278
7267 "Segment low boundary address multiple. Must be page aligned. For the "
7268 "current implementation the B<SHMLBA> value is B<PAGE_SIZE>."
7272 #: build/C/man2/shmop.2:282
7274 "The implementation places no intrinsic limit on the per-process maximum "
7275 "number of shared memory segments (B<SHMSEG>)."
7279 #: build/C/man2/shmop.2:290
7281 "B<brk>(2), B<mmap>(2), B<shmctl>(2), B<shmget>(2), B<capabilities>(7), "
7282 "B<shm_overview>(7), B<svipc>(7)"
7286 #: build/C/man2/subpage_prot.2:28
7288 msgid "SUBPAGE_PROT"
7292 #: build/C/man2/subpage_prot.2:28
7298 #: build/C/man2/subpage_prot.2:31
7299 msgid "subpage_prot - define a subpage protection for an address range"
7303 #: build/C/man2/subpage_prot.2:35
7306 "B<long subpage_prot(unsigned long >I<addr>B<, unsigned long >I<len>B<,>\n"
7307 "B< uint32_t *>I<map>B<);>\n"
7311 #: build/C/man2/subpage_prot.2:42
7313 "The PowerPC-specific B<subpage_prot>() system call provides the facility to "
7314 "control the access permissions on individual 4kB subpages on systems "
7315 "configured with a page size of 64kB."
7319 #: build/C/man2/subpage_prot.2:49
7321 "The protection map is applied to the memory pages in the region starting at "
7322 "I<addr> and continuing for I<len> bytes. Both of these arguments must be "
7323 "aligned to a 64-kB boundary."
7327 #: build/C/man2/subpage_prot.2:61
7329 "The protection map is specified in the buffer pointed to by I<map>. The map "
7330 "has 2 bits per 4kB subpage; thus each 32-bit word specifies the protections "
7331 "of 16 4kB subpages inside a 64kB page (so, the number of 32-bit words "
7332 "pointed to by I<map> should equate to the number of 64-kB pages specified by "
7333 "I<len>). Each 2-bit field in the protection map is either 0 to allow any "
7334 "access, 1 to prevent writes, or 2 or 3 to prevent all accesses."
7338 #: build/C/man2/subpage_prot.2:66
7340 "On success, B<subpage_prot>() returns 0. Otherwise, one of the error codes "
7341 "specified below is returned."
7345 #: build/C/man2/subpage_prot.2:72
7346 msgid "The buffer referred to by I<map> is not accessible."
7350 #: build/C/man2/subpage_prot.2:82
7352 "The I<addr> or I<len> arguments are incorrect. Both of these arguments must "
7353 "be aligned to a multiple of the system page size, and they must not refer to "
7354 "a region outside of the address space of the process or to a region that "
7355 "consists of huge pages."
7359 #: build/C/man2/subpage_prot.2:85 build/C/man2/sync_file_range.2:166
7360 msgid "Out of memory."
7364 #: build/C/man2/subpage_prot.2:91
7366 "This system call is provided on the PowerPC architecture since Linux "
7367 "2.6.25. The system call is provided only if the kernel is configured with "
7368 "B<CONFIG_PPC_64K_PAGES>. No library support is provided."
7372 #: build/C/man2/subpage_prot.2:98
7374 "Normal page protections (at the 64-kB page level) also apply; the subpage "
7375 "protection mechanism is an additional constraint, so putting 0 in a 2-bit "
7376 "field won't allow writes to a page that is otherwise write-protected."
7380 #: build/C/man2/subpage_prot.2:98
7385 #. In the initial implementation, it was the case that:
7386 #. In fact the whole process is switched to use 4k hardware pages when the
7387 #. subpage_prot system call is used, but this could be improved in future
7388 #. to switch only the affected segments.
7389 #. But Paul Mackerass says (Oct 2010): I'm pretty sure we now only switch
7390 #. the affected segment, not the whole process.
7392 #: build/C/man2/subpage_prot.2:120
7394 "This system call is provided to assist writing emulators that operate using "
7395 "64-kB pages on PowerPC systems. When emulating systems such as x86, which "
7396 "uses a smaller page size, the emulator can no longer use the "
7397 "memory-management unit (MMU) and normal system calls for controlling page "
7398 "protections. (The emulator could emulate the MMU by checking and possibly "
7399 "remapping the address for each memory access in software, but that is slow.) "
7400 "The idea is that the emulator supplies an array of protection masks to apply "
7401 "to a specified range of virtual addresses. These masks are applied at the "
7402 "level where hardware page-table entries (PTEs) are inserted into the "
7403 "hardware page table based on the Linux PTEs, so the Linux PTEs are not "
7404 "affected. Implicit in this is that the regions of the address space that "
7405 "are protected are switched to use 4-kB hardware pages rather than 64-kB "
7406 "hardware pages (on machines with hardware 64-kB page support)."
7410 #: build/C/man2/subpage_prot.2:123
7411 msgid "B<mprotect>(2), B<syscall>(2);"
7415 #: build/C/man2/subpage_prot.2:126
7416 msgid "the kernel source file I<Documentation/vm/hugetlbpage.txt>."
7420 #: build/C/man2/sync_file_range.2:30
7422 msgid "SYNC_FILE_RANGE"
7426 #: build/C/man2/sync_file_range.2:33
7427 msgid "sync_file_range - sync a file segment with disk"
7431 #: build/C/man2/sync_file_range.2:37
7434 "B<#define _GNU_SOURCE> /* See feature_test_macros(7) */\n"
7435 "B<#include E<lt>fcntl.hE<gt>>\n"
7439 #: build/C/man2/sync_file_range.2:40
7442 "B<int sync_file_range(int >I<fd>B<, off64_t >I<offset>B<, off64_t "
7444 "B< unsigned int >I<flags>B<);>\n"
7448 #: build/C/man2/sync_file_range.2:47
7450 "B<sync_file_range>() permits fine control when synchronizing the open file "
7451 "referred to by the file descriptor I<fd> with disk."
7455 #: build/C/man2/sync_file_range.2:61
7457 "I<offset> is the starting byte of the file range to be synchronized. "
7458 "I<nbytes> specifies the length of the range to be synchronized, in bytes; if "
7459 "I<nbytes> is zero, then all bytes from I<offset> through to the end of file "
7460 "are synchronized. Synchronization is in units of the system page size: "
7461 "I<offset> is rounded down to a page boundary; I<(offset+nbytes-1)> is "
7462 "rounded up to a page boundary."
7466 #: build/C/man2/sync_file_range.2:65
7467 msgid "The I<flags> bit-mask argument can include any of the following values:"
7471 #: build/C/man2/sync_file_range.2:65
7473 msgid "B<SYNC_FILE_RANGE_WAIT_BEFORE>"
7477 #: build/C/man2/sync_file_range.2:70
7479 "Wait upon write-out of all pages in the specified range that have already "
7480 "been submitted to the device driver for write-out before performing any "
7485 #: build/C/man2/sync_file_range.2:70 build/C/man2/sync_file_range.2:120
7487 msgid "B<SYNC_FILE_RANGE_WRITE>"
7491 #: build/C/man2/sync_file_range.2:76
7493 "Initiate write-out of all dirty pages in the specified range which are not "
7494 "presently submitted write-out. Note that even this may block if you attempt "
7495 "to write more than request queue size."
7499 #: build/C/man2/sync_file_range.2:76
7501 msgid "B<SYNC_FILE_RANGE_WAIT_AFTER>"
7505 #: build/C/man2/sync_file_range.2:80
7506 msgid "Wait upon write-out of all pages in the range after performing any write."
7510 #: build/C/man2/sync_file_range.2:84
7511 msgid "Specifying I<flags> as 0 is permitted, as a no-op."
7515 #: build/C/man2/sync_file_range.2:84
7521 #: build/C/man2/sync_file_range.2:100
7523 "This system call is extremely dangerous and should not be used in portable "
7524 "programs. None of these operations writes out the file's metadata. "
7525 "Therefore, unless the application is strictly performing overwrites of "
7526 "already-instantiated disk blocks, there are no guarantees that the data will "
7527 "be available after a crash. There is no user interface to know if a write "
7528 "is purely an overwrite. On file systems using copy-on-write semantics "
7529 "(e.g., I<btrfs>) an overwrite of existing allocated blocks is impossible. "
7530 "When writing into preallocated space, many file systems also require calls "
7531 "into the block allocator, which this system call does not sync out to disk. "
7532 "This system call does not flush disk write caches and thus does not provide "
7533 "any data integrity on systems with volatile disk write caches."
7537 #: build/C/man2/sync_file_range.2:100
7539 msgid "Some details"
7543 #: build/C/man2/sync_file_range.2:108
7545 "B<SYNC_FILE_RANGE_WAIT_BEFORE> and B<SYNC_FILE_RANGE_WAIT_AFTER> will detect "
7546 "any I/O errors or B<ENOSPC> conditions and will return these to the caller."
7550 #: build/C/man2/sync_file_range.2:112
7551 msgid "Useful combinations of the I<flags> bits are:"
7555 #: build/C/man2/sync_file_range.2:112
7557 msgid "B<SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE>"
7561 #: build/C/man2/sync_file_range.2:120
7563 "Ensures that all pages in the specified range which were dirty when "
7564 "B<sync_file_range>() was called are placed under write-out. This is a "
7565 "start-write-for-data-integrity operation."
7569 #: build/C/man2/sync_file_range.2:127
7571 "Start write-out of all dirty pages in the specified range which are not "
7572 "presently under write-out. This is an asynchronous flush-to-disk "
7573 "operation. This is not suitable for data integrity operations."
7577 #: build/C/man2/sync_file_range.2:127
7579 msgid "B<SYNC_FILE_RANGE_WAIT_BEFORE> (or B<SYNC_FILE_RANGE_WAIT_AFTER>)"
7583 #: build/C/man2/sync_file_range.2:134
7585 "Wait for completion of write-out of all pages in the specified range. This "
7586 "can be used after an earlier B<SYNC_FILE_RANGE_WAIT_BEFORE | "
7587 "SYNC_FILE_RANGE_WRITE> operation to wait for completion of that operation, "
7588 "and obtain its result."
7592 #: build/C/man2/sync_file_range.2:134
7595 "B<SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE | "
7596 "SYNC_FILE_RANGE_WAIT_AFTER>"
7600 #: build/C/man2/sync_file_range.2:141
7602 "This is a write-for-data-integrity operation that will ensure that all pages "
7603 "in the specified range which were dirty when B<sync_file_range>() was "
7604 "called are committed to disk."
7608 #: build/C/man2/sync_file_range.2:147
7610 "On success, B<sync_file_range>() returns 0; on failure -1 is returned and "
7611 "I<errno> is set to indicate the error."
7615 #: build/C/man2/sync_file_range.2:152
7616 msgid "I<fd> is not a valid file descriptor."
7620 #: build/C/man2/sync_file_range.2:160
7621 msgid "I<flags> specifies an invalid bit; or I<offset> or I<nbytes> is invalid."
7625 #: build/C/man2/sync_file_range.2:163
7630 #: build/C/man2/sync_file_range.2:169
7631 msgid "Out of disk space."
7634 #. FIXME . (bug?) Actually, how can 'fd' refer to a symbolic link (S_ISLNK)?
7635 #. (In userspace at least) it isn't possible to obtain a file descriptor
7636 #. for a symbolic link.
7638 #: build/C/man2/sync_file_range.2:177
7640 "I<fd> refers to something other than a regular file, a block device, a "
7641 "directory, or a symbolic link."
7645 #: build/C/man2/sync_file_range.2:180
7646 msgid "B<sync_file_range>() appeared on Linux in kernel 2.6.17."
7650 #: build/C/man2/sync_file_range.2:183
7652 "This system call is Linux-specific, and should be avoided in portable "
7656 #. See kernel commit edd5cd4a9424f22b0fa08bef5e299d41befd5622
7658 #: build/C/man2/sync_file_range.2:196
7660 "Some architectures (e.g., PowerPC, ARM) need 64-bit arguments to be aligned "
7661 "in a suitable pair of registers. On such architectures, the call signature "
7662 "of B<sync_file_range>() is flawed, since it forces a register to be wasted "
7663 "as padding between the I<fd> and I<offset> arguments. Therefore, these "
7664 "architectures define a different system call that orders the arguments "
7669 #: build/C/man2/sync_file_range.2:201
7672 "B<int sync_file_range2(int >I<fd>B<, unsigned int >I<flags>B<,>\n"
7673 "B< off64_t >I<offset>B<, off64_t >I<nbytes>B<);>\n"
7677 #: build/C/man2/sync_file_range.2:206
7679 "The behavior of this system call is otherwise exactly the same as "
7680 "B<sync_file_range>()."
7684 #: build/C/man2/sync_file_range.2:217
7686 "A system call with this signature first appeared on the ARM architecture in "
7687 "Linux 2.6.20, with the name B<arm_sync_file_range>(). It was renamed in "
7688 "Linux 2.6.22, when the analogous system call was added for PowerPC. On "
7689 "architectures where glibc support is provided, glibc transparently wraps "
7690 "B<sync_file_range2>() under the name B<sync_file_range>()."
7694 #: build/C/man2/sync_file_range.2:222
7695 msgid "B<fdatasync>(2), B<fsync>(2), B<msync>(2), B<sync>(2)"