1 .\" Copyright (C) 2003, Michael Kerrisk (mtk.manpages@gmail.com)
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" 2003-12-10 Initial creation, Michael Kerrisk <mtk.manpages@gmail.com>
24 .\" 2004-10-28 aeb, corrected prototype, prot must be 0
26 .\" Japanese Version Copyright (c) 2004-2005 Yuichi SATO
27 .\" all rights reserved.
28 .\" Translated Thu Jun 24 06:00:37 JST 2004
29 .\" by Yuichi SATO <ysato444@yahoo.co.jp>
30 .\" Updated & Modified Mon Jan 3 02:50:11 JST 2005 by Yuichi SATO
31 .\" Updated & Modified Mon Oct 10 01:15:38 JST 2005
32 .\" by Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
34 .TH REMAP_FILE_PAGES 2 2008-04-22 "Linux" "Linux Programmer's Manual"
37 .\"O remap_file_pages \- create a nonlinear file mapping
38 remap_file_pages \- ÈóÀþ·Á¥Õ¥¡¥¤¥ë¥Þ¥Ã¥Ô¥ó¥°¤òºîÀ®¤¹¤ë¡£
42 .B #define _GNU_SOURCE
43 .B #include <sys/mman.h>
45 .BI "int remap_file_pages(void *" addr ", size_t " size ", int " prot ,
46 .BI " ssize_t " pgoff ", int " flags );
51 .\"O .BR remap_file_pages ()
52 .\"O system call is used to create a nonlinear mapping, that is, a mapping
53 .\"O in which the pages of the file are mapped into a nonsequential order
55 .BR remap_file_pages ()
56 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÏÈóÀþ·Á¤Ê¥Þ¥Ã¥Ô¥ó¥°¡¢
57 ¤Ä¤Þ¤ê¥Õ¥¡¥¤¥ë¤Î¥Ú¡¼¥¸¤¬¥á¥â¥ê¾å¤ÇϢ³¤·¤Ê¤¤½çÈ֤ǥޥåפµ¤ì¤ë
58 ¥Þ¥Ã¥Ô¥ó¥°¤òºîÀ®¤¹¤ë¤¿¤á¤Ë»È¤ï¤ì¤ë¡£
59 .\"O The advantage of using
60 .\"O .BR remap_file_pages ()
61 .\"O over using repeated calls to
63 .\"O is that the former approach does not require the kernel to create
64 .\"O additional VMA (Virtual Memory Area) data structures.
65 .BR remap_file_pages ()
68 ¤ò·«¤êÊÖ¤·¤Æ»È¤¦¤è¤êÍ¥¤ì¤Æ¤¤¤ëÅÀ¤Ï¡¢
69 Á°¼Ô¤ÎÊýË¡¤Ç¤Ï¥«¡¼¥Í¥ë¤¬ VMA (Virtual Memory Area, ²¾ÁÛ¥á¥â¥êÎΰè)
70 ¥Ç¡¼¥¿¹½Â¤ÂΤòÄɲäǺîÀ®¤¹¤ëɬÍפ¬¤Ê¤¤¤³¤È¤Ç¤¢¤ë¡£
72 .\"O To create a nonlinear mapping we perform the following steps:
73 ÈóÀþ·Á¥Þ¥Ã¥Ô¥ó¥°¤òºîÀ®¤¹¤ë¤¿¤á¤Ë¤Ï¡¢
74 °Ê²¼¤Î¤è¤¦¤Ê¥¹¥Æ¥Ã¥×¤ò¼Â¹Ô¤¹¤ë:
79 .\"O to create a mapping (which is initially linear).
81 ¤ò»È¤¤¡¢¥Þ¥Ã¥Ô¥ó¥°¤òºîÀ®¤¹¤ë (¤³¤Î¥Þ¥Ã¥Ô¥ó¥°¤ÏºÇ½é¤ÏÀþ·Á¤Ç¤¢¤ë)¡£
82 .\"O This mapping must be created with the
87 ¥Õ¥é¥°¤ò»ØÄꤷ¤ÆºîÀ®¤µ¤ì¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
90 .\"O Use one or more calls to
91 .\"O .BR remap_file_pages ()
92 .\"O to rearrange the correspondence between the pages of the mapping
93 .\"O and the pages of the file.
94 .\"O It is possible to map the same page of a file
95 .\"O into multiple locations within the mapped region.
96 .BR remap_file_pages ()
97 ¤ò 1 ²ó°Ê¾å¸Æ¤Ó½Ð¤·¤Æ¡¢
98 ¥Þ¥Ã¥Ô¥ó¥°¤Î¥Ú¡¼¥¸¤È¥Õ¥¡¥¤¥ë¤Î¥Ú¡¼¥¸¤ÎÂбþ´Ø·¸¤òºÆ¹½À®¤¹¤ë¡£
99 ¥Õ¥¡¥¤¥ë¤ÎƱ¤¸¥Ú¡¼¥¸¤ò¥Þ¥Ã¥Ô¥ó¥°Îΰè¤ÎÊ£¿ô¤Î¾ì½ê¤Ë
100 ¥Þ¥Ã¥×¤¹¤ë¤³¤È¤¬²Äǽ¤Ç¤¢¤ë¡£
106 .\"O arguments specify the region of the file that is to be relocated
107 .\"O within the mapping:
111 °ú¤¿ô¤Ï¡¢¥Þ¥Ã¥Ô¥ó¥°Æâ¤ÇºÆÇÛÃÖ¤µ¤ì¤ë¥Õ¥¡¥¤¥ë¤ÎÎΰè¤ò»ØÄꤹ¤ë¡£
113 .\"O is a file offset in units of the system page size;
115 ¤Ï¥Õ¥¡¥¤¥ë¥ª¥Õ¥»¥Ã¥È¤Ç¤¢¤ê¡¢Ã±°Ì¤Ï¥·¥¹¥Æ¥à¤Î¥Ú¡¼¥¸¥µ¥¤¥º¤Ç¤¢¤ë¡£
117 .\"O is the length of the region in bytes.
119 ¤ÏÎΰè¤ÎŤµ¤Ç¤¢¤ê¡¢Ã±°Ì¤Ï¥Ð¥¤¥È¤Ç¤¢¤ë¡£
123 .\"O argument serves two purposes.
125 °ú¤¿ô¤Ï 2 ¤Ä¤ÎÌÜŪ¤Ç»È¤ï¤ì¤ë¡£
126 .\"O First, it identifies the mapping whose pages we want to rearrange.
127 Âè 1 ¤ÎÌÜŪ¤Ï¡¢¤³¤Î°ú¤¿ô¤Ë¤è¤Ã¤ÆºÆÊÔÀ®¤·¤¿¤¤¥Ú¡¼¥¸¤Î
128 ¥Þ¥Ã¥Ô¥ó¥°¤ò¼±Ê̤¹¤ë¤³¤È¤Ç¤¢¤ë¡£
131 .\"O must be an address that falls within
132 .\"O a region previously mapped by a call to
138 ¤Î¸Æ¤Ó½Ð¤·¤Ç²áµî¤Ë¥Þ¥Ã¥×¤µ¤ì¤¿ÎΰèÆâ¤Î¥¢¥É¥ì¥¹¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
141 .\"O specifies the address at which the file pages
151 ¤Ç¼±Ê̤µ¤ì¤ë¥Õ¥¡¥¤¥ë¥Ú¡¼¥¸¤¬ÃÖ¤«¤ì¤ëͽÄê¤Î¥¢¥É¥ì¥¹¤ò¡¢
153 ¤Ë¤è¤Ã¤Æ»ØÄꤹ¤ë¤³¤È¤Ç¤¢¤ë¡£
155 .\"O The values specified in
159 .\"O should be multiples of the system page size.
160 .\"O If they are not, then the kernel rounds
164 .\"O to the nearest multiple of the page size.
165 .\"O .\" This rounding is weird, and not consistent with the treatment of
166 .\"O .\" the analogous arguments for munmap()/mprotect() and for mlock().
167 .\"O .\" MTK, 14 Sep 2005
171 ¤Ë»ØÄꤹ¤ëÃͤϡ¢¥·¥¹¥Æ¥à¤Î¥Ú¡¼¥¸¥µ¥¤¥º¤ÎÇÜ¿ô¤È¤¹¤Ù¤¤Ç¤¢¤ë¡£
172 ¤½¤ì°Ê³°¤Î¾ì¹ç¡¢¥«¡¼¥Í¥ë¤Ï¡ÖξÊý¡×¤ÎÃͤò
173 ºÇ¤â¶á¤¤¥Ú¡¼¥¸¥µ¥¤¥º¤ÎÇÜ¿ô¤Ø¡ÖÀڤ겼¤²¤ë¡×¡£
174 .\" ¤³¤Î´Ý¤á½èÍý¤ÏÉ÷ÊѤï¤ê¤Ç¡¢munmap()/mprotect() ¤ä mlock() ¤Î
175 .\" ƱÍͤΰú¤¿ô¤Î½èÍýÊýË¡¤È¤âÌ·½â¤¹¤ë¡£
180 .\"O argument must be specified as 0.
182 °ú¤¿ô¤Ï 0 ¤Ë»ØÄꤵ¤ì¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
186 .\"O argument has the same meaning as for
188 .\"O but all flags other than
194 ¤Î¤â¤Î¤ÈƱ¤¸°ÕÌ£¤Ç¤¢¤ë¤¬¡¢
196 °Ê³°¤ÎÁ´¤Æ¤Î¥Õ¥é¥°¤Ï̵»ë¤µ¤ì¤ë¡£
197 .\"O .SH "RETURN VALUE"
200 .\"O .BR remap_file_pages ()
202 .\"O On error, \-1 is returned, and
204 .\"O is set appropriately.
206 .BR remap_file_pages ()
208 ¥¨¥é¡¼¤Î¾ì¹ç¡¢\-1 ¤¬ÊÖ¤µ¤ì¡¢
216 .\"O does not refer to a valid mapping
217 .\"O created with the
223 ¥Õ¥é¥°¤ò»ØÄꤷ¤ÆºîÀ®¤µ¤ì¤¿Í¸ú¤Ê¥Þ¥Ã¥Ô¥ó¥°¤ò»²¾È¤·¤Æ¤¤¤Ê¤¤¡£
236 ¤Î¤¤¤º¤ì¤«¤¬ÉÔÀµ¤Ç¤¢¤ë¡£
237 .\"O .\" And possibly others from vma->vm_ops->populate()
239 .\"Osato: others ¤¬²¿¤ò»Ø¤¹¤Î¤«¤è¤¯Ê¬¤«¤é¤Ê¤¤¡£
241 .\" ¤Þ¤¿¤Ï vma->vm_ops->populate() ¤«¤é¤Î¾¤Î¥¨¥é¡¼¤«¤â¤·¤ì¤Ê¤¤¡£
245 .\"O .BR remap_file_pages ()
246 .\"O system call appeared in Linux 2.5.46;
247 .\"O glibc support was added in version 2.3.3.
248 .BR remap_file_pages ()
249 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï Linux 2.5.46 ¤ÇÅо줷¤¿¡£
250 glibc ¤Ç¤Î¥µ¥Ý¡¼¥È¤Ï glibc ¥Ð¡¼¥¸¥ç¥ó 2.3.3 ¤ÇÄɲ䵤줿¡£
251 .\"O .SH "CONFORMING TO"
254 .\"O .BR remap_file_pages ()
255 .\"O system call is Linux-specific.
256 .BR remap_file_pages ()
257 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï Linux ¸ÇͤΤâ¤Î¤Ç¤¢¤ë¡£
266 .BR feature_test_macros (7)