From: David Hildenbrand <david@redhat.com>
To: "Maciej S. Szmigiero" <mail@maciej.szmigiero.name>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Igor Mammedov" <imammedo@redhat.com>,
"Xiao Guangrong" <xiaoguangrong.eric@gmail.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Peter Xu" <peterx@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Yanan Wang" <wangyanan55@huawei.com>,
"Michal Privoznik" <mprivozn@redhat.com>,
"Daniel P . Berrangé" <berrange@redhat.com>,
"Gavin Shan" <gshan@redhat.com>,
"Alex Williamson" <alex.williamson@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
kvm@vger.kernel.org, qemu-devel@nongnu.org
Subject: Re: [PATCH v3 12/16] memory-device, vhost: Support automatic decision on the number of memslots
Date: Mon, 18 Sep 2023 14:33:07 +0200 [thread overview]
Message-ID: <43d310b6-e4aa-da33-c845-49e606a947fe@redhat.com> (raw)
In-Reply-To: <75866f2e-13c3-220e-cea8-bebc983b8cf7@maciej.szmigiero.name>
On 17.09.23 12:46, Maciej S. Szmigiero wrote:
> On 8.09.2023 16:21, David Hildenbrand wrote:
>> We want to support memory devices that can automatically decide how many
>> memslots they will use. In the worst case, they have to use a single
>> memslot.
>>
>> The target use cases are virtio-mem and the hyper-v balloon.
>>
>> Let's calculate a reasonable limit such a memory device may use, and
>> instruct the device to make a decision based on that limit. Use a simple
>> heuristic that considers:
>> * A memslot soft-limit for all memory devices of 256; also, to not
>> consume too many memslots -- which could harm performance.
>> * Actually still free and unreserved memslots
>> * The percentage of the remaining device memory region that memory device
>> will occupy.
>>
>> Further, while we properly check before plugging a memory device whether
>> there still is are free memslots, we have other memslot consumers (such as
>> boot memory, PCI BARs) that don't perform any checks and might dynamically
>> consume memslots without any prior reservation. So we might succeed in
>> plugging a memory device, but once we dynamically map a PCI BAR we would
>> be in trouble. Doing accounting / reservation / checks for all such
>> users is problematic (e.g., sometimes we might temporarily split boot
>> memory into two memslots, triggered by the BIOS).
>>
>> We use the historic magic memslot number of 509 as orientation to when
>> supporting 256 memory devices -> memslots (leaving 253 for boot memory and
>> other devices) has been proven to work reliable. We'll fallback to
>> suggesting a single memslot if we don't have at least 509 total memslots.
>>
>> Plugging vhost devices with less than 509 memslots available while we
>> have memory devices plugged that consume multiple memslots due to
>> automatic decisions can be problematic. Most configurations might just fail
>> due to "limit < used + reserved", however, it can also happen that these
>> memory devices would suddenly consume memslots that would actually be
>> required by other memslot consumers (boot, PCI BARs) later. Note that this
>> has always been sketchy with vhost devices that support only a small number
>> of memslots; but we don't want to make it any worse.So let's keep it simple
>> and simply reject plugging such vhost devices in such a configuration.
>>
>> Eventually, all vhost devices that want to be fully compatible with such
>> memory devices should support a decent number of memslots (>= 509).
>>
>> Signed-off-by: David Hildenbrand <david@redhat.com>
>> ---
>
> Reviewed-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Thanks!
>
> I would be nice to ultimately allow raising the 509 memslot limit,
> considering that KVM had supported 32k memslots for more than two years
> now and had a much more scalable implementation since early 2022.
It's all tricky due to vhost (and hotplug of such devices) and the QEMU
internal address translation (which isn't that scalable).
I was thinking about having a parameter to configure the number of
memslots for memory devices, such that one could manually raise the
"256" limit for memory devices.
But for now I kept it simple, because it all turned out to become way to
complicated.
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2023-09-18 12:33 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-08 14:21 [PATCH v3 00/16] virtio-mem: Expose device memory through multiple memslots David Hildenbrand
2023-09-08 14:21 ` [PATCH v3 01/16] vhost: Rework memslot filtering and fix "used_memslot" tracking David Hildenbrand
2023-09-08 14:21 ` [PATCH v3 02/16] vhost: Remove vhost_backend_can_merge() callback David Hildenbrand
2023-09-08 14:21 ` [PATCH v3 03/16] softmmu/physmem: Fixup qemu_ram_block_from_host() documentation David Hildenbrand
2023-09-08 14:21 ` [PATCH v3 04/16] kvm: Return number of free memslots David Hildenbrand
2023-09-16 16:05 ` Maciej S. Szmigiero
2023-09-08 14:21 ` [PATCH v3 05/16] vhost: " David Hildenbrand
2023-09-16 16:07 ` Maciej S. Szmigiero
2023-09-08 14:21 ` [PATCH v3 06/16] memory-device: Support memory devices with multiple memslots David Hildenbrand
2023-09-16 16:27 ` Maciej S. Szmigiero
2023-09-08 14:21 ` [PATCH v3 07/16] stubs: Rename qmp_memory_device.c to memory_device.c David Hildenbrand
2023-09-16 16:28 ` Maciej S. Szmigiero
2023-09-08 14:21 ` [PATCH v3 08/16] memory-device: Track required and actually used memslots in DeviceMemoryState David Hildenbrand
2023-09-16 16:36 ` Maciej S. Szmigiero
2023-09-08 14:21 ` [PATCH v3 09/16] memory-device, vhost: Support memory devices that dynamically consume memslots David Hildenbrand
2023-09-16 17:52 ` Maciej S. Szmigiero
2023-09-08 14:21 ` [PATCH v3 10/16] kvm: Add stub for kvm_get_max_memslots() David Hildenbrand
2023-09-16 17:13 ` Maciej S. Szmigiero
2023-09-08 14:21 ` [PATCH v3 11/16] vhost: Add vhost_get_max_memslots() David Hildenbrand
2023-09-16 17:16 ` Maciej S. Szmigiero
2023-09-08 14:21 ` [PATCH v3 12/16] memory-device, vhost: Support automatic decision on the number of memslots David Hildenbrand
2023-09-17 10:46 ` Maciej S. Szmigiero
2023-09-18 12:33 ` David Hildenbrand [this message]
2023-09-08 14:21 ` [PATCH v3 13/16] memory: Clarify mapping requirements for RamDiscardManager David Hildenbrand
2023-09-16 17:31 ` Maciej S. Szmigiero
2023-09-08 14:21 ` [PATCH v3 14/16] virtio-mem: Expose device memory via multiple memslots if enabled David Hildenbrand
2023-09-17 11:47 ` Maciej S. Szmigiero
2023-09-19 8:08 ` David Hildenbrand
2023-09-08 14:21 ` [PATCH v3 15/16] memory, vhost: Allow for marking memory device memory regions unmergeable David Hildenbrand
2023-09-08 14:21 ` [PATCH v3 16/16] virtio-mem: Mark memslot alias " David Hildenbrand
2023-09-11 7:45 ` [PATCH v3 00/16] virtio-mem: Expose device memory through multiple memslots David Hildenbrand
2023-09-19 8:20 ` David Hildenbrand
2023-09-19 9:34 ` David Hildenbrand
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=43d310b6-e4aa-da33-c845-49e606a947fe@redhat.com \
--to=david@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=berrange@redhat.com \
--cc=eduardo@habkost.net \
--cc=gshan@redhat.com \
--cc=imammedo@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mail@maciej.szmigiero.name \
--cc=marcel.apfelbaum@gmail.com \
--cc=mprivozn@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=wangyanan55@huawei.com \
--cc=xiaoguangrong.eric@gmail.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).