qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Optimization for the virtio-balloon feature on the ARM platform


From: David Hildenbrand
Subject: Re: Optimization for the virtio-balloon feature on the ARM platform
Date: Mon, 20 Feb 2023 10:15:37 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2

On 20.02.23 02:33, Yangming via wrote:
Dear QEMU maintainers,

I am writing to discuss a possible optimization for the virtio-balloon feature on the ARM platform. The ‘virtio_balloon_set_config’ function is called frequently during the balloon inflation process, and its subfunction ‘get_current_ram_size’ needs to traverse the virtual machine's memory modules in order to count the current virtual machine's memory (i.e initial ram size + hotplugged memory). This can be very time consuming on the ARM platform, as the ARM virtual machine has much more complex memory modules than the x86 virtual machine.

Therefore, I suggest introducing a global variable, ‘total_ram_size’, that would be updated only when the balloon is initialized and hotplug memory has completed. This would increase the efficiency of balloon inflation by more than 60% on the ARM platform.

The following code is part of the optimization for balloon:

--- a/qemu/hw/virtio/virtio-balloon.c

+++ b/qemu/hw/virtio/virtio-balloon.c

static void virtio_balloon_set_config(…)

…

-    ram_addr_t vm_ram_size = get_current_ram_size();

+   ram_addr_t vm_ram_size = total_ram_size;

…

I hope this suggestion could be considered or discussed by QEMU developers. I would love to seeing this improvement added to QEMU in the future.

I'd suggest keeping track of the plugged DIMM size inside ms->device_memory->dimm_size. We can update it from pc_dimm_plug/pc_dimm_unplug. We just have to make sure to exclude NVDIMMs.

We can then optimize get_current_ram_size() to return "ms->ram_size + ms->device_memory->dimm_size", of course taking care of ms->device_memory == NULL on some machines.

--
Thanks,

David / dhildenb




reply via email to

[Prev in Thread] Current Thread [Next in Thread]