Skip to content

Commit

Permalink
libvhost-user: Bump up VHOST_USER_MAX_RAM_SLOTS to 509
Browse files Browse the repository at this point in the history
Let's support up to 509 mem slots, just like vhost in the kernel usually
does and the rust vhost-user implementation recently [1] started doing.
This is required to properly support memory hotplug, either using
multiple DIMMs (ACPI supports up to 256) or using virtio-mem.

The 509 used to be the KVM limit, it supported 512, but 3 were
used for internal purposes. Currently, KVM supports more than 512, but
it usually doesn't make use of more than ~260 (i.e., 256 DIMMs + boot
memory), except when other memory devices like PCI devices with BARs are
used. So, 509 seems to work well for vhost in the kernel.

Details can be found in the QEMU change that made virtio-mem consume
up to 256 mem slots across all virtio-mem devices. [2]

509 mem slots implies 509 VMAs/mappings in the worst case (even though,
in practice with virtio-mem we won't be seeing more than ~260 in most
setups).

With max_map_count under Linux defaulting to 64k, 509 mem slots
still correspond to less than 1% of the maximum number of mappings.
There are plenty left for the application to consume.

[1] rust-vmm/vhost#224
[2] https://lore.kernel.org/all/[email protected]/

Reviewed-by: Raphael Norwitz <[email protected]>
Acked-by: Stefano Garzarella <[email protected]>
Signed-off-by: David Hildenbrand <[email protected]>
Message-Id: <[email protected]>
Tested-by: Mario Casquero <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
  • Loading branch information
davidhildenbrand authored and mstsirkin committed Mar 12, 2024
1 parent d884e27 commit 0fa6344
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions subprojects/libvhost-user/libvhost-user.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@
#define VHOST_MEMORY_BASELINE_NREGIONS 8

/*
* Set a reasonable maximum number of ram slots, which will be supported by
* any architecture.
* vhost in the kernel usually supports 509 mem slots. 509 used to be the
* KVM limit, it supported 512, but 3 were used for internal purposes. This
* limit is sufficient to support many DIMMs and virtio-mem in
* "dynamic-memslots" mode.
*/
#define VHOST_USER_MAX_RAM_SLOTS 32
#define VHOST_USER_MAX_RAM_SLOTS 509

#define VHOST_USER_HDR_SIZE offsetof(VhostUserMsg, payload.u64)

Expand Down

0 comments on commit 0fa6344

Please sign in to comment.