ALLOC_HUGEPAGES(2) Linux Programmer’s Manual ALLOC_HUGEPAGES(2) 名前 alloc_hugepages, free_hugepages - 大きなサイズのページの割り当てと解放 を行う 書式 void *alloc_hugepages(int key, void *addr, size_t len, int prot, int flag); int free_hugepages(void *addr); 説明 システムコール alloc_hugepages() と free_hugepages() は Linux 2.5.36 で 導 入 さ れ 、2.5.54 で再び削除された。これらのシステムコールは i386 と ia64 のみで (かつ CONFIG_HUGETLB_PAGE を指定してビルドされた場合に) 存 在 す る。 Linux 2.4.20 では syscall 番号が存在するが、呼び出すとエラー ENOSYS で失敗する。 i386 では、メモリ管理ハードウェアは通常のページ (4 KiB) と大きなサイ ズ のページ (以下、ヒュージページ; 2MiB または 4 MiB) を扱うことができる。 同様に、ia64 もいくつかのサイズのヒュージページを扱うことができる。これ ら のシステムコールは、ヒュージページをプロセスのメモリにマップしたり、 再び解放したりする。ヒュージページはメモリ内にロックされ、スワップさ れ ない。 key 引き数は識別子である。 0 の場合、ページは非公開になり、子プロセスに 継承されない。正の場合、ページは同じ key を使う他のアプリケーションと共 有され、子プロセスに継承される。 free_hugepages() の addr 引き数は、どのページを解放するかを指定する: addr は alloc_hugepages() の呼び出しの返り値である (全てのユーザがメ モ リ を 解 放 し た と き に 、 そ の メ モ リは初めて実際に解放される)。 alloc_hugepages() の addr 引き数はヒントであり、カーネルはそれに従う か も しれないし、従わないかもしれない。アドレスは正しく配置されなければな らない。 len 引き数は要求されたセグメントの長さである。これはヒュージページの サ イズの倍数にしなければならない。 prot 引 き 数 は セ グメントのメモリ保護を指定する。これは PROT_READ, PROT_WRITE, PROT_EXEC のいずれかである。 key が正でない限り、 flag 引き数は無視される。 key が正で、かつ flag が IPC_CREAT であり、かつ指定された key で (セグメントが) 何も存在しない場 合、新しいヒュージページセグメントが作成される。 flag が設定されてお ら ず、かつ指定された key のセグメントが存在しない場合、 ENOENT が返される 。 返り値 成功した場合、 alloc_hugepages() は割り当てられた仮想アドレスを返 し 、 free_hugepages() は 0 を返す。失敗した場合、-1 を返し、 errno が適切に 設定される。 エラー ENOSYS このシステムコールはカーネルでサポートされていない。 ファイル /proc/sys/vm/nr_hugepages 設定された hugetlb ページの数。このファイルは読み書きできる。 /proc/meminfo 設定された hugetlb ページの数と、 3 つの 変 数 HugePages_Total, HugePages_Free, Hugepagesize のサイズについての情報を提供する。 準拠 こ のシステムコールは Intel プロセッサ上の Linux に固有のものであり、移 植性が必要なプログラムで使うべきでない。 注意 これらのシステムコールはなくなった。これらは Linux 2.5.36 か ら 2.5.54 にのみ存在する。代わりに今は hugetlbfs ファイルシステムを使うことができ る。 (CPU がサポートしている場合) ヒュージページを 持 つ メ モ リ は 、 mmap(2) を使ってこの仮想ファイルシステムでファイルをマップすることで取 得できる。 ヒュージページの最大数は、 hugepages= 起動パラメータを使って指定でき る 。 Linux 2007-05-31 ALLOC_HUGEPAGES(2)
ALLOC_HUGEPAGES(2) Linux Programmer’s Manual ALLOC_HUGEPAGES(2) NAME alloc_hugepages, free_hugepages - allocate or free huge pages SYNOPSIS void *alloc_hugepages(int key, void *addr, size_t len, int prot, int flag); int free_hugepages(void *addr); DESCRIPTION The system calls alloc_hugepages() and free_hugepages() were introduced in Linux 2.5.36 and removed again in 2.5.54. They existed only on i386 and ia64 (when built with CONFIG_HUGETLB_PAGE). In Linux 2.4.20 the syscall numbers exist, but the calls fail with the error ENOSYS. On i386 the memory management hardware knows about ordinary pages (4 KiB) and huge pages (2 or 4 MiB). Similarly ia64 knows about huge pages of several sizes. These system calls serve to map huge pages into the process’s memory or to free them again. Huge pages are locked into memory, and are not swapped. The key argument is an identifier. When zero the pages are private, and not inherited by children. When positive the pages are shared with other applications using the same key, and inherited by child pro- cesses. The addr argument of free_hugepages() tells which page is being freed: it was the return value of a call to alloc_hugepages(). (The memory is first actually freed when all users have released it.) The addr argu- ment of alloc_hugepages() is a hint, that the kernel may or may not follow. Addresses must be properly aligned. The len argument is the length of the required segment. It must be a multiple of the huge page size. The prot argument specifies the memory protection of the segment. It is one of PROT_READ, PROT_WRITE, PROT_EXEC. The flag argument is ignored, unless key is positive. In that case, if flag is IPC_CREAT, then a new huge page segment is created when none with the given key existed. If this flag is not set, then ENOENT is returned when no segment with the given key exists. RETURN VALUE On success, alloc_hugepages() returns the allocated virtual address, and free_hugepages() returns zero. On error, -1 is returned, and errno is set appropriately. ERRORS ENOSYS The system call is not supported on this kernel. FILES /proc/sys/vm/nr_hugepages Number of configured hugetlb pages. This can be read and written. /proc/meminfo Gives info on the number of configured hugetlb pages and on their size in the three variables HugePages_Total, HugePages_Free, Hugepagesize. CONFORMING TO These calls are specific to Linux on Intel processors, and should not be used in programs intended to be portable. NOTES These system calls are gone; they existed only in Linux 2.5.36 through to 2.5.54. Now the hugetlbfs file system can be used instead. Memory backed by huge pages (if the CPU supports them) is obtained by using mmap(2) to map files in this virtual file system. The maximal number of huge pages can be specified using the hugepages= boot parameter. 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 2007-05-31 ALLOC_HUGEPAGES(2)
Copyright(C) linux-cmd.com All Rights Reserved. Author Takayuki Yukawa