From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dor Laor Subject: Re: Ballooning Queries Date: Sun, 10 Aug 2008 13:03:28 +0300 Message-ID: <489EBCF0.50405@il.qumranet.com> References: <489DE269.9000207@codemonkey.ws> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Anthony Liguori , kvm@vger.kernel.org To: Sukanto Ghosh Return-path: Received: from il.qumranet.com ([212.179.150.194]:53970 "EHLO il.qumranet.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752267AbYHJKDS (ORCPT ); Sun, 10 Aug 2008 06:03:18 -0400 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: Sukanto Ghosh wrote: > On Sat, Aug 9, 2008 at 2:31 PM, Anthony Liguori wrote: > >> Sukanto Ghosh wrote: >> >>> I understand the idea behind ballooning as " it effectively increases >>> or decreases the amount of physical memory given to the guest, with >>> the help of the guest's native memory management algorithms". The >>> benefit is obvious in cases where the hypervisor does a hard >>> partitioning of the memory between the guests. The guest vm (virtual >>> memory manager) will indirectly say that these are my least used >>> pages, or the safest candidates for eviction. >>> >>> But in case of kvm, the guest memory is itself allocated and managed >>> by the host linux vm. So, suppose if the guest evicts a lru page >>> (which might even not actually reside in host physical memory at the >>> time) and even the host chooses a lru page for eviction, the host >>> decision is better in a sense that this page is definitely residing in >>> the physical memory. So, are we gaining from using a balloon driver in >>> the guest. >>> >>> >> What ballooning is useful for in KVM, is reducing the amount of memory a >> guest uses by a large amount. It's not terribly useful for shaving a few >> dozen MBs from a guest, but it is useful for dropping a 1GB guest down to >> 512GB. >> >> Since the guest tells the host what portions of it's memory it won't be >> using, we can evict it completely from memory (it's not even swapped, it's >> just deleted). >> >> > > But for deleting these pages shouldn't it be ensured that the guest > remains under the illusion that these pages are least recently used > (may be, by modifying the guest pte for those pages, so the reference > bits are always set for them) and the guest's page eviction algorithm > won't touch these pages. Later on when it is possible to give back the > guest those pages, you remove this illusion. > The guest pins the ballooned pages in memory and it won't swap them. It's simpler than hacking the LRU data. > Another alternative will be, not to have the guest under any sort of > illusion and give it back the pages when it wants to evict them. But > this will defeat the purpose of having the balloon. > > > Which way is it done in kvm/linux ? > > > > The guest is not under any illusion, it's para virtualization and the guest kernel is aware about all these pages. Host request the balloon to grow->guest allocates pages and does not touch them -> host frees these pages. The opposite way for balloon deflate.