1REMAP_FILE_PAGES(2)        Linux Programmer's Manual       REMAP_FILE_PAGES(2)
2
3
4

NAME

6       remap_file_pages - create a nonlinear file mapping
7

SYNOPSIS

9       #define _GNU_SOURCE         /* See feature_test_macros(7) */
10       #include <sys/mman.h>
11
12       int remap_file_pages(void *addr, size_t size, int prot,
13                            size_t pgoff, int flags);
14

DESCRIPTION

16       Note:  this  system  call  was marked as deprecated starting with Linux
17       3.16.  In Linux 4.0, the implementation was replaced by  a  slower  in-
18       kernel  emulation.   Those  few  applications that use this system call
19       should consider  migrating  to  alternatives.   This  change  was  made
20       because  the  kernel  code  for this system call was complex, and it is
21       believed to be little used or perhaps even completely unused.  While it
22       had  some  use  cases in database applications on 32-bit systems, those
23       use cases don't exist on 64-bit systems.
24
25       The remap_file_pages() system call is used to create a  nonlinear  map‐
26       ping, that is, a mapping in which the pages of the file are mapped into
27       a  nonsequential   order   in   memory.    The   advantage   of   using
28       remap_file_pages()  over  using  repeated  calls to mmap(2) is that the
29       former approach does not require the kernel to  create  additional  VMA
30       (Virtual Memory Area) data structures.
31
32       To create a nonlinear mapping we perform the following steps:
33
34       1. Use  mmap(2)  to create a mapping (which is initially linear).  This
35          mapping must be created with the MAP_SHARED flag.
36
37       2. Use one or more calls to remap_file_pages() to rearrange the  corre‐
38          spondence  between  the  pages  of  the mapping and the pages of the
39          file.  It is possible to map the same page of a file  into  multiple
40          locations within the mapped region.
41
42       The  pgoff and size arguments specify the region of the file that is to
43       be relocated within the mapping: pgoff is a file offset in units of the
44       system page size; size is the length of the region in bytes.
45
46       The  addr  argument serves two purposes.  First, it identifies the map‐
47       ping whose pages we want to rearrange.  Thus, addr must be  an  address
48       that  falls  within  a  region  previously mapped by a call to mmap(2).
49       Second, addr specifies the address at which the file  pages  identified
50       by pgoff and size will be placed.
51
52       The values specified in addr and size should be multiples of the system
53       page size.  If they are not, then the kernel rounds both values down to
54       the nearest multiple of the page size.
55
56       The prot argument must be specified as 0.
57
58       The  flags  argument has the same meaning as for mmap(2), but all flags
59       other than MAP_NONBLOCK are ignored.
60

RETURN VALUE

62       On success, remap_file_pages() returns 0.  On error,  -1  is  returned,
63       and errno is set appropriately.
64

ERRORS

66       EINVAL addr  does  not  refer  to  a  valid  mapping  created  with the
67              MAP_SHARED flag.
68
69       EINVAL addr, size, prot, or pgoff is invalid.
70

VERSIONS

72       The remap_file_pages() system call appeared in Linux 2.5.46; glibc sup‐
73       port was added in version 2.3.3.
74

CONFORMING TO

76       The remap_file_pages() system call is Linux-specific.
77

NOTES

79       Since Linux 2.6.23, remap_file_pages() creates non-linear mappings only
80       on in-memory filesystems such as  tmpfs(5),  hugetlbfs  or  ramfs.   On
81       filesystems  with  a backing store, remap_file_pages() is not much more
82       efficient than using mmap(2) to adjust which  parts  of  the  file  are
83       mapped to which addresses.
84

SEE ALSO

86       getpagesize(2), mmap(2), mmap2(2), mprotect(2), mremap(2), msync(2)
87

COLOPHON

89       This  page  is  part of release 5.02 of the Linux man-pages project.  A
90       description of the project, information about reporting bugs,  and  the
91       latest     version     of     this    page,    can    be    found    at
92       https://www.kernel.org/doc/man-pages/.
93
94
95
96Linux                             2017-09-15               REMAP_FILE_PAGES(2)
Impressum