1 .\" Copyright (C) 2003, Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\" 2003-12-10 Initial creation, Michael Kerrisk <mtk.manpages@gmail.com>
6 .\" 2004-10-28 aeb, corrected prototype, prot must be 0
8 .TH remap_file_pages 2 (date) "Linux man-pages (unreleased)"
10 remap_file_pages \- create a nonlinear file mapping
13 .RI ( libc ", " \-lc )
16 .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
17 .B #include <sys/mman.h>
19 .BI "[[deprecated]] int remap_file_pages(void " addr [. size "], size_t " size ,
20 .BI " int " prot ", size_t " pgoff ", \
25 .\" commit 33041a0d76d3c3e0aff28ac95a2ffdedf1282dbc
26 .\" http://lwn.net/Articles/597632/
27 this system call was marked as deprecated starting with Linux 3.16.
28 In Linux 4.0, the implementation was replaced
29 .\" commit c8d78c1823f46519473949d33f0d1d33fe21ea16
30 by a slower in-kernel emulation.
31 Those few applications that use this system call should
32 consider migrating to alternatives.
33 This change was made because the kernel code for this system call was complex,
34 and it is believed to be little used or perhaps even completely unused.
35 While it had some use cases in database applications on 32-bit systems,
36 those use cases don't exist on 64-bit systems.
39 .BR remap_file_pages ()
40 system call is used to create a nonlinear mapping, that is, a mapping
41 in which the pages of the file are mapped into a nonsequential order
43 The advantage of using
44 .BR remap_file_pages ()
45 over using repeated calls to
47 is that the former approach does not require the kernel to create
48 additional VMA (Virtual Memory Area) data structures.
50 To create a nonlinear mapping we perform the following steps:
55 to create a mapping (which is initially linear).
56 This mapping must be created with the
61 Use one or more calls to
62 .BR remap_file_pages ()
63 to rearrange the correspondence between the pages of the mapping
64 and the pages of the file.
65 It is possible to map the same page of a file
66 into multiple locations within the mapped region.
72 arguments specify the region of the file that is to be relocated
75 is a file offset in units of the system page size;
77 is the length of the region in bytes.
81 argument serves two purposes.
82 First, it identifies the mapping whose pages we want to rearrange.
85 must be an address that falls within
86 a region previously mapped by a call to
90 specifies the address at which the file pages
97 The values specified in
101 should be multiples of the system page size.
102 If they are not, then the kernel rounds
106 to the nearest multiple of the page size.
107 .\" This rounding is weird, and not consistent with the treatment of
108 .\" the analogous arguments for munmap()/mprotect() and for mlock().
113 argument must be specified as 0.
117 argument has the same meaning as for
119 but all flags other than
124 .BR remap_file_pages ()
126 On error, \-1 is returned, and
128 is set to indicate the error.
133 does not refer to a valid mapping
145 .\" And possibly others from vma->vm_ops->populate()
153 .\" commit 3ee6dafc677a68e461a7ddafc94a580ebab80735
154 .BR remap_file_pages ()
155 creates non-linear mappings only
156 on in-memory filesystems such as
159 On filesystems with a backing store,
160 .BR remap_file_pages ()
161 is not much more efficient than using
163 to adjust which parts of the file are mapped to which addresses.