1 .\" Copyright (C) 2003, Michael Kerrisk (mtk.manpages@gmail.com)
3 .\" %%%LICENSE_START(verbatim)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" 2003-12-10 Initial creation, Michael Kerrisk <mtk.manpages@gmail.com>
26 .\" 2004-10-28 aeb, corrected prototype, prot must be 0
28 .TH REMAP_FILE_PAGES 2 2008-04-22 "Linux" "Linux Programmer's Manual"
30 remap_file_pages \- create a nonlinear file mapping
33 .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
34 .B #include <sys/mman.h>
36 .BI "int remap_file_pages(void *" addr ", size_t " size ", int " prot ,
37 .BI " ssize_t " pgoff ", int " flags );
41 .BR remap_file_pages ()
42 system call is used to create a nonlinear mapping, that is, a mapping
43 in which the pages of the file are mapped into a nonsequential order
45 The advantage of using
46 .BR remap_file_pages ()
47 over using repeated calls to
49 is that the former approach does not require the kernel to create
50 additional VMA (Virtual Memory Area) data structures.
52 To create a nonlinear mapping we perform the following steps:
57 to create a mapping (which is initially linear).
58 This mapping must be created with the
63 Use one or more calls to
64 .BR remap_file_pages ()
65 to rearrange the correspondence between the pages of the mapping
66 and the pages of the file.
67 It is possible to map the same page of a file
68 into multiple locations within the mapped region.
74 arguments specify the region of the file that is to be relocated
77 is a file offset in units of the system page size;
79 is the length of the region in bytes.
83 argument serves two purposes.
84 First, it identifies the mapping whose pages we want to rearrange.
87 must be an address that falls within
88 a region previously mapped by a call to
92 specifies the address at which the file pages
99 The values specified in
103 should be multiples of the system page size.
104 If they are not, then the kernel rounds
108 to the nearest multiple of the page size.
109 .\" This rounding is weird, and not consistent with the treatment of
110 .\" the analogous arguments for munmap()/mprotect() and for mlock().
115 argument must be specified as 0.
119 argument has the same meaning as for
121 but all flags other than
126 .BR remap_file_pages ()
128 On error, \-1 is returned, and
130 is set appropriately.
135 does not refer to a valid mapping
147 .\" And possibly others from vma->vm_ops->populate()
150 .BR remap_file_pages ()
151 system call appeared in Linux 2.5.46;
152 glibc support was added in version 2.3.3.
155 .BR remap_file_pages ()
156 system call is Linux-specific.