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 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html