[Top][All Lists]

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

Re: [PATCH v1 00/13] Ram blocks with resizable anonymous allocations und

From: David Hildenbrand
Subject: Re: [PATCH v1 00/13] Ram blocks with resizable anonymous allocations under POSIX
Date: Thu, 6 Feb 2020 10:45:57 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1

On 06.02.20 10:27, Michael S. Tsirkin wrote:
> On Mon, Feb 03, 2020 at 07:31:12PM +0100, David Hildenbrand wrote:
>> We already allow resizable ram blocks for anonymous memory, however, they
>> are not actually resized. All memory is mmaped() R/W, including the memory
>> exceeding the used_length, up to the max_length.
>> When resizing, effectively only the boundary is moved. Implement actually
>> resizable anonymous allocations and make use of them in resizable ram
>> blocks when possible. Memory exceeding the used_length will be
>> inaccessible. Especially ram block notifiers require care.
>> Having actually resizable anonymous allocations (via mmap-hackery) allows
>> to reserve a big region in virtual address space and grow the
>> accessible/usable part on demand. Even if "/proc/sys/vm/overcommit_memory"
>> is set to "never" under Linux, huge reservations will succeed. If there is
>> not enough memory when resizing (to populate parts of the reserved region),
>> trying to resize will fail. Only the actually used size is reserved in the
>> OS.
>> E.g., virtio-mem [1] wants to reserve big resizable memory regions and
>> grow the usable part on demand. I think this change is worth sending out
>> individually. Accompanied by a bunch of minor fixes and cleanups.
>> [1] https://lore.kernel.org/kvm/address@hidden/
> How does this inteact with all the prealloc/mlock things designed
> for realtime?

- Prealloc: we don't support resizable ram blocks with prealloc
-- qemu_ram_alloc_from_ptr() is the only way to get "real" preallocated
   ram blocks from a pointer. They are never resizable.
-- "prealloc" with memory backends (e.g., backends/hostmem.c): Memory
   backends don't support resizable ram blocks yet. I have patches to
   support that, and disallow prealloc for them.
-- file-based ram blocks are not resizable

- mlock
-- os_mlock() does a mlockall(MCL_CURRENT | MCL_FUTURE)
-- That should work just fine with ordinary mmap() invalidating old
   mmaps and creating new mmaps(). Just like when hotplugging/unplugging
   a DIMM.

Resizing currently only happens during reboot/migration. If mlock_all
would result in issues, we could fallback to old handling (if
(enable_mlock) ...) - but I don't think this is necessary.

So I don't see an issues with that :) Thanks!


David / dhildenb

reply via email to

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