Questo contenuto non è disponibile nella lingua selezionata.

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>
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:
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:
    # 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:
    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:
    # 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:
    # mount -t hugetlbfs hugetlbfs /dev/hugepages
  4. Restart libvirtd, then restart the virtual machine:
    # service libvirtd restart
    Stopping libvirtd daemon:                                  [  OK ]
    Starting libvirtd daemon:                                  [  OK ]
    # virsh start virtual_machine
  5. Verify the changes in /proc/meminfo:
    # 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

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita ilBlog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

© 2024 Red Hat, Inc.