Linux の Huge Pages 使用量の計算

Linux の Huge Pages 使用量の計算

私はJavaで使用するためにHuge Pagesを設定しましたが、うまく動作しているようですが、/proc/meminfoの記録について疑問があります。例を挙げると、

# grep HugePages /proc/meminfo 
AnonHugePages:    274432 kB
HugePages_Total:    1008
HugePages_Free:      596
HugePages_Rsvd:      594
HugePages_Surp:        0

私の質問は、「Free」と「Rsvd」の数字に関するものです。なぜ、合計が 1008 にならないのでしょうか。実際は 1190 になります。ここで私が理解していないことは何でしょうか。

答え1

これは、HugePages_rsvd が基本的に HugePages_Free から読み取られるためです。つまり、空いている 596 個の巨大ページのうち、594 個はすでに何らかのアプリケーションによって使用するために予約されています。つまり、カーネルは、それらの 594 個の巨大ページがアプリケーションで使用可能であるとコミットしています。

現在、3 つの巨大ページに対する要求がある場合、予約できるのは 2 つだけなので、要求は失敗します。プロセスの VSZ を考慮してメモリ仮想ページを予約しますが、プロセスが実際にそれらを使用すると、プロセスの RSZ (実行セット) になるという malloc() 呼び出しと考えてください。

巨大ページは常にメイン メモリ上に常駐するため、アプリがそれらを要求すると、カーネルは空きプールからそれを減らし、Rsvd カウンターを増やします。

これはカーネルソースからのものです。https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt

where:
HugePages_Total is the size of the pool of huge pages.
HugePages_Free  is the number of huge pages in the pool that are not yet
                allocated.
HugePages_Rsvd  is short for "reserved," and is the number of huge pages for
                which a commitment to allocate from the pool has been made,
                but no allocation has yet been made.  Reserved huge pages
                guarantee that an application will be able to allocate a
                huge page from the pool of huge pages at fault time.
HugePages_Surp  is short for "surplus," and is the number of huge pages in
                the pool above the value in /proc/sys/vm/nr_hugepages. The
                maximum number of surplus huge pages is controlled by
                /proc/sys/vm/nr_overcommit_hugepages.

関連情報