From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCqLG-0006kz-0a for qemu-devel@nongnu.org; Tue, 14 Jun 2016 11:33:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bCqLB-0005Ic-PK for qemu-devel@nongnu.org; Tue, 14 Jun 2016 11:33:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34365) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCqLB-0005IX-H9 for qemu-devel@nongnu.org; Tue, 14 Jun 2016 11:33:21 -0400 References: <1465813009-21390-1-git-send-email-liang.z.li@intel.com> <1465813009-21390-2-git-send-email-liang.z.li@intel.com> <575FEC80.2070500@redhat.com> From: Thomas Huth Message-ID: <576023BD.1040700@redhat.com> Date: Tue, 14 Jun 2016 17:33:17 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [QEMU 1/7] balloon: speed up inflating & deflating process List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Li, Liang Z" , "qemu-devel@nongnu.org" Cc: "kvm@vger.kernel.org" , "mst@redhat.com" , "lcapitulino@redhat.com" , "pbonzini@redhat.com" , "quintela@redhat.com" , "amit.shah@redhat.com" , "dgilbert@redhat.com" On 14.06.2016 16:41, Li, Liang Z wrote: >>> On 13.06.2016 12:16, Liang Li wrote: >>>> The implementation of the current virtio-balloon is not very >>>> efficient, Bellow is test result of time spends on inflating the >>>> balloon to 3GB of a 4GB idle guest: >>>> >>>> a. allocating pages (6.5%, 103ms) >>>> b. sending PFNs to host (68.3%, 787ms) c. address translation (6.1%, >>>> 96ms) d. madvise (19%, 300ms) >>>> >>>> It takes about 1577ms for the whole inflating process to complete. >>>> The test shows that the bottle neck is the stage b and stage d. >>>> >>>> If using a bitmap to send the page info instead of the PFNs, we can >>>> reduce the overhead spends on stage b quite a lot. Furthermore, it's >>>> possible to do the address translation and do the madvise with a >>>> bulk of pages, instead of the current page per page way, so the >>>> overhead of stage c and stage d can also be reduced a lot. >>>> >>>> This patch is the QEMU side implementation which is intended to >>>> speed up the inflating & deflating process by adding a new feature >>>> to the virtio-balloon device. And now, inflating the balloon to 3GB >>>> of a 4GB idle guest only takes 210ms, it's about 8 times as fast as before. [...] >>>> + chunk = TARGET_PAGE_SIZE; >>>> + } >>>> + } >>>> +} >>>> + >>>> +static void balloon_bulk_pages(ram_addr_t base_pfn, unsigned long >>> *bitmap, >>>> + unsigned long len, int page_shift, >>>> +bool deflate) { #if defined(__linux__) >>> >>> Why do you need this #if here? >>> >> Ooh, it is wrong to add the '#if' here, will remove. >> > No, it is needed, just follow the code in balloon_page(). > only Linux support the madvise(). I think it is not needed anymore today and the #if in balloon_page could be removed, too: As far as I can see, the #if there is from the early days, when there was no wrapper around madvise() yet. But nowadays, we've got the qemu_madvise() wrapper which takes care of either using madvise(), posix_madvise() or doing nothing, so the virtio-balloon code should be able to work without the #if now. Thomas