Este contenido no está disponible en el idioma seleccionado.
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:
<memoryBacking> <hugepages/> </memoryBacking>
<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
Copied!
Toggle word wrap
Toggle overflow
cat /proc/sys/vm/nr_hugepages
cat /proc/sys/vm/nr_hugepages
Procedure 8.1. Setting huge pages
The following example procedure shows the commands to set huge pages.
- View the current huge pages value:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Huge pages are set in increments of 2MB. To set the number of huge pages to 25000, use the following command:
echo 25000 > /proc/sys/vm/nr_hugepages
echo 25000 > /proc/sys/vm/nr_hugepagesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Note
To make the setting persistent, add the following lines to the/etc/sysctl.conffile on the guest machine, with X being the intended number of huge pages:echo 'vm.nr_hugepages = X' >> /etc/sysctl.conf sysctl -p
# echo 'vm.nr_hugepages = X' >> /etc/sysctl.conf # sysctl -pCopy to Clipboard Copied! Toggle word wrap Toggle overflow Afterwards, addtransparent_hugepage=neverto the kernel boot parameters by appending it to the end of the/kernelline in the/etc/grub2.cfgfile on the guest. - Mount the huge pages:
mount -t hugetlbfs hugetlbfs /dev/hugepages
# mount -t hugetlbfs hugetlbfs /dev/hugepagesCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Restart libvirtd, then restart the virtual machine:
service libvirtd restart Stopping libvirtd daemon: [ OK ] Starting libvirtd daemon: [ OK ]
# service libvirtd restart Stopping libvirtd daemon: [ OK ] Starting libvirtd daemon: [ OK ]Copy to Clipboard Copied! Toggle word wrap Toggle overflow virsh start virtual_machine
# virsh start virtual_machineCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Verify the changes in
/proc/meminfo:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
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.