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-03-22 04:26+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/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_hook.3:6 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:4 build/C/man2/posix_fadvise.2:27 build/C/man3/posix_fallocate.3:23 build/C/man3/posix_memalign.3:26 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_hook.3:7 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:5 build/C/man2/posix_fadvise.2:28 build/C/man3/posix_fallocate.3:24 build/C/man3/posix_memalign.3:27 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_hook.3:11 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:7 build/C/man2/posix_fadvise.2:30 build/C/man3/posix_fallocate.3:26 build/C/man3/posix_memalign.3:29 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_hook.3:29 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:13 build/C/man2/posix_fadvise.2:49 build/C/man3/posix_fallocate.3:44 build/C/man3/posix_memalign.3:70 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/man2/mlock.2:117 build/C/man2/mmap.2:373 build/C/man2/mmap2.2:50 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:111 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/man2/mlock.2:123 build/C/man2/mmap.2:390 build/C/man2/mmap2.2:57 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:123 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:186 build/C/man2/madvise.2:307 build/C/man3/malloc_hook.3:76 build/C/man2/mlock.2:187 build/C/man2/mmap.2:483 build/C/man2/mmap2.2:73 build/C/man2/mprotect.2:107 build/C/man2/mremap.2:186 build/C/man2/msync.2:96 build/C/man3/mtrace.3:34 build/C/man2/posix_fadvise.2:111 build/C/man3/posix_fallocate.3:101 build/C/man3/posix_memalign.3:142 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_hook.3:78 build/C/man2/mlock.2:214 build/C/man2/mmap.2:501 build/C/man2/mmap2.2:75 build/C/man2/mprotect.2:116 build/C/man2/mremap.2:192 build/C/man3/mtrace.3:36 build/C/man2/posix_fadvise.2:120 build/C/man3/posix_memalign.3:179 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:193 build/C/man2/madvise.2:360 build/C/man3/malloc_hook.3:138 build/C/man2/mlock.2:337 build/C/man2/mmap.2:667 build/C/man2/mmap2.2:94 build/C/man2/mprotect.2:223 build/C/man2/mremap.2:214 build/C/man2/msync.2:122 build/C/man3/mtrace.3:44 build/C/man2/posix_fadvise.2:188 build/C/man3/posix_fallocate.3:130 build/C/man3/posix_memalign.3:235 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:200 build/C/man2/madvise.2:367 build/C/man3/malloc_hook.3:145 build/C/man2/mlock.2:344 build/C/man2/mmap.2:674 build/C/man2/mmap2.2:101 build/C/man2/mprotect.2:230 build/C/man2/mremap.2:221 build/C/man2/msync.2:129 build/C/man3/mtrace.3:51 build/C/man2/posix_fadvise.2:195 build/C/man3/posix_fallocate.3:137 build/C/man3/posix_memalign.3:242 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.37 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_hook.3:6 build/C/man3/mtrace.3:4 build/C/man3/posix_fallocate.3:23 build/C/man3/posix_memalign.3:26
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/man2/mlock.2:305 build/C/man2/mmap.2:540 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:189 build/C/man2/madvise.2:353 build/C/man3/malloc_hook.3:133 build/C/man2/mlock.2:330 build/C/man2/mmap.2:649 build/C/man2/mmap2.2:88 build/C/man2/mprotect.2:220 build/C/man2/mremap.2:200 build/C/man2/msync.2:118 build/C/man3/mtrace.3:41 build/C/man2/posix_fadvise.2:182 build/C/man3/posix_fallocate.3:126 build/C/man3/posix_memalign.3:230 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:58 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:61 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:124 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 + 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 I<offset "
614 "+ len> is greater than the file size. Preallocating zeroed blocks beyond "
615 "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:156
741 "The file system containing the file referred to by I<fd> does not support "
746 #: build/C/man2/fallocate.2:156
748 msgid "B<EOPNOTSUPP>"
752 #: build/C/man2/fallocate.2:162
754 "The I<mode> is not supported by the file system containing the file referred "
759 #: build/C/man2/fallocate.2:162 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
765 #: build/C/man2/fallocate.2:178
767 "The file referred to by I<fd> is marked immutable (see B<chattr>(1)). Or: "
768 "I<mode> specifies B<FALLOC_FL_PUNCH_HOLE> and the file referred to by I<fd> "
769 "is marked append-only (see B<chattr>(1))."
773 #: build/C/man2/fallocate.2:178 build/C/man2/posix_fadvise.2:96 build/C/man3/posix_fallocate.3:94 build/C/man2/sync_file_range.2:169
779 #: build/C/man2/fallocate.2:182
780 msgid "I<fd> refers to a pipe or FIFO."
784 #: build/C/man2/fallocate.2:182 build/C/man2/mmap2.2:70 build/C/man2/posix_fadvise.2:103 build/C/man3/posix_fallocate.3:98 build/C/man3/posix_memalign.3:133 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
790 #: build/C/man2/fallocate.2:186
792 "B<fallocate>() is available on Linux since kernel 2.6.23. Support is "
793 "provided by glibc since version 2.10."
797 #: build/C/man2/fallocate.2:189
798 msgid "B<fallocate>() is Linux-specific."
802 #: build/C/man2/fallocate.2:193
803 msgid "B<ftruncate>(2), B<posix_fadvise>(3), B<posix_fallocate>(3)"
807 #: build/C/man2/madvise.2:35
813 #: build/C/man2/madvise.2:35
819 #: build/C/man2/madvise.2:38
820 msgid "madvise - give advice about use of memory"
824 #: build/C/man2/madvise.2:40 build/C/man2/msync.2:30 build/C/man3/shm_open.3:31
825 msgid "B<#include E<lt>sys/mman.hE<gt>>"
829 #: build/C/man2/madvise.2:42
830 msgid "B<int madvise(void *>I<addr>B<, size_t >I<length>B<, int >I<advice>B<);>"
834 #: 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:44
835 msgid "Feature Test Macro Requirements for glibc (see B<feature_test_macros>(7)):"
839 #: build/C/man2/madvise.2:50
840 msgid "B<madvise>(): _BSD_SOURCE"
844 #: build/C/man2/madvise.2:68
846 "The B<madvise>() system call advises the kernel about how to handle paging "
847 "input/output in the address range beginning at address I<addr> and with size "
848 "I<length> bytes. It allows an application to tell the kernel how it expects "
849 "to use some mapped or shared memory areas, so that the kernel can choose "
850 "appropriate read-ahead and caching techniques. This call does not influence "
851 "the semantics of the application (except in the case of B<MADV_DONTNEED>), "
852 "but may influence its performance. The kernel is free to ignore the advice."
856 #: build/C/man2/madvise.2:72
857 msgid "The advice is indicated in the I<advice> argument which can be"
861 #: build/C/man2/madvise.2:72
863 msgid "B<MADV_NORMAL>"
867 #: build/C/man2/madvise.2:76
868 msgid "No special treatment. This is the default."
872 #: build/C/man2/madvise.2:76
874 msgid "B<MADV_RANDOM>"
878 #: build/C/man2/madvise.2:80
880 "Expect page references in random order. (Hence, read ahead may be less "
881 "useful than normally.)"
885 #: build/C/man2/madvise.2:80
887 msgid "B<MADV_SEQUENTIAL>"
891 #: build/C/man2/madvise.2:85
893 "Expect page references in sequential order. (Hence, pages in the given "
894 "range can be aggressively read ahead, and may be freed soon after they are "
899 #: build/C/man2/madvise.2:85
901 msgid "B<MADV_WILLNEED>"
905 #: build/C/man2/madvise.2:89
907 "Expect access in the near future. (Hence, it might be a good idea to read "
912 #: build/C/man2/madvise.2:89
914 msgid "B<MADV_DONTNEED>"
918 #: build/C/man2/madvise.2:100
920 "Do not expect access in the near future. (For the time being, the "
921 "application is finished with the given range, so the kernel can free "
922 "resources associated with it.) Subsequent accesses of pages in this range "
923 "will succeed, but will result either in reloading of the memory contents "
924 "from the underlying mapped file (see B<mmap>(2)) or zero-fill-on-demand "
925 "pages for mappings without an underlying file."
929 #: build/C/man2/madvise.2:100
931 msgid "B<MADV_REMOVE> (Since Linux 2.6.16)"
935 #. Databases want to use this feature to drop a section of their
936 #. bufferpool (shared memory segments) - without writing back to
937 #. disk/swap space. This feature is also useful for supporting
938 #. hot-plug memory on UML.
940 #: build/C/man2/madvise.2:113
942 "Free up a given range of pages and its associated backing store. Currently, "
943 "only shmfs/tmpfs supports this; other file systems return with the error "
948 #: build/C/man2/madvise.2:113
950 msgid "B<MADV_DONTFORK> (Since Linux 2.6.16)"
953 #. See http://lwn.net/Articles/171941/
954 #. [PATCH] madvise MADV_DONTFORK/MADV_DOFORK
955 #. Currently, copy-on-write may change the physical address of
956 #. a page even if the user requested that the page is pinned in
957 #. memory (either by mlock or by get_user_pages). This happens
958 #. if the process forks meanwhile, and the parent writes to that
959 #. page. As a result, the page is orphaned: in case of
960 #. get_user_pages, the application will never see any data hardware
961 #. DMA's into this page after the COW. In case of mlock'd memory,
962 #. the parent is not getting the realtime/security benefits of mlock.
964 #. In particular, this affects the Infiniband modules which do DMA from
965 #. and into user pages all the time.
967 #. This patch adds madvise options to control whether memory range is
968 #. inherited across fork. Useful e.g. for when hardware is doing DMA
969 #. from/into these pages. Could also be useful to an application
970 #. wanting to speed up its forks by cutting large areas out of
973 #. SEE ALSO: http://lwn.net/Articles/171941/
974 #. "Tweaks to madvise() and posix_fadvise()", 14 Feb 2006
976 #: build/C/man2/madvise.2:144
978 "Do not make the pages in this range available to the child after a "
979 "B<fork>(2). This is useful to prevent copy-on-write semantics from changing "
980 "the physical location of a page(s) if the parent writes to it after a "
981 "B<fork>(2). (Such page relocations cause problems for hardware that DMAs "
986 #: build/C/man2/madvise.2:144
988 msgid "B<MADV_DOFORK> (Since Linux 2.6.16)"
992 #: build/C/man2/madvise.2:150
994 "Undo the effect of B<MADV_DONTFORK>, restoring the default behavior, whereby "
995 "a mapping is inherited across B<fork>(2)."
999 #: build/C/man2/madvise.2:150
1001 msgid "B<MADV_HWPOISON> (Since Linux 2.6.32)"
1005 #: build/C/man2/madvise.2:162
1007 "Poison a page and handle it like a hardware memory corruption. This "
1008 "operation is only available for privileged (B<CAP_SYS_ADMIN>) processes. "
1009 "This operation may result in the calling process receiving a B<SIGBUS> and "
1010 "the page being unmapped. This feature is intended for testing of memory "
1011 "error-handling code; it is only available if the kernel was configured with "
1012 "B<CONFIG_MEMORY_FAILURE>."
1016 #: build/C/man2/madvise.2:162
1018 msgid "B<MADV_SOFT_OFFLINE> (Since Linux 2.6.33)"
1022 #: build/C/man2/madvise.2:180
1024 "Soft offline the pages in the range specified by I<addr> and I<length>. The "
1025 "memory of each page in the specified range is preserved (i.e., when next "
1026 "accessed, the same content will be visible, but in a new physical page "
1027 "frame), and the original page is offlined (i.e., no longer used, and taken "
1028 "out of normal memory management). The effect of the B<MADV_SOFT_OFFLINE> "
1029 "operation is invisible to (i.e., does not change the semantics of) the "
1030 "calling process. This feature is intended for testing of memory "
1031 "error-handling code; it is only available if the kernel was configured with "
1032 "B<CONFIG_MEMORY_FAILURE>."
1036 #: build/C/man2/madvise.2:180
1038 msgid "B<MADV_MERGEABLE> (since Linux 2.6.32)"
1042 #: build/C/man2/madvise.2:205
1044 "Enable Kernel Samepage Merging (KSM) for the pages in the range specified by "
1045 "I<addr> and I<length>. The kernel regularly scans those areas of user "
1046 "memory that have been marked as mergeable, looking for pages with identical "
1047 "content. These are replaced by a single write-protected page (which is "
1048 "automatically copied if a process later wants to update the content of the "
1049 "page). KSM only merges private anonymous pages (see B<mmap>(2)). The KSM "
1050 "feature is intended for applications that generate many instances of the "
1051 "same data (e.g., virtualization systems such as KVM). It can consume a lot "
1052 "of processing power; use with care. See the kernel source file "
1053 "I<Documentation/vm/ksm.txt> for more details. The B<MADV_MERGEABLE> and "
1054 "B<MADV_UNMERGEABLE> operations are only available if the kernel was "
1055 "configured with B<CONFIG_KSM>."
1059 #: build/C/man2/madvise.2:205
1061 msgid "B<MADV_UNMERGEABLE> (since Linux 2.6.32)"
1065 #: build/C/man2/madvise.2:214
1067 "Undo the effect of an earlier B<MADV_MERGEABLE> operation on the specified "
1068 "address range; KSM unmerges whatever pages it had merged in the address "
1069 "range specified by I<addr> and I<length>."
1073 #: build/C/man2/madvise.2:214
1075 msgid "B<MADV_HUGEPAGE> (since Linux 2.6.38)"
1078 #. http://lwn.net/Articles/358904/
1079 #. https://lwn.net/Articles/423584/
1081 #: build/C/man2/madvise.2:243
1083 "Enables Transparent Huge Pages (THP) for pages in the range specified by "
1084 "I<addr> and I<length>. Currently, Transparent Huge Pages only work with "
1085 "private anonymous pages (see B<mmap>(2)). The kernel will regularly scan "
1086 "the areas marked as huge page candidates to replace them with huge pages. "
1087 "The kernel will also allocate huge pages directly when the region is "
1088 "naturally aligned to the huge page size (see B<posix_memalign>(2)). This "
1089 "feature is primarily aimed at applications that use large mappings of data "
1090 "and access large regions of that memory at a time (e.g. virtualization "
1091 "systems such as QEMU). It can very easily waste memory (e.g. a 2MB mapping "
1092 "that only ever accesses 1 byte will result in 2MB of wired memory instead of "
1093 "one 4KB page). See the kernel source file I<Documentation/vm/transhuge.txt> "
1094 "for more details. The B<MADV_HUGEPAGE> and B<MADV_NOHUGEPAGE> operations "
1095 "are only available if the kernel was configured with "
1096 "B<CONFIG_TRANSPARENT_HUGEPAGE>."
1100 #: build/C/man2/madvise.2:243
1102 msgid "B<MADV_NOHUGEPAGE> (since Linux 2.6.38)"
1106 #: build/C/man2/madvise.2:250
1108 "Ensures that memory in the address range specified by I<addr> and I<length> "
1109 "will not be collapsed into huge pages."
1113 #: build/C/man2/madvise.2:257
1115 "On success B<madvise>() returns zero. On error, it returns -1 and I<errno> "
1116 "is set appropriately."
1120 #: build/C/man2/madvise.2:258 build/C/man2/mlock.2:155 build/C/man2/mmap.2:411 build/C/man2/mremap.2:137
1126 #: build/C/man2/madvise.2:261
1127 msgid "A kernel resource was temporarily unavailable."
1131 #: build/C/man2/madvise.2:264
1132 msgid "The map exists, but the area maps something that isn't a file."
1136 #: build/C/man2/madvise.2:267
1137 msgid "This error can occur for the following reasons:"
1141 #: 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
1149 #: build/C/man2/madvise.2:274
1150 msgid "The value I<len> is negative."
1154 #: build/C/man2/madvise.2:277
1155 msgid "I<addr> is not page-aligned."
1159 #: build/C/man2/madvise.2:280
1160 msgid "I<advice> is not a valid value"
1164 #: build/C/man2/madvise.2:283
1166 "The application is attempting to release locked or shared pages (with "
1167 "B<MADV_DONTNEED>)."
1171 #: build/C/man2/madvise.2:291
1173 "B<MADV_MERGEABLE> or B<MADV_UNMERGEABLE> was specified in I<advice>, but the "
1174 "kernel was not configured with B<CONFIG_KSM>."
1178 #: build/C/man2/madvise.2:298
1180 "(for B<MADV_WILLNEED>) Paging in this area would exceed the process's "
1181 "maximum resident set size."
1185 #: 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:130 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
1191 #: build/C/man2/madvise.2:303
1192 msgid "(for B<MADV_WILLNEED>) Not enough memory: paging in failed."
1196 #: build/C/man2/madvise.2:307
1198 "Addresses in the specified range are not currently mapped, or are outside "
1199 "the address space of the process."
1202 #. FIXME . Write a posix_fadvise(3) page.
1204 #: build/C/man2/madvise.2:319
1206 "POSIX.1b. POSIX.1-2001 describes B<posix_madvise>(3) with constants "
1207 "B<POSIX_MADV_NORMAL>, etc., with a behavior close to that described here. "
1208 "There is a similar B<posix_fadvise>(2) for file access."
1212 #: build/C/man2/madvise.2:328
1214 "B<MADV_REMOVE>, B<MADV_DONTFORK>, B<MADV_DOFORK>, B<MADV_HWPOISON>, "
1215 "B<MADV_MERGEABLE>, and B<MADV_UNMERGEABLE> are Linux-specific."
1219 #: build/C/man2/madvise.2:329 build/C/man2/mlock.2:268 build/C/man2/shmget.2:278
1225 #: build/C/man2/madvise.2:337
1227 "The current Linux implementation (2.4.0) views this system call more as a "
1228 "command than as advice and hence may return an error when it cannot do what "
1229 "it usually would do in response to this advice. (See the ERRORS description "
1230 "above.) This is nonstandard behavior."
1236 #. function first appeared in 4.4BSD.
1238 #: build/C/man2/madvise.2:353
1240 "The Linux implementation requires that the address I<addr> be page-aligned, "
1241 "and allows I<length> to be zero. If there are some parts of the specified "
1242 "address range that are not mapped, the Linux version of B<madvise>() "
1243 "ignores them and applies the call to the rest (but returns B<ENOMEM> from "
1244 "the system call, as it should)."
1248 #: build/C/man2/madvise.2:360
1250 "B<getrlimit>(2), B<mincore>(2), B<mmap>(2), B<mprotect>(2), B<msync>(2), "
1255 #: build/C/man3/malloc_hook.3:6
1261 #: build/C/man3/malloc_hook.3:6
1267 #: build/C/man3/malloc_hook.3:11
1269 "__malloc_hook, __malloc_initialize_hook, __memalign_hook, __free_hook, "
1270 "__realloc_hook, __after_morecore_hook - malloc debugging variables"
1274 #: build/C/man3/malloc_hook.3:14 build/C/man3/posix_memalign.3:36
1276 msgid "B<#include E<lt>malloc.hE<gt>>\n"
1280 #: build/C/man3/malloc_hook.3:16
1282 msgid "B<void *(*__malloc_hook)(size_t >I<size>B<, const void *>I<caller>B<);>\n"
1286 #: build/C/man3/malloc_hook.3:19
1289 "B<void *(*__realloc_hook)(void *>I<ptr>B<, size_t >I<size>B<, const void "
1290 "*>I<caller>B<);>\n"
1294 #: build/C/man3/malloc_hook.3:22
1297 "B<void *(*__memalign_hook)(size_t >I<alignment>B<, size_t >I<size>B<,>\n"
1298 "B< const void *>I<caller>B<);>\n"
1302 #: build/C/man3/malloc_hook.3:24
1304 msgid "B<void (*__free_hook)(void *>I<ptr>B<, const void *>I<caller>B<);>\n"
1308 #: build/C/man3/malloc_hook.3:26
1310 msgid "B<void (*__malloc_initialize_hook)(void);>\n"
1314 #: build/C/man3/malloc_hook.3:28
1316 msgid "B<void (*__after_morecore_hook)(void);>\n"
1320 #: build/C/man3/malloc_hook.3:39
1322 "The GNU C library lets you modify the behavior of B<malloc>(3), "
1323 "B<realloc>(3), and B<free>(3) by specifying appropriate hook functions. "
1324 "You can use these hooks to help you debug programs that use dynamic memory "
1325 "allocation, for example."
1329 #: build/C/man3/malloc_hook.3:46
1331 "The variable B<__malloc_initialize_hook> points at a function that is called "
1332 "once when the malloc implementation is initialized. This is a weak "
1333 "variable, so it can be overridden in the application with a definition like "
1338 #: build/C/man3/malloc_hook.3:49
1340 msgid " void (*__malloc_initialize_hook)(void) = my_init_hook;\n"
1344 #: build/C/man3/malloc_hook.3:54
1345 msgid "Now the function I<my_init_hook>() can do the initialization of all hooks."
1349 #: build/C/man3/malloc_hook.3:70
1351 "The four functions pointed to by B<__malloc_hook>, B<__realloc_hook>, "
1352 "B<__memalign_hook>, B<__free_hook> have a prototype like the functions "
1353 "B<malloc>(3), B<realloc>(3), B<memalign>(3), B<free>(3), respectively, "
1354 "except that they have a final argument I<caller> that gives the address of "
1355 "the caller of B<malloc>(3), etc."
1359 #: build/C/man3/malloc_hook.3:76
1361 "The variable B<__after_morecore_hook> points at a function that is called "
1362 "each time after B<sbrk>(2) was asked for more memory."
1366 #: build/C/man3/malloc_hook.3:78
1367 msgid "These functions are GNU extensions."
1370 #. https://bugzilla.redhat.com/show_bug.cgi?id=450187
1371 #. http://sourceware.org/bugzilla/show_bug.cgi?id=9957
1373 #: build/C/man3/malloc_hook.3:85
1375 "The use of these hook functions is not safe in multithreaded programs, and "
1376 "they are now deprecated. Programmers should instead preempt calls to the "
1377 "relevant functions by defining and exporting functions such as \"malloc\" "
1382 #: build/C/man3/malloc_hook.3:85 build/C/man2/mmap.2:567 build/C/man2/mprotect.2:142
1388 #: build/C/man3/malloc_hook.3:87
1389 msgid "Here is a short example of how to use these variables."
1393 #: build/C/man3/malloc_hook.3:91
1396 "#include E<lt>stdio.hE<gt>\n"
1397 "#include E<lt>malloc.hE<gt>\n"
1401 #: build/C/man3/malloc_hook.3:95
1404 "/* Prototypes for our hooks. */\n"
1405 "static void my_init_hook(void);\n"
1406 "static void *my_malloc_hook(size_t, const void *);\n"
1410 #: build/C/man3/malloc_hook.3:98
1413 "/* Variables to save original hooks. */\n"
1414 "static void *(*old_malloc_hook)(size_t, const void *);\n"
1418 #: build/C/man3/malloc_hook.3:101
1421 "/* Override initializing hook from the C library. */\n"
1422 "void (*__malloc_initialize_hook) (void) = my_init_hook;\n"
1426 #: build/C/man3/malloc_hook.3:108
1430 "my_init_hook(void)\n"
1432 " old_malloc_hook = __malloc_hook;\n"
1433 " __malloc_hook = my_malloc_hook;\n"
1438 #: build/C/man3/malloc_hook.3:113
1442 "my_malloc_hook(size_t size, const void *caller)\n"
1448 #: build/C/man3/malloc_hook.3:116
1451 " /* Restore all old hooks */\n"
1452 " __malloc_hook = old_malloc_hook;\n"
1456 #: build/C/man3/malloc_hook.3:119
1459 " /* Call recursively */\n"
1460 " result = malloc(size);\n"
1464 #: build/C/man3/malloc_hook.3:122
1467 " /* Save underlying hooks */\n"
1468 " old_malloc_hook = __malloc_hook;\n"
1472 #: build/C/man3/malloc_hook.3:126
1475 " /* printf() might call malloc(), so protect it too. */\n"
1476 " printf(\"malloc(%u) called from %p returns %p\\en\",\n"
1477 " (unsigned int) size, caller, result);\n"
1481 #: build/C/man3/malloc_hook.3:129
1484 " /* Restore our own hooks */\n"
1485 " __malloc_hook = my_malloc_hook;\n"
1489 #: build/C/man3/malloc_hook.3:132
1497 #: build/C/man3/malloc_hook.3:138
1498 msgid "B<mallinfo>(3), B<malloc>(3), B<mcheck>(3), B<mtrace>(3)"
1502 #: build/C/man2/mlock.2:27
1508 #: build/C/man2/mlock.2:27
1514 #: build/C/man2/mlock.2:30
1515 msgid "mlock, munlock, mlockall, munlockall - lock and unlock memory"
1519 #: 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
1521 msgid "B<#include E<lt>sys/mman.hE<gt>>\n"
1525 #: build/C/man2/mlock.2:36
1528 "B<int mlock(const void *>I<addr>B<, size_t >I<len>B<);>\n"
1529 "B<int munlock(const void *>I<addr>B<, size_t >I<len>B<);>\n"
1533 #: build/C/man2/mlock.2:39
1536 "B<int mlockall(int >I<flags>B<);>\n"
1537 "B<int munlockall(void);>\n"
1541 #: build/C/man2/mlock.2:55
1543 "B<mlock>() and B<mlockall>() respectively lock part or all of the calling "
1544 "process's virtual address space into RAM, preventing that memory from being "
1545 "paged to the swap area. B<munlock>() and B<munlockall>() perform the "
1546 "converse operation, respectively unlocking part or all of the calling "
1547 "process's virtual address space, so that pages in the specified virtual "
1548 "address range may once more to be swapped out if required by the kernel "
1549 "memory manager. Memory locking and unlocking are performed in units of "
1554 #: build/C/man2/mlock.2:55
1556 msgid "mlock() and munlock()"
1560 #: build/C/man2/mlock.2:65
1562 "B<mlock>() locks pages in the address range starting at I<addr> and "
1563 "continuing for I<len> bytes. All pages that contain a part of the specified "
1564 "address range are guaranteed to be resident in RAM when the call returns "
1565 "successfully; the pages are guaranteed to stay in RAM until later unlocked."
1569 #: build/C/man2/mlock.2:74
1571 "B<munlock>() unlocks pages in the address range starting at I<addr> and "
1572 "continuing for I<len> bytes. After this call, all pages that contain a part "
1573 "of the specified memory range can be moved to external swap space again by "
1578 #: build/C/man2/mlock.2:74
1580 msgid "mlockall() and munlockall()"
1584 #: build/C/man2/mlock.2:84
1586 "B<mlockall>() locks all pages mapped into the address space of the calling "
1587 "process. This includes the pages of the code, data and stack segment, as "
1588 "well as shared libraries, user space kernel data, shared memory, and "
1589 "memory-mapped files. All mapped pages are guaranteed to be resident in RAM "
1590 "when the call returns successfully; the pages are guaranteed to stay in RAM "
1591 "until later unlocked."
1595 #: build/C/man2/mlock.2:89
1597 "The I<flags> argument is constructed as the bitwise OR of one or more of the "
1598 "following constants:"
1602 #: build/C/man2/mlock.2:89
1604 msgid "B<MCL_CURRENT>"
1608 #: build/C/man2/mlock.2:93
1610 "Lock all pages which are currently mapped into the address space of the "
1615 #: build/C/man2/mlock.2:93
1617 msgid "B<MCL_FUTURE>"
1621 #: build/C/man2/mlock.2:100
1623 "Lock all pages which will become mapped into the address space of the "
1624 "process in the future. These could be for instance new pages required by a "
1625 "growing heap and stack as well as new memory mapped files or shared memory "
1630 #: build/C/man2/mlock.2:113
1632 "If B<MCL_FUTURE> has been specified, then a later system call (e.g., "
1633 "B<mmap>(2), B<sbrk>(2), B<malloc>(3)), may fail if it would cause the number "
1634 "of locked bytes to exceed the permitted maximum (see below). In the same "
1635 "circumstances, stack growth may likewise fail: the kernel will deny stack "
1636 "expansion and deliver a B<SIGSEGV> signal to the process."
1640 #: build/C/man2/mlock.2:117
1642 "B<munlockall>() unlocks all pages mapped into the address space of the "
1647 #: build/C/man2/mlock.2:123
1649 "On success these system calls return 0. On error, -1 is returned, I<errno> "
1650 "is set appropriately, and no changes are made to any locks in the address "
1651 "space of the process."
1655 #: build/C/man2/mlock.2:132
1657 "(Linux 2.6.9 and later) the caller had a nonzero B<RLIMIT_MEMLOCK> soft "
1658 "resource limit, but tried to lock more memory than the limit permitted. "
1659 "This limit is not enforced if the process is privileged (B<CAP_IPC_LOCK>)."
1662 #. In the case of mlock(), this check is somewhat buggy: it doesn't
1663 #. take into account whether the to-be-locked range overlaps with
1664 #. already locked pages. Thus, suppose we allocate
1665 #. (num_physpages / 4 + 1) of memory, and lock those pages once using
1666 #. mlock(), and then lock the *same* page range a second time.
1667 #. In the case, the second mlock() call will fail, since the check
1668 #. calculates that the process is trying to lock (num_physpages / 2 + 2)
1669 #. pages, which of course is not true. (MTK, Nov 04, kernel 2.4.28)
1671 #: build/C/man2/mlock.2:144
1673 "(Linux 2.4 and earlier) the calling process tried to lock more than half of "
1677 #. SVr4 documents an additional EAGAIN error code.
1679 #: build/C/man2/mlock.2:150
1681 "The caller is not privileged, but needs privilege (B<CAP_IPC_LOCK>) to "
1682 "perform the requested operation."
1686 #: build/C/man2/mlock.2:155
1687 msgid "For B<mlock>() and B<munlock>():"
1691 #: build/C/man2/mlock.2:158
1692 msgid "Some or all of the specified address range could not be locked."
1696 #: build/C/man2/mlock.2:165
1698 "The result of the addition I<start>+I<len> was less than I<start> (e.g., the "
1699 "addition may have resulted in an overflow)."
1703 #: build/C/man2/mlock.2:170
1704 msgid "(Not on Linux) I<addr> was not a multiple of the page size."
1708 #: build/C/man2/mlock.2:174
1710 "Some of the specified address range does not correspond to mapped pages in "
1711 "the address space of the process."
1715 #: build/C/man2/mlock.2:177
1716 msgid "For B<mlockall>():"
1720 #: build/C/man2/mlock.2:180
1721 msgid "Unknown I<flags> were specified."
1725 #: build/C/man2/mlock.2:183
1726 msgid "For B<munlockall>():"
1730 #: build/C/man2/mlock.2:187
1731 msgid "(Linux 2.6.8 and earlier) The caller was not privileged (B<CAP_IPC_LOCK>)."
1735 #: build/C/man2/mlock.2:189
1736 msgid "POSIX.1-2001, SVr4."
1740 #: build/C/man2/mlock.2:189 build/C/man2/mmap.2:487 build/C/man2/msync.2:105
1742 msgid "AVAILABILITY"
1746 #: build/C/man2/mlock.2:201
1748 "On POSIX systems on which B<mlock>() and B<munlock>() are available, "
1749 "B<_POSIX_MEMLOCK_RANGE> is defined in I<E<lt>unistd.hE<gt>> and the number "
1750 "of bytes in a page can be determined from the constant B<PAGESIZE> (if "
1751 "defined) in I<E<lt>limits.hE<gt>> or by calling I<sysconf(_SC_PAGESIZE)>."
1754 #. POSIX.1-2001: It shall be defined to -1 or 0 or 200112L.
1755 #. -1: unavailable, 0: ask using sysconf().
1756 #. glibc defines it to 1.
1758 #: build/C/man2/mlock.2:214
1760 "On POSIX systems on which B<mlockall>() and B<munlockall>() are available, "
1761 "B<_POSIX_MEMLOCK> is defined in I<E<lt>unistd.hE<gt>> to a value greater "
1762 "than 0. (See also B<sysconf>(3).)"
1766 #: build/C/man2/mlock.2:232
1768 "Memory locking has two main applications: real-time algorithms and "
1769 "high-security data processing. Real-time applications require deterministic "
1770 "timing, and, like scheduling, paging is one major cause of unexpected "
1771 "program execution delays. Real-time applications will usually also switch "
1772 "to a real-time scheduler with B<sched_setscheduler>(2). Cryptographic "
1773 "security software often handles critical bytes like passwords or secret keys "
1774 "as data structures. As a result of paging, these secrets could be "
1775 "transferred onto a persistent swap store medium, where they might be "
1776 "accessible to the enemy long after the security software has erased the "
1777 "secrets in RAM and terminated. (But be aware that the suspend mode on "
1778 "laptops and some desktop computers will save a copy of the system's RAM to "
1779 "disk, regardless of memory locks.)"
1783 #: build/C/man2/mlock.2:245
1785 "Real-time processes that are using B<mlockall>() to prevent delays on page "
1786 "faults should reserve enough locked stack pages before entering the "
1787 "time-critical section, so that no page fault can be caused by function "
1788 "calls. This can be achieved by calling a function that allocates a "
1789 "sufficiently large automatic variable (an array) and writes to the memory "
1790 "occupied by this array in order to touch these stack pages. This way, "
1791 "enough pages will be mapped for the stack and can be locked into RAM. The "
1792 "dummy writes ensure that not even copy-on-write page faults can occur in the "
1797 #: build/C/man2/mlock.2:251
1799 "Memory locks are not inherited by a child created via B<fork>(2) and are "
1800 "automatically removed (unlocked) during an B<execve>(2) or when the process "
1805 #: build/C/man2/mlock.2:255
1807 "The memory lock on an address range is automatically removed if the address "
1808 "range is unmapped via B<munmap>(2)."
1812 #: build/C/man2/mlock.2:268
1814 "Memory locks do not stack, that is, pages which have been locked several "
1815 "times by calls to B<mlock>() or B<mlockall>() will be unlocked by a single "
1816 "call to B<munlock>() for the corresponding range or by B<munlockall>(). "
1817 "Pages which are mapped to several locations or by several processes stay "
1818 "locked into RAM as long as they are locked at least at one location or by at "
1819 "least one process."
1823 #: build/C/man2/mlock.2:279
1825 "Under Linux, B<mlock>() and B<munlock>() automatically round I<addr> down "
1826 "to the nearest page boundary. However, POSIX.1-2001 allows an "
1827 "implementation to require that I<addr> is page aligned, so portable "
1828 "applications should ensure this."
1832 #: build/C/man2/mlock.2:292
1834 "The I<VmLck> field of the Linux-specific I</proc/PID/status> file shows how "
1835 "many kilobytes of memory the process with ID I<PID> has locked using "
1836 "B<mlock>(), B<mlockall>(), and B<mmap>(2) B<MAP_LOCKED>."
1840 #: build/C/man2/mlock.2:292
1842 msgid "Limits and permissions"
1846 #: build/C/man2/mlock.2:299
1848 "In Linux 2.6.8 and earlier, a process must be privileged (B<CAP_IPC_LOCK>) "
1849 "in order to lock memory and the B<RLIMIT_MEMLOCK> soft resource limit "
1850 "defines a limit on how much memory the process may lock."
1854 #: build/C/man2/mlock.2:305
1856 "Since Linux 2.6.9, no limits are placed on the amount of memory that a "
1857 "privileged process can lock and the B<RLIMIT_MEMLOCK> soft resource limit "
1858 "instead defines a limit on how much memory an unprivileged process may lock."
1862 #: build/C/man2/mlock.2:313
1864 "In the 2.4 series Linux kernels up to and including 2.4.17, a bug caused the "
1865 "B<mlockall>() B<MCL_FUTURE> flag to be inherited across a B<fork>(2). This "
1866 "was rectified in kernel 2.4.18."
1869 #. See the following LKML thread:
1870 #. http://marc.theaimsgroup.com/?l=linux-kernel&m=113801392825023&w=2
1871 #. "Rationale for RLIMIT_MEMLOCK"
1874 #: build/C/man2/mlock.2:330
1876 "Since kernel 2.6.9, if a privileged process calls I<mlockall(MCL_FUTURE)> "
1877 "and later drops privileges (loses the B<CAP_IPC_LOCK> capability by, for "
1878 "example, setting its effective UID to a nonzero value), then subsequent "
1879 "memory allocations (e.g., B<mmap>(2), B<brk>(2)) will fail if the "
1880 "B<RLIMIT_MEMLOCK> resource limit is encountered."
1884 #: build/C/man2/mlock.2:337
1886 "B<mmap>(2), B<setrlimit>(2), B<shmctl>(2), B<sysconf>(3), B<proc>(5), "
1887 "B<capabilities>(7)"
1891 #: build/C/man2/mmap.2:40
1897 #: build/C/man2/mmap.2:40
1903 #: build/C/man2/mmap.2:43
1904 msgid "mmap, munmap - map or unmap files or devices into memory"
1908 #: build/C/man2/mmap.2:51
1911 "B<void *mmap(void *>I<addr>B<, size_t >I<length>B<, int >I<prot>B<, int "
1913 "B< int >I<fd>B<, off_t >I<offset>B<);>\n"
1914 "B<int munmap(void *>I<addr>B<, size_t >I<length>B<);>\n"
1918 #: build/C/man2/mmap.2:61
1920 "B<mmap>() creates a new mapping in the virtual address space of the calling "
1921 "process. The starting address for the new mapping is specified in I<addr>. "
1922 "The I<length> argument specifies the length of the mapping."
1925 #. Before Linux 2.6.24, the address was rounded up to the next page
1926 #. boundary; since 2.6.24, it is rounded down!
1928 #: build/C/man2/mmap.2:75
1930 "If I<addr> is NULL, then the kernel chooses the address at which to create "
1931 "the mapping; this is the most portable method of creating a new mapping. If "
1932 "I<addr> is not NULL, then the kernel takes it as a hint about where to place "
1933 "the mapping; on Linux, the mapping will be created at a nearby page "
1934 "boundary. The address of the new mapping is returned as the result of the "
1939 #: build/C/man2/mmap.2:87
1941 "The contents of a file mapping (as opposed to an anonymous mapping; see "
1942 "B<MAP_ANONYMOUS> below), are initialized using I<length> bytes starting at "
1943 "offset I<offset> in the file (or other object) referred to by the file "
1944 "descriptor I<fd>. I<offset> must be a multiple of the page size as returned "
1945 "by I<sysconf(_SC_PAGE_SIZE)>."
1949 #: build/C/man2/mmap.2:95
1951 "The I<prot> argument describes the desired memory protection of the mapping "
1952 "(and must not conflict with the open mode of the file). It is either "
1953 "B<PROT_NONE> or the bitwise OR of one or more of the following flags:"
1957 #: build/C/man2/mmap.2:95 build/C/man2/mprotect.2:67
1959 msgid "B<PROT_EXEC>"
1963 #: build/C/man2/mmap.2:98
1964 msgid "Pages may be executed."
1968 #: build/C/man2/mmap.2:98 build/C/man2/mprotect.2:61
1970 msgid "B<PROT_READ>"
1974 #: build/C/man2/mmap.2:101
1975 msgid "Pages may be read."
1979 #: build/C/man2/mmap.2:101 build/C/man2/mprotect.2:64
1981 msgid "B<PROT_WRITE>"
1985 #: build/C/man2/mmap.2:104
1986 msgid "Pages may be written."
1990 #: build/C/man2/mmap.2:104 build/C/man2/mprotect.2:58
1992 msgid "B<PROT_NONE>"
1996 #: build/C/man2/mmap.2:107
1997 msgid "Pages may not be accessed."
2001 #: build/C/man2/mmap.2:116
2003 "The I<flags> argument determines whether updates to the mapping are visible "
2004 "to other processes mapping the same region, and whether updates are carried "
2005 "through to the underlying file. This behavior is determined by including "
2006 "exactly one of the following values in I<flags>:"
2010 #: build/C/man2/mmap.2:116
2012 msgid "B<MAP_SHARED>"
2016 #: build/C/man2/mmap.2:126
2018 "Share this mapping. Updates to the mapping are visible to other processes "
2019 "that map this file, and are carried through to the underlying file. The "
2020 "file may not actually be updated until B<msync>(2) or B<munmap>() is "
2025 #: build/C/man2/mmap.2:126
2027 msgid "B<MAP_PRIVATE>"
2031 #: build/C/man2/mmap.2:135
2033 "Create a private copy-on-write mapping. Updates to the mapping are not "
2034 "visible to other processes mapping the same file, and are not carried "
2035 "through to the underlying file. It is unspecified whether changes made to "
2036 "the file after the B<mmap>() call are visible in the mapped region."
2040 #: build/C/man2/mmap.2:137
2041 msgid "Both of these flags are described in POSIX.1-2001."
2045 #: build/C/man2/mmap.2:140
2046 msgid "In addition, zero or more of the following values can be ORed in I<flags>:"
2050 #: build/C/man2/mmap.2:140
2052 msgid "B<MAP_32BIT> (since Linux 2.4.20, 2.6)"
2055 #. See http://lwn.net/Articles/294642 "Tangled up in threads", 19 Aug 08
2057 #: build/C/man2/mmap.2:156
2059 "Put the mapping into the first 2 Gigabytes of the process address space. "
2060 "This flag is only supported on x86-64, for 64-bit programs. It was added to "
2061 "allow thread stacks to be allocated somewhere in the first 2GB of memory, so "
2062 "as to improve context-switch performance on some early 64-bit processors. "
2063 "Modern x86-64 processors no longer have this performance problem, so use of "
2064 "this flag is not required on those systems. The B<MAP_32BIT> flag is "
2065 "ignored when B<MAP_FIXED> is set."
2069 #: build/C/man2/mmap.2:156
2075 #: build/C/man2/mmap.2:161
2076 msgid "Synonym for B<MAP_ANONYMOUS>. Deprecated."
2080 #: build/C/man2/mmap.2:161
2082 msgid "B<MAP_ANONYMOUS>"
2086 #: build/C/man2/mmap.2:183
2088 "The mapping is not backed by any file; its contents are initialized to "
2089 "zero. The I<fd> and I<offset> arguments are ignored; however, some "
2090 "implementations require I<fd> to be -1 if B<MAP_ANONYMOUS> (or B<MAP_ANON>) "
2091 "is specified, and portable applications should ensure this. The use of "
2092 "B<MAP_ANONYMOUS> in conjunction with B<MAP_SHARED> is only supported on "
2093 "Linux since kernel 2.4."
2097 #: build/C/man2/mmap.2:183
2099 msgid "B<MAP_DENYWRITE>"
2102 #. Introduced in 1.1.36, removed in 1.3.24.
2104 #: build/C/man2/mmap.2:191
2106 "This flag is ignored. (Long ago, it signaled that attempts to write to the "
2107 "underlying file should fail with B<ETXTBUSY>. But this was a source of "
2108 "denial-of-service attacks.)"
2112 #: build/C/man2/mmap.2:191
2114 msgid "B<MAP_EXECUTABLE>"
2117 #. Introduced in 1.1.38, removed in 1.3.24. Flag tested in proc_follow_link.
2118 #. (Long ago, it signaled that the underlying file is an executable.
2119 #. However, that information was not really used anywhere.)
2120 #. Linus talked about DOS related to MAP_EXECUTABLE, but he was thinking of
2123 #: build/C/man2/mmap.2:199
2124 msgid "This flag is ignored."
2128 #: build/C/man2/mmap.2:199
2133 #. On some systems, this was required as the opposite of
2134 #. MAP_ANONYMOUS -- mtk, 1 May 2007
2136 #: build/C/man2/mmap.2:205
2137 msgid "Compatibility flag. Ignored."
2141 #: build/C/man2/mmap.2:205
2143 msgid "B<MAP_FIXED>"
2147 #: build/C/man2/mmap.2:223
2149 "Don't interpret I<addr> as a hint: place the mapping at exactly that "
2150 "address. I<addr> must be a multiple of the page size. If the memory region "
2151 "specified by I<addr> and I<len> overlaps pages of any existing mapping(s), "
2152 "then the overlapped part of the existing mapping(s) will be discarded. If "
2153 "the specified address cannot be used, B<mmap>() will fail. Because "
2154 "requiring a fixed address for a mapping is less portable, the use of this "
2155 "option is discouraged."
2159 #: build/C/man2/mmap.2:223
2161 msgid "B<MAP_GROWSDOWN>"
2165 #: build/C/man2/mmap.2:228
2167 "Used for stacks. Indicates to the kernel virtual memory system that the "
2168 "mapping should extend downward in memory."
2172 #: build/C/man2/mmap.2:228
2174 msgid "B<MAP_HUGETLB> (since Linux 2.6.32)"
2178 #: build/C/man2/mmap.2:234
2180 "Allocate the mapping using \"huge pages.\" See the kernel source file "
2181 "I<Documentation/vm/hugetlbpage.txt> for further information."
2185 #: build/C/man2/mmap.2:234
2187 msgid "B<MAP_LOCKED> (since Linux 2.5.37)"
2190 #. If set, the mapped pages will not be swapped out.
2192 #: build/C/man2/mmap.2:240
2194 "Lock the pages of the mapped region into memory in the manner of "
2195 "B<mlock>(2). This flag is ignored in older kernels."
2199 #: build/C/man2/mmap.2:240
2201 msgid "B<MAP_NONBLOCK> (since Linux 2.5.46)"
2205 #: build/C/man2/mmap.2:255
2207 "Only meaningful in conjunction with B<MAP_POPULATE>. Don't perform "
2208 "read-ahead: only create page tables entries for pages that are already "
2209 "present in RAM. Since Linux 2.6.23, this flag causes B<MAP_POPULATE> to do "
2210 "nothing. One day the combination of B<MAP_POPULATE> and B<MAP_NONBLOCK> may "
2215 #: build/C/man2/mmap.2:255
2217 msgid "B<MAP_NORESERVE>"
2221 #: build/C/man2/mmap.2:270
2223 "Do not reserve swap space for this mapping. When swap space is reserved, "
2224 "one has the guarantee that it is possible to modify the mapping. When swap "
2225 "space is not reserved one might get B<SIGSEGV> upon a write if no physical "
2226 "memory is available. See also the discussion of the file "
2227 "I</proc/sys/vm/overcommit_memory> in B<proc>(5). In kernels before 2.6, "
2228 "this flag only had effect for private writable mappings."
2232 #: build/C/man2/mmap.2:270
2234 msgid "B<MAP_POPULATE> (since Linux 2.5.46)"
2238 #: build/C/man2/mmap.2:277
2240 "Populate (prefault) page tables for a mapping. For a file mapping, this "
2241 "causes read-ahead on the file. Later accesses to the mapping will not be "
2242 "blocked by page faults. B<MAP_POPULATE> is only supported for private "
2243 "mappings since Linux 2.6.23."
2247 #: build/C/man2/mmap.2:277
2249 msgid "B<MAP_STACK> (since Linux 2.6.27)"
2252 #. See http://lwn.net/Articles/294642 "Tangled up in threads", 19 Aug 08
2253 #. commit cd98a04a59e2f94fa64d5bf1e26498d27427d5e7
2254 #. http://thread.gmane.org/gmane.linux.kernel/720412
2255 #. "pthread_create() slow for many threads; also time to revisit 64b
2256 #. context switch optimization?"
2258 #: build/C/man2/mmap.2:290
2260 "Allocate the mapping at an address suitable for a process or thread stack. "
2261 "This flag is currently a no-op, but is used in the glibc threading "
2262 "implementation so that if some architectures require special treatment for "
2263 "stack allocations, support can later be transparently implemented for glibc."
2267 #: build/C/man2/mmap.2:290
2269 msgid "B<MAP_UNINITIALIZED> (since Linux 2.6.33)"
2273 #: build/C/man2/mmap.2:300
2275 "Don't clear anonymous pages. This flag is intended to improve performance "
2276 "on embedded devices. This flag is only honored if the kernel was configured "
2277 "with the B<CONFIG_MMAP_ALLOW_UNINITIALIZED> option. Because of the security "
2278 "implications, that option is normally enabled only on embedded devices "
2279 "(i.e., devices where one has complete control of the contents of user "
2284 #: build/C/man2/mmap.2:308
2286 "Of the above flags, only B<MAP_FIXED> is specified in POSIX.1-2001. "
2287 "However, most systems also support B<MAP_ANONYMOUS> (or its synonym "
2292 #: build/C/man2/mmap.2:315
2294 "Some systems document the additional flags B<MAP_AUTOGROW>, "
2295 "B<MAP_AUTORESRV>, B<MAP_COPY>, and B<MAP_LOCAL>."
2299 #: build/C/man2/mmap.2:321
2301 "Memory mapped by B<mmap>() is preserved across B<fork>(2), with the same "
2306 #: build/C/man2/mmap.2:329
2308 "A file is mapped in multiples of the page size. For a file that is not a "
2309 "multiple of the page size, the remaining memory is zeroed when mapped, and "
2310 "writes to that region are not written out to the file. The effect of "
2311 "changing the size of the underlying file of a mapping on the pages that "
2312 "correspond to added or removed regions of the file is unspecified."
2316 #: build/C/man2/mmap.2:329
2322 #: build/C/man2/mmap.2:339
2324 "The B<munmap>() system call deletes the mappings for the specified address "
2325 "range, and causes further references to addresses within the range to "
2326 "generate invalid memory references. The region is also automatically "
2327 "unmapped when the process is terminated. On the other hand, closing the "
2328 "file descriptor does not unmap the region."
2332 #: build/C/man2/mmap.2:349
2334 "The address I<addr> must be a multiple of the page size. All pages "
2335 "containing a part of the indicated range are unmapped, and subsequent "
2336 "references to these pages will generate B<SIGSEGV>. It is not an error if "
2337 "the indicated range does not contain any mapped pages."
2341 #: build/C/man2/mmap.2:349
2343 msgid "Timestamps changes for file-backed mappings"
2347 #: build/C/man2/mmap.2:356
2349 "For file-backed mappings, the I<st_atime> field for the mapped file may be "
2350 "updated at any time between the B<mmap>() and the corresponding unmapping; "
2351 "the first reference to a mapped page will update the field if it has not "
2356 #: build/C/man2/mmap.2:373
2358 "The I<st_ctime> and I<st_mtime> field for a file mapped with B<PROT_WRITE> "
2359 "and B<MAP_SHARED> will be updated after a write to the mapped region, and "
2360 "before a subsequent B<msync>(2) with the B<MS_SYNC> or B<MS_ASYNC> flag, if "
2365 #: build/C/man2/mmap.2:390
2367 "On success, B<mmap>() returns a pointer to the mapped area. On error, the "
2368 "value B<MAP_FAILED> (that is, I<(void\\ *)\\ -1>) is returned, and I<errno> "
2369 "is set appropriately. On success, B<munmap>() returns 0, on failure -1, "
2370 "and I<errno> is set (probably to B<EINVAL>)."
2374 #: 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
2380 #: build/C/man2/mmap.2:411
2382 "A file descriptor refers to a non-regular file. Or B<MAP_PRIVATE> was "
2383 "requested, but I<fd> is not open for reading. Or B<MAP_SHARED> was "
2384 "requested and B<PROT_WRITE> is set, but I<fd> is not open in read/write "
2385 "(B<O_RDWR>) mode. Or B<PROT_WRITE> is set, but the file is append-only."
2389 #: build/C/man2/mmap.2:415
2391 "The file has been locked, or too much memory has been locked (see "
2396 #: build/C/man2/mmap.2:421
2397 msgid "I<fd> is not a valid file descriptor (and B<MAP_ANONYMOUS> was not set)."
2401 #: build/C/man2/mmap.2:429
2403 "We don't like I<addr>, I<length>, or I<offset> (e.g., they are too large, or "
2404 "not aligned on a page boundary)."
2408 #: build/C/man2/mmap.2:434
2409 msgid "(since Linux 2.6.12) I<length> was 0."
2413 #: build/C/man2/mmap.2:442
2415 "I<flags> contained neither B<MAP_PRIVATE> or B<MAP_SHARED>, or contained "
2416 "both of these values."
2420 #: build/C/man2/mmap.2:442 build/C/man3/shm_open.3:227 build/C/man2/shmget.2:202
2425 #. [2.6.7] shmem_zero_setup()-->shmem_file_setup()-->get_empty_filp()
2427 #: build/C/man2/mmap.2:450 build/C/man2/shmget.2:206
2428 msgid "The system limit on the total number of open files has been reached."
2432 #: build/C/man2/mmap.2:454
2434 "The underlying file system of the specified file does not support memory "
2439 #: build/C/man2/mmap.2:458
2441 "No memory is available, or the process's maximum number of mappings would "
2442 "have been exceeded."
2445 #. (Since 2.4.25 / 2.6.0.)
2447 #: build/C/man2/mmap.2:467
2449 "The I<prot> argument asks for B<PROT_EXEC> but the mapped area belongs to a "
2450 "file on a file system that was mounted no-exec."
2454 #: build/C/man2/mmap.2:467
2460 #: build/C/man2/mmap.2:473
2462 "B<MAP_DENYWRITE> was set but the object specified by I<fd> is open for "
2467 #: build/C/man2/mmap.2:475
2468 msgid "Use of a mapped region can result in these signals:"
2472 #: build/C/man2/mmap.2:475
2478 #: build/C/man2/mmap.2:478
2479 msgid "Attempted write into a region mapped as read-only."
2483 #: build/C/man2/mmap.2:478
2489 #: build/C/man2/mmap.2:483
2491 "Attempted access to a portion of the buffer that does not correspond to the "
2492 "file (for example, beyond the end of the file, including the case where "
2493 "another process has truncated the file)."
2496 #. SVr4 documents additional error codes ENXIO and ENODEV.
2497 #. SUSv2 documents additional error codes EMFILE and EOVERFLOW.
2499 #: build/C/man2/mmap.2:487
2500 msgid "SVr4, 4.4BSD, POSIX.1-2001."
2503 #. POSIX.1-2001: It shall be defined to -1 or 0 or 200112L.
2504 #. -1: unavailable, 0: ask using sysconf().
2505 #. glibc defines it to 1.
2507 #: build/C/man2/mmap.2:501
2509 "On POSIX systems on which B<mmap>(), B<msync>(2) and B<munmap>() are "
2510 "available, B<_POSIX_MAPPED_FILES> is defined in I<E<lt>unistd.hE<gt>> to a "
2511 "value greater than 0. (See also B<sysconf>(3).)"
2514 #. Since around glibc 2.1/2.2, depending on the platform.
2516 #: build/C/man2/mmap.2:512
2518 "Since kernel 2.4, this system call has been superseded by B<mmap2>(2). "
2519 "Nowadays, the glibc B<mmap>() wrapper function invokes B<mmap2>(2) with a "
2520 "suitably adjusted value for I<offset>."
2524 #: build/C/man2/mmap.2:525
2526 "On some hardware architectures (e.g., i386), B<PROT_WRITE> implies "
2527 "B<PROT_READ>. It is architecture dependent whether B<PROT_READ> implies "
2528 "B<PROT_EXEC> or not. Portable programs should always set B<PROT_EXEC> if "
2529 "they intend to execute code in the new mapping."
2533 #: build/C/man2/mmap.2:540
2535 "The portable way to create a mapping is to specify I<addr> as 0 (NULL), and "
2536 "omit B<MAP_FIXED> from I<flags>. In this case, the system chooses the "
2537 "address for the mapping; the address is chosen so as not to conflict with "
2538 "any existing mapping, and will not be 0. If the B<MAP_FIXED> flag is "
2539 "specified, and I<addr> is 0 (NULL), then the mapped address will be 0 "
2544 #: build/C/man2/mmap.2:545
2546 "On Linux there are no guarantees like those suggested above under "
2547 "B<MAP_NORESERVE>. By default, any process can be killed at any moment when "
2548 "the system runs out of memory."
2552 #: build/C/man2/mmap.2:552
2554 "In kernels before 2.6.7, the B<MAP_POPULATE> flag only has effect if I<prot> "
2555 "is specified as B<PROT_NONE>."
2559 #: build/C/man2/mmap.2:567
2561 "SUSv3 specifies that B<mmap>() should fail if I<length> is 0. However, in "
2562 "kernels before 2.6.12, B<mmap>() succeeded in this case: no mapping was "
2563 "created and the call returned I<addr>. Since kernel 2.6.12, B<mmap>() "
2564 "fails with the error B<EINVAL> for this case."
2568 #: build/C/man2/mmap.2:579
2570 "The following program prints part of the file specified in its first "
2571 "command-line argument to standard output. The range of bytes to be printed "
2572 "is specified via offset and length values in the second and third "
2573 "command-line arguments. The program creates a memory mapping of the "
2574 "required pages of the file and then uses B<write>(2) to output the desired "
2579 #: build/C/man2/mmap.2:587
2582 "#include E<lt>sys/mman.hE<gt>\n"
2583 "#include E<lt>sys/stat.hE<gt>\n"
2584 "#include E<lt>fcntl.hE<gt>\n"
2585 "#include E<lt>stdio.hE<gt>\n"
2586 "#include E<lt>stdlib.hE<gt>\n"
2587 "#include E<lt>unistd.hE<gt>\n"
2591 #: build/C/man2/mmap.2:590 build/C/man2/mprotect.2:172
2594 "#define handle_error(msg) \\e\n"
2595 " do { perror(msg); exit(EXIT_FAILURE); } while (0)\n"
2599 #: build/C/man2/mmap.2:600
2603 "main(int argc, char *argv[])\n"
2607 " struct stat sb;\n"
2608 " off_t offset, pa_offset;\n"
2614 #: build/C/man2/mmap.2:605
2617 " if (argc E<lt> 3 || argc E<gt> 4) {\n"
2618 " fprintf(stderr, \"%s file offset [length]\\en\", argv[0]);\n"
2619 " exit(EXIT_FAILURE);\n"
2624 #: build/C/man2/mmap.2:609
2627 " fd = open(argv[1], O_RDONLY);\n"
2629 " handle_error(\"open\");\n"
2633 #: build/C/man2/mmap.2:612
2636 " if (fstat(fd, &sb) == -1) /* To obtain file size */\n"
2637 " handle_error(\"fstat\");\n"
2641 #: build/C/man2/mmap.2:616
2644 " offset = atoi(argv[2]);\n"
2645 " pa_offset = offset & ~(sysconf(_SC_PAGE_SIZE) - 1);\n"
2646 " /* offset for mmap() must be page aligned */\n"
2650 #: build/C/man2/mmap.2:621
2653 " if (offset E<gt>= sb.st_size) {\n"
2654 " fprintf(stderr, \"offset is past end of file\\en\");\n"
2655 " exit(EXIT_FAILURE);\n"
2660 #: build/C/man2/mmap.2:627
2663 " if (argc == 4) {\n"
2664 " length = atoi(argv[3]);\n"
2665 " if (offset + length E<gt> sb.st_size)\n"
2666 " length = sb.st_size - offset;\n"
2667 " /* Can\\(aqt display bytes past end of file */\n"
2671 #: build/C/man2/mmap.2:631
2674 " } else { /* No length arg ==E<gt> display to end of file */\n"
2675 " length = sb.st_size - offset;\n"
2680 #: build/C/man2/mmap.2:636
2683 " addr = mmap(NULL, length + offset - pa_offset, PROT_READ,\n"
2684 " MAP_PRIVATE, fd, pa_offset);\n"
2685 " if (addr == MAP_FAILED)\n"
2686 " handle_error(\"mmap\");\n"
2690 #: build/C/man2/mmap.2:641
2693 " s = write(STDOUT_FILENO, addr + offset - pa_offset, length);\n"
2694 " if (s != length) {\n"
2696 " handle_error(\"write\");\n"
2700 #: build/C/man2/mmap.2:645
2703 " fprintf(stderr, \"partial write\");\n"
2704 " exit(EXIT_FAILURE);\n"
2709 #: build/C/man2/mmap.2:648
2712 " exit(EXIT_SUCCESS);\n"
2717 #: build/C/man2/mmap.2:662
2719 "B<getpagesize>(2), B<mincore>(2), B<mlock>(2), B<mmap2>(2), B<mprotect>(2), "
2720 "B<mremap>(2), B<msync>(2), B<remap_file_pages>(2), B<setrlimit>(2), "
2721 "B<shmat>(2), B<shm_open>(3), B<shm_overview>(7)"
2725 #: build/C/man2/mmap.2:667 build/C/man2/msync.2:122
2726 msgid "B.O. Gallmeister, POSIX.4, O'Reilly, pp. 128-129 and 389-391."
2730 #: build/C/man2/mmap2.2:29
2736 #: build/C/man2/mmap2.2:29 build/C/man2/msync.2:25 build/C/man2/remap_file_pages.2:26
2742 #: build/C/man2/mmap2.2:32
2743 msgid "mmap2 - map files or devices into memory"
2747 #: build/C/man2/mmap2.2:38
2750 "B<void *mmap2(void *>I<addr>B<, size_t >I<length>B<, int >I<prot>B<,>\n"
2751 "B< int >I<flags>B<, int >I<fd>B<, off_t >I<pgoffset>B<);>\n"
2755 #: build/C/man2/mmap2.2:50
2757 "The B<mmap2>() system call operates in exactly the same way as B<mmap>(2), "
2758 "except that the final argument specifies the offset into the file in "
2759 "4096-byte units (instead of bytes, as is done by B<mmap>(2)). This enables "
2760 "applications that use a 32-bit I<off_t> to map large files (up to 2^44 "
2765 #: build/C/man2/mmap2.2:57
2767 "On success, B<mmap2>() returns a pointer to the mapped area. On error -1 "
2768 "is returned and I<errno> is set appropriately."
2772 #: build/C/man2/mmap2.2:61
2773 msgid "Problem with getting the data from userspace."
2777 #: build/C/man2/mmap2.2:66
2779 "(Various platforms where the page size is not 4096 bytes.) I<offset * 4096> "
2780 "is not a multiple of the system page size."
2784 #: build/C/man2/mmap2.2:70
2785 msgid "B<mmap2>() can return any of the same errors as B<mmap>(2)."
2789 #: build/C/man2/mmap2.2:73
2790 msgid "B<mmap2>() is available since Linux 2.3.31."
2794 #: build/C/man2/mmap2.2:75 build/C/man2/subpage_prot.2:93
2795 msgid "This system call is Linux-specific."
2799 #: build/C/man2/mmap2.2:81
2801 "Nowadays, the glibc B<mmap>() wrapper function invokes this system call "
2802 "rather than the B<mmap>(2) system call."
2805 #. ia64 can have page sizes ranging from 4kB to 64kB.
2806 #. On cris, it looks like the unit might also be the page size,
2807 #. which is 8192 bytes. -- mtk, June 2007
2809 #: build/C/man2/mmap2.2:88
2811 "On ia64, the unit for I<offset> is actually the system page size, rather "
2816 #: build/C/man2/mmap2.2:94
2817 msgid "B<getpagesize>(2), B<mmap>(2), B<mremap>(2), B<msync>(2), B<shm_open>(3)"
2821 #: build/C/man2/mprotect.2:32
2827 #: build/C/man2/mprotect.2:32
2833 #: build/C/man2/mprotect.2:35
2834 msgid "mprotect - set protection on a region of memory"
2838 #: build/C/man2/mprotect.2:40
2840 msgid "B<int mprotect(const void *>I<addr>B<, size_t >I<len>B<, int >I<prot>B<);>\n"
2844 #: build/C/man2/mprotect.2:48
2846 "B<mprotect>() changes protection for the calling process's memory page(s) "
2847 "containing any part of the address range in the interval [I<addr>,\\ "
2848 "I<addr>+I<len>-1]. I<addr> must be aligned to a page boundary."
2852 #: build/C/man2/mprotect.2:53
2854 "If the calling process tries to access memory in a manner that violates the "
2855 "protection, then the kernel generates a B<SIGSEGV> signal for the process."
2859 #: build/C/man2/mprotect.2:58
2861 "I<prot> is either B<PROT_NONE> or a bitwise-or of the other values in the "
2866 #: build/C/man2/mprotect.2:61
2867 msgid "The memory cannot be accessed at all."
2871 #: build/C/man2/mprotect.2:64
2872 msgid "The memory can be read."
2876 #: build/C/man2/mprotect.2:67
2877 msgid "The memory can be modified."
2881 #. Document PROT_GROWSUP and PROT_GROWSDOWN
2883 #: build/C/man2/mprotect.2:72
2884 msgid "The memory can be executed."
2888 #: build/C/man2/mprotect.2:79
2890 "On success, B<mprotect>() returns zero. On error, -1 is returned, and "
2891 "I<errno> is set appropriately."
2895 #: build/C/man2/mprotect.2:89
2897 "The memory cannot be given the specified access. This can happen, for "
2898 "example, if you B<mmap>(2) a file to which you have read-only access, then "
2899 "ask B<mprotect>() to mark it B<PROT_WRITE>."
2902 #. Or: both PROT_GROWSUP and PROT_GROWSDOWN were specified in 'prot'.
2904 #: build/C/man2/mprotect.2:94
2905 msgid "I<addr> is not a valid pointer, or not a multiple of the system page size."
2909 #: build/C/man2/mprotect.2:97
2910 msgid "Internal kernel structures could not be allocated."
2914 #: build/C/man2/mprotect.2:107
2916 "Addresses in the range [I<addr>, I<addr>+I<len>-1] are invalid for the "
2917 "address space of the process, or specify one or more pages that are not "
2918 "mapped. (Before kernel 2.4.19, the error B<EFAULT> was incorrectly produced "
2922 #. SVr4 defines an additional error
2923 #. code EAGAIN. The SVr4 error conditions don't map neatly onto Linux's.
2925 #: build/C/man2/mprotect.2:116
2927 "SVr4, POSIX.1-2001. POSIX says that the behavior of B<mprotect>() is "
2928 "unspecified if it is applied to a region of memory that was not obtained via "
2933 #: build/C/man2/mprotect.2:123
2935 "On Linux it is always permissible to call B<mprotect>() on any address in a "
2936 "process's address space (except for the kernel vsyscall area). In "
2937 "particular it can be used to change existing code mappings to be writable."
2941 #: build/C/man2/mprotect.2:133
2943 "Whether B<PROT_EXEC> has any effect different from B<PROT_READ> is "
2944 "architecture- and kernel version-dependent. On some hardware architectures "
2945 "(e.g., i386), B<PROT_WRITE> implies B<PROT_READ>."
2949 #: build/C/man2/mprotect.2:142
2951 "POSIX.1-2001 says that an implementation may permit access other than that "
2952 "specified in I<prot>, but at a minimum can only allow write access if "
2953 "B<PROT_WRITE> has been set, and must not allow any access if B<PROT_NONE> "
2958 #: build/C/man2/mprotect.2:148
2960 "The program below allocates four pages of memory, makes the third of these "
2961 "pages read-only, and then executes a loop that walks upward through the "
2962 "allocated region modifying bytes."
2966 #: build/C/man2/mprotect.2:151
2967 msgid "An example of what we might see when running the program is the following:"
2971 #: build/C/man2/mprotect.2:157
2975 "Start of region: 0x804c000\n"
2976 "Got SIGSEGV at address: 0x804e000\n"
2980 #: build/C/man2/mprotect.2:159
2982 msgid "Program source"
2986 #: build/C/man2/mprotect.2:169
2989 "#include E<lt>unistd.hE<gt>\n"
2990 "#include E<lt>signal.hE<gt>\n"
2991 "#include E<lt>stdio.hE<gt>\n"
2992 "#include E<lt>malloc.hE<gt>\n"
2993 "#include E<lt>stdlib.hE<gt>\n"
2994 "#include E<lt>errno.hE<gt>\n"
2995 "#include E<lt>sys/mman.hE<gt>\n"
2999 #: build/C/man2/mprotect.2:174
3001 msgid "char *buffer;\n"
3005 #: build/C/man2/mprotect.2:182
3009 "handler(int sig, siginfo_t *si, void *unused)\n"
3011 " printf(\"Got SIGSEGV at address: 0x%lx\\en\",\n"
3012 " (long) si-E<gt>si_addr);\n"
3013 " exit(EXIT_FAILURE);\n"
3018 #: build/C/man2/mprotect.2:189
3022 "main(int argc, char *argv[])\n"
3026 " struct sigaction sa;\n"
3030 #: build/C/man2/mprotect.2:195
3033 " sa.sa_flags = SA_SIGINFO;\n"
3034 " sigemptyset(&sa.sa_mask);\n"
3035 " sa.sa_sigaction = handler;\n"
3036 " if (sigaction(SIGSEGV, &sa, NULL) == -1)\n"
3037 " handle_error(\"sigaction\");\n"
3041 #: build/C/man2/mprotect.2:199
3044 " pagesize = sysconf(_SC_PAGE_SIZE);\n"
3045 " if (pagesize == -1)\n"
3046 " handle_error(\"sysconf\");\n"
3050 #: build/C/man2/mprotect.2:202
3053 " /* Allocate a buffer aligned on a page boundary;\n"
3054 " initial protection is PROT_READ | PROT_WRITE */\n"
3058 #: build/C/man2/mprotect.2:206
3061 " buffer = memalign(pagesize, 4 * pagesize);\n"
3062 " if (buffer == NULL)\n"
3063 " handle_error(\"memalign\");\n"
3067 #: build/C/man2/mprotect.2:208
3069 msgid " printf(\"Start of region: 0x%lx\\en\", (long) buffer);\n"
3073 #: build/C/man2/mprotect.2:212
3076 " if (mprotect(buffer + pagesize * 2, pagesize,\n"
3077 " PROT_READ) == -1)\n"
3078 " handle_error(\"mprotect\");\n"
3082 #: build/C/man2/mprotect.2:215
3085 " for (p = buffer ; ; )\n"
3086 " *(p++) = \\(aqa\\(aq;\n"
3090 #: build/C/man2/mprotect.2:219
3093 " printf(\"Loop completed\\en\"); /* Should never happen */\n"
3094 " exit(EXIT_SUCCESS);\n"
3099 #: build/C/man2/mprotect.2:223
3100 msgid "B<mmap>(2), B<sysconf>(3)"
3104 #: build/C/man2/mremap.2:31
3110 #: build/C/man2/mremap.2:31
3116 #: build/C/man2/mremap.2:34
3117 msgid "mremap - remap a virtual memory address"
3121 #: build/C/man2/mremap.2:37
3123 msgid "B<#define _GNU_SOURCE> /* See feature_test_macros(7) */\n"
3127 #: build/C/man2/mremap.2:42
3130 "B<void *mremap(void *>I<old_address>B<, size_t >I<old_size>B<,>\n"
3131 "B< size_t >I<new_size>B<, int >I<flags>B<, ... /* void "
3132 "*>I<new_address>B< */);>\n"
3136 #: build/C/man2/mremap.2:48
3138 "B<mremap>() expands (or shrinks) an existing memory mapping, potentially "
3139 "moving it at the same time (controlled by the I<flags> argument and the "
3140 "available virtual address space)."
3144 #: build/C/man2/mremap.2:62
3146 "I<old_address> is the old address of the virtual memory block that you want "
3147 "to expand (or shrink). Note that I<old_address> has to be page aligned. "
3148 "I<old_size> is the old size of the virtual memory block. I<new_size> is the "
3149 "requested size of the virtual memory block after the resize. An optional "
3150 "fifth argument, I<new_address>, may be provided; see the description of "
3151 "B<MREMAP_FIXED> below."
3155 #: build/C/man2/mremap.2:74
3157 "In Linux the memory is divided into pages. A user process has (one or) "
3158 "several linear virtual memory segments. Each virtual memory segment has one "
3159 "or more mappings to real memory pages (in the page table). Each virtual "
3160 "memory segment has its own protection (access rights), which may cause a "
3161 "segmentation violation if the memory is accessed incorrectly (e.g., writing "
3162 "to a read-only segment). Accessing virtual memory outside of the segments "
3163 "will also cause a segmentation violation."
3167 #: build/C/man2/mremap.2:82
3169 "B<mremap>() uses the Linux page table scheme. B<mremap>() changes the "
3170 "mapping between virtual addresses and memory pages. This can be used to "
3171 "implement a very efficient B<realloc>(3)."
3175 #: build/C/man2/mremap.2:84
3176 msgid "The I<flags> bit-mask argument may be 0, or include the following flag:"
3180 #: build/C/man2/mremap.2:84
3182 msgid "B<MREMAP_MAYMOVE>"
3186 #: build/C/man2/mremap.2:96
3188 "By default, if there is not sufficient space to expand a mapping at its "
3189 "current location, then B<mremap>() fails. If this flag is specified, then "
3190 "the kernel is permitted to relocate the mapping to a new virtual address, if "
3191 "necessary. If the mapping is relocated, then absolute pointers into the old "
3192 "mapping location become invalid (offsets relative to the starting address of "
3193 "the mapping should be employed)."
3197 #: build/C/man2/mremap.2:96
3199 msgid "B<MREMAP_FIXED> (since Linux 2.3.31)"
3203 #: build/C/man2/mremap.2:118
3205 "This flag serves a similar purpose to the B<MAP_FIXED> flag of B<mmap>(2). "
3206 "If this flag is specified, then B<mremap>() accepts a fifth argument, "
3207 "I<void *new_address>, which specifies a page-aligned address to which the "
3208 "mapping must be moved. Any previous mapping at the address range specified "
3209 "by I<new_address> and I<new_size> is unmapped. If B<MREMAP_FIXED> is "
3210 "specified, then B<MREMAP_MAYMOVE> must also be specified."
3214 #: build/C/man2/mremap.2:128
3216 "If the memory segment specified by I<old_address> and I<old_size> is locked "
3217 "(using B<mlock>(2) or similar), then this lock is maintained when the "
3218 "segment is resized and/or relocated. As a consequence, the amount of memory "
3219 "locked by the process may change."
3223 #: build/C/man2/mremap.2:136
3225 "On success B<mremap>() returns a pointer to the new virtual memory area. "
3226 "On error, the value B<MAP_FAILED> (that is, I<(void\\ *)\\ -1>) is returned, "
3227 "and I<errno> is set appropriately."
3231 #: build/C/man2/mremap.2:143
3233 "The caller tried to expand a memory segment that is locked, but this was not "
3234 "possible without exceeding the B<RLIMIT_MEMLOCK> resource limit."
3238 #: build/C/man2/mremap.2:152
3240 "\"Segmentation fault.\" Some address in the range I<old_address> to "
3241 "I<old_address>+I<old_size> is an invalid virtual memory address for this "
3242 "process. You can also get B<EFAULT> even if there exist mappings that cover "
3243 "the whole address space requested, but those mappings are of different "
3248 #: build/C/man2/mremap.2:180
3250 "An invalid argument was given. Possible causes are: I<old_address> was not "
3251 "page aligned; a value other than B<MREMAP_MAYMOVE> or B<MREMAP_FIXED> was "
3252 "specified in I<flags>; I<new_size> was zero; I<new_size> or I<new_address> "
3253 "was invalid; or the new address range specified by I<new_address> and "
3254 "I<new_size> overlapped the old address range specified by I<old_address> and "
3255 "I<old_size>; or B<MREMAP_FIXED> was specified without also specifying "
3256 "B<MREMAP_MAYMOVE>."
3260 #: build/C/man2/mremap.2:186
3262 "The memory area cannot be expanded at the current virtual address, and the "
3263 "B<MREMAP_MAYMOVE> flag is not set in I<flags>. Or, there is not enough "
3264 "(virtual) memory available."
3267 #. 4.2BSD had a (never actually implemented)
3269 #. call with completely different semantics.
3271 #: build/C/man2/mremap.2:192
3273 "This call is Linux-specific, and should not be used in programs intended to "
3278 #: build/C/man2/mremap.2:200
3280 "Prior to version 2.4, glibc did not expose the definition of "
3281 "B<MREMAP_FIXED>, and the prototype for B<mremap>() did not allow for the "
3282 "I<new_address> argument."
3286 #: build/C/man2/mremap.2:209
3288 "B<brk>(2), B<getpagesize>(2), B<getrlimit>(2), B<mlock>(2), B<mmap>(2), "
3289 "B<sbrk>(2), B<malloc>(3), B<realloc>(3)"
3293 #: build/C/man2/mremap.2:214
3295 "Your favorite OS text book for more information on paged memory. (I<Modern "
3296 "Operating Systems> by Andrew S. Tanenbaum, I<Inside Linux> by Randolf "
3297 "Bentson, I<The Design of the UNIX Operating System> by Maurice J. Bach.)"
3301 #: build/C/man2/msync.2:25
3307 #: build/C/man2/msync.2:28
3308 msgid "msync - synchronize a file with a memory map"
3312 #: build/C/man2/msync.2:32
3313 msgid "B<int msync(void *>I<addr>B<, size_t >I<length>B<, int >I<flags>B<);>"
3317 #: build/C/man2/msync.2:48
3319 "B<msync>() flushes changes made to the in-core copy of a file that was "
3320 "mapped into memory using B<mmap>(2) back to disk. Without use of this call "
3321 "there is no guarantee that changes are written back before B<munmap>(2) is "
3322 "called. To be more precise, the part of the file that corresponds to the "
3323 "memory area starting at I<addr> and having length I<length> is updated."
3327 #: build/C/man2/msync.2:68
3329 "The I<flags> argument may have the bits B<MS_ASYNC>, B<MS_SYNC>, and "
3330 "B<MS_INVALIDATE> set, but not both B<MS_ASYNC> and B<MS_SYNC>. B<MS_ASYNC> "
3331 "specifies that an update be scheduled, but the call returns immediately. "
3332 "B<MS_SYNC> asks for an update and waits for it to complete. "
3333 "B<MS_INVALIDATE> asks to invalidate other mappings of the same file (so that "
3334 "they can be updated with the fresh values just written)."
3338 #: build/C/man2/msync.2:73
3340 "On success, zero is returned. On error, -1 is returned, and I<errno> is set "
3345 #: build/C/man2/msync.2:74
3351 #: build/C/man2/msync.2:80
3353 "B<MS_INVALIDATE> was specified in I<flags>, and a memory lock exists for the "
3354 "specified address range."
3358 #: build/C/man2/msync.2:93
3360 "I<addr> is not a multiple of PAGESIZE; or any bit other than B<MS_ASYNC> | "
3361 "B<MS_INVALIDATE> | B<MS_SYNC> is set in I<flags>; or both B<MS_SYNC> and "
3362 "B<MS_ASYNC> are set in I<flags>."
3366 #: build/C/man2/msync.2:96
3367 msgid "The indicated memory (or part of it) was not mapped."
3371 #: 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
3372 msgid "POSIX.1-2001."
3376 #: build/C/man2/msync.2:105
3378 "This call was introduced in Linux 1.3.21, and then used B<EFAULT> instead of "
3379 "B<ENOMEM>. In Linux 2.4.19 this was changed to the POSIX value B<ENOMEM>."
3382 #. POSIX.1-2001: It shall be defined to -1 or 0 or 200112L.
3383 #. -1: unavailable, 0: ask using sysconf().
3384 #. glibc defines them to 1.
3386 #: build/C/man2/msync.2:118
3388 "On POSIX systems on which B<msync>() is available, both "
3389 "B<_POSIX_MAPPED_FILES> and B<_POSIX_SYNCHRONIZED_IO> are defined in "
3390 "I<E<lt>unistd.hE<gt>> to a value greater than 0. (See also B<sysconf>(3).)"
3394 #: build/C/man2/msync.2:120 build/C/man7/shm_overview.7:46
3400 #: build/C/man3/mtrace.3:4
3406 #: build/C/man3/mtrace.3:4
3412 #: build/C/man3/mtrace.3:7
3413 msgid "mtrace, muntrace - malloc debugging"
3417 #: build/C/man3/mtrace.3:9
3418 msgid "B<#include E<lt>mcheck.hE<gt>>"
3422 #: build/C/man3/mtrace.3:11
3423 msgid "B<void mtrace(void);>"
3427 #: build/C/man3/mtrace.3:13
3428 msgid "B<void muntrace(void);>"
3432 #: build/C/man3/mtrace.3:24
3434 "The function B<mtrace>() installs handlers for B<malloc>(3), B<realloc>(3) "
3435 "and B<free>(3). The function B<muntrace>() disables these handlers."
3439 #: build/C/man3/mtrace.3:34
3441 "The environment variable B<MALLOC_TRACE> defines a file where B<mtrace>() "
3442 "writes its output. This file must be writable to the user or B<mtrace>() "
3443 "will do nothing. If the file is not empty it will be truncated."
3447 #: build/C/man3/mtrace.3:36
3448 msgid "These are GNU extensions."
3452 #: build/C/man3/mtrace.3:41
3454 "The output of B<mtrace>() will be ASCII but not in a friendly format. So "
3455 "glibc comes with a perl-script called mtrace to make sense of it."
3459 #: build/C/man3/mtrace.3:44
3460 msgid "B<malloc>(3), B<malloc_hook>(3)"
3464 #: build/C/man2/posix_fadvise.2:27
3466 msgid "POSIX_FADVISE"
3470 #: build/C/man2/posix_fadvise.2:27 build/C/man2/sync_file_range.2:30
3476 #: build/C/man2/posix_fadvise.2:30
3477 msgid "posix_fadvise - predeclare an access pattern for file data"
3481 #: build/C/man2/posix_fadvise.2:33 build/C/man3/posix_fallocate.3:29
3483 msgid "B<#include E<lt>fcntl.hE<gt>>\n"
3487 #: build/C/man2/posix_fadvise.2:36
3490 "B<int posix_fadvise(int >I<fd>B<, off_t >I<offset>B<, off_t >I<len>B<, int "
3495 #: build/C/man2/posix_fadvise.2:45
3496 msgid "B<posix_fadvise>():"
3500 #: build/C/man2/posix_fadvise.2:47 build/C/man3/posix_fallocate.3:42
3501 msgid "_XOPEN_SOURCE\\ E<gt>=\\ 600 || _POSIX_C_SOURCE\\ E<gt>=\\ 200112L"
3505 #: build/C/man2/posix_fadvise.2:55
3507 "Programs can use B<posix_fadvise>() to announce an intention to access file "
3508 "data in a specific pattern in the future, thus allowing the kernel to "
3509 "perform appropriate optimizations."
3513 #: build/C/man2/posix_fadvise.2:62
3515 "The I<advice> applies to a (not necessarily existent) region starting at "
3516 "I<offset> and extending for I<len> bytes (or until the end of the file if "
3517 "I<len> is 0) within the file referred to by I<fd>. The I<advice> is not "
3518 "binding; it merely constitutes an expectation on behalf of the application."
3522 #: build/C/man2/posix_fadvise.2:64
3523 msgid "Permissible values for I<advice> include:"
3527 #: build/C/man2/posix_fadvise.2:64
3529 msgid "B<POSIX_FADV_NORMAL>"
3533 #: build/C/man2/posix_fadvise.2:70
3535 "Indicates that the application has no advice to give about its access "
3536 "pattern for the specified data. If no advice is given for an open file, "
3537 "this is the default assumption."
3541 #: build/C/man2/posix_fadvise.2:70
3543 msgid "B<POSIX_FADV_SEQUENTIAL>"
3547 #: build/C/man2/posix_fadvise.2:74
3549 "The application expects to access the specified data sequentially (with "
3550 "lower offsets read before higher ones)."
3554 #: build/C/man2/posix_fadvise.2:74
3556 msgid "B<POSIX_FADV_RANDOM>"
3560 #: build/C/man2/posix_fadvise.2:77
3561 msgid "The specified data will be accessed in random order."
3565 #: build/C/man2/posix_fadvise.2:77
3567 msgid "B<POSIX_FADV_NOREUSE>"
3571 #: build/C/man2/posix_fadvise.2:80
3572 msgid "The specified data will be accessed only once."
3576 #: build/C/man2/posix_fadvise.2:80
3578 msgid "B<POSIX_FADV_WILLNEED>"
3582 #: build/C/man2/posix_fadvise.2:83
3583 msgid "The specified data will be accessed in the near future."
3587 #: build/C/man2/posix_fadvise.2:83
3589 msgid "B<POSIX_FADV_DONTNEED>"
3593 #: build/C/man2/posix_fadvise.2:86
3594 msgid "The specified data will not be accessed in the near future."
3598 #: build/C/man2/posix_fadvise.2:89
3599 msgid "On success, zero is returned. On error, an error number is returned."
3603 #: build/C/man2/posix_fadvise.2:93
3604 msgid "The I<fd> argument was not a valid file descriptor."
3608 #: build/C/man2/posix_fadvise.2:96
3609 msgid "An invalid value was specified for I<advice>."
3613 #: build/C/man2/posix_fadvise.2:103
3615 "The specified file descriptor refers to a pipe or FIFO. (Linux actually "
3616 "returns B<EINVAL> in this case.)"
3619 #. of fadvise64_64()
3621 #: build/C/man2/posix_fadvise.2:111
3623 "Kernel support first appeared in Linux 2.5.60; the underlying system call is "
3624 "called B<fadvise64>(). Library support has been provided since glibc "
3625 "version 2.2, via the wrapper function B<posix_fadvise>()."
3629 #: build/C/man2/posix_fadvise.2:120
3631 "POSIX.1-2001. Note that the type of the I<len> argument was changed from "
3632 "I<size_t> to I<off_t> in POSIX.1-2003 TC1."
3636 #: build/C/man2/posix_fadvise.2:126
3638 "Under Linux, B<POSIX_FADV_NORMAL> sets the readahead window to the default "
3639 "size for the backing device; B<POSIX_FADV_SEQUENTIAL> doubles this size, and "
3640 "B<POSIX_FADV_RANDOM> disables file readahead entirely. These changes affect "
3641 "the entire file, not just the specified region (but other open file handles "
3642 "to the same file are unaffected)."
3646 #: build/C/man2/posix_fadvise.2:133
3648 "B<POSIX_FADV_WILLNEED> initiates a nonblocking read of the specified region "
3649 "into the page cache. The amount of data read may be decreased by the kernel "
3650 "depending on virtual memory load. (A few megabytes will usually be fully "
3651 "satisfied, and more is rarely useful.)"
3655 #: build/C/man2/posix_fadvise.2:137
3657 "In kernels before 2.6.18, B<POSIX_FADV_NOREUSE> had the same semantics as "
3658 "B<POSIX_FADV_WILLNEED>. This was probably a bug; since kernel 2.6.18, this "
3663 #: build/C/man2/posix_fadvise.2:145
3665 "B<POSIX_FADV_DONTNEED> attempts to free cached pages associated with the "
3666 "specified region. This is useful, for example, while streaming large "
3667 "files. A program may periodically request the kernel to free cached data "
3668 "that has already been used, so that more useful cached pages are not "
3669 "discarded instead."
3673 #: build/C/man2/posix_fadvise.2:153
3675 "Pages that have not yet been written out will be unaffected, so if the "
3676 "application wishes to guarantee that pages will be released, it should call "
3677 "B<fsync>(2) or B<fdatasync>(2) first."
3681 #: build/C/man2/posix_fadvise.2:153
3683 msgid "arm_fadvise()"
3687 #: build/C/man2/posix_fadvise.2:165
3689 "The ARM architecture needs 64-bit arguments to be aligned in a suitable pair "
3690 "of registers. On this architecture, the call signature of "
3691 "B<posix_fadvise>() is flawed, since it forces a register to be wasted as "
3692 "padding between the I<fd> and I<len> arguments. Therefore, since Linux "
3693 "2.6.14, ARM defines a different system call that orders the arguments "
3698 #: build/C/man2/posix_fadvise.2:170
3701 "B<long arm_fadvise64_64(int >I<fd>B<, int >I<advice>B<,>\n"
3702 "B< loff_t >I<offset>B<, loff_t >I<len>B<);>\n"
3705 #. No ARM support in glibc.
3707 #: build/C/man2/posix_fadvise.2:177
3709 "The behavior of this system call is otherwise exactly the same as "
3710 "B<posix_fadvise>(). No library support is provided for this system call in "
3715 #: build/C/man2/posix_fadvise.2:182
3717 "In kernels before 2.6.6, if I<len> was specified as 0, then this was "
3718 "interpreted literally as \"zero bytes\", rather than as meaning \"all bytes "
3719 "through to the end of the file\"."
3722 #. FIXME . Write a posix_fadvise(3) page.
3724 #: build/C/man2/posix_fadvise.2:188
3726 "B<readahead>(2), B<sync_file_range>(2), B<posix_fallocate>(3), "
3727 "B<posix_madvise>(3)"
3731 #: build/C/man3/posix_fallocate.3:23
3733 msgid "POSIX_FALLOCATE"
3737 #: build/C/man3/posix_fallocate.3:23 build/C/man3/posix_memalign.3:26
3743 #: build/C/man3/posix_fallocate.3:26
3744 msgid "posix_fallocate - allocate file space"
3748 #: build/C/man3/posix_fallocate.3:31
3750 msgid "B<int posix_fallocate(int >I<fd>B<, off_t >I<offset>B<, off_t >I<len>B<);>\n"
3754 #: build/C/man3/posix_fallocate.3:40
3755 msgid "B<posix_fallocate>():"
3759 #: build/C/man3/posix_fallocate.3:59
3761 "The function B<posix_fallocate>() ensures that disk space is allocated for "
3762 "the file referred to by the descriptor I<fd> for the bytes in the range "
3763 "starting at I<offset> and continuing for I<len> bytes. After a successful "
3764 "call to B<posix_fallocate>(), subsequent writes to bytes in the specified "
3765 "range are guaranteed not to fail because of lack of disk space."
3769 #: build/C/man3/posix_fallocate.3:64
3771 "If the size of the file is less than I<offset>+I<len>, then the file is "
3772 "increased to this size; otherwise the file size is left unchanged."
3776 #: build/C/man3/posix_fallocate.3:70
3778 "B<posix_fallocate>() returns zero on success, or an error number on "
3779 "failure. Note that I<errno> is not set."
3783 #: build/C/man3/posix_fallocate.3:79
3784 msgid "I<offset+len> exceeds the maximum file size."
3788 #: build/C/man3/posix_fallocate.3:89
3789 msgid "I<fd> does not refer to a regular file."
3793 #: build/C/man3/posix_fallocate.3:98
3794 msgid "I<fd> refers to a pipe."
3798 #: build/C/man3/posix_fallocate.3:101
3799 msgid "B<posix_fallocate>() is available since glibc 2.1.94."
3803 #: build/C/man3/posix_fallocate.3:126
3805 "POSIX.1-2008 says that an implementation I<shall> give the B<EINVAL> error "
3806 "if I<len> was 0, or I<offset> was less than 0. POSIX.1-2001 says that an "
3807 "implementation I<shall> give the B<EINVAL> error if I<len> is less than 0, "
3808 "or I<offset> was less than 0, and I<may> give the error if I<len> equals "
3813 #: build/C/man3/posix_fallocate.3:130
3814 msgid "B<fallocate>(2), B<lseek>(2), B<posix_fadvise>(2)"
3818 #: build/C/man3/posix_memalign.3:26
3820 msgid "POSIX_MEMALIGN"
3824 #: build/C/man3/posix_memalign.3:29
3825 msgid "posix_memalign, memalign, valloc - Allocate aligned memory"
3829 #: build/C/man3/posix_memalign.3:32
3831 msgid "B<#include E<lt>stdlib.hE<gt>>\n"
3835 #: build/C/man3/posix_memalign.3:34
3838 "B<int posix_memalign(void **>I<memptr>B<, size_t >I<alignment>B<, size_t "
3843 #: build/C/man3/posix_memalign.3:39
3846 "B<void *valloc(size_t >I<size>B<);>\n"
3847 "B<void *memalign(size_t >I<boundary>B<, size_t >I<size>B<);>\n"
3851 #: build/C/man3/posix_memalign.3:49
3853 "B<posix_memalign>(): _POSIX_C_SOURCE\\ E<gt>=\\ 200112L || _XOPEN_SOURCE\\ "
3858 #: build/C/man3/posix_memalign.3:51
3859 msgid "B<valloc>():"
3863 #: build/C/man3/posix_memalign.3:54
3865 msgid "Since glibc 2.12:"
3869 #: build/C/man3/posix_memalign.3:61
3873 " (_XOPEN_SOURCE\\ E<gt>=\\ 500 ||\n"
3874 " _XOPEN_SOURCE\\ &&\\ _XOPEN_SOURCE_EXTENDED) &&\n"
3875 " !(_POSIX_C_SOURCE\\ E<gt>=\\ 200112L || _XOPEN_SOURCE\\ E<gt>=\\ 600)\n"
3879 #: build/C/man3/posix_memalign.3:63
3881 msgid "Before glibc 2.12:"
3885 #: build/C/man3/posix_memalign.3:67
3887 "_BSD_SOURCE || _XOPEN_SOURCE\\ E<gt>=\\ 500 || _XOPEN_SOURCE\\ &&\\ "
3888 "_XOPEN_SOURCE_EXTENDED"
3893 #: build/C/man3/posix_memalign.3:89
3895 "The function B<posix_memalign>() allocates I<size> bytes and places the "
3896 "address of the allocated memory in I<*memptr>. The address of the allocated "
3897 "memory will be a multiple of I<alignment>, which must be a power of two and "
3898 "a multiple of I<sizeof(void *)>. If I<size> is 0, then B<posix_memalign>() "
3899 "returns either NULL, or a unique pointer value that can later be "
3900 "successfully passed to B<free>(3)."
3903 #. The behavior of memalign() for size==0 is as for posix_memalign()
3904 #. but no standards govern this.
3906 #: build/C/man3/posix_memalign.3:100
3908 "The obsolete function B<memalign>() allocates I<size> bytes and returns a "
3909 "pointer to the allocated memory. The memory address will be a multiple of "
3910 "I<boundary>, which must be a power of two."
3914 #: build/C/man3/posix_memalign.3:109
3916 "The obsolete function B<valloc>() allocates I<size> bytes and returns a "
3917 "pointer to the allocated memory. The memory address will be a multiple of "
3918 "the page size. It is equivalent to I<memalign(sysconf(_SC_PAGESIZE),size)>."
3922 #: build/C/man3/posix_memalign.3:111
3923 msgid "For all three routines, the memory is not zeroed."
3927 #: build/C/man3/posix_memalign.3:116
3929 "B<memalign>() and B<valloc>() return the pointer to the allocated memory, "
3930 "or NULL if the request fails."
3934 #: build/C/man3/posix_memalign.3:123
3936 "B<posix_memalign>() returns zero on success, or one of the error values "
3937 "listed in the next section on failure. Note that I<errno> is not set."
3941 #: build/C/man3/posix_memalign.3:130
3943 "The I<alignment> argument was not a power of two, or was not a multiple of "
3944 "I<sizeof(void *)>."
3948 #: build/C/man3/posix_memalign.3:133
3949 msgid "There was insufficient memory to fulfill the allocation request."
3953 #: build/C/man3/posix_memalign.3:142
3955 "The functions B<memalign>() and B<valloc>() have been available in all "
3956 "Linux libc libraries. The function B<posix_memalign>() is available since "
3961 #: build/C/man3/posix_memalign.3:155
3963 "The function B<valloc>() appeared in 3.0BSD. It is documented as being "
3964 "obsolete in 4.3BSD, and as legacy in SUSv2. It does not appear in "
3965 "POSIX.1-2001. The function B<memalign>() appears in SunOS 4.1.3 but not in "
3966 "4.4BSD. The function B<posix_memalign>() comes from POSIX.1d."
3970 #: build/C/man3/posix_memalign.3:155
3976 #: build/C/man3/posix_memalign.3:159
3978 "Everybody agrees that B<posix_memalign>() is declared in "
3979 "I<E<lt>stdlib.hE<gt>>."
3983 #: build/C/man3/posix_memalign.3:163
3985 "On some systems B<memalign>() is declared in I<E<lt>stdlib.hE<gt>> instead "
3986 "of I<E<lt>malloc.hE<gt>>."
3990 #: build/C/man3/posix_memalign.3:179
3992 "According to SUSv2, B<valloc>() is declared in I<E<lt>stdlib.hE<gt>>. "
3993 "Libc4,5 and glibc declare it in I<E<lt>malloc.hE<gt>> and perhaps also in "
3994 "I<E<lt>stdlib.hE<gt>> (namely, if B<_GNU_SOURCE> is defined, or "
3995 "B<_BSD_SOURCE> is defined, or, for glibc, if B<_XOPEN_SOURCE_EXTENDED> is "
3996 "defined, or, equivalently, B<_XOPEN_SOURCE> is defined to a value not less "
4001 #: build/C/man3/posix_memalign.3:188
4003 "On many systems there are alignment restrictions, for example, on buffers "
4004 "used for direct block device I/O. POSIX specifies the "
4005 "I<pathconf(path,_PC_REC_XFER_ALIGN)> call that tells what alignment is "
4006 "needed. Now one can use B<posix_memalign>() to satisfy this requirement."
4010 #: build/C/man3/posix_memalign.3:197
4012 "B<posix_memalign>() verifies that I<alignment> matches the requirements "
4013 "detailed above. B<memalign>() may not check that the I<boundary> argument "
4017 #. Other systems allow passing the result of
4024 #: build/C/man3/posix_memalign.3:225
4026 "POSIX requires that memory obtained from B<posix_memalign>() can be freed "
4027 "using B<free>(3). Some systems provide no way to reclaim memory allocated "
4028 "with B<memalign>() or B<valloc>() (because one can only pass to B<free>(3) "
4029 "a pointer gotten from B<malloc>(3), while, for example, B<memalign>() would "
4030 "call B<malloc>(3) and then align the obtained value). The glibc "
4031 "implementation allows memory obtained from any of these three routines to be "
4032 "reclaimed with B<free>(3)."
4036 #: build/C/man3/posix_memalign.3:230
4038 "The glibc B<malloc>(3) always returns 8-byte aligned memory addresses, so "
4039 "these routines are only needed if you require larger alignment values."
4043 #: build/C/man3/posix_memalign.3:235
4044 msgid "B<brk>(2), B<getpagesize>(2), B<free>(3), B<malloc>(3)"
4048 #: build/C/man2/readahead.2:28
4054 #: build/C/man2/readahead.2:28 build/C/man7/shm_overview.7:27
4060 #: build/C/man2/readahead.2:31
4061 msgid "readahead - perform file readahead into page cache"
4065 #: build/C/man2/readahead.2:37
4068 "B<ssize_t readahead(int >I<fd>B<, off64_t >I<offset>B<, size_t "
4073 #: build/C/man2/readahead.2:65
4075 "B<readahead>() populates the page cache with data from a file so that "
4076 "subsequent reads from that file will not block on disk I/O. The I<fd> "
4077 "argument is a file descriptor identifying the file which is to be read. The "
4078 "I<offset> argument specifies the starting point from which data is to be "
4079 "read and I<count> specifies the number of bytes to be read. I/O is "
4080 "performed in whole pages, so that I<offset> is effectively rounded down to a "
4081 "page boundary and bytes are read up to the next page boundary greater than "
4082 "or equal to I<(offset+count)>. B<readahead>() does not read beyond the end "
4083 "of the file. B<readahead>() blocks until the specified data has been "
4084 "read. The current file offset of the open file referred to by I<fd> is left "
4089 #: build/C/man2/readahead.2:71
4091 "On success, B<readahead>() returns 0; on failure, -1 is returned, with "
4092 "I<errno> set to indicate the cause of the error."
4096 #: build/C/man2/readahead.2:76
4097 msgid "I<fd> is not a valid file descriptor or is not open for reading."
4101 #: build/C/man2/readahead.2:82
4102 msgid "I<fd> does not refer to a file type to which B<readahead>() can be applied."
4106 #: build/C/man2/readahead.2:87
4108 "The B<readahead>() system call appeared in Linux 2.4.13; glibc support has "
4109 "been provided since version 2.3."
4113 #: build/C/man2/readahead.2:92
4115 "The B<readahead>() system call is Linux-specific, and its use should be "
4116 "avoided in portable applications."
4120 #: build/C/man2/readahead.2:98
4121 msgid "B<lseek>(2), B<madvise>(2), B<mmap>(2), B<posix_fadvise>(2), B<read>(2)"
4125 #: build/C/man2/remap_file_pages.2:26
4127 msgid "REMAP_FILE_PAGES"
4131 #: build/C/man2/remap_file_pages.2:29
4132 msgid "remap_file_pages - create a nonlinear file mapping"
4136 #: build/C/man2/remap_file_pages.2:33
4139 "B<#define _GNU_SOURCE> /* See feature_test_macros(7) */\n"
4140 "B<#include E<lt>sys/mman.hE<gt>>\n"
4144 #: build/C/man2/remap_file_pages.2:36
4147 "B<int remap_file_pages(void *>I<addr>B<, size_t >I<size>B<, int "
4149 "B< ssize_t >I<pgoff>B<, int >I<flags>B<);>\n"
4153 #: build/C/man2/remap_file_pages.2:49
4155 "The B<remap_file_pages>() system call is used to create a nonlinear "
4156 "mapping, that is, a mapping in which the pages of the file are mapped into a "
4157 "nonsequential order in memory. The advantage of using B<remap_file_pages>() "
4158 "over using repeated calls to B<mmap>(2) is that the former approach does "
4159 "not require the kernel to create additional VMA (Virtual Memory Area) data "
4164 #: build/C/man2/remap_file_pages.2:51
4165 msgid "To create a nonlinear mapping we perform the following steps:"
4169 #: build/C/man2/remap_file_pages.2:51
4175 #: build/C/man2/remap_file_pages.2:59
4177 "Use B<mmap>(2) to create a mapping (which is initially linear). This "
4178 "mapping must be created with the B<MAP_SHARED> flag."
4182 #: build/C/man2/remap_file_pages.2:59
4188 #: build/C/man2/remap_file_pages.2:67
4190 "Use one or more calls to B<remap_file_pages>() to rearrange the "
4191 "correspondence between the pages of the mapping and the pages of the file. "
4192 "It is possible to map the same page of a file into multiple locations within "
4193 "the mapped region."
4197 #: build/C/man2/remap_file_pages.2:78
4199 "The I<pgoff> and I<size> arguments specify the region of the file that is to "
4200 "be relocated within the mapping: I<pgoff> is a file offset in units of the "
4201 "system page size; I<size> is the length of the region in bytes."
4205 #: build/C/man2/remap_file_pages.2:96
4207 "The I<addr> argument serves two purposes. First, it identifies the mapping "
4208 "whose pages we want to rearrange. Thus, I<addr> must be an address that "
4209 "falls within a region previously mapped by a call to B<mmap>(2). Second, "
4210 "I<addr> specifies the address at which the file pages identified by I<pgoff> "
4211 "and I<size> will be placed."
4214 #. This rounding is weird, and not consistent with the treatment of
4215 #. the analogous arguments for munmap()/mprotect() and for mlock().
4218 #: build/C/man2/remap_file_pages.2:110
4220 "The values specified in I<addr> and I<size> should be multiples of the "
4221 "system page size. If they are not, then the kernel rounds I<both> values "
4222 "I<down> to the nearest multiple of the page size."
4226 #: build/C/man2/remap_file_pages.2:114
4227 msgid "The I<prot> argument must be specified as 0."
4231 #: build/C/man2/remap_file_pages.2:122
4233 "The I<flags> argument has the same meaning as for B<mmap>(2), but all flags "
4234 "other than B<MAP_NONBLOCK> are ignored."
4238 #: build/C/man2/remap_file_pages.2:129
4240 "On success, B<remap_file_pages>() returns 0. On error, -1 is returned, and "
4241 "I<errno> is set appropriately."
4245 #: build/C/man2/remap_file_pages.2:137
4247 "I<addr> does not refer to a valid mapping created with the B<MAP_SHARED> "
4251 #. And possibly others from vma->vm_ops->populate()
4253 #: build/C/man2/remap_file_pages.2:146
4254 msgid "I<addr>, I<size>, I<prot>, or I<pgoff> is invalid."
4258 #: build/C/man2/remap_file_pages.2:151
4260 "The B<remap_file_pages>() system call appeared in Linux 2.5.46; glibc "
4261 "support was added in version 2.3.3."
4265 #: build/C/man2/remap_file_pages.2:155
4266 msgid "The B<remap_file_pages>() system call is Linux-specific."
4270 #: build/C/man2/remap_file_pages.2:162
4272 "B<getpagesize>(2), B<mmap>(2), B<mmap2>(2), B<mprotect>(2), B<mremap>(2), "
4277 #: build/C/man3/shm_open.3:26
4283 #: build/C/man3/shm_open.3:26
4289 #: build/C/man3/shm_open.3:29
4290 msgid "shm_open, shm_unlink - Create/open or unlink POSIX shared memory objects"
4294 #: build/C/man3/shm_open.3:33
4295 msgid "B<#include E<lt>sys/stat.hE<gt>> /* For mode constants */"
4299 #: build/C/man3/shm_open.3:35
4300 msgid "B<#include E<lt>fcntl.hE<gt>> /* For O_* constants */"
4304 #: build/C/man3/shm_open.3:37
4305 msgid "B<int shm_open(const char *>I<name>B<, int >I<oflag>B<, mode_t >I<mode>B<);>"
4309 #: build/C/man3/shm_open.3:39
4310 msgid "B<int shm_unlink(const char *>I<name>B<);>"
4314 #: build/C/man3/shm_open.3:41
4315 msgid "Link with I<-lrt>."
4319 #: build/C/man3/shm_open.3:53
4321 "B<shm_open>() creates and opens a new, or opens an existing, POSIX shared "
4322 "memory object. A POSIX shared memory object is in effect a handle which can "
4323 "be used by unrelated processes to B<mmap>(2) the same region of shared "
4324 "memory. The B<shm_unlink>() function performs the converse operation, "
4325 "removing an object previously created by B<shm_open>()."
4328 #. glibc allows the initial slash to be omitted, and makes
4329 #. multiple initial slashes equivalent to a single slash.
4330 #. This differs from the implementation of POSIX message queues.
4331 #. glibc allows subdirectory components in the name, in which
4332 #. case the subdirectory must exist under /dev/shm, and allow the
4333 #. required permissions if a user wants to create a shared memory
4334 #. object in that subdirectory.
4336 #: build/C/man3/shm_open.3:74
4338 "The operation of B<shm_open>() is analogous to that of B<open>(2). I<name> "
4339 "specifies the shared memory object to be created or opened. For portable "
4340 "use, a shared memory object should be identified by a name of the form "
4341 "I</somename>; that is, a null-terminated string of up to B<NAME_MAX> (i.e., "
4342 "255) characters consisting of an initial slash, followed by one or more "
4343 "characters, none of which are slashes."
4347 #: build/C/man3/shm_open.3:81
4349 "I<oflag> is a bit mask created by ORing together exactly one of B<O_RDONLY> "
4350 "or B<O_RDWR> and any of the other flags listed here:"
4354 #: build/C/man3/shm_open.3:81
4360 #: build/C/man3/shm_open.3:87
4362 "Open the object for read access. A shared memory object opened in this way "
4363 "can only be B<mmap>(2)ed for read (B<PROT_READ>) access."
4367 #: build/C/man3/shm_open.3:87
4373 #: build/C/man3/shm_open.3:90
4374 msgid "Open the object for read-write access."
4378 #: build/C/man3/shm_open.3:90
4383 #. In truth it is actually the file system IDs on Linux, but these
4384 #. are nearly always the same as the effective IDs. (MTK, Jul 05)
4386 #: build/C/man3/shm_open.3:110
4388 "Create the shared memory object if it does not exist. The user and group "
4389 "ownership of the object are taken from the corresponding effective IDs of "
4390 "the calling process, and the object's permission bits are set according to "
4391 "the low-order 9 bits of I<mode>, except that those bits set in the process "
4392 "file mode creation mask (see B<umask>(2)) are cleared for the new object. "
4393 "A set of macro constants which can be used to define I<mode> is listed in "
4394 "B<open>(2). (Symbolic definitions of these constants can be obtained by "
4395 "including I<E<lt>sys/stat.hE<gt>>.)"
4399 #: build/C/man3/shm_open.3:116
4401 "A new shared memory object initially has zero length\\(emthe size of the "
4402 "object can be set using B<ftruncate>(2). The newly allocated bytes of a "
4403 "shared memory object are automatically initialized to 0."
4407 #: build/C/man3/shm_open.3:116
4413 #: build/C/man3/shm_open.3:125
4415 "If B<O_CREAT> was also specified, and a shared memory object with the given "
4416 "I<name> already exists, return an error. The check for the existence of the "
4417 "object, and its creation if it does not exist, are performed atomically."
4421 #: build/C/man3/shm_open.3:125
4427 #: build/C/man3/shm_open.3:128
4428 msgid "If the shared memory object already exists, truncate it to zero bytes."
4432 #: build/C/man3/shm_open.3:131
4434 "Definitions of these flag values can be obtained by including "
4435 "I<E<lt>fcntl.hE<gt>>."
4439 #: build/C/man3/shm_open.3:142
4441 "On successful completion B<shm_open>() returns a new file descriptor "
4442 "referring to the shared memory object. This file descriptor is guaranteed "
4443 "to be the lowest-numbered file descriptor not previously opened within the "
4444 "process. The B<FD_CLOEXEC> flag (see B<fcntl>(2)) is set for the file "
4449 #: build/C/man3/shm_open.3:151
4451 "The file descriptor is normally used in subsequent calls to B<ftruncate>(2) "
4452 "(for a newly created object) and B<mmap>(2). After a call to B<mmap>(2) "
4453 "the file descriptor may be closed without affecting the memory mapping."
4457 #: build/C/man3/shm_open.3:169
4459 "The operation of B<shm_unlink>() is analogous to B<unlink>(2): it removes a "
4460 "shared memory object name, and, once all processes have unmapped the object, "
4461 "de-allocates and destroys the contents of the associated memory region. "
4462 "After a successful B<shm_unlink>(), attempts to B<shm_open>() an object "
4463 "with the same I<name> will fail (unless B<O_CREAT> was specified, in which "
4464 "case a new, distinct object is created)."
4468 #: build/C/man3/shm_open.3:178
4470 "On success, B<shm_open>() returns a nonnegative file descriptor. On "
4471 "failure, B<shm_open>() returns -1. B<shm_unlink>() returns 0 on success, "
4476 #: build/C/man3/shm_open.3:185
4478 "On failure, I<errno> is set to indicate the cause of the error. Values "
4479 "which may appear in I<errno> include the following:"
4483 #: build/C/man3/shm_open.3:190
4484 msgid "Permission to B<shm_unlink>() the shared memory object was denied."
4488 #: build/C/man3/shm_open.3:200
4490 "Permission was denied to B<shm_open>() I<name> in the specified I<mode>, or "
4491 "B<O_TRUNC> was specified and the caller does not have write permission on "
4496 #: build/C/man3/shm_open.3:200 build/C/man2/shmget.2:192
4502 #: build/C/man3/shm_open.3:211
4504 "Both B<O_CREAT> and B<O_EXCL> were specified to B<shm_open>() and the "
4505 "shared memory object specified by I<name> already exists."
4509 #: build/C/man3/shm_open.3:218
4510 msgid "The I<name> argument to B<shm_open>() was invalid."
4514 #: build/C/man3/shm_open.3:218
4520 #: build/C/man3/shm_open.3:221
4521 msgid "The process already has the maximum number of files open."
4525 #: build/C/man3/shm_open.3:221
4527 msgid "B<ENAMETOOLONG>"
4531 #: build/C/man3/shm_open.3:227
4532 msgid "The length of I<name> exceeds B<PATH_MAX>."
4536 #: build/C/man3/shm_open.3:231
4537 msgid "The limit on the total number of files open on the system has been reached."
4541 #: build/C/man3/shm_open.3:231 build/C/man3/shm_open.3:240 build/C/man2/shmget.2:206
4547 #: build/C/man3/shm_open.3:240
4549 "An attempt was made to B<shm_open>() a I<name> that did not exist, and "
4550 "B<O_CREAT> was not specified."
4554 #: build/C/man3/shm_open.3:247
4555 msgid "An attempt was to made to B<shm_unlink>() a I<name> that does not exist."
4559 #: build/C/man3/shm_open.3:249
4560 msgid "These functions are provided in glibc 2.2 and later."
4564 #: build/C/man3/shm_open.3:255
4566 "POSIX.1-2001 says that the group ownership of a newly created shared memory "
4567 "object is set to either the calling process's effective group ID or \"a "
4568 "system default group ID\"."
4572 #: build/C/man3/shm_open.3:264
4574 "POSIX leaves the behavior of the combination of B<O_RDONLY> and B<O_TRUNC> "
4575 "unspecified. On Linux, this will successfully truncate an existing shared "
4576 "memory object\\(emthis may not be so on other UNIX systems."
4580 #: build/C/man3/shm_open.3:269
4582 "The POSIX shared memory object implementation on Linux 2.4 makes use of a "
4583 "dedicated file system, which is normally mounted under I</dev/shm>."
4587 #: build/C/man3/shm_open.3:280
4589 "B<close>(2), B<fchmod>(2), B<fchown>(2), B<fcntl>(2), B<fstat>(2), "
4590 "B<ftruncate>(2), B<mmap>(2), B<open>(2), B<umask>(2), B<shm_overview>(7)"
4594 #: build/C/man7/shm_overview.7:27
4596 msgid "SHM_OVERVIEW"
4600 #: build/C/man7/shm_overview.7:30
4601 msgid "shm_overview - Overview of POSIX shared memory"
4605 #: build/C/man7/shm_overview.7:33
4607 "The POSIX shared memory API allows processes to communicate information by "
4608 "sharing a region of memory."
4612 #: build/C/man7/shm_overview.7:35
4613 msgid "The interfaces employed in the API are:"
4617 #: build/C/man7/shm_overview.7:35
4619 msgid "B<shm_open>(3)"
4623 #: build/C/man7/shm_overview.7:42
4625 "Create and open a new object, or open an existing object. This is analogous "
4626 "to B<open>(2). The call returns a file descriptor for use by the other "
4627 "interfaces listed below."
4631 #: build/C/man7/shm_overview.7:42
4633 msgid "B<ftruncate>(2)"
4637 #: build/C/man7/shm_overview.7:46
4639 "Set the size of the shared memory object. (A newly created shared memory "
4640 "object has a length of zero.)"
4644 #: build/C/man7/shm_overview.7:50
4646 "Map the shared memory object into the virtual address space of the calling "
4651 #: build/C/man7/shm_overview.7:50
4653 msgid "B<munmap>(2)"
4657 #: build/C/man7/shm_overview.7:54
4659 "Unmap the shared memory object from the virtual address space of the calling "
4664 #: build/C/man7/shm_overview.7:54
4666 msgid "B<shm_unlink>(3)"
4670 #: build/C/man7/shm_overview.7:57
4671 msgid "Remove a shared memory object name."
4675 #: build/C/man7/shm_overview.7:57
4681 #: build/C/man7/shm_overview.7:62
4683 "Close the file descriptor allocated by B<shm_open>(3) when it is no longer "
4688 #: build/C/man7/shm_overview.7:62
4694 #: build/C/man7/shm_overview.7:76
4696 "Obtain a I<stat> structure that describes the shared memory object. Among "
4697 "the information returned by this call are the object's size (I<st_size>), "
4698 "permissions (I<st_mode>), owner (I<st_uid>), and group (I<st_gid>)."
4702 #: build/C/man7/shm_overview.7:76
4704 msgid "B<fchown>(2)"
4708 #: build/C/man7/shm_overview.7:79
4709 msgid "To change the ownership of a shared memory object."
4713 #: build/C/man7/shm_overview.7:79
4715 msgid "B<fchmod>(2)"
4719 #: build/C/man7/shm_overview.7:82
4720 msgid "To change the permissions of a shared memory object."
4724 #: build/C/man7/shm_overview.7:82
4730 #: build/C/man7/shm_overview.7:84
4731 msgid "POSIX shared memory is supported since Linux 2.4 and glibc 2.2."
4735 #: build/C/man7/shm_overview.7:84
4741 #: build/C/man7/shm_overview.7:89
4743 "POSIX shared memory objects have kernel persistence: a shared memory object "
4744 "will exist until the system is shut down, or until all processes have "
4745 "unmapped the object and it has been deleted with B<shm_unlink>(3)"
4749 #: build/C/man7/shm_overview.7:89
4755 #: build/C/man7/shm_overview.7:94
4757 "Programs using the POSIX shared memory API must be compiled with I<cc -lrt> "
4758 "to link against the real-time library, I<librt>."
4762 #: build/C/man7/shm_overview.7:94
4764 msgid "Accessing shared memory objects via the file system"
4768 #: build/C/man7/shm_overview.7:101
4770 "On Linux, shared memory objects are created in a (I<tmpfs>) virtual file "
4771 "system, normally mounted under I</dev/shm>. Since kernel 2.6.19, Linux "
4772 "supports the use of access control lists (ACLs) to control the permissions "
4773 "of objects in the virtual file system."
4777 #: build/C/man7/shm_overview.7:106
4779 "Typically, processes must synchronize their access to a shared memory "
4780 "object, using, for example, POSIX semaphores."
4784 #: build/C/man7/shm_overview.7:114
4786 "System V shared memory (B<shmget>(2), B<shmop>(2), etc.) is an older shared "
4787 "memory API. POSIX shared memory provides a simpler, and better designed "
4788 "interface; on the other hand POSIX shared memory is somewhat less widely "
4789 "available (especially on older systems) than System V shared memory."
4793 #: build/C/man7/shm_overview.7:127
4795 "B<fchmod>(2), B<fchown>(2), B<fstat>(2), B<ftruncate>(2), B<mmap>(2), "
4796 "B<mprotect>(2), B<munmap>(2), B<shmget>(2), B<shmop>(2), B<shm_open>(3), "
4797 "B<shm_unlink>(3), B<sem_overview>(7)"
4801 #: build/C/man2/shmctl.2:43
4807 #: build/C/man2/shmctl.2:43
4813 #: build/C/man2/shmctl.2:46
4814 msgid "shmctl - shared memory control"
4818 #: build/C/man2/shmctl.2:49 build/C/man2/shmget.2:42
4819 msgid "B<#include E<lt>sys/ipc.hE<gt>>"
4823 #: build/C/man2/shmctl.2:51 build/C/man2/shmget.2:44
4824 msgid "B<#include E<lt>sys/shm.hE<gt>>"
4828 #: build/C/man2/shmctl.2:53
4829 msgid "B<int shmctl(int >I<shmid>B<, int >I<cmd>B<, struct shmid_ds *>I<buf>B<);>"
4833 #: build/C/man2/shmctl.2:60
4835 "B<shmctl>() performs the control operation specified by I<cmd> on the "
4836 "shared memory segment whose identifier is given in I<shmid>."
4840 #: build/C/man2/shmctl.2:65
4842 "The I<buf> argument is a pointer to a I<shmid_ds> structure, defined in "
4843 "I<E<lt>sys/shm.hE<gt>> as follows:"
4847 #: build/C/man2/shmctl.2:79
4850 "struct shmid_ds {\n"
4851 " struct ipc_perm shm_perm; /* Ownership and permissions */\n"
4852 " size_t shm_segsz; /* Size of segment (bytes) */\n"
4853 " time_t shm_atime; /* Last attach time */\n"
4854 " time_t shm_dtime; /* Last detach time */\n"
4855 " time_t shm_ctime; /* Last change time */\n"
4856 " pid_t shm_cpid; /* PID of creator */\n"
4857 " pid_t shm_lpid; /* PID of last shmat(2)/shmdt(2) */\n"
4858 " shmatt_t shm_nattch; /* No. of current attaches */\n"
4864 #: build/C/man2/shmctl.2:87
4866 "The I<ipc_perm> structure is defined in I<E<lt>sys/ipc.hE<gt>> as follows "
4867 "(the highlighted fields are settable using B<IPC_SET>):"
4871 #: build/C/man2/shmctl.2:100
4874 "struct ipc_perm {\n"
4875 " key_t __key; /* Key supplied to shmget(2) */\n"
4876 " uid_t B<uid>; /* Effective UID of owner */\n"
4877 " gid_t B<gid>; /* Effective GID of owner */\n"
4878 " uid_t cuid; /* Effective UID of creator */\n"
4879 " gid_t cgid; /* Effective GID of creator */\n"
4880 " unsigned short B<mode>; /* B<Permissions> + SHM_DEST and\n"
4881 " SHM_LOCKED flags */\n"
4882 " unsigned short __seq; /* Sequence number */\n"
4887 #: build/C/man2/shmctl.2:106
4888 msgid "Valid values for I<cmd> are:"
4892 #: build/C/man2/shmctl.2:107
4898 #: build/C/man2/shmctl.2:116
4900 "Copy information from the kernel data structure associated with I<shmid> "
4901 "into the I<shmid_ds> structure pointed to by I<buf>. The caller must have "
4902 "read permission on the shared memory segment."
4906 #: build/C/man2/shmctl.2:116
4912 #: build/C/man2/shmctl.2:134
4914 "Write the values of some members of the I<shmid_ds> structure pointed to by "
4915 "I<buf> to the kernel data structure associated with this shared memory "
4916 "segment, updating also its I<shm_ctime> member. The following fields can be "
4917 "changed: I<shm_perm.uid>, I<shm_perm.gid>, and (the least significant 9 bits "
4918 "of) I<shm_perm.mode>. The effective UID of the calling process must match "
4919 "the owner (I<shm_perm.uid>) or creator (I<shm_perm.cuid>) of the shared "
4920 "memory segment, or the caller must be privileged."
4924 #: build/C/man2/shmctl.2:134
4930 #: build/C/man2/shmctl.2:151
4932 "Mark the segment to be destroyed. The segment will only actually be "
4933 "destroyed after the last process detaches it (i.e., when the I<shm_nattch> "
4934 "member of the associated structure I<shmid_ds> is zero). The caller must be "
4935 "the owner or creator, or be privileged. If a segment has been marked for "
4936 "destruction, then the (nonstandard) B<SHM_DEST> flag of the "
4937 "I<shm_perm.mode> field in the associated data structure retrieved by "
4938 "B<IPC_STAT> will be set."
4942 #: build/C/man2/shmctl.2:154
4944 "The caller I<must> ensure that a segment is eventually destroyed; otherwise "
4945 "its pages that were faulted in will remain in memory or swap."
4949 #: build/C/man2/shmctl.2:154
4951 msgid "B<IPC_INFO> (Linux-specific)"
4955 #: build/C/man2/shmctl.2:167
4957 "Returns information about system-wide shared memory limits and parameters in "
4958 "the structure pointed to by I<buf>. This structure is of type I<shminfo> "
4959 "(thus, a cast is required), defined in I<E<lt>sys/shm.hE<gt>> if the "
4960 "B<_GNU_SOURCE> feature test macro is defined:"
4964 #: build/C/man2/shmctl.2:181
4967 "struct shminfo {\n"
4968 " unsigned long shmmax; /* Maximum segment size */\n"
4969 " unsigned long shmmin; /* Minimum segment size;\n"
4971 " unsigned long shmmni; /* Maximum number of segments */\n"
4972 " unsigned long shmseg; /* Maximum number of segments\n"
4973 " that a process can attach;\n"
4974 " unused within kernel */\n"
4975 " unsigned long shmall; /* Maximum number of pages of\n"
4976 " shared memory, system-wide */\n"
4981 #: build/C/man2/shmctl.2:194
4983 "The I<shmmni>, I<shmmax>, and I<shmall> settings can be changed via I</proc> "
4984 "files of the same name; see B<proc>(5) for details."
4988 #: build/C/man2/shmctl.2:194
4990 msgid "B<SHM_INFO> (Linux-specific)"
4994 #: build/C/man2/shmctl.2:205
4996 "Returns a I<shm_info> structure whose fields contain information about "
4997 "system resources consumed by shared memory. This structure is defined in "
4998 "I<E<lt>sys/shm.hE<gt>> if the B<_GNU_SOURCE> feature test macro is defined:"
5002 #: build/C/man2/shmctl.2:222
5005 "struct shm_info {\n"
5006 " int used_ids; /* # of currently existing\n"
5008 " unsigned long shm_tot; /* Total number of shared\n"
5009 " memory pages */\n"
5010 " unsigned long shm_rss; /* # of resident shared\n"
5011 " memory pages */\n"
5012 " unsigned long shm_swp; /* # of swapped shared\n"
5013 " memory pages */\n"
5014 " unsigned long swap_attempts;\n"
5015 " /* Unused since Linux 2.4 */\n"
5016 " unsigned long swap_successes;\n"
5017 " /* Unused since Linux 2.4 */\n"
5022 #: build/C/man2/shmctl.2:224
5024 msgid "B<SHM_STAT> (Linux-specific)"
5028 #: build/C/man2/shmctl.2:235
5030 "Returns a I<shmid_ds> structure as for B<IPC_STAT>. However, the I<shmid> "
5031 "argument is not a segment identifier, but instead an index into the kernel's "
5032 "internal array that maintains information about all shared memory segments "
5037 #: build/C/man2/shmctl.2:238
5039 "The caller can prevent or allow swapping of a shared memory segment with the "
5040 "following I<cmd> values:"
5044 #: build/C/man2/shmctl.2:239
5046 msgid "B<SHM_LOCK> (Linux-specific)"
5050 #: build/C/man2/shmctl.2:251
5052 "Prevent swapping of the shared memory segment. The caller must fault in any "
5053 "pages that are required to be present after locking is enabled. If a "
5054 "segment has been locked, then the (nonstandard) B<SHM_LOCKED> flag of the "
5055 "I<shm_perm.mode> field in the associated data structure retrieved by "
5056 "B<IPC_STAT> will be set."
5060 #: build/C/man2/shmctl.2:251
5062 msgid "B<SHM_UNLOCK> (Linux-specific)"
5066 #: build/C/man2/shmctl.2:254
5067 msgid "Unlock the segment, allowing it to be swapped out."
5070 #. There was some weirdness in 2.6.9: SHM_LOCK and SHM_UNLOCK could
5071 #. be applied to a segment, regardless of ownership of the segment.
5072 #. This was a botch-up in the move to RLIMIT_MEMLOCK, and was fixed
5073 #. in 2.6.10. MTK, May 2005
5075 #: build/C/man2/shmctl.2:272
5077 "In kernels before 2.6.10, only a privileged process could employ B<SHM_LOCK> "
5078 "and B<SHM_UNLOCK>. Since kernel 2.6.10, an unprivileged process can employ "
5079 "these operations if its effective UID matches the owner or creator UID of "
5080 "the segment, and (for B<SHM_LOCK>) the amount of memory to be locked falls "
5081 "within the B<RLIMIT_MEMLOCK> resource limit (see B<setrlimit>(2))."
5085 #: build/C/man2/shmctl.2:290
5087 "A successful B<IPC_INFO> or B<SHM_INFO> operation returns the index of the "
5088 "highest used entry in the kernel's internal array recording information "
5089 "about all shared memory segments. (This information can be used with "
5090 "repeated B<SHM_STAT> operations to obtain information about all shared "
5091 "memory segments on the system.) A successful B<SHM_STAT> operation returns "
5092 "the identifier of the shared memory segment whose index was given in "
5093 "I<shmid>. Other operations return 0 on success."
5097 #: build/C/man2/shmctl.2:294
5098 msgid "On error, -1 is returned, and I<errno> is set appropriately."
5102 #: build/C/man2/shmctl.2:303
5104 "B<IPC_STAT> or B<SHM_STAT> is requested and I<shm_perm.mode> does not allow "
5105 "read access for I<shmid>, and the calling process does not have the "
5106 "B<CAP_IPC_OWNER> capability."
5110 #: build/C/man2/shmctl.2:314
5112 "The argument I<cmd> has value B<IPC_SET> or B<IPC_STAT> but the address "
5113 "pointed to by I<buf> isn't accessible."
5117 #: build/C/man2/shmctl.2:314
5123 #: build/C/man2/shmctl.2:317
5124 msgid "I<shmid> points to a removed identifier."
5128 #: build/C/man2/shmctl.2:326
5130 "I<shmid> is not a valid identifier, or I<cmd> is not a valid command. Or: "
5131 "for a B<SHM_STAT> operation, the index value specified in I<shmid> referred "
5132 "to an array slot that is currently unused."
5136 #: build/C/man2/shmctl.2:337
5138 "(In kernels since 2.6.9), B<SHM_LOCK> was specified and the size of the "
5139 "to-be-locked segment would mean that the total bytes in locked shared memory "
5140 "segments would exceed the limit for the real user ID of the calling "
5141 "process. This limit is defined by the B<RLIMIT_MEMLOCK> soft resource limit "
5142 "(see B<setrlimit>(2))."
5146 #: build/C/man2/shmctl.2:337
5148 msgid "B<EOVERFLOW>"
5152 #: build/C/man2/shmctl.2:342
5154 "B<IPC_STAT> is attempted, and the GID or UID value is too large to be stored "
5155 "in the structure pointed to by I<buf>."
5159 #: build/C/man2/shmctl.2:354
5161 "B<IPC_SET> or B<IPC_RMID> is attempted, and the effective user ID of the "
5162 "calling process is not that of the creator (found in I<shm_perm.cuid>), or "
5163 "the owner (found in I<shm_perm.uid>), and the process was not privileged "
5164 "(Linux: did not have the B<CAP_SYS_ADMIN> capability)."
5168 #: build/C/man2/shmctl.2:366
5170 "Or (in kernels before 2.6.9), B<SHM_LOCK> or B<SHM_UNLOCK> was specified, "
5171 "but the process was not privileged (Linux: did not have the B<CAP_IPC_LOCK> "
5172 "capability). (Since Linux 2.6.9, this error can also occur if the "
5173 "B<RLIMIT_MEMLOCK> is 0 and the caller is not privileged.)"
5176 #. SVr4 documents an additional error condition EMFILE.
5178 #: build/C/man2/shmctl.2:371 build/C/man2/shmget.2:232 build/C/man2/shmop.2:229
5179 msgid "SVr4, POSIX.1-2001."
5183 #: build/C/man2/shmctl.2:382
5185 "The B<IPC_INFO>, B<SHM_STAT> and B<SHM_INFO> operations are used by the "
5186 "B<ipcs>(1) program to provide information on allocated resources. In the "
5187 "future these may modified or moved to a /proc file system interface."
5191 #: build/C/man2/shmctl.2:390
5193 "Linux permits a process to attach (B<shmat>(2)) a shared memory segment "
5194 "that has already been marked for deletion using I<shmctl(IPC_RMID)>. This "
5195 "feature is not available on other UNIX implementations; portable "
5196 "applications should avoid relying on it."
5200 #: build/C/man2/shmctl.2:403
5202 "Various fields in a I<struct shmid_ds> were typed as I<short> under Linux "
5203 "2.2 and have become I<long> under Linux 2.4. To take advantage of this, a "
5204 "recompilation under glibc-2.1.91 or later should suffice. (The kernel "
5205 "distinguishes old and new calls by an B<IPC_64> flag in I<cmd>.)"
5209 #: build/C/man2/shmctl.2:410
5211 "B<mlock>(2), B<setrlimit>(2), B<shmget>(2), B<shmop>(2), B<capabilities>(7), "
5216 #: build/C/man2/shmget.2:36
5222 #: build/C/man2/shmget.2:36
5228 #: build/C/man2/shmget.2:39
5229 msgid "shmget - allocates a shared memory segment"
5233 #: build/C/man2/shmget.2:46
5234 msgid "B<int shmget(key_t >I<key>B<, size_t >I<size>B<, int >I<shmflg>B<);>"
5238 #: build/C/man2/shmget.2:70
5240 "B<shmget>() returns the identifier of the shared memory segment associated "
5241 "with the value of the argument I<key>. A new shared memory segment, with "
5242 "size equal to the value of I<size> rounded up to a multiple of B<PAGE_SIZE>, "
5243 "is created if I<key> has the value B<IPC_PRIVATE> or I<key> isn't "
5244 "B<IPC_PRIVATE>, no shared memory segment corresponding to I<key> exists, and "
5245 "B<IPC_CREAT> is specified in I<shmflg>."
5249 #: build/C/man2/shmget.2:89
5251 "If I<shmflg> specifies both B<IPC_CREAT> and B<IPC_EXCL> and a shared memory "
5252 "segment already exists for I<key>, then B<shmget>() fails with I<errno> set "
5253 "to B<EEXIST>. (This is analogous to the effect of the combination B<O_CREAT "
5254 "| O_EXCL> for B<open>(2).)"
5258 #: build/C/man2/shmget.2:93
5259 msgid "The value I<shmflg> is composed of:"
5263 #: build/C/man2/shmget.2:93
5265 msgid "B<IPC_CREAT>"
5269 #: build/C/man2/shmget.2:100
5271 "to create a new segment. If this flag is not used, then B<shmget>() will "
5272 "find the segment associated with I<key> and check to see if the user has "
5273 "permission to access the segment."
5277 #: build/C/man2/shmget.2:100
5283 #: build/C/man2/shmget.2:103
5284 msgid "used with B<IPC_CREAT> to ensure failure if the segment already exists."
5288 #: build/C/man2/shmget.2:103
5290 msgid "I<mode_flags>"
5294 #: build/C/man2/shmget.2:113
5296 "(least significant 9 bits) specifying the permissions granted to the owner, "
5297 "group, and world. These bits have the same format, and the same meaning, as "
5298 "the I<mode> argument of B<open>(2). Presently, the execute permissions are "
5299 "not used by the system."
5303 #: build/C/man2/shmget.2:113
5305 msgid "B<SHM_HUGETLB> (since Linux 2.6)"
5309 #: build/C/man2/shmget.2:119
5311 "Allocate the segment using \"huge pages.\" See the kernel source file "
5312 "I<Documentation/vm/hugetlbpage.txt> for further information."
5316 #: build/C/man2/shmget.2:119
5318 msgid "B<SHM_NORESERVE> (since Linux 2.6.15)"
5321 #. As at 2.6.17-rc2, this flag has no effect if SHM_HUGETLB was also
5324 #: build/C/man2/shmget.2:138
5326 "This flag serves the same purpose as the B<mmap>(2) B<MAP_NORESERVE> flag. "
5327 "Do not reserve swap space for this segment. When swap space is reserved, "
5328 "one has the guarantee that it is possible to modify the segment. When swap "
5329 "space is not reserved one might get B<SIGSEGV> upon a write if no physical "
5330 "memory is available. See also the discussion of the file "
5331 "I</proc/sys/vm/overcommit_memory> in B<proc>(5)."
5335 #: build/C/man2/shmget.2:146
5337 "When a new shared memory segment is created, its contents are initialized to "
5338 "zero values, and its associated data structure, I<shmid_ds> (see "
5339 "B<shmctl>(2)), is initialized as follows:"
5343 #: build/C/man2/shmget.2:151
5345 "I<shm_perm.cuid> and I<shm_perm.uid> are set to the effective user ID of the "
5350 #: build/C/man2/shmget.2:156
5352 "I<shm_perm.cgid> and I<shm_perm.gid> are set to the effective group ID of "
5353 "the calling process."
5357 #: build/C/man2/shmget.2:161
5359 "The least significant 9 bits of I<shm_perm.mode> are set to the least "
5360 "significant 9 bit of I<shmflg>."
5364 #: build/C/man2/shmget.2:165
5365 msgid "I<shm_segsz> is set to the value of I<size>."
5369 #: build/C/man2/shmget.2:172
5370 msgid "I<shm_lpid>, I<shm_nattch>, I<shm_atime> and I<shm_dtime> are set to 0."
5374 #: build/C/man2/shmget.2:175
5375 msgid "I<shm_ctime> is set to the current time."
5379 #: build/C/man2/shmget.2:178
5381 "If the shared memory segment already exists, the permissions are verified, "
5382 "and a check is made to see if it is marked for destruction."
5386 #: build/C/man2/shmget.2:182
5387 msgid "A valid segment identifier, I<shmid>, is returned on success, -1 on error."
5391 #: build/C/man2/shmget.2:186
5392 msgid "On failure, I<errno> is set to one of the following:"
5396 #: build/C/man2/shmget.2:192
5398 "The user does not have permission to access the shared memory segment, and "
5399 "does not have the B<CAP_IPC_OWNER> capability."
5403 #: build/C/man2/shmget.2:196
5404 msgid "B<IPC_CREAT | IPC_EXCL> was specified and the segment exists."
5408 #: build/C/man2/shmget.2:202
5410 "A new segment was to be created and I<size> E<lt> B<SHMMIN> or I<size> E<gt> "
5411 "B<SHMMAX>, or no new segment was to be created, a segment with given key "
5412 "existed, but I<size> is greater than the size of that segment."
5416 #: build/C/man2/shmget.2:211
5417 msgid "No segment exists for the given I<key>, and B<IPC_CREAT> was not specified."
5421 #: build/C/man2/shmget.2:214
5422 msgid "No memory could be allocated for segment overhead."
5426 #: build/C/man2/shmget.2:222
5428 "All possible shared memory IDs have been taken (B<SHMMNI>), or allocating a "
5429 "segment of the requested I<size> would cause the system to exceed the "
5430 "system-wide limit on shared memory (B<SHMALL>)."
5434 #: build/C/man2/shmget.2:229
5436 "The B<SHM_HUGETLB> flag was specified, but the caller was not privileged "
5437 "(did not have the B<CAP_IPC_LOCK> capability)."
5441 #: build/C/man2/shmget.2:235
5442 msgid "B<SHM_HUGETLB> is a nonportable Linux extension."
5446 #: build/C/man2/shmget.2:245
5448 "B<IPC_PRIVATE> isn't a flag field but a I<key_t> type. If this special "
5449 "value is used for I<key>, the system call ignores everything but the least "
5450 "significant 9 bits of I<shmflg> and creates a new shared memory segment (on "
5455 #: build/C/man2/shmget.2:249
5457 "The following limits on shared memory segment resources affect the "
5462 #: build/C/man2/shmget.2:249
5468 #: build/C/man2/shmget.2:254
5470 "System wide maximum of shared memory pages (on Linux, this limit can be read "
5471 "and modified via I</proc/sys/kernel/shmall>)."
5475 #: build/C/man2/shmget.2:254
5481 #: build/C/man2/shmget.2:259
5483 "Maximum size in bytes for a shared memory segment: policy dependent (on "
5484 "Linux, this limit can be read and modified via I</proc/sys/kernel/shmmax>)."
5488 #: build/C/man2/shmget.2:259
5494 #: build/C/man2/shmget.2:265
5496 "Minimum size in bytes for a shared memory segment: implementation dependent "
5497 "(currently 1 byte, though B<PAGE_SIZE> is the effective minimum size)."
5501 #: build/C/man2/shmget.2:265
5506 #. Kernels between 2.4.x and 2.6.8 had an off-by-one error that meant
5507 #. that we could create one more segment than SHMMNI -- MTK
5508 #. This /proc file is not available in Linux 2.2 and earlier -- MTK
5510 #: build/C/man2/shmget.2:274
5512 "System wide maximum number of shared memory segments: implementation "
5513 "dependent (currently 4096, was 128 before Linux 2.3.99; on Linux, this limit "
5514 "can be read and modified via I</proc/sys/kernel/shmmni>)."
5518 #: build/C/man2/shmget.2:278
5520 "The implementation has no specific limits for the per-process maximum number "
5521 "of shared memory segments (B<SHMSEG>)."
5525 #: build/C/man2/shmget.2:284
5527 "Until version 2.3.30 Linux would return B<EIDRM> for a B<shmget>() on a "
5528 "shared memory segment scheduled for deletion."
5532 #: build/C/man2/shmget.2:290
5534 "The name choice B<IPC_PRIVATE> was perhaps unfortunate, B<IPC_NEW> would "
5535 "more clearly show its function."
5539 #: build/C/man2/shmget.2:298
5541 "B<shmat>(2), B<shmctl>(2), B<shmdt>(2), B<ftok>(3), B<capabilities>(7), "
5542 "B<shm_overview>(7), B<svipc>(7)"
5546 #: build/C/man2/shmop.2:39
5552 #: build/C/man2/shmop.2:39
5558 #: build/C/man2/shmop.2:42
5559 msgid "shmat, shmdt - shared memory operations"
5563 #: build/C/man2/shmop.2:46
5566 "B<#include E<lt>sys/types.hE<gt>>\n"
5567 "B<#include E<lt>sys/shm.hE<gt>>\n"
5571 #: build/C/man2/shmop.2:48
5574 "B<void *shmat(int >I<shmid>B<, const void *>I<shmaddr>B<, int "
5579 #: build/C/man2/shmop.2:50
5581 msgid "B<int shmdt(const void *>I<shmaddr>B<);>\n"
5585 #: build/C/man2/shmop.2:59
5587 "B<shmat>() attaches the shared memory segment identified by I<shmid> to the "
5588 "address space of the calling process. The attaching address is specified by "
5589 "I<shmaddr> with one of the following criteria:"
5593 #: build/C/man2/shmop.2:65
5595 "If I<shmaddr> is NULL, the system chooses a suitable (unused) address at "
5596 "which to attach the segment."
5600 #: build/C/man2/shmop.2:80
5602 "If I<shmaddr> isn't NULL and B<SHM_RND> is specified in I<shmflg>, the "
5603 "attach occurs at the address equal to I<shmaddr> rounded down to the nearest "
5604 "multiple of B<SHMLBA>. Otherwise I<shmaddr> must be a page-aligned address "
5605 "at which the attach occurs."
5609 #: build/C/man2/shmop.2:90
5611 "If B<SHM_RDONLY> is specified in I<shmflg>, the segment is attached for "
5612 "reading and the process must have read permission for the segment. "
5613 "Otherwise the segment is attached for read and write and the process must "
5614 "have read and write permission for the segment. There is no notion of a "
5615 "write-only shared memory segment."
5619 #: build/C/man2/shmop.2:105
5621 "The (Linux-specific) B<SHM_REMAP> flag may be specified in I<shmflg> to "
5622 "indicate that the mapping of the segment should replace any existing mapping "
5623 "in the range starting at I<shmaddr> and continuing for the size of the "
5624 "segment. (Normally an B<EINVAL> error would result if a mapping already "
5625 "exists in this address range.) In this case, I<shmaddr> must not be NULL."
5629 #: build/C/man2/shmop.2:112
5631 "The B<brk>(2) value of the calling process is not altered by the attach. "
5632 "The segment will automatically be detached at process exit. The same "
5633 "segment may be attached as a read and as a read-write one, and more than "
5634 "once, in the process's address space."
5638 #: build/C/man2/shmop.2:120
5640 "A successful B<shmat>() call updates the members of the I<shmid_ds> "
5641 "structure (see B<shmctl>(2)) associated with the shared memory segment as "
5646 #: build/C/man2/shmop.2:123
5647 msgid "I<shm_atime> is set to the current time."
5651 #: build/C/man2/shmop.2:126 build/C/man2/shmop.2:152
5652 msgid "I<shm_lpid> is set to the process-ID of the calling process."
5656 #: build/C/man2/shmop.2:129
5657 msgid "I<shm_nattch> is incremented by one."
5661 #: build/C/man2/shmop.2:140
5663 "B<shmdt>() detaches the shared memory segment located at the address "
5664 "specified by I<shmaddr> from the address space of the calling process. The "
5665 "to-be-detached segment must be currently attached with I<shmaddr> equal to "
5666 "the value returned by the attaching B<shmat>() call."
5670 #: build/C/man2/shmop.2:146
5672 "On a successful B<shmdt>() call the system updates the members of the "
5673 "I<shmid_ds> structure associated with the shared memory segment as follows:"
5677 #: build/C/man2/shmop.2:149
5678 msgid "I<shm_dtime> is set to the current time."
5682 #: build/C/man2/shmop.2:157
5684 "I<shm_nattch> is decremented by one. If it becomes 0 and the segment is "
5685 "marked for deletion, the segment is deleted."
5689 #: build/C/man2/shmop.2:161
5690 msgid "After a B<fork>(2) the child inherits the attached shared memory segments."
5694 #: build/C/man2/shmop.2:165
5696 "After an B<execve>(2) all attached shared memory segments are detached from "
5701 #: build/C/man2/shmop.2:169
5703 "Upon B<_exit>(2) all attached shared memory segments are detached from the "
5708 #: build/C/man2/shmop.2:177
5710 "On success B<shmat>() returns the address of the attached shared memory "
5711 "segment; on error I<(void\\ *)\\ -1> is returned, and I<errno> is set to "
5712 "indicate the cause of the error."
5716 #: build/C/man2/shmop.2:183
5718 "On success B<shmdt>() returns 0; on error -1 is returned, and I<errno> is "
5719 "set to indicate the cause of the error."
5723 #: build/C/man2/shmop.2:189
5724 msgid "When B<shmat>() fails, I<errno> is set to one of the following:"
5728 #: build/C/man2/shmop.2:195
5730 "The calling process does not have the required permissions for the requested "
5731 "attach type, and does not have the B<CAP_IPC_OWNER> capability."
5735 #: build/C/man2/shmop.2:209
5737 "Invalid I<shmid> value, unaligned (i.e., not page-aligned and B<SHM_RND> was "
5738 "not specified) or invalid I<shmaddr> value, or can't attach segment at "
5739 "I<shmaddr>, or B<SHM_REMAP> was specified and I<shmaddr> was NULL."
5743 #: build/C/man2/shmop.2:212
5744 msgid "Could not allocate memory for the descriptor or for the page tables."
5748 #: build/C/man2/shmop.2:218
5749 msgid "When B<shmdt>() fails, I<errno> is set as follows:"
5752 #. The following since 2.6.17-rc1:
5754 #: build/C/man2/shmop.2:226
5756 "There is no shared memory segment attached at I<shmaddr>; or, I<shmaddr> is "
5757 "not aligned on a page boundary."
5761 #: build/C/man2/shmop.2:245
5763 "In SVID 3 (or perhaps earlier) the type of the I<shmaddr> argument was "
5764 "changed from I<char *> into I<const void *>, and the returned type of "
5765 "B<shmat>() from I<char *> into I<void *>. (Linux libc4 and libc5 have the "
5766 "I<char *> prototypes; glibc2 has I<void *>.)"
5770 #: build/C/man2/shmop.2:257
5772 "Using B<shmat>() with I<shmaddr> equal to NULL is the preferred, portable "
5773 "way of attaching a shared memory segment. Be aware that the shared memory "
5774 "segment attached in this way may be attached at different addresses in "
5775 "different processes. Therefore, any pointers maintained within the shared "
5776 "memory must be made relative (typically to the starting address of the "
5777 "segment), rather than absolute."
5781 #: build/C/man2/shmop.2:262
5783 "On Linux, it is possible to attach a shared memory segment even if it is "
5784 "already marked to be deleted. However, POSIX.1-2001 does not specify this "
5785 "behavior and many other implementations do not support it."
5789 #: build/C/man2/shmop.2:265
5790 msgid "The following system parameter affects B<shmat>():"
5793 #. FIXME A good explanation of the rationale for the existence
5794 #. of SHMLBA would be useful here
5796 #: build/C/man2/shmop.2:265
5801 #. FIXME That last sentence isn't true for all Linux
5802 #. architectures (i.e., SHMLBA != PAGE_SIZE for some architectures)
5805 #: build/C/man2/shmop.2:278
5807 "Segment low boundary address multiple. Must be page aligned. For the "
5808 "current implementation the B<SHMLBA> value is B<PAGE_SIZE>."
5812 #: build/C/man2/shmop.2:282
5814 "The implementation places no intrinsic limit on the per-process maximum "
5815 "number of shared memory segments (B<SHMSEG>)."
5819 #: build/C/man2/shmop.2:290
5821 "B<brk>(2), B<mmap>(2), B<shmctl>(2), B<shmget>(2), B<capabilities>(7), "
5822 "B<shm_overview>(7), B<svipc>(7)"
5826 #: build/C/man2/subpage_prot.2:28
5828 msgid "SUBPAGE_PROT"
5832 #: build/C/man2/subpage_prot.2:28
5838 #: build/C/man2/subpage_prot.2:31
5839 msgid "subpage_prot - define a subpage protection for an address range"
5843 #: build/C/man2/subpage_prot.2:35
5846 "B<long subpage_prot(unsigned long >I<addr>B<, unsigned long >I<len>B<,>\n"
5847 "B< uint32_t *>I<map>B<);>\n"
5851 #: build/C/man2/subpage_prot.2:42
5853 "The PowerPC-specific B<subpage_prot>() system call provides the facility to "
5854 "control the access permissions on individual 4kB subpages on systems "
5855 "configured with a page size of 64kB."
5859 #: build/C/man2/subpage_prot.2:49
5861 "The protection map is applied to the memory pages in the region starting at "
5862 "I<addr> and continuing for I<len> bytes. Both of these arguments must be "
5863 "aligned to a 64-kB boundary."
5867 #: build/C/man2/subpage_prot.2:61
5869 "The protection map is specified in the buffer pointed to by I<map>. The map "
5870 "has 2 bits per 4kB subpage; thus each 32-bit word specifies the protections "
5871 "of 16 4kB subpages inside a 64kB page (so, the number of 32-bit words "
5872 "pointed to by I<map> should equate to the number of 64-kB pages specified by "
5873 "I<len>). Each 2-bit field in the protection map is either 0 to allow any "
5874 "access, 1 to prevent writes, or 2 or 3 to prevent all accesses."
5878 #: build/C/man2/subpage_prot.2:66
5880 "On success, B<subpage_prot>() returns 0. Otherwise, one of the error codes "
5881 "specified below is returned."
5885 #: build/C/man2/subpage_prot.2:72
5886 msgid "The buffer referred to by I<map> is not accessible."
5890 #: build/C/man2/subpage_prot.2:82
5892 "The I<addr> or I<len> arguments are incorrect. Both of these arguments must "
5893 "be aligned to a multiple of the system page size, and they must not refer to "
5894 "a region outside of the address space of the process or to a region that "
5895 "consists of huge pages."
5899 #: build/C/man2/subpage_prot.2:85 build/C/man2/sync_file_range.2:166
5900 msgid "Out of memory."
5904 #: build/C/man2/subpage_prot.2:91
5906 "This system call is provided on the PowerPC architecture since Linux "
5907 "2.6.25. The system call is provided only if the kernel is configured with "
5908 "B<CONFIG_PPC_64K_PAGES>. No library support is provided."
5912 #: build/C/man2/subpage_prot.2:98
5914 "Normal page protections (at the 64-kB page level) also apply; the subpage "
5915 "protection mechanism is an additional constraint, so putting 0 in a 2-bit "
5916 "field won't allow writes to a page that is otherwise write-protected."
5920 #: build/C/man2/subpage_prot.2:98
5925 #. In the initial implementation, it was the case that:
5926 #. In fact the whole process is switched to use 4k hardware pages when the
5927 #. subpage_prot system call is used, but this could be improved in future
5928 #. to switch only the affected segments.
5929 #. But Paul Mackerass says (Oct 2010): I'm pretty sure we now only switch
5930 #. the affected segment, not the whole process.
5932 #: build/C/man2/subpage_prot.2:120
5934 "This system call is provided to assist writing emulators that operate using "
5935 "64-kB pages on PowerPC systems. When emulating systems such as x86, which "
5936 "uses a smaller page size, the emulator can no longer use the "
5937 "memory-management unit (MMU) and normal system calls for controlling page "
5938 "protections. (The emulator could emulate the MMU by checking and possibly "
5939 "remapping the address for each memory access in software, but that is slow.) "
5940 "The idea is that the emulator supplies an array of protection masks to apply "
5941 "to a specified range of virtual addresses. These masks are applied at the "
5942 "level where hardware page-table entries (PTEs) are inserted into the "
5943 "hardware page table based on the Linux PTEs, so the Linux PTEs are not "
5944 "affected. Implicit in this is that the regions of the address space that "
5945 "are protected are switched to use 4-kB hardware pages rather than 64-kB "
5946 "hardware pages (on machines with hardware 64-kB page support)."
5950 #: build/C/man2/subpage_prot.2:123
5951 msgid "B<mprotect>(2), B<syscall>(2);"
5955 #: build/C/man2/subpage_prot.2:126
5956 msgid "the kernel source file I<Documentation/vm/hugetlbpage.txt>."
5960 #: build/C/man2/sync_file_range.2:30
5962 msgid "SYNC_FILE_RANGE"
5966 #: build/C/man2/sync_file_range.2:33
5967 msgid "sync_file_range - sync a file segment with disk"
5971 #: build/C/man2/sync_file_range.2:37
5974 "B<#define _GNU_SOURCE> /* See feature_test_macros(7) */\n"
5975 "B<#include E<lt>fcntl.hE<gt>>\n"
5979 #: build/C/man2/sync_file_range.2:40
5982 "B<int sync_file_range(int >I<fd>B<, off64_t >I<offset>B<, off64_t "
5984 "B< unsigned int >I<flags>B<);>\n"
5988 #: build/C/man2/sync_file_range.2:47
5990 "B<sync_file_range>() permits fine control when synchronizing the open file "
5991 "referred to by the file descriptor I<fd> with disk."
5995 #: build/C/man2/sync_file_range.2:61
5997 "I<offset> is the starting byte of the file range to be synchronized. "
5998 "I<nbytes> specifies the length of the range to be synchronized, in bytes; if "
5999 "I<nbytes> is zero, then all bytes from I<offset> through to the end of file "
6000 "are synchronized. Synchronization is in units of the system page size: "
6001 "I<offset> is rounded down to a page boundary; I<(offset+nbytes-1)> is "
6002 "rounded up to a page boundary."
6006 #: build/C/man2/sync_file_range.2:65
6007 msgid "The I<flags> bit-mask argument can include any of the following values:"
6011 #: build/C/man2/sync_file_range.2:65
6013 msgid "B<SYNC_FILE_RANGE_WAIT_BEFORE>"
6017 #: build/C/man2/sync_file_range.2:70
6019 "Wait upon write-out of all pages in the specified range that have already "
6020 "been submitted to the device driver for write-out before performing any "
6025 #: build/C/man2/sync_file_range.2:70 build/C/man2/sync_file_range.2:120
6027 msgid "B<SYNC_FILE_RANGE_WRITE>"
6031 #: build/C/man2/sync_file_range.2:76
6033 "Initiate write-out of all dirty pages in the specified range which are not "
6034 "presently submitted write-out. Note that even this may block if you attempt "
6035 "to write more than request queue size."
6039 #: build/C/man2/sync_file_range.2:76
6041 msgid "B<SYNC_FILE_RANGE_WAIT_AFTER>"
6045 #: build/C/man2/sync_file_range.2:80
6046 msgid "Wait upon write-out of all pages in the range after performing any write."
6050 #: build/C/man2/sync_file_range.2:84
6051 msgid "Specifying I<flags> as 0 is permitted, as a no-op."
6055 #: build/C/man2/sync_file_range.2:84
6061 #: build/C/man2/sync_file_range.2:100
6063 "This system call is extremely dangerous and should not be used in portable "
6064 "programs. None of these operations writes out the file's metadata. "
6065 "Therefore, unless the application is strictly performing overwrites of "
6066 "already-instantiated disk blocks, there are no guarantees that the data will "
6067 "be available after a crash. There is no user interface to know if a write "
6068 "is purely an overwrite. On file systems using copy-on-write semantics "
6069 "(e.g., I<btrfs>) an overwrite of existing allocated blocks is impossible. "
6070 "When writing into preallocated space, many file systems also require calls "
6071 "into the block allocator, which this system call does not sync out to disk. "
6072 "This system call does not flush disk write caches and thus does not provide "
6073 "any data integrity on systems with volatile disk write caches."
6077 #: build/C/man2/sync_file_range.2:100
6079 msgid "Some details"
6083 #: build/C/man2/sync_file_range.2:108
6085 "B<SYNC_FILE_RANGE_WAIT_BEFORE> and B<SYNC_FILE_RANGE_WAIT_AFTER> will detect "
6086 "any I/O errors or B<ENOSPC> conditions and will return these to the caller."
6090 #: build/C/man2/sync_file_range.2:112
6091 msgid "Useful combinations of the I<flags> bits are:"
6095 #: build/C/man2/sync_file_range.2:112
6097 msgid "B<SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE>"
6101 #: build/C/man2/sync_file_range.2:120
6103 "Ensures that all pages in the specified range which were dirty when "
6104 "B<sync_file_range>() was called are placed under write-out. This is a "
6105 "start-write-for-data-integrity operation."
6109 #: build/C/man2/sync_file_range.2:127
6111 "Start write-out of all dirty pages in the specified range which are not "
6112 "presently under write-out. This is an asynchronous flush-to-disk "
6113 "operation. This is not suitable for data integrity operations."
6117 #: build/C/man2/sync_file_range.2:127
6119 msgid "B<SYNC_FILE_RANGE_WAIT_BEFORE> (or B<SYNC_FILE_RANGE_WAIT_AFTER>)"
6123 #: build/C/man2/sync_file_range.2:134
6125 "Wait for completion of write-out of all pages in the specified range. This "
6126 "can be used after an earlier B<SYNC_FILE_RANGE_WAIT_BEFORE | "
6127 "SYNC_FILE_RANGE_WRITE> operation to wait for completion of that operation, "
6128 "and obtain its result."
6132 #: build/C/man2/sync_file_range.2:134
6135 "B<SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE | "
6136 "SYNC_FILE_RANGE_WAIT_AFTER>"
6140 #: build/C/man2/sync_file_range.2:141
6142 "This is a write-for-data-integrity operation that will ensure that all pages "
6143 "in the specified range which were dirty when B<sync_file_range>() was "
6144 "called are committed to disk."
6148 #: build/C/man2/sync_file_range.2:147
6150 "On success, B<sync_file_range>() returns 0; on failure -1 is returned and "
6151 "I<errno> is set to indicate the error."
6155 #: build/C/man2/sync_file_range.2:152
6156 msgid "I<fd> is not a valid file descriptor."
6160 #: build/C/man2/sync_file_range.2:160
6161 msgid "I<flags> specifies an invalid bit; or I<offset> or I<nbytes> is invalid."
6165 #: build/C/man2/sync_file_range.2:163
6170 #: build/C/man2/sync_file_range.2:169
6171 msgid "Out of disk space."
6174 #. FIXME . (bug?) Actually, how can 'fd' refer to a symbolic link (S_ISLNK)?
6175 #. (In userspace at least) it isn't possible to obtain a file descriptor
6176 #. for a symbolic link.
6178 #: build/C/man2/sync_file_range.2:177
6180 "I<fd> refers to something other than a regular file, a block device, a "
6181 "directory, or a symbolic link."
6185 #: build/C/man2/sync_file_range.2:180
6186 msgid "B<sync_file_range>() appeared on Linux in kernel 2.6.17."
6190 #: build/C/man2/sync_file_range.2:183
6192 "This system call is Linux-specific, and should be avoided in portable "
6196 #. See kernel commit edd5cd4a9424f22b0fa08bef5e299d41befd5622
6198 #: build/C/man2/sync_file_range.2:196
6200 "Some architectures (e.g., PowerPC, ARM) need 64-bit arguments to be aligned "
6201 "in a suitable pair of registers. On such architectures, the call signature "
6202 "of B<sync_file_range>() is flawed, since it forces a register to be wasted "
6203 "as padding between the I<fd> and I<offset> arguments. Therefore, these "
6204 "architectures define a different system call that orders the arguments "
6209 #: build/C/man2/sync_file_range.2:201
6212 "B<int sync_file_range2(int >I<fd>B<, unsigned int >I<flags>B<,>\n"
6213 "B< off64_t >I<offset>B<, off64_t >I<nbytes>B<);>\n"
6217 #: build/C/man2/sync_file_range.2:206
6219 "The behavior of this system call is otherwise exactly the same as "
6220 "B<sync_file_range>()."
6224 #: build/C/man2/sync_file_range.2:217
6226 "A system call with this signature first appeared on the ARM architecture in "
6227 "Linux 2.6.20, with the name B<arm_sync_file_range>(). It was renamed in "
6228 "Linux 2.6.22, when the analogous system call was added for PowerPC. On "
6229 "architectures where glibc support is provided, glibc transparently wraps "
6230 "B<sync_file_range2>() under the name B<sync_file_range>()."
6234 #: build/C/man2/sync_file_range.2:222
6235 msgid "B<fdatasync>(2), B<fsync>(2), B<msync>(2), B<sync>(2)"