8.3.3.2. Configuring Static Huge Pages


In some cases, greater control of huge pages is preferable. To use static huge pages on guests, add the following to the guest XML configuration:
Copy to Clipboard Toggle word wrap
<memoryBacking>
	<hugepages/>
</memoryBacking>
This instructs the host to allocate memory to the guest using huge pages, instead of using the default page size.
To view the current huge pages value, run the following command: Copy to Clipboard Toggle word wrap
cat /proc/sys/vm/nr_hugepages

Procedure 8.1. Setting huge pages

The following example procedure shows the commands to set huge pages.
  1. View the current huge pages value: Copy to Clipboard Toggle word wrap
    # cat /proc/meminfo | grep Huge
    AnonHugePages:      2048 kB
    HugePages_Total:       0
    HugePages_Free:        0
    HugePages_Rsvd:        0
    HugePages_Surp:        0
    Hugepagesize:       2048 kB
  2. Huge pages are set in increments of 2MB. To set the number of huge pages to 25000, use the following command: Copy to Clipboard Toggle word wrap
    echo 25000 > /proc/sys/vm/nr_hugepages

    Note

    To make the setting persistent, add the following lines to the /etc/sysctl.conf file on the guest machine, with X being the intended number of huge pages:
    Copy to Clipboard Toggle word wrap
    # echo 'vm.nr_hugepages = X' >> /etc/sysctl.conf
    # sysctl -p
    
    Afterwards, add transparent_hugepage=never to the kernel boot parameters by appending it to the end of the /kernel line in the /etc/grub2.cfg file on the guest.
  3. Mount the huge pages: Copy to Clipboard Toggle word wrap
    # mount -t hugetlbfs hugetlbfs /dev/hugepages
  4. Restart libvirtd, then restart the virtual machine: Copy to Clipboard Toggle word wrap
    # service libvirtd restart
    Stopping libvirtd daemon:                                  [  OK ]
    Starting libvirtd daemon:                                  [  OK ]
    Copy to Clipboard Toggle word wrap
    # virsh start virtual_machine
  5. Verify the changes in /proc/meminfo: Copy to Clipboard Toggle word wrap
    # cat /proc/meminfo | grep Huge
    AnonHugePages:         0 kB
    HugePages_Total:   25000
    HugePages_Free:    23425
    HugePages_Rsvd:        0
    HugePages_Surp:        0
    Hugepagesize:       2048 kB
Huge pages can benefit not only the host but also guests, however, their total huge pages value must be less than what is available in the host.
トップに戻る
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2025 Red Hat, Inc.