X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=draft%2Fman2%2Fmadvise.2;h=1c9d9a45fe8cb8c4d6b3acd24339feb6c3be020f;hb=c1dfa2f6ab1bbed84992d3c59ee9925f4d453668;hp=abf0bb75357a992fdc2f07cbda2aedd25ada99f2;hpb=633a2252e0be3c867dce264a180a89ce8181d36f;p=linuxjm%2FLDP_man-pages.git diff --git a/draft/man2/madvise.2 b/draft/man2/madvise.2 index abf0bb75..1c9d9a45 100644 --- a/draft/man2/madvise.2 +++ b/draft/man2/madvise.2 @@ -1,7 +1,6 @@ -.\" Hey Emacs! This file is -*- nroff -*- source. -.\" -.\" Copyright (C) 2001 David Gez +.\" Copyright (C) 2001 David Gómez .\" +.\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. @@ -21,171 +20,78 @@ .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. +.\" %%%LICENSE_END .\" .\" Based on comments from mm/filemap.c. Last modified on 10-06-2001 .\" Modified, 25 Feb 2002, Michael Kerrisk, -.\" Added notes on MADV_DONTNEED -.\" FIXME -.\" 2.6.32 added MADV_HWPOISON, MADV_MERGEABLE, and MADV_UNMERGEABLE -.\" 2.6.33 added MADV_SOFT_OFFLINE +.\" Added notes on MADV_DONTNEED +.\" 2010-06-19, mtk, Added documentation of MADV_MERGEABLE and +.\" MADV_UNMERGEABLE +.\" 2010-06-15, Andi Kleen, Add documentation of MADV_HWPOISON. +.\" 2010-06-19, Andi Kleen, Add documentation of MADV_SOFT_OFFLINE. +.\" 2011-09-18, Doug Goldstein +.\" Document MADV_HUGEPAGE and MADV_NOHUGEPAGE +.\" +.\"******************************************************************* .\" -.\" Japanese Version Copyright (c) 2001 NAKANO Takeo all rights reserved. -.\" Translated Thu Aug 16 2001 by NAKANO Takeo -.\" Updated Tue 8 Oct 2002 by NAKANO Takeo -.\" Updated 2007-01-08, Akihiro MOTOKI , LDP v2.43 +.\" This file was generated with po4a. Translate the source file. .\" -.TH MADVISE 2 2008-04-22 "Linux" "Linux Programmer's Manual" -.\"O .SH NAME -.\"O madvise \- give advice about use of memory -.SH ̾Á° -madvise \- ¥á¥â¥êÍøÍѤ˴ؤ¹¤ë¥¢¥É¥Ð¥¤¥¹¤òÍ¿¤¨¤ë -.\"O .SH SYNOPSIS -.SH ½ñ¼° -.B #include +.\"******************************************************************* +.TH MADVISE 2 2012\-04\-28 Linux "Linux Programmer's Manual" +.SH 名前 +madvise \- メモリ利用に関するアドバイスを与える +.SH 書式 +\fB#include \fP .sp -.BI "int madvise(void *" addr ", size_t " length ", int " advice ); +\fBint madvise(void *\fP\fIaddr\fP\fB, size_t \fP\fIlength\fP\fB, int \fP\fIadvice\fP\fB);\fP .sp .in -4n -.\"O Feature Test Macro Requirements for glibc (see -.\"O .BR feature_test_macros (7)): -glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï -.RB ( feature_test_macros (7) -»²¾È): +glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .in .sp -.BR madvise (): -_BSD_SOURCE -.\"O .SH DESCRIPTION -.SH ÀâÌÀ -.\"O The -.\"O .BR madvise () -.\"O system call advises the kernel about how to handle paging input/output in -.\"O the address range beginning at address -.\"O .I addr -.\"O and with size -.\"O .I length -.\"O bytes. -.\"O It allows an application to tell the kernel how it expects to use -.\"O some mapped or shared memory areas, so that the kernel can choose -.\"O appropriate read-ahead and caching techniques. -.\"O This call does not influence the semantics of the application -.\"O (except in the case of -.\"O .BR MADV_DONTNEED ), -.\"O but -.\"O may influence its performance. -.\"O The kernel is free to ignore the advice. -.BR madvise () -¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¡¢¥¢¥É¥ì¥¹ -.I addr -¤«¤é¤Ï¤¸¤Þ¤ë -.I length -¥Ð¥¤¥È¤Î¥á¥â¥ê¥Ö¥í¥Ã¥¯¤Î¥Ú¡¼¥¸¥ó¥°Æþ½ÐÎϤò¤É¤¦°·¤¨¤ÐÎɤ¤¤«¡¢ -¥«¡¼¥Í¥ë¤Ë¥¢¥É¥Ð¥¤¥¹¤¹¤ë¡£ -¤³¤ì¤òÍѤ¤¤ë¤È¡¢ -¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤«¤é¥«¡¼¥Í¥ë¤Ë¡¢ -¥Þ¥Ã¥×¤µ¤ì¤¿¥á¥â¥ê¤ä¶¦Í­¥á¥â¥ê¤ò¤É¤Î¤è¤¦¤Ë°·¤Ã¤Æ¤Û¤·¤¤¤«ÅÁ¤¨¤ë¤³¤È¤¬¤Ç¤­¡¢ -¥«¡¼¥Í¥ë¤Ï¤½¤ì¤Ë±þ¤¸¤ÆÀèÆɤߤ䥭¥ã¥Ã¥·¥å¤Ê¤É¤ÎŬÀڤʼêË¡¤òÁªÂò¤Ç¤­¤ë¡£ -¤³¤Î¥³¡¼¥ë¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ÎÆ°ºî¤½¤Î¤â¤Î¤Ë¤Ï±Æ¶Á¤·¤Ê¤¤ -.RB ( MADV_DONTNEED -¤Î¾ì¹ç¤ÏÊÌ) ¤¬¡¢ -À­Ç½¤Ë¤Ï±Æ¶Á¤·¤¦¤ë¡£ -¤Ê¤ª¤³¤Î¥¢¥É¥Ð¥¤¥¹¤ò¼õ¤±Æþ¤ì¤ë¤«¤É¤¦¤«¤Ï¥«¡¼¥Í¥ë¤ËǤ¤µ¤ì¤ë¡£ +\fBmadvise\fP(): _BSD_SOURCE +.SH 説明 +\fBmadvise\fP() システムコールは、アドレス \fIaddr\fP からはじまる \fIlength\fP +バイトのメモリブロックのページング入出力をどう扱えば良いか、 カーネルにアドバイスする。 これを用いると、 アプリケーションからカーネルに、 +マップされたメモリや共有メモリをどのように扱ってほしいか伝えることができ、 カーネルはそれに応じて先読みやキャッシュなどの適切な手法を選択できる。 +このコールはアプリケーションの動作そのものには影響しない (\fBMADV_DONTNEED\fP の場合は別) が、 性能には影響しうる。 +なおこのアドバイスを受け入れるかどうかはカーネルに任される。 .LP -.\"O The advice is indicated in the -.\"O .I advice -.\"O argument which can be -¥¢¥É¥Ð¥¤¥¹¤Ï°ú¤­¿ô -.I advice -¤Ë¤è¤Ã¤ÆÍ¿¤¨¤ë¡£°Ê²¼¤Î¤¤¤º¤ì¤«¤ò»ØÄê¤Ç¤­¤ë¡£ -.TP -.B MADV_NORMAL -.\"O No special treatment. -.\"O This is the default. -ÆÃÊ̤ʰ·¤¤¤Ï¹Ô¤ï¤Ê¤¤¡£¤³¤ì¤¬¥Ç¥Õ¥©¥ë¥È¤Ç¤¢¤ë¡£ -.TP -.B MADV_RANDOM -.\"O Expect page references in random order. -.\"O (Hence, read ahead may be less useful than normally.) -¥Ú¡¼¥¸»²¾È¤Ï¥é¥ó¥À¥à¤Ê½ç½ø¤Ç¹Ô¤ï¤ì¤½¤¦¤À¡£ -(¤·¤¿¤¬¤Ã¤Æ¡¢ÀèÆɤߤϤ¢¤Þ¤ê¸ú²Ì¤¬¤Ê¤µ¤½¤¦¤À¡£) -.TP -.B MADV_SEQUENTIAL -.\"O Expect page references in sequential order. -.\"O (Hence, pages in the given range can be aggressively read ahead, -.\"O and may be freed soon after they are accessed.) -¥Ú¡¼¥¸»²¾È¤Ï¥·¡¼¥±¥ó¥·¥ã¥ë¤Ê½ç½ø¤Ç¹Ô¤ï¤ì¤½¤¦¤À¡£ -(¤·¤¿¤¬¤Ã¤ÆÍ¿¤¨¤¿ÈϰϤΥڡ¼¥¸¤ÏÀѶËŪ¤ËÀèÆɤߤ·¤Æ¤ª¤¯¤ÈÎɤ¤¤À¤í¤¦¡£ -¤Þ¤¿¥¢¥¯¥»¥¹¤¬½ª¤ï¤Ã¤¿¤é®¤ä¤«¤Ë²òÊü¤·¤ÆÎɤ¤¡£) -.TP -.B MADV_WILLNEED -.\"O Expect access in the near future. -.\"O (Hence, it might be a good idea to read some pages ahead.) -¶á¤¤¾­Íè¤Ë¥¢¥¯¥»¥¹¤µ¤ì¤½¤¦¤À¡£ -(¤·¤¿¤¬¤Ã¤Æ¤³¤ì¤é¤Î¥Ú¡¼¥¸¤òº£¤Î¤¦¤Á¤ËÀèÆɤߤ·¤Æ¤ª¤¯¤È¤¤¤¤¤À¤í¤¦¡£) -.TP -.B MADV_DONTNEED -.\"O Do not expect access in the near future. -.\"O (For the time being, the application is finished with the given range, -.\"O so the kernel can free resources associated with it.) -¤·¤Ð¤é¤¯¥¢¥¯¥»¥¹¤Ï¤Ê¤µ¤½¤¦¤À¡£ -(¸½»þÅÀ¤Ç¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ÏÍ¿¤¨¤¿ÈϰϤνèÍý¤ò½ª¤¨¤Æ¤¤¤ë¡£ -¤·¤¿¤¬¤Ã¤Æ¥«¡¼¥Í¥ë¤Ï¤³¤ì¤Ë´ØÏ¢¤¹¤ë¥ê¥½¡¼¥¹¤ò²òÊü¤·¤ÆÎɤ¤¡£) -.\"O Subsequent accesses of pages in this range will succeed, but will result -.\"O either in reloading of the memory contents from the underlying mapped file -.\"O (see -.\"O .BR mmap (2)) -.\"O or zero-fill-on-demand pages for mappings -.\"O without an underlying file. -¤³¤ì°Ê¹ß¤³¤ÎÈϰϤΥڡ¼¥¸¤Ø¤Î¥¢¥¯¥»¥¹¤¬¤¢¤ë¤È¡¢ -À®¸ù¤Ï¤¹¤ë¤¬¡¢¥á¥â¥ê¤ÎÆâÍƤò¥Þ¥Ã¥×¸µ¤Î¥Õ¥¡¥¤¥ë¤«¤é¥í¡¼¥É¤·Ä¾¤¹¤³¤È¤Ë¤Ê¤ë -.RB ( mmap (2) -¤ò¸«¤è) ¤«¡¢ -¤Þ¤¿¤Ï¸µ¥Õ¥¡¥¤¥ë¤¬¤Ê¤¤¥Þ¥Ã¥×¥Ú¡¼¥¸¤Ç¤Ï -¥¢¥¯¥»¥¹¤¬¤¢¤Ã¤¿¤È¤­¤Ë 0 Ëä¤á¤¬¹Ô¤ï¤ì¤ë¤³¤È¤Ë¤Ê¤ë¡£ -.TP -.\"O .BR MADV_REMOVE " (Since Linux 2.6.16)" -.BR MADV_REMOVE " (Linux 2.6.16 °Ê¹ß)" -.\"O Free up a given range of pages -.\"O and its associated backing store. -.\"O Currently, -.\"O .\" 2.6.18-rc5 -.\"O only shmfs/tmpfs supports this; other file systems return with the -.\"O error -.\"O .BR ENOSYS . -»ØÄꤵ¤ì¤¿ÈϰϤΥڡ¼¥¸¤È´ØÏ¢¤¹¤ë¥Ð¥Ã¥­¥ó¥°¥¹¥È¥¢¤ò²òÊü¤¹¤ë¡£ -¸½ºß¤Î¤È¤³¤í¡¢ +アドバイスは引き数 \fIadvice\fP によって与える。以下のいずれかを指定できる。 +.TP +\fBMADV_NORMAL\fP +特別な扱いは行わない。これがデフォルトである。 +.TP +\fBMADV_RANDOM\fP +ページ参照はランダムな順序で行われそうだ。 (したがって、先読みはあまり効果がなさそうだ。) +.TP +\fBMADV_SEQUENTIAL\fP +ページ参照はシーケンシャルな順序で行われそうだ。 (したがって与えた範囲のページは積極的に先読みしておくと良いだろう。 +またアクセスが終わったら速やかに解放して良い。) +.TP +\fBMADV_WILLNEED\fP +近い将来にアクセスされそうだ。 (したがってこれらのページを今のうちに先読みしておくといいだろう。) +.TP +\fBMADV_DONTNEED\fP +しばらくアクセスはなさそうだ。 (現時点でアプリケーションは与えた範囲の処理を終えている。 したがってカーネルはこれに関連するリソースを解放して良い。) +これ以降この範囲のページへのアクセスがあると、 成功はするが、メモリの内容をマップ元のファイルからロードし直すことになる (\fBmmap\fP(2) +を見よ) か、 または元ファイルがないマップページでは アクセスがあったときに 0 埋めが行われることになる。 +.TP +\fBMADV_REMOVE\fP (Linux 2.6.16 以降) .\" 2.6.18-rc5 -shmfs/tmpfs ¤À¤±¤¬¤³¤ì¤ËÂбþ¤·¤Æ¤¤¤ë¡£ -¾¤Î¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Ç¤Ï -.B ENOSYS -¤¬ÊÖ¤µ¤ì¤ë¡£ .\" Databases want to use this feature to drop a section of their .\" bufferpool (shared memory segments) - without writing back to -.\" disk/swap space. This feature is also useful for supporting +.\" disk/swap space. This feature is also useful for supporting .\" hot-plug memory on UML. -.TP -.\"O .BR MADV_DONTFORK " (Since Linux 2.6.16)" -.BR MADV_DONTFORK " (Linux 2.6.16 °Ê¹ß)" +指定された範囲のページと関連するバッキングストアを解放する。 現在のところ、 shmfs/tmpfs だけがこれに対応している。 +他のファイルシステムでは \fBENOSYS\fP が返される。 +.TP +\fBMADV_DONTFORK\fP (Linux 2.6.16 以降) .\" See http://lwn.net/Articles/171941/ -.\"O Do not make the pages in this range available to the child after a -.\"O .BR fork (2). -.\"O This is useful to prevent copy-on-write semantics from changing -.\"O the physical location of a page(s) if the parent writes to it after a -.\"O .BR fork (2). -.\"O (Such page relocations cause problems for hardware that -.\"O DMAs into the page(s).) -.BR fork (2) -¤¬¹Ô¤ï¤ì¤¿¸å¡¢»ØÄꤵ¤ì¤¿ÈϰϤΥڡ¼¥¸¤ò»Ò¥×¥í¥»¥¹¤¬ÍøÍѤǤ­¤Ê¤¤¤è¤¦¤Ë¤¹¤ë¡£ -¤³¤Îµ¡Ç½¤Ï¡¢½ñ¤­¹þ¤ß»þ¥³¥Ô¡¼ (copy-on-write) Êý¼°¤Ç¡¢ -.BR fork (2) -¤Î¸å¤Ç¿Æ¥×¥í¥»¥¹¤¬¥Ú¡¼¥¸¤Ë½ñ¤­¹þ¤ß¤ò¹Ô¤Ã¤¿¾ì¹ç¤Ë -¥Ú¡¼¥¸¤ÎʪÍý°ÌÃÖ¤¬ÊѲ½¤·¤Ê¤¤¤è¤¦¤Ë¤¹¤ë¤Î¤ËÍ­¸ú¤Ç¤¢¤ë -(¥Ú¡¼¥¸¤ÎºÆÇÛÃ֤ϥϡ¼¥É¥¦¥§¥¢¤¬¤½¤Î¥Ú¡¼¥¸¤Ë DMA žÁ÷¤ò¹Ô¤¦¤è¤¦¤Ê¾ì¹ç¤Ë -ÌäÂê¤òµ¯¤³¤¹¤³¤È¤¬¤¢¤ë)¡£ .\" [PATCH] madvise MADV_DONTFORK/MADV_DOFORK .\" Currently, copy-on-write may change the physical address of .\" a page even if the user requested that the page is pinned in -.\" memory (either by mlock or by get_user_pages). This happens +.\" memory (either by mlock or by get_user_pages). This happens .\" if the process forks meanwhile, and the parent writes to that .\" page. As a result, the page is orphaned: in case of .\" get_user_pages, the application will never see any data hardware @@ -203,171 +109,148 @@ shmfs/tmpfs .\" .\" SEE ALSO: http://lwn.net/Articles/171941/ .\" "Tweaks to madvise() and posix_fadvise()", 14 Feb 2006 -.TP -.\"O .BR MADV_DOFORK " (Since Linux 2.6.16)" -.BR MADV_DOFORK " (Linux 2.6.16 °Ê¹ß)" -.\"O Undo the effect of -.\"O .BR MADV_DONTFORK , -.\"O restoring the default behavior, whereby a mapping is inherited across -.\"O .BR fork (2). -.B MADV_DONTFORK -¤Î±Æ¶Á¤ò¼è¤ê¾Ã¤·¡¢¥Ç¥Õ¥©¥ë¥È¤ÎÆ°ºî¤ËÌ᤹¡£ -¤Ä¤Þ¤ê¡¢ -.BR fork (2) -¤ÎÁ°¸å¤Ç¥Þ¥Ã¥Ô¥ó¥°¤Ï·Ñ¾µ¤µ¤ì¤ë¤è¤¦¤Ë¤Ê¤ë¡£ -.\"O .SH "RETURN VALUE" -.SH ÊÖ¤êÃÍ -.\"O On success -.\"O .BR madvise () -.\"O returns zero. -.\"O On error, it returns \-1 and -.\"O .I errno -.\"O is set appropriately. -.BR madvise () -¤ÏÀ®¸ù¤¹¤ë¤È 0 ¤òÊÖ¤¹¡£ -¥¨¥é¡¼¤¬µ¯¤³¤ë¤È \-1 ¤òÊÖ¤·¡¢ -.I errno -¤òŬÀÚ¤ÊÃͤËÀßÄꤹ¤ë¡£ -.\"O .SH ERRORS -.SH ¥¨¥é¡¼ -.TP -.B EAGAIN -.\"O A kernel resource was temporarily unavailable. -²¿¤é¤«¤Î¥«¡¼¥Í¥ë¥ê¥½¡¼¥¹¤¬°ì»þŪ¤ËÍøÍѤǤ­¤Ê¤«¤Ã¤¿¡£ -.TP -.B EBADF -.\"O The map exists, but the area maps something that isn't a file. -»ØÄꤷ¤¿¥Þ¥Ã¥×¤Ï¸ºß¤¹¤ë¤¬¡¢¥Õ¥¡¥¤¥ë¤Ç¤Ï¤Ê¤¤¤È¤³¤í¤ò¥Þ¥Ã¥×¤·¤Æ¤¤¤ë¡£ -.TP -.B EINVAL -.\"O The value -.\"O .I len -.\"O is negative, +\fBfork\fP(2) が行われた後、指定された範囲のページを子プロセスが利用できないようにする。 この機能は、書き込み時コピー +(copy\-on\-write) 方式で、 \fBfork\fP(2) の後で親プロセスがページに書き込みを行った場合に +ページの物理位置が変化しないようにするのに有効である (ページの再配置はハードウェアがそのページに DMA 転送を行うような場合に +問題を起こすことがある)。 +.TP +\fBMADV_DOFORK\fP (Linux 2.6.16 以降) +\fBMADV_DONTFORK\fP の影響を取り消し、デフォルトの動作に戻す。 つまり、 \fBfork\fP(2) +の前後でマッピングは継承されるようになる。 +.TP +\fBMADV_HWPOISON\fP (Linux 2.6.32 以降) +Poison a page and handle it like a hardware memory corruption. This +operation is available only for privileged (\fBCAP_SYS_ADMIN\fP) processes. +This operation may result in the calling process receiving a \fBSIGBUS\fP and +the page being unmapped. This feature is intended for testing of memory +error\-handling code; it is available only if the kernel was configured with +\fBCONFIG_MEMORY_FAILURE\fP. +.TP +\fBMADV_SOFT_OFFLINE\fP (Linux 2.6.33 以降) +Soft offline the pages in the range specified by \fIaddr\fP and \fIlength\fP. The +memory of each page in the specified range is preserved (i.e., when next +accessed, the same content will be visible, but in a new physical page +frame), and the original page is offlined (i.e., no longer used, and taken +out of normal memory management). The effect of the \fBMADV_SOFT_OFFLINE\fP +operation is invisible to (i.e., does not change the semantics of) the +calling process. This feature is intended for testing of memory +error\-handling code; it is available only if the kernel was configured with +\fBCONFIG_MEMORY_FAILURE\fP. +.TP +\fBMADV_MERGEABLE\fP (Linux 2.6.32 以降) +Enable Kernel Samepage Merging (KSM) for the pages in the range specified by +\fIaddr\fP and \fIlength\fP. The kernel regularly scans those areas of user +memory that have been marked as mergeable, looking for pages with identical +content. These are replaced by a single write\-protected page (which is +automatically copied if a process later wants to update the content of the +page). KSM merges only private anonymous pages (see \fBmmap\fP(2)). The KSM +feature is intended for applications that generate many instances of the +same data (e.g., virtualization systems such as KVM). It can consume a lot +of processing power; use with care. See the Linux kernel source file +\fIDocumentation/vm/ksm.txt\fP for more details. The \fBMADV_MERGEABLE\fP and +\fBMADV_UNMERGEABLE\fP operations are available only if the kernel was +configured with \fBCONFIG_KSM\fP. +.TP +\fBMADV_UNMERGEABLE\fP (Linux 2.6.32 以降) +Undo the effect of an earlier \fBMADV_MERGEABLE\fP operation on the specified +address range; KSM unmerges whatever pages it had merged in the address +range specified by \fIaddr\fP and \fIlength\fP. +.TP +\fBMADV_HUGEPAGE\fP (Linux 2.6.38 以降) +.\" http://lwn.net/Articles/358904/ +.\" https://lwn.net/Articles/423584/ +Enables Transparent Huge Pages (THP) for pages in the range specified by +\fIaddr\fP and \fIlength\fP. Currently, Transparent Huge Pages work only with +private anonymous pages (see \fBmmap\fP(2)). The kernel will regularly scan +the areas marked as huge page candidates to replace them with huge pages. +The kernel will also allocate huge pages directly when the region is +naturally aligned to the huge page size (see \fBposix_memalign\fP(2)). This +feature is primarily aimed at applications that use large mappings of data +and access large regions of that memory at a time (e.g., virtualization +systems such as QEMU). It can very easily waste memory (e.g., a 2MB mapping +that only ever accesses 1 byte will result in 2MB of wired memory instead of +one 4KB page). See the Linux kernel source file +\fIDocumentation/vm/transhuge.txt\fP for more details. The \fBMADV_HUGEPAGE\fP +and \fBMADV_NOHUGEPAGE\fP operations are available only if the kernel was +configured with \fBCONFIG_TRANSPARENT_HUGEPAGE\fP. +.TP +\fBMADV_NOHUGEPAGE\fP (Linux 2.6.38 以降) +Ensures that memory in the address range specified by \fIaddr\fP and \fIlength\fP +will not be collapsed into huge pages. +.TP +\fBMADV_DONTDUMP\fP (Linux 3.4 以降) +Exclude from a core dump those pages in the range specified by \fIaddr\fP and +\fIlength\fP. This is useful in applications that have large areas of memory +that are known not to be useful in a core dump. The effect of +\fBMADV_DONTDUMP\fP takes precedence over the bit mask that is set via the +\fI/proc/PID/coredump_filter\fP file (see \fBcore\fP(5)). +.TP +\fBMADV_DODUMP\fP (Linux 3.4 以降) +Undo the effect of an earlier \fBMADV_DONTDUMP\fP. +.SH 返り値 +\fBmadvise\fP() は成功すると 0 を返す。 エラーが起こると \-1 を返し、 \fIerrno\fP を適切な値に設定する。 +.SH エラー +.TP +\fBEAGAIN\fP +何らかのカーネルリソースが一時的に利用できなかった。 +.TP +\fBEBADF\fP +指定したマップは存在するが、ファイルではないところをマップしている。 +.TP +\fBEINVAL\fP +このエラーは以下の理由で発生する。 +.RS +.IP * 3 .\" .I len .\" is zero, -.\"O .I addr -.\"O is not page-aligned, -.\"O .I advice -.\"O is not a valid value, or the application is attempting -.\"O to release locked or shared pages (with -.\"O .BR MADV_DONTNEED ). -.I len -¤ÎÃͤ¬Éé¡¢ -.I addr -¤¬¥Ú¡¼¥¸¶­³¦¤Ç¤Ê¤¤¡¢ -.I advice -¤¬Àµ¤·¤¤ÃͤǤʤ¤¡¢ -¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬¥í¥Ã¥¯¤µ¤ì¤¿¥Ú¡¼¥¸¤ä¶¦Í­¥Ú¡¼¥¸¤ò -.RB ( MADV_DONTNEED -¤Ç) ²òÊü¤·¤è¤¦¤È¤·¤Æ¤¤¤ë¡¢¤Ê¤É¡£ -.TP -.B EIO -.\"O (for -.\"O .BR MADV_WILLNEED ) -.\"O Paging in this area would exceed the process's -.\"O maximum resident set size. -.RB ( MADV_WILLNEED -¤Î¾ì¹ç) ¤³¤ÎÈϰϤΥڡ¼¥¸¥ó¥°¤ò¹Ô¤¦¤È¡¢ -¥×¥í¥»¥¹¤Î RSS (resident set size) ¤ÎºÇÂçÃͤò±Û¤¨¤Æ¤·¤Þ¤¦¡£ -.\"nakano RSS ¤ÏÌõ¸ì¤¬¤¢¤ê¤Þ¤·¤¿¤Ã¤±? -.TP -.B ENOMEM -.\"O (for -.\"O .BR MADV_WILLNEED ) -.\"O Not enough memory: paging in failed. -.RB ( MADV_WILLNEED -¤Î¾ì¹ç) ¥á¥â¥ê¤¬Â­¤ê¤º¡¢¥Ú¡¼¥¸¥ó¥°¤Ë¼ºÇÔ¤·¤¿¡£ -.TP -.B ENOMEM -.\"O Addresses in the specified range are not currently -.\"O mapped, or are outside the address space of the process. -»ØÄꤷ¤¿ÈϰϤΥ¢¥É¥ì¥¹¤¬¡¢¸½ºß¥Þ¥Ã¥×¤µ¤ì¤Æ¤¤¤Ê¤¤¡£ -¤¢¤ë¤¤¤Ï¥×¥í¥»¥¹¤Î¥¢¥É¥ì¥¹¶õ´Ö¤ÎÆâÉô¤Ë¤Ê¤¤¡£ -.\"O .SH "CONFORMING TO" -.SH ½àµò -POSIX.1b. -.\"O POSIX.1-2001 describes -.\"O .BR posix_madvise (3) -.\"O .\" FIXME . Write a posix_fadvise(3) page. -.\"O with constants -.\"O .BR POSIX_MADV_NORMAL , -.\"O etc., -.\"O with a behavior close to that described here. -.\"O There is a similar -.\"O .BR posix_fadvise (2) -.\"O for file access. -POSIX.1-2001 ¤Ç¤Ï¡¢ -.BR posix_madvise (3) -.\" FIXME . Write a posix_fadvise(3) page. -¤ò -.B POSIX_MADV_NORMAL -¤Ê¤É¤ÎÄê¿ô¤È¤È¤â¤Ëµ­½Ò¤·¤Æ¤¤¤¿ -(¤½¤ì¤¾¤ì¤Î¿¶¤ëÉñ¤¤¤Ï¤³¤³¤Ç½Ò¤Ù¤¿¤â¤Î¤Ë¶á¤¤)¡£ -¥Õ¥¡¥¤¥ë¥¢¥¯¥»¥¹¤ËÂФ·¤Æ¤â -.BR posix_fadvise (2) -¤È¤¤¤¦Îà»÷¤Î´Ø¿ô¤¬Â¸ºß¤¹¤ë¡£ +\fIlen\fP が負の値である。 +.IP * +\fIaddr\fP がページ境界ではない。 +.IP * +\fIadvice\fP が有効な値でない。 +.IP * +アプリケーションがロックされたページや共有ページを (\fBMADV_DONTNEED\fP で) 解放 +しようとしている。 +.IP * +\fIadvice\fP に \fBMADV_MERGEABLE\fP か \fBMADV_UNMERGEABLE\fP が指定されたが、 カーネルの設定が +\fBCONFIG_KSM\fP が有効になっていなかった。 +.RE +.TP +\fBEIO\fP +(\fBMADV_WILLNEED\fP の場合) この範囲のページングを行うと、 プロセスの RSS (resident set size) +の最大値を越えてしまう。 +.TP +\fBENOMEM\fP +(\fBMADV_WILLNEED\fP の場合) メモリが足りず、ページングに失敗した。 +.TP +\fBENOMEM\fP +指定した範囲のアドレスが、現在マップされていない。 あるいはプロセスのアドレス空間の内部にない。 +.SH 準拠 +.\" FIXME . Write a posix_madvise(3) page. +POSIX.1b. POSIX.1\-2001 では、 \fBposix_madvise\fP(3) を \fBPOSIX_MADV_NORMAL\fP +などの定数とともに記述していた (それぞれの振る舞いはここで述べたものに近い)。 ファイルアクセスに対しても \fBposix_fadvise\fP(2) +という類似の関数が存在する。 -.\"O .BR MADV_REMOVE , -.\"O .BR MADV_DONTFORK , -.\"O and -.\"O .B MADV_DOFORK -.\"O are Linux-specific. -.BR MADV_REMOVE , -.BR MADV_DONTFORK , -.B MADV_DOFORK -¤Ï Linux ¸ÇÍ­¤Ç¤¢¤ë¡£ -.\"O .SH NOTES -.\"O .SS "Linux Notes" -.SH Ãí°Õ -.SS "Linux ¤Ç¤ÎÃí°Õ" -.\"O .LP -.\"O The current Linux implementation (2.4.0) views this system call -.\"O more as a command than as advice and hence may return an error -.\"O when it cannot do what it usually would do in response to this -.\"O advice. -.\"O (See the ERRORS description above.) -.\"O This is nonstandard behavior. -¸½ºß¤Î Linux ¤Î¼ÂÁõ (2.4.0) ¤Ç¤Ï¡¢ -¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ò¥¢¥É¥Ð¥¤¥¹¤È¤¤¤¦¤è¤ê¤ÏÌ¿Îá¤È¸«¤Æ¤¤¤ë¡£ -¤·¤¿¤¬¤Ã¤Æ¤³¤Î¥¢¥É¥Ð¥¤¥¹¤ËÂФ·¤ÆÄ̾ï¹Ô¤ï¤ì¤ëÆ°ºî¤¬ÉÔ²Äǽ¤Ê¾ì¹ç¤Ï¡¢ -¥¨¥é¡¼¤òÊÖ¤¹¤³¤È¤¬¤¢¤ë (¾åµ­¤Î ¥¨¥é¡¼ ¤Îµ­½Ò¤ò»²¾È)¡£ -¤³¤Î¿¶Éñ¤¤¤Ïɸ½à¤È¤Ï°Û¤Ê¤ë¡£ +\fBMADV_REMOVE\fP, \fBMADV_DONTFORK\fP, \fBMADV_DOFORK\fP, \fBMADV_HWPOISON\fP, +\fBMADV_MERGEABLE\fP, \fBMADV_UNMERGEABLE\fP は Linux 固有である。 +.SH 注意 +.SS "Linux での注意" +.LP +現在の Linux の実装 (2.4.0) では、 このシステムコールをアドバイスというよりは命令と見ている。 +したがってこのアドバイスに対して通常行われる動作が不可能な場合は、 エラーを返すことがある (上記の エラー の記述を参照)。 +この振舞いは標準とは異なる。 .LP -.\"O The Linux implementation requires that the address -.\"O .I addr -.\"O be page-aligned, and allows -.\"O .I length -.\"O to be zero. -.\"O If there are some parts of the specified address range -.\"O that are not mapped, the Linux version of -.\"O .BR madvise () -.\"O ignores them and applies the call to the rest (but returns -.\"O .B ENOMEM -.\"O from the system call, as it should). -Linux ¤Î¼ÂÁõ¤Ç¤Ï -.I addr -¤Î¥¢¥É¥ì¥¹¤Ï¥Ú¡¼¥¸¶­³¦¤ÎÃͤǤʤ±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£¤Þ¤¿ -.I length -¤Ï 0 ¤Ç¤¢¤Ã¤Æ¤â¹½¤ï¤Ê¤¤¡£ -¤Þ¤¿ Linux ÈǤΠ-.BR madvise () -¤Ç¤Ï¡¢»ØÄꤵ¤ì¤¿¥¢¥É¥ì¥¹ÈϰϤ˥ޥåפµ¤ì¤Æ¤¤¤Ê¤¤Éôʬ¤¬¤¢¤ë¤È¡¢ -¤³¤ì¤é¤ò̵»ë¤·¤Æ»Ä¤ê¤ÎÉôʬ¤Ë¥¢¥É¥Ð¥¤¥¹¤òŬÍѤ¹¤ë -(¤·¤«¤·¥·¥¹¥Æ¥à¥³¡¼¥ë¤ËÂФ·¤Æ¤Ï¤Á¤ã¤ó¤È -.B ENOMEM -¤òÊÖ¤¹)¡£ -.\"O .\" .SH HISTORY -.\" .SH Îò»Ë -.\"O .\" The -.\"O .\" .BR madvise () -.\"O .\" function first appeared in 4.4BSD. +.\" .SH HISTORY +.\" The .\" .BR madvise () -.\" ´Ø¿ô¤Ï 4.4BSD ¤ÇºÇ½é¤ËÅо줷¤¿¡£ -.\"O .SH "SEE ALSO" -.SH ´ØÏ¢¹àÌÜ -.BR getrlimit (2), -.BR mincore (2), -.BR mmap (2), -.BR mprotect (2), -.BR msync (2), -.BR munmap (2) +.\" function first appeared in 4.4BSD. +Linux の実装では \fIaddr\fP のアドレスはページ境界の値でなければならない。また \fIlength\fP は 0 であっても構わない。 また +Linux 版の \fBmadvise\fP() では、指定されたアドレス範囲にマップされていない部分があると、 +これらを無視して残りの部分にアドバイスを適用する (しかしシステムコールに対してはちゃんと \fBENOMEM\fP を返す)。 +.SH 関連項目 +\fBgetrlimit\fP(2), \fBmincore\fP(2), \fBmmap\fP(2), \fBmprotect\fP(2), \fBmsync\fP(2), +\fBmunmap\fP(2), \fBcore\fP(5) +.SH この文書について +この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.53 の一部 +である。プロジェクトの説明とバグ報告に関する情報は +http://www.kernel.org/doc/man\-pages/ に書かれている。