remap_file_pagesのヘルプ・マニュアル
日本語 英語
remap_file_pages --help
man remap_file_pages
REMAP_FILE_PAGES(2) Linux Programmer’s Manual REMAP_FILE_PAGES(2)
名前
remap_file_pages - 非線形ファイルマッピングを作成する。
書式
#define _GNU_SOURCE
#include
int remap_file_pages(void *addr, size_t size, int prot,
ssize_t pgoff, int flags);
説明
remap_file_pages() システムコールは非線形なマッピング、つまりファイルの
ページがメモリ上で連続しない順番でマップされるマッピングを作成するた め
に使われる。 remap_file_pages() を使う方が mmap(2) を繰り返して使うより
優れている点は、前者の方法ではカーネルが VMA (Virtual Memory Area, 仮想
メモリ領域) データ構造体を追加で作成する必要がないことである。
非線形マッピングを作成するためには、以下のようなステップを実行する:
1. mmap(2) を使い、マッピングを作成する (このマッピングは最初は線形であ
る)。このマッピングは MAP_SHARED フラグを指定して作成されなければ な
らない。
2. remap_file_pages() を 1 回以上呼び出して、マッピングのページとファイ
ルのページの対応関係を再構成する。ファイルの同じページをマッピング領
域の複数の場所にマップすることが可能である。
pgoff と size 引き数は、マッピング内で再配置されるファイルの領域を指定
する。 pgoff はファイルオフセットであり、単位はシステムのページサイズで
ある。 size は領域の長さであり、単位はバイトである。
addr 引き数は 2 つの目的で使われる。第 1 の目的は、この引き数によって再
編成したいページのマッピングを識別することである 。 よ っ て addr は
mmap(2) の呼び出しで過去にマップされた領域内のアドレスでなければならな
い。第 2 の目的は、 pgoff と size で識別されるファイルページが置かれ る
予定のアドレスを、 addr によって指定することである。
addr と size に指定する値は、システムのページサイズの倍数とすべきである
。それ以外の場合、カーネルは「両方」の値を最も近いページサイズの倍数 へ
「切り下げる」。
prot 引き数は 0 に指定されなければならない。
flags 引き数は mmap(2) のものと同じ意味であるが、 MAP_NONBLOCK 以外の全
てのフラグは無視される。
返り値
成功した場合、 remap_file_pages() は 0 を返す。エラーの場合、-1 が返 さ
れ、 errno が適切に設定される。
エラー
EINVAL addr が MAP_SHARED フラグを指定して作成された有効なマッピングを
参照していない。
EINVAL addr, size, prot, pgoff のいずれかが不正である。
バージョン
remap_file_pages() システムコールは Linux 2.5.46 で登場した。 glibc で
のサポートは glibc バージョン 2.3.3 で追加された。
準拠
remap_file_pages() システムコールは Linux 固有のものである。
関連項目
getpagesize(2), mmap(2), mmap2(2), mprotect(2), mremap(2), msync(2),
feature_test_macros(7)
Linux 2008-04-22 REMAP_FILE_PAGES(2)
REMAP_FILE_PAGES(2) Linux Programmer’s Manual REMAP_FILE_PAGES(2)
NAME
remap_file_pages - create a non-linear file mapping
SYNOPSIS
#define _GNU_SOURCE
#include
int remap_file_pages(void *addr, size_t size, int prot,
ssize_t pgoff, int flags);
DESCRIPTION
The remap_file_pages() system call is used to create a non-linear map-
ping, that is, a mapping in which the pages of the file are mapped into
a non-sequential order in memory. The advantage of using
remap_file_pages() over using repeated calls to mmap(2) is that the
former approach does not require the kernel to create additional VMA
(Virtual Memory Area) data structures.
To create a non-linear mapping we perform the following steps:
1. Use mmap(2) to create a mapping (which is initially linear). This
mapping must be created with the MAP_SHARED flag.
2. Use one or more calls to remap_file_pages() to rearrange the corre-
spondence between the pages of the mapping and the pages of the
file. It is possible to map the same page of a file into multiple
locations within the mapped region.
The pgoff and size arguments specify the region of the file that is to
be relocated within the mapping: pgoff is a file offset in units of the
system page size; size is the length of the region in bytes.
The addr argument serves two purposes. First, it identifies the map-
ping whose pages we want to rearrange. Thus, addr must be an address
that falls within a region previously mapped by a call to mmap(2).
Second, addr specifies the address at which the file pages identified
by pgoff and size will be placed.
The values specified in addr and size should be multiples of the system
page size. If they are not, then the kernel rounds both values down to
the nearest multiple of the page size.
The prot argument must be specified as 0.
The flags argument has the same meaning as for mmap(2), but all flags
other than MAP_NONBLOCK are ignored.
RETURN VALUE
On success, remap_file_pages() returns 0. On error, -1 is returned,
and errno is set appropriately.
ERRORS
EINVAL addr does not refer to a valid mapping created with the
MAP_SHARED flag.
EINVAL addr, size, prot, or pgoff is invalid.
VERSIONS
The remap_file_pages() system call appeared in Linux 2.5.46; glibc sup-
port was added in version 2.3.3.
CONFORMING TO
The remap_file_pages() system call is Linux-specific.
SEE ALSO
getpagesize(2), mmap(2), mmap2(2), mprotect(2), mremap(2), msync(2),
feature_test_macros(7)
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
Linux 2008-04-22 REMAP_FILE_PAGES(2)