From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L8bZ4-00077P-8Q for qemu-devel@nongnu.org; Fri, 05 Dec 2008 09:21:54 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L8bZ1-00076H-OT for qemu-devel@nongnu.org; Fri, 05 Dec 2008 09:21:52 -0500 Received: from [199.232.76.173] (port=60328 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L8bZ1-00076A-Ij for qemu-devel@nongnu.org; Fri, 05 Dec 2008 09:21:51 -0500 Received: from an-out-0708.google.com ([209.85.132.250]:57090) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1L8bZ1-0001xi-4x for qemu-devel@nongnu.org; Fri, 05 Dec 2008 09:21:51 -0500 Received: by an-out-0708.google.com with SMTP id c38so36774ana.37 for ; Fri, 05 Dec 2008 06:21:47 -0800 (PST) Message-ID: <493938F7.7090602@codemonkey.ws> Date: Fri, 05 Dec 2008 08:21:43 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [5874] Add virtio-balloon support References: <1228426490.19459.44.camel@localhost.localdomain> <49385B02.9010206@codemonkey.ws> <200812051414.38406.paul@codesourcery.com> In-Reply-To: <200812051414.38406.paul@codesourcery.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paul Brook Cc: Rusty Russell , qemu-devel@nongnu.org, Hollis Blanchard , kvm-devel Paul Brook wrote: > On Thursday 04 December 2008, Anthony Liguori wrote: > >> Hollis Blanchard wrote: >> >>> 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? >>> >> We need to pass multiple of TARGET_PAGE_SIZE to madvise() >> > > You mean HOST_PAGE_SIZE? > I change my previous answer :-) I think we should just pass addr and the appropriate size of the memory the guest is ballooning. Whether the host can handle it is up to it. Worst case scenario, madvise() returns an error and no harm is done. Regards, Anthony Liguori > My linux manpage says that the address must be page aligned. > > Paul >