From: David Hildenbrand <david@redhat.com>
To: qemu-devel@nongnu.org
Cc: Eduardo Habkost <ehabkost@redhat.com>,
"Michael S . Tsirkin" <mst@redhat.com>,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
Igor Mammedov <imammedo@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Richard Henderson <rth@twiddle.net>
Subject: Re: [PATCH v2 00/16] Ram blocks with resizable anonymous allocations under POSIX
Date: Wed, 12 Feb 2020 14:40:54 +0100 [thread overview]
Message-ID: <6cec3934-da0c-6d61-dd39-17fd39bbce24@redhat.com> (raw)
In-Reply-To: <20200212133601.10555-1-david@redhat.com>
On 12.02.20 14:35, 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.
>
> Especially, memory notifiers already handle resizing by first removing
> the old region, and then re-adding the resized region. prealloc is
> currently not possible with resizable ram blocks. mlock() should continue
> to work as is. Resizing is currently rare and must only happen on the
> start of an incoming migration, or during resets. No code path (except
> HAX and SEV ram block notifiers) should access memory outside of the usable
> range - and if we ever find one, that one has to be fixed (I did not
> identify any).
>
> v1 -> v2:
> - Add "util: vfio-helpers: Fix qemu_vfio_close()"
> - Add "util: vfio-helpers: Remove Error parameter from
> qemu_vfio_undo_mapping()"
> - Add "util: vfio-helpers: Factor out removal from
> qemu_vfio_undo_mapping()"
> - "util/mmap-alloc: ..."
> -- Minor changes due to review feedback (e.g., assert alignment, return
> bool when resizing)
> - "util: vfio-helpers: Implement ram_block_resized()"
> -- Reserve max_size in the IOVA address space.
> -- On resize, undo old mapping and do new mapping. We can later implement
> a new ioctl to resize the mapping directly.
> - "numa: Teach ram block notifiers about resizable ram blocks"
> -- Pass size/max_size to ram block notifiers, which makes things easier an
> cleaner
> - "exec: Ram blocks with resizable anonymous allocations under POSIX"
> -- Adapt to new ram block notifiers
> -- Shrink after notifying. Always trigger ram block notifiers on resizes
> -- Add a safety net that all ram block notifiers registered at runtime
> support resizes.
>
> [1] https://lore.kernel.org/kvm/20191212171137.13872-1-david@redhat.com/
>
> David Hildenbrand (16):
> util: vfio-helpers: Factor out and fix processing of existing ram
> blocks
> util: vfio-helpers: Fix qemu_vfio_close()
> util: vfio-helpers: Remove Error parameter from
> qemu_vfio_undo_mapping()
> util: vfio-helpers: Factor out removal from qemu_vfio_undo_mapping()
> exec: Factor out setting ram settings (madvise ...) into
> qemu_ram_apply_settings()
> exec: Reuse qemu_ram_apply_settings() in qemu_ram_remap()
> exec: Drop "shared" parameter from ram_block_add()
> util/mmap-alloc: Factor out calculation of pagesize to mmap_pagesize()
> util/mmap-alloc: Factor out reserving of a memory region to
> mmap_reserve()
> util/mmap-alloc: Factor out populating of memory to mmap_populate()
> util/mmap-alloc: Prepare for resizable mmaps
> util/mmap-alloc: Implement resizable mmaps
> numa: Teach ram block notifiers about resizable ram blocks
> util: vfio-helpers: Implement ram_block_resized()
> util: oslib: Resizable anonymous allocations under POSIX
> exec: Ram blocks with resizable anonymous allocations under POSIX
I should double check what I send out while doing last minute changes.
Please ignore this series, will send the proper one right away.
--
Thanks,
David / dhildenb
prev parent reply other threads:[~2020-02-12 13:50 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-12 13:35 [PATCH v2 00/16] Ram blocks with resizable anonymous allocations under POSIX David Hildenbrand
2020-02-12 13:35 ` [PATCH v2 01/16] virtio-mem: Prototype David Hildenbrand
2020-02-12 14:15 ` Eric Blake
2020-02-12 14:20 ` David Hildenbrand
2020-02-12 13:35 ` [PATCH v2 02/16] virtio-pci: Proxy for virtio-mem David Hildenbrand
2020-02-12 13:35 ` [PATCH v2 03/16] hmp: Handle virtio-mem when printing memory device infos David Hildenbrand
2020-02-12 13:35 ` [PATCH v2 04/16] numa: Handle virtio-mem in NUMA stats David Hildenbrand
2020-02-12 13:35 ` [PATCH v2 05/16] pc: Support for virtio-mem-pci David Hildenbrand
2020-02-12 13:35 ` [PATCH v2 06/16] exec: Provide owner when resizing memory region David Hildenbrand
2020-02-12 13:35 ` [PATCH v2 07/16] memory: Add memory_region_max_size() and memory_region_is_resizable() David Hildenbrand
2020-02-12 13:35 ` [PATCH v2 08/16] memory: Disallow resizing to 0 David Hildenbrand
2020-02-12 13:35 ` [PATCH v2 09/16] memory-device: properly deal with resizable memory regions David Hildenbrand
2020-02-12 13:35 ` [PATCH v2 10/16] hostmem: Factor out applying settings David Hildenbrand
2020-02-12 13:35 ` [PATCH v2 11/16] hostmem: Factor out common checks into host_memory_backend_validate() David Hildenbrand
2020-02-12 13:35 ` [PATCH v2 12/16] hostmem: Introduce "managed-size" for memory-backend-ram David Hildenbrand
2020-02-12 13:35 ` [PATCH v2 13/16] qmp/hmp: Expose "managed-size" for memory backends David Hildenbrand
2020-02-12 14:17 ` Eric Blake
2020-02-12 13:35 ` [PATCH v2 14/16] virtio-mem: Support for resizable memory regions David Hildenbrand
2020-02-12 13:36 ` [PATCH v2 15/16] memory: Add region_resize() callback to memory notifier David Hildenbrand
2020-02-12 13:36 ` [PATCH v2 16/16] kvm: Implement region_resize() for atomic memory section resizes David Hildenbrand
2020-02-12 13:40 ` David Hildenbrand [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=6cec3934-da0c-6d61-dd39-17fd39bbce24@redhat.com \
--to=david@redhat.com \
--cc=dgilbert@redhat.com \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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).