From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andre Przywara Subject: Re: .img on nfs, relative on ram, consuming mass ram Date: Thu, 16 Sep 2010 11:09:49 +0200 Message-ID: <4C91DEDD.9030508@amd.com> References: <20100915113941.9536341d.f.tournier@iut.univ-paris8.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: "kvm@vger.kernel.org" To: =?ISO-8859-1?Q?TOURNIER_Fr=E9d=E9ric?= Return-path: Received: from va3ehsobe003.messaging.microsoft.com ([216.32.180.13]:57205 "EHLO VA3EHSOBE003.bigfish.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750813Ab0IPJLj convert rfc822-to-8bit (ORCPT ); Thu, 16 Sep 2010 05:11:39 -0400 In-Reply-To: <20100915113941.9536341d.f.tournier@iut.univ-paris8.fr> Sender: kvm-owner@vger.kernel.org List-ID: TOURNIER Fr=E9d=E9ric wrote: > Hi ! > Here's my config : >=20 > Version : qemu-kvm-0.12.5, qemu-kvm-0.12.4 > Hosts : AMD 64X2, Phenom and Core 2 duo > OS : Slackware 64 13.0 > Kernel : 2.6.35.4 and many previous versions >=20 > I use a PXE server to boot semi-diskless (swap partitions and some lo= cal stuff) stations. > This server also serves a read-only nfs folder, with plenty of .img o= n it. > When clients connects, a relative image is created in /tmp, which is = a tmpfs, so hosted in ram. >=20 > And here i go on my 2G stations : > qemu-system-x86_64 -m 1024 -vga std -usb -usbdevice tablet -localtime= -soundhw es1370 /tmp/relimg.img > qemu-system-x86_64 -m 1024 -vga std -usb -usbdevice tablet -localtime= -soundhw es1370 /dev/shm/relimg.img >=20 > I tried both. Always the same result : the ram is consumed quickly, a= nd mass swap occurs. Which is only natural, as tmpfs is promising to never swap. So it will=20 take precedence over other RAM (that's why it is limited to half of the= =20 memory by default). As soon as the guest has (re)written more disk=20 sectors than your free RAM can hold, the system will start to swap out=20 your guest RAM (and other host applications). So in general you should avoid putting relative disk images to tmpfs if= =20 your host memory is limited. As a workaround you could try to further=20 limit the tmpfs max size (mount -t tmpfs -o size=3D512M none /dev/shm),= =20 but this could lead to data loss in your guest as it possibly cannot=20 back the written sectors anymore. > On a 4G system, i see kvm uses more than 1024, maybe 1200. > And everytime a launch a program inside the vm, the amount of the hos= t free ram (not cached) diminishes, which is weird, because it should h= ave been reserved. KVM uses on-demand paging like other applications. So it will not=20 reserve memory for your guest (unless you use hugetlbfs's -mempath): $ kvm -cdrom ttylinux_ser.iso -nographic -m 3072M $ top PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND=20 6015 user 20 0 3205m 128m 3020 S 2 2.2 0:04.94 kvm=20 Regards, Andre. >=20 > So on a 2G system, swap occurs very fast and the machine slow a lot d= own. > An on a total diskless system, this leads fast to a freeze. >=20 > I have no problem if i use a relative image on disk : > qemu-system-x86_64 -m 1024 -vga std -usb -usbdevice tablet -localtime= -soundhw es1370 -drive file=3D/mnt/hd/sda/sda1/tmp/relimg.img,cache=3D= none --=20 Andre Przywara AMD-Operating System Research Center (OSRC), Dresden, Germany Tel: +49 351 448-3567-12