jump to navigation

Tuning KVM with hugepages agosto 4, 2011

Posted by krustynet in IT.
add a comment

KVM (Kernel Virtual Machine) is becoming one of the Main Virtualization solutions because of his simplicity, performance and reliability.

It is part of almost any Linux Distro around today and after the aquisition by Redhat it is growing fast as the main competitor of Vmware.

Instead of explaining how to install and configure it’s basics, as this argument is vastly documented on the internet, I decided to write how to squeeze the maximum performance out of it.

From the host point of view a kvm virtual machine is a common process which follow the normal scheduling and memory allocation mechanism, but in the enterprise it could happen that the guest allocates plenty of memory and use a lot of cpu, which could lead to some performance problems.

Linux by default uses 4 kb memory pages which mean that if a guest has 16 gb of memory you have around 4 milion pages.

And here we have the problem, as you probably know each process thinks to be alone on the system, and use a defined address space, the operating system, to permit more processes to run at the same time, creates a virtual memory space where it maps the physical memory to the virtual one which the process see.

Each time a process need to read or write data to memory a translation happen from virtual to physical memory. To speed up this process the modern cpu usually has a so called TLB (Translation lookaside buffer) where the most recent referred memory pages translations are saved, if the needed address is in the TLB you have a TLB hit, the physical address is returned and the process go on, if the page is not in the tlb ( which by the way isn’t that big) you have a miss, and a so called pagewalk occurs.

Pagewalk is a really expensive, in terms of cpu time, activity so it can impact the performance.

In the example before where the guest has 16 GB of ram the cpu has to check 4 Milion-TLB size pages.

how we can reduce TLB misses ? Clearly using bigger memory pages size.

Linux as an enterprise operating system has the so called Hugepages, which when activated instead of having 4kb memory pages provide 2Mb ones.

So if we use 2Mb pages we have 8000 instead of 4Milion pages for the 16 Gb guest which greatly reduce TLB misses and can improve performance for memory intensive guests.

So after this introduction we can actually implement it..

I personally used Ubuntu 11.04, but basically it will work in all recent Distros.

              Reserve HugePages

As root add the following lines to the /etc/systcl.conf file:

###### HugePages #########
vm.nr_hugepages = 1000

This actually will reserve 1000 hugepages

1000*2MB = 2GB

if you need more, like in our example 16 GB

16000MB/ 2= 8000

so:

###### HugePages #########
vm.nr_hugepages = 8000

at this point reboot the system

Login as root

execute cat /proc/meminfo

you should see

HugePages_Total:    1000
HugePages_Free:     1000

it means that now you have reserved 1000 2MB pages

Mount the Mermory !?!?

Create a folder

mkdir /HugePageKvm

mount -t hugetlbfs hugetlbfs /HugePageKvm

check if it’s working:

mount

you should see:

hugetlbfs on /HugePageKvm type hugetlbfs (rw)

add the folowing line to the /etc/fstab so that after reboot the mount will automatically done.

hugetlbfs       /HugePageKvm  hugetlbfs       defaults        0 0

Uninstall apparmor ( I got an error otherwise, any suggestion is welcome )

apt-get purge apparmor

Modify the Guest XML file:

Adding the following lines

<memoryBacking>
    <hugepages/>
</memoryBacking>

The file should look similar to the following:

<domain type=’kvm’>
  <name>centos-6</name>
  <uuid>62cf9ccd-1964-6b06-9546-b8ce178dccd5</uuid>
  <memory>1048576</memory>
  <currentMemory>1048576</currentMemory>
  <memoryBacking>
    <hugepages/>
  </memoryBacking>
  <vcpu cpuset=’1′>1</vcpu>
  <os>
    <type arch=’x86_64′ machine=’pc-0.14′>hvm</type>
    <boot dev=’hd’/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <clock offset=’utc’/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/bin/kvm</emulator>
    <disk type=’block’ device=’disk’>
      <driver name=’qemu’ type=’raw’ cache=’none’/>
      <source dev=’/dev/VMFS/centos-6′/>
      <target dev=’vda’ bus=’virtio’/>
      <address type=’pci’ domain=’0×0000′ bus=’0×00′ slot=’0×05′ function=’0×0′/>
    </disk>
    <disk type=’block’ device=’cdrom’>
      <driver name=’qemu’ type=’raw’/>
      <target dev=’hdc’ bus=’ide’/>
      <readonly/>
      <address type=’drive’ controller=’0′ bus=’1′ unit=’0′/>
    </disk>
    <disk type=’block’ device=’disk’>
      <driver name=’qemu’ type=’raw’ cache=’none’/>
      <source dev=’/dev/VMFS/Shared’/>
      <target dev=’vdb’ bus=’virtio’/>
      <shareable/>
      <address type=’pci’ domain=’0×0000′ bus=’0×00′ slot=’0×07′ function=’0×0′/>
    </disk>
    <controller type=’ide’ index=’0′>
      <address type=’pci’ domain=’0×0000′ bus=’0×00′ slot=’0×01′ function=’0×1′/>
    </controller>
    <interface type=’network’>
      <mac address=’52:54:00:83:96:3d’/>
      <source network=’default’/>
      <model type=’virtio’/>
      <address type=’pci’ domain=’0×0000′ bus=’0×00′ slot=’0×03′ function=’0×0′/>
    </interface>
    <serial type=’pty’>
      <target port=’0′/>
    </serial>
    <console type=’pty’>
      <target type=’serial’ port=’0′/>
    </console>
    <input type=’tablet’ bus=’usb’/>
    <input type=’mouse’ bus=’ps2′/>
    <graphics type=’vnc’ port=’-1′ autoport=’yes’/>
    <sound model=’ac97′>
      <address type=’pci’ domain=’0×0000′ bus=’0×00′ slot=’0×04′ function=’0×0′/>
    </sound>
    <video>
      <model type=’cirrus’ vram=’9216′ heads=’1′/>
      <address type=’pci’ domain=’0×0000′ bus=’0×00′ slot=’0×02′ function=’0×0′/>
    </video>
    <memballoon model=’virtio’>
      <address type=’pci’ domain=’0×0000′ bus=’0×00′ slot=’0×06′ function=’0×0′/>
    </memballoon>
  </devices>
</domain>

 

Start the virtual Machine

In my case:

virsh start centos-6

check if the machine is using Hugepages

cat /proc/meminfo

HugePages_Total:    1000
HugePages_Free:      480

you should se that the number of free pages is reduced, in my case I’m using 520 huge pages.

 

Any suggestion or question is welcome

Some Benchmark

 

 

Softmod WII Firmware 4.2 ottobre 6, 2009

Posted by krustynet in Uncategorized.
Tags: , , , ,
add a comment

Anche il firmware 4.2 si è dovuto piegare ai modders.
Al seguente link la guida su come reinstallare L’homebrew ed il backup Loader

http://www.moddingstudio.com/forum/viewtopic.php?f=5&t=2261

Non mi ritengo responsabile di eventuali danni…..

Buon Modding a Tutti

WII update 4.2 settembre 29, 2009

Posted by krustynet in Uncategorized.
Tags: ,
add a comment

Dopo un lungo periodo che nintendo non aveva mai interferito con i softmod ha rilasciato L’update in Oggetto, che non solo disinstalla l’hombrew channel, ma elimina anche tutti i cIOS che avete installato, rendendo di fatto impossibile utilizzare i backup dei giochi, e tutte le applicazioni non certificate.

Al momento pare che non esista rimedio, tutti i Bug precedenti sono stati fixati.

Il Super Hacker della WII waninkoko, autore di tanti cIOS ed altre modifiche pare che sia già all’opera per risolvere il problema….

Stay tuned

WII Softmod settembre 29, 2009

Posted by krustynet in Uncategorized.
Tags:
add a comment

Visto che per i miei 30…. mi hanno regalato la Wii, non ho resistito ed ho eseguito il softmod per caricare i backup dei miei giochi ed utilizzare le applicazioni Homebrew.
Ho seguito la guida che trovate al seguente Link:

http://hackjunkies.com/2009/09/07/softmod-wii-with-4-1u-firmware-ntsc-pal/

Che dire Modifica riuscita perfettamente….

Buon Mod a tutti…..
Ma ricordate, lo fate a vstro rischio e pericolo non sono responsabile di eventuali danni causati dalla Modifica…..

Reconfiguring X on Ubuntu agosto 16, 2009

Posted by krustynet in Uncategorized.
Tags: , , , ,
add a comment

Per riconfigurare Xorg in Ubuntu o Debian eseguire i Seguenti Comandi:

sudo dpkg-reconfigure xserver-xorg

verranno chiesti i parametri

Per eseguire la configurazione automatica:

sudo dpkg-reconfigure -phigh xserver-xorg

I Puffi….Tutti Comunisti gennaio 9, 2008

Posted by krustynet in Uncategorized.
1 comment so far

Di seguito il link ad un analisi Socio-Culturale del mondo dei Puffi, che sarebbero di chiara Matrice Comunista……..

http://it.geocities.com/nonsoloscacchinews/Puffi_comunisti.htm 

Siamo i peggio pagati d’europa gennaio 4, 2008

Posted by krustynet in Life.
add a comment

Tornando in treno da casa dei miei genitori, ed avendo, durante il soggiorno a lecce, finito di leggere il bellissimo Achille pie veloce di Benni, decido di comperare un pò di riviste per il viaggio, visto che il bruco d’accaio impiega “solo” 7 ore per tornare a Roma, tra cui Panorama (pessima scelta visto l’orientamento politico) in cui cmq leggo un articolo piutosto interessante anche se abbastanza ovvio, gli italiani sono i peggio pagati d’europa, dall’articolo emerge inoltre che il potere d’aquisto nel nostro paese è nettamente inferiore…..quindi non solo siamo i peggio pagati, ma il nostro paese e tra quelli più cari….Altro che bel Paese.

Travaglio e De Magistris Al parlamento Europeo dicembre 10, 2007

Posted by krustynet in politica.
Tags: , , , , ,
add a comment

Per chi non la conoscesse, la vera storia del caso Mastella e De Magistris.

Il quinto giorno dicembre 10, 2007

Posted by krustynet in books.
add a comment

Ho appena terminato di leggere il libro in questione, e devo dire che ne sono rimasto molto sodisfatto anche se per vari motivi, non ultimo le 1000 pagine, ci ho messo un eternita. Il libro è a tratti poco scorrevole, ma molto ” scientifico” l’autore, Schatzing è riuscito nel difficile compito di unire una storia fantascientifica alla scienza vera e propria dando molti aprofondimenti su vari temi inerenti al Profondo Blu. La storia mette in luce la psycologia dei personaggi in maniera molto chiara, tant’è che alla fine alcuni di loro sembra conoscerli. L’autore inoltre non nasconde le proprie ideologie, il che da un lato è un bene ( visto che molte cose le condivido) dall’altro potrebbe irritare chi non è d’accordo con le sue credenze visto che in alcuni casi ci va giù abbastanza pesante. Concludendo è un bel libro, anche se non mi sento di consigliarlo a tutti.

Phenom Travagliato dicembre 10, 2007

Posted by krustynet in IT, Life.
Tags: , ,
add a comment

Dopo aver atteso mesi il rilascio della nuova CPU, ed aver letto tonnellate di review, inizio a credere che l’architettura del K10 sia stato un parto abbastanza travagliato, inoltre adesso viene fuori anche il bug che riguarda la cache che a quanto pare verra fixato tramite un aggiornamento del bios che comporta un ulteriore perdita di performance del 20% circa. Dopo tutto cio mi sono finalmente deciso a comperare un nuovo PC, ed ho scelto intel che in questo momento mi sembra avere la piattaforma migliore ( sono pronto a discuterne….). Ho comperato una macchina configurata come segue:

Intel Q6600;Asus p5ke wifi, 4 gb dir ddr2 800 mhz, geforce 8800gt, enermax liberty 620 w, enermax chakra, dischi da 500 GB sata2 WD;

I componenti dovrebbero arrivarmi Mercoledi, vediamo che ne viene fuori. Cmq era da più di 6 mesi che attendevo principalmente a causa del phenom….ma a questo punto non posso attendere oltre.

Follow

Get every new post delivered to your Inbox.