From: Hollis Blanchard Subject: Re: [Qemu-devel] [5874] Add virtio-balloon support Date: Thu, 04 Dec 2008 15:34:50 -0600 Message-ID: <1228426490.19459.44.camel@localhost.localdomain> References: Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Cc: Rusty Russell , kvm-devel To: qemu-devel@nongnu.org Return-path: Received: from e4.ny.us.ibm.com ([32.97.182.144]:57095 "EHLO e4.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754296AbYLDVew (ORCPT ); Thu, 4 Dec 2008 16:34:52 -0500 Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by e4.ny.us.ibm.com (8.13.1/8.13.1) with ESMTP id mB4LYN3v012568 for ; Thu, 4 Dec 2008 16:34:23 -0500 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay02.pok.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id mB4LYp98179030 for ; Thu, 4 Dec 2008 16:34:51 -0500 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id mB4LYNCA019628 for ; Thu, 4 Dec 2008 16:34:24 -0500 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On Thu, 2008-12-04 at 20:33 +0000, Anthony Liguori wrote: > > +static void balloon_page(void *addr, int deflate) > +{ > +#if defined(__linux__) > + if (!kvm_enabled() || kvm_has_sync_mmu()) > + madvise(addr, TARGET_PAGE_SIZE, > + deflate ? MADV_WILLNEED : MADV_DONTNEED); > +#endif > +} Hmm, I just noticed this... we need to use VIRTIO_BALLOON_PFN_SHIFT like Rusty did on the kernel side. However, in general I'm not sure how this is supposed to work. Isn't it true that madvise() is a no-op if 0 < length < getpagesize()? If so, how should the guest know the chunk size needed on the host? What happens when a guest tries to balloon 4K pages when it's backed on the host by hugetlbfs? We can't even use getpagesize() there. Maybe the virtio balloon interface needs to advertise a unit size from the host, and use that size instead of alloc_page() in the guest? -- Hollis Blanchard IBM Linux Technology Center