1 .\" Copyright (C) 2003, Michael Kerrisk (mtk-manpages@gmx.net)
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.
17 .\" Formatted or processed versions of this manual, if unaccompanied by
18 .\" the source, must acknowledge the copyright and authors of this work.
20 .\" 2003-12-10 Initial creation, Michael Kerrisk <mtk-manpages@gmx.net>
21 .\" 2004-10-28 aeb, corrected prototype, prot must be 0
23 .TH REMAP_FILE_PAGES 2 2004-10-28 "Linux 2.6" "Linux Programmer's Manual"
25 remap_file_pages \- create a non-linear file mapping
27 .B #include <sys/mman.h>
29 .BI "int remap_file_pages(void *" start ", "
30 .BI "size_t " size ", int " prot ", "
31 .BI "ssize_t " pgoff ", int " flags );
34 .BR remap_file_pages ()
35 system call is used to create a non-linear mapping, that is, a mapping
36 in which the pages of the file are mapped into a non-sequential order
38 The advantage of using
39 .BR remap_file_pages ()
40 over using repeated calls to
42 is that the former approach does not require the kernel to create
43 additional VMA (Virtual Memory Area) data structures.
45 To create a non-linear mapping we perform the following steps:
50 to create a mapping (which is initially linear).
51 This mapping must be created with the
55 Use one or more calls to
56 .BR remap_file_pages ()
57 to rearrange the correspondence between the pages of the mapping
58 and the pages of the file.
59 It is possible to map the same page of a file
60 into multiple locations within the mapped region.
66 arguments specify the region of the file that is to be relocated
69 is a file offset in units of the system page size;
71 is the length of the region in bytes.
75 argument serves two purposes.
76 First, it identifies the mapping whose pages we want to rearrange.
79 must be an address that falls within
80 a region previously mapped by a call to
84 specifies the address at which the file pages
91 The values specified in
95 should be multiples of the system page size.
96 If they are not, then the kernel rounds
100 to the nearest multiple of the page size.
101 .\" This rounding is weird, and not consistent with the treatment of
102 .\" the analogous arguments for munmap()/mprotect() and for mlock().
107 argument must be specified as 0.
111 argument has the same meaning as for
113 but all flags other than MAP_NONBLOCK are ignored.
116 .BR remap_file_pages ()
118 On error, \-1 is returned, and
120 is set appropriately.
123 .BR remap_file_pages ()
124 system call appeared in Linux 2.5.46.
129 does not refer to a valid mapping
130 created with the MAP_SHARED flag.
139 .\" And possibly others from vma->vm_ops->populate()
142 .BR remap_file_pages ()
143 system call is Linux specific.