From: "Michael S. Tsirkin" <mst@redhat.com>
To: David Hildenbrand <david@redhat.com>
Cc: Yangming <yangming73@huawei.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"wangzhigang (O)" <wangzhigang17@huawei.com>,
"zhangliang (AG)" <zhangliang5@huawei.com>,
xiqi <xiqi2@huawei.com>
Subject: Re: Optimization for the virtio-balloon feature on the ARM platform
Date: Mon, 20 Feb 2023 07:11:25 -0500 [thread overview]
Message-ID: <20230220071054-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <bbbd3382-f33c-1e8a-789b-dec1c4766730@redhat.com>
On Mon, Feb 20, 2023 at 10:15:37AM +0100, David Hildenbrand wrote:
> 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.
And as any optimization, patches are welcome accompanied by
a measurement showing it's a net improvement.
> --
> Thanks,
>
> David / dhildenb
prev parent reply other threads:[~2023-02-20 12:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <8c6d264163574d8b886afdd3e4b77a2d@huawei.com>
2023-02-20 1:33 ` Optimization for the virtio-balloon feature on the ARM platform Yangming via
2023-02-20 9:15 ` David Hildenbrand
2023-02-20 12:11 ` Michael S. Tsirkin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230220071054-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=david@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=wangzhigang17@huawei.com \
--cc=xiqi2@huawei.com \
--cc=yangming73@huawei.com \
--cc=zhangliang5@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).