1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright (C) 2001 David Gez <davidge@jazzfree.com>
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" Based on comments from mm/filemap.c. Last modified on 10-06-2001
26 .\" Modified, 25 Feb 2002, Michael Kerrisk, <mtk.manpages@gmail.com>
27 .\" Added notes on MADV_DONTNEED
29 .\" 2.6.32 added MADV_HWPOISON, MADV_MERGEABLE, and MADV_UNMERGEABLE
30 .\" 2.6.33 added MADV_SOFT_OFFLINE
32 .\" Japanese Version Copyright (c) 2001 NAKANO Takeo all rights reserved.
33 .\" Translated Thu Aug 16 2001 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
34 .\" Updated Tue 8 Oct 2002 by NAKANO Takeo
35 .\" Updated 2007-01-08, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.43
37 .TH MADVISE 2 2008-04-22 "Linux" "Linux Programmer's Manual"
39 madvise \- ¥á¥â¥êÍøÍѤ˴ؤ¹¤ë¥¢¥É¥Ð¥¤¥¹¤òÍ¿¤¨¤ë
41 .B #include <sys/mman.h>
43 .BI "int madvise(void *" addr ", size_t " length ", int " advice );
46 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
47 .RB ( feature_test_macros (7)
55 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¡¢¥¢¥É¥ì¥¹
59 ¥Ð¥¤¥È¤Î¥á¥â¥ê¥Ö¥í¥Ã¥¯¤Î¥Ú¡¼¥¸¥ó¥°Æþ½ÐÎϤò¤É¤¦°·¤¨¤ÐÎɤ¤¤«¡¢
60 ¥«¡¼¥Í¥ë¤Ë¥¢¥É¥Ð¥¤¥¹¤¹¤ë¡£
62 ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤«¤é¥«¡¼¥Í¥ë¤Ë¡¢
63 ¥Þ¥Ã¥×¤µ¤ì¤¿¥á¥â¥ê¤ä¶¦Í¥á¥â¥ê¤ò¤É¤Î¤è¤¦¤Ë°·¤Ã¤Æ¤Û¤·¤¤¤«ÅÁ¤¨¤ë¤³¤È¤¬¤Ç¤¡¢
64 ¥«¡¼¥Í¥ë¤Ï¤½¤ì¤Ë±þ¤¸¤ÆÀèÆɤߤ䥥ã¥Ã¥·¥å¤Ê¤É¤ÎŬÀڤʼêË¡¤òÁªÂò¤Ç¤¤ë¡£
65 ¤³¤Î¥³¡¼¥ë¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ÎÆ°ºî¤½¤Î¤â¤Î¤Ë¤Ï±Æ¶Á¤·¤Ê¤¤
69 ¤Ê¤ª¤³¤Î¥¢¥É¥Ð¥¤¥¹¤ò¼õ¤±Æþ¤ì¤ë¤«¤É¤¦¤«¤Ï¥«¡¼¥Í¥ë¤ËǤ¤µ¤ì¤ë¡£
73 ¤Ë¤è¤Ã¤ÆÍ¿¤¨¤ë¡£°Ê²¼¤Î¤¤¤º¤ì¤«¤ò»ØÄê¤Ç¤¤ë¡£
76 ÆÃÊ̤ʰ·¤¤¤Ï¹Ô¤ï¤Ê¤¤¡£¤³¤ì¤¬¥Ç¥Õ¥©¥ë¥È¤Ç¤¢¤ë¡£
79 ¥Ú¡¼¥¸»²¾È¤Ï¥é¥ó¥À¥à¤Ê½ç½ø¤Ç¹Ô¤ï¤ì¤½¤¦¤À¡£
80 (¤·¤¿¤¬¤Ã¤Æ¡¢ÀèÆɤߤϤ¢¤Þ¤ê¸ú²Ì¤¬¤Ê¤µ¤½¤¦¤À¡£)
83 ¥Ú¡¼¥¸»²¾È¤Ï¥·¡¼¥±¥ó¥·¥ã¥ë¤Ê½ç½ø¤Ç¹Ô¤ï¤ì¤½¤¦¤À¡£
84 (¤·¤¿¤¬¤Ã¤ÆÍ¿¤¨¤¿ÈϰϤΥڡ¼¥¸¤ÏÀѶËŪ¤ËÀèÆɤߤ·¤Æ¤ª¤¯¤ÈÎɤ¤¤À¤í¤¦¡£
85 ¤Þ¤¿¥¢¥¯¥»¥¹¤¬½ª¤ï¤Ã¤¿¤é®¤ä¤«¤Ë²òÊü¤·¤ÆÎɤ¤¡£)
88 ¶á¤¤¾Íè¤Ë¥¢¥¯¥»¥¹¤µ¤ì¤½¤¦¤À¡£
89 (¤·¤¿¤¬¤Ã¤Æ¤³¤ì¤é¤Î¥Ú¡¼¥¸¤òº£¤Î¤¦¤Á¤ËÀèÆɤߤ·¤Æ¤ª¤¯¤È¤¤¤¤¤À¤í¤¦¡£)
92 ¤·¤Ð¤é¤¯¥¢¥¯¥»¥¹¤Ï¤Ê¤µ¤½¤¦¤À¡£
93 (¸½»þÅÀ¤Ç¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ÏÍ¿¤¨¤¿ÈϰϤνèÍý¤ò½ª¤¨¤Æ¤¤¤ë¡£
94 ¤·¤¿¤¬¤Ã¤Æ¥«¡¼¥Í¥ë¤Ï¤³¤ì¤Ë´ØÏ¢¤¹¤ë¥ê¥½¡¼¥¹¤ò²òÊü¤·¤ÆÎɤ¤¡£)
95 ¤³¤ì°Ê¹ß¤³¤ÎÈϰϤΥڡ¼¥¸¤Ø¤Î¥¢¥¯¥»¥¹¤¬¤¢¤ë¤È¡¢
96 À®¸ù¤Ï¤¹¤ë¤¬¡¢¥á¥â¥ê¤ÎÆâÍƤò¥Þ¥Ã¥×¸µ¤Î¥Õ¥¡¥¤¥ë¤«¤é¥í¡¼¥É¤·Ä¾¤¹¤³¤È¤Ë¤Ê¤ë
99 ¤Þ¤¿¤Ï¸µ¥Õ¥¡¥¤¥ë¤¬¤Ê¤¤¥Þ¥Ã¥×¥Ú¡¼¥¸¤Ç¤Ï
100 ¥¢¥¯¥»¥¹¤¬¤¢¤Ã¤¿¤È¤¤Ë 0 Ëä¤á¤¬¹Ô¤ï¤ì¤ë¤³¤È¤Ë¤Ê¤ë¡£
102 .BR MADV_REMOVE " (Linux 2.6.16 °Ê¹ß)"
103 »ØÄꤵ¤ì¤¿ÈϰϤΥڡ¼¥¸¤È´ØÏ¢¤¹¤ë¥Ð¥Ã¥¥ó¥°¥¹¥È¥¢¤ò²òÊü¤¹¤ë¡£
106 shmfs/tmpfs ¤À¤±¤¬¤³¤ì¤ËÂбþ¤·¤Æ¤¤¤ë¡£
107 ¾¤Î¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Ç¤Ï
110 .\" Databases want to use this feature to drop a section of their
111 .\" bufferpool (shared memory segments) - without writing back to
112 .\" disk/swap space. This feature is also useful for supporting
113 .\" hot-plug memory on UML.
115 .BR MADV_DONTFORK " (Linux 2.6.16 °Ê¹ß)"
116 .\" See http://lwn.net/Articles/171941/
118 ¤¬¹Ô¤ï¤ì¤¿¸å¡¢»ØÄꤵ¤ì¤¿ÈϰϤΥڡ¼¥¸¤ò»Ò¥×¥í¥»¥¹¤¬ÍøÍѤǤ¤Ê¤¤¤è¤¦¤Ë¤¹¤ë¡£
119 ¤³¤Îµ¡Ç½¤Ï¡¢½ñ¤¹þ¤ß»þ¥³¥Ô¡¼ (copy-on-write) Êý¼°¤Ç¡¢
121 ¤Î¸å¤Ç¿Æ¥×¥í¥»¥¹¤¬¥Ú¡¼¥¸¤Ë½ñ¤¹þ¤ß¤ò¹Ô¤Ã¤¿¾ì¹ç¤Ë
122 ¥Ú¡¼¥¸¤ÎʪÍý°ÌÃÖ¤¬ÊѲ½¤·¤Ê¤¤¤è¤¦¤Ë¤¹¤ë¤Î¤Ë͸ú¤Ç¤¢¤ë
123 (¥Ú¡¼¥¸¤ÎºÆÇÛÃ֤ϥϡ¼¥É¥¦¥§¥¢¤¬¤½¤Î¥Ú¡¼¥¸¤Ë DMA žÁ÷¤ò¹Ô¤¦¤è¤¦¤Ê¾ì¹ç¤Ë
124 ÌäÂê¤òµ¯¤³¤¹¤³¤È¤¬¤¢¤ë)¡£
125 .\" [PATCH] madvise MADV_DONTFORK/MADV_DOFORK
126 .\" Currently, copy-on-write may change the physical address of
127 .\" a page even if the user requested that the page is pinned in
128 .\" memory (either by mlock or by get_user_pages). This happens
129 .\" if the process forks meanwhile, and the parent writes to that
130 .\" page. As a result, the page is orphaned: in case of
131 .\" get_user_pages, the application will never see any data hardware
132 .\" DMA's into this page after the COW. In case of mlock'd memory,
133 .\" the parent is not getting the realtime/security benefits of mlock.
135 .\" In particular, this affects the Infiniband modules which do DMA from
136 .\" and into user pages all the time.
138 .\" This patch adds madvise options to control whether memory range is
139 .\" inherited across fork. Useful e.g. for when hardware is doing DMA
140 .\" from/into these pages. Could also be useful to an application
141 .\" wanting to speed up its forks by cutting large areas out of
144 .\" SEE ALSO: http://lwn.net/Articles/171941/
145 .\" "Tweaks to madvise() and posix_fadvise()", 14 Feb 2006
147 .BR MADV_DOFORK " (Linux 2.6.16 °Ê¹ß)"
149 ¤Î±Æ¶Á¤ò¼è¤ê¾Ã¤·¡¢¥Ç¥Õ¥©¥ë¥È¤ÎÆ°ºî¤ËÌ᤹¡£
152 ¤ÎÁ°¸å¤Ç¥Þ¥Ã¥Ô¥ó¥°¤Ï·Ñ¾µ¤µ¤ì¤ë¤è¤¦¤Ë¤Ê¤ë¡£
155 ¤ÏÀ®¸ù¤¹¤ë¤È 0 ¤òÊÖ¤¹¡£
156 ¥¨¥é¡¼¤¬µ¯¤³¤ë¤È \-1 ¤òÊÖ¤·¡¢
158 ¤òŬÀÚ¤ÊÃͤËÀßÄꤹ¤ë¡£
162 ²¿¤é¤«¤Î¥«¡¼¥Í¥ë¥ê¥½¡¼¥¹¤¬°ì»þŪ¤ËÍøÍѤǤ¤Ê¤«¤Ã¤¿¡£
165 »ØÄꤷ¤¿¥Þ¥Ã¥×¤Ï¸ºß¤¹¤ë¤¬¡¢¥Õ¥¡¥¤¥ë¤Ç¤Ï¤Ê¤¤¤È¤³¤í¤ò¥Þ¥Ã¥×¤·¤Æ¤¤¤ë¡£
176 ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬¥í¥Ã¥¯¤µ¤ì¤¿¥Ú¡¼¥¸¤ä¶¦Í¥Ú¡¼¥¸¤ò
178 ¤Ç) ²òÊü¤·¤è¤¦¤È¤·¤Æ¤¤¤ë¡¢¤Ê¤É¡£
182 ¤Î¾ì¹ç) ¤³¤ÎÈϰϤΥڡ¼¥¸¥ó¥°¤ò¹Ô¤¦¤È¡¢
183 ¥×¥í¥»¥¹¤Î RSS (resident set size) ¤ÎºÇÂçÃͤò±Û¤¨¤Æ¤·¤Þ¤¦¡£
184 .\"nakano RSS ¤ÏÌõ¸ì¤¬¤¢¤ê¤Þ¤·¤¿¤Ã¤±?
188 ¤Î¾ì¹ç) ¥á¥â¥ê¤¬Â¤ê¤º¡¢¥Ú¡¼¥¸¥ó¥°¤Ë¼ºÇÔ¤·¤¿¡£
191 »ØÄꤷ¤¿ÈϰϤΥ¢¥É¥ì¥¹¤¬¡¢¸½ºß¥Þ¥Ã¥×¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
192 ¤¢¤ë¤¤¤Ï¥×¥í¥»¥¹¤Î¥¢¥É¥ì¥¹¶õ´Ö¤ÎÆâÉô¤Ë¤Ê¤¤¡£
196 .BR posix_madvise (3)
197 .\" FIXME . Write a posix_fadvise(3) page.
200 ¤Ê¤É¤ÎÄê¿ô¤È¤È¤â¤Ëµ½Ò¤·¤Æ¤¤¤¿
201 (¤½¤ì¤¾¤ì¤Î¿¶¤ëÉñ¤¤¤Ï¤³¤³¤Ç½Ò¤Ù¤¿¤â¤Î¤Ë¶á¤¤)¡£
202 ¥Õ¥¡¥¤¥ë¥¢¥¯¥»¥¹¤ËÂФ·¤Æ¤â
203 .BR posix_fadvise (2)
204 ¤È¤¤¤¦Îà»÷¤Î´Ø¿ô¤¬Â¸ºß¤¹¤ë¡£
209 ¤Ï Linux ¸ÇͤǤ¢¤ë¡£
212 ¸½ºß¤Î Linux ¤Î¼ÂÁõ (2.4.0) ¤Ç¤Ï¡¢
213 ¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ò¥¢¥É¥Ð¥¤¥¹¤È¤¤¤¦¤è¤ê¤ÏÌ¿Îá¤È¸«¤Æ¤¤¤ë¡£
214 ¤·¤¿¤¬¤Ã¤Æ¤³¤Î¥¢¥É¥Ð¥¤¥¹¤ËÂФ·¤ÆÄ̾ï¹Ô¤ï¤ì¤ëÆ°ºî¤¬ÉÔ²Äǽ¤Ê¾ì¹ç¤Ï¡¢
215 ¥¨¥é¡¼¤òÊÖ¤¹¤³¤È¤¬¤¢¤ë (¾åµ¤Î ¥¨¥é¡¼ ¤Îµ½Ò¤ò»²¾È)¡£
216 ¤³¤Î¿¶Éñ¤¤¤Ïɸ½à¤È¤Ï°Û¤Ê¤ë¡£
220 ¤Î¥¢¥É¥ì¥¹¤Ï¥Ú¡¼¥¸¶³¦¤ÎÃͤǤʤ±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£¤Þ¤¿
222 ¤Ï 0 ¤Ç¤¢¤Ã¤Æ¤â¹½¤ï¤Ê¤¤¡£
225 ¤Ç¤Ï¡¢»ØÄꤵ¤ì¤¿¥¢¥É¥ì¥¹ÈϰϤ˥ޥåפµ¤ì¤Æ¤¤¤Ê¤¤Éôʬ¤¬¤¢¤ë¤È¡¢
226 ¤³¤ì¤é¤ò̵»ë¤·¤Æ»Ä¤ê¤ÎÉôʬ¤Ë¥¢¥É¥Ð¥¤¥¹¤òŬÍѤ¹¤ë
227 (¤·¤«¤·¥·¥¹¥Æ¥à¥³¡¼¥ë¤ËÂФ·¤Æ¤Ï¤Á¤ã¤ó¤È
232 .\" ´Ø¿ô¤Ï 4.4BSD ¤ÇºÇ½é¤ËÅо줷¤¿¡£