From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: David Hildenbrand <david@redhat.com>
Cc: Murilo Opsfelder Araujo <muriloo@linux.ibm.com>,
Stefano Stabellini <sstabellini@kernel.org>,
Eduardo Habkost <ehabkost@redhat.com>,
"Michael S . Tsirkin" <mst@redhat.com>,
Stefan Weil <sw@weilnetz.de>,
Igor Kotrasinski <i.kotrasinsk@partner.samsung.com>,
Richard Henderson <richard.henderson@linaro.org>,
qemu-devel@nongnu.org,
Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com>,
Greg Kurz <groug@kaod.org>, Paul Durrant <paul@xen.org>,
Alex Williamson <alex.williamson@redhat.com>,
Igor Mammedov <imammedo@redhat.com>,
Anthony Perard <anthony.perard@citrix.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Richard Henderson <rth@twiddle.net>
Subject: Re: [PATCH v2 fixed 00/16] Ram blocks with resizable anonymous allocations under POSIX
Date: Fri, 14 Feb 2020 13:08:54 +0000 [thread overview]
Message-ID: <20200214130854.GF3283@work-vm> (raw)
In-Reply-To: <6dbb3f4a-95d4-5d64-860a-0583e90a760e@redhat.com>
* David Hildenbrand (david@redhat.com) wrote:
> On 12.02.20 14:42, 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
> >
> > exec.c | 104 +++++++++++++++++++----
> > hw/core/numa.c | 53 +++++++++++-
> > hw/i386/xen/xen-mapcache.c | 7 +-
> > include/exec/cpu-common.h | 3 +
> > include/exec/memory.h | 8 ++
> > include/exec/ramlist.h | 14 +++-
> > include/qemu/mmap-alloc.h | 21 +++--
> > include/qemu/osdep.h | 6 +-
> > stubs/ram-block.c | 20 -----
> > target/i386/hax-mem.c | 5 +-
> > target/i386/sev.c | 18 ++--
> > util/mmap-alloc.c | 165 +++++++++++++++++++++++--------------
> > util/oslib-posix.c | 37 ++++++++-
> > util/oslib-win32.c | 14 ++++
> > util/trace-events | 9 +-
> > util/vfio-helpers.c | 145 +++++++++++++++++++++-----------
> > 16 files changed, 450 insertions(+), 179 deletions(-)
> >
>
> 1. I will do resizable -> resizeable
> 2. I think migration might indeed need some care regarding
> max_length. We should never migrate anything beyond used_length. And
> if we receive something, it should be discarded. Will look into that.
It feels like we should warn/error if we receive something beyond used?
Dave
> --
> Thanks,
>
> David / dhildenb
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
prev parent reply other threads:[~2020-02-14 13:10 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-12 13:42 [PATCH v2 fixed 00/16] Ram blocks with resizable anonymous allocations under POSIX David Hildenbrand
2020-02-12 13:42 ` [PATCH v2 fixed 01/16] util: vfio-helpers: Factor out and fix processing of existing ram blocks David Hildenbrand
2020-02-18 22:00 ` Peter Xu
2020-02-19 8:43 ` David Hildenbrand
2020-02-19 11:27 ` David Hildenbrand
2020-02-19 17:34 ` Peter Xu
2020-02-12 13:42 ` [PATCH v2 fixed 02/16] util: vfio-helpers: Fix qemu_vfio_close() David Hildenbrand
2020-02-18 22:00 ` Peter Xu
2020-02-12 13:42 ` [PATCH v2 fixed 03/16] util: vfio-helpers: Remove Error parameter from qemu_vfio_undo_mapping() David Hildenbrand
2020-02-18 22:07 ` Peter Xu
2020-02-19 8:49 ` David Hildenbrand
2020-02-12 13:42 ` [PATCH v2 fixed 04/16] util: vfio-helpers: Factor out removal " David Hildenbrand
2020-02-18 22:10 ` Peter Xu
2020-02-12 13:42 ` [PATCH v2 fixed 05/16] exec: Factor out setting ram settings (madvise ...) into qemu_ram_apply_settings() David Hildenbrand
2020-02-18 22:10 ` Peter Xu
2020-02-12 13:42 ` [PATCH v2 fixed 06/16] exec: Reuse qemu_ram_apply_settings() in qemu_ram_remap() David Hildenbrand
2020-02-18 22:11 ` Peter Xu
2020-02-12 13:42 ` [PATCH v2 fixed 07/16] exec: Drop "shared" parameter from ram_block_add() David Hildenbrand
2020-02-18 22:12 ` Peter Xu
2020-02-12 13:42 ` [PATCH v2 fixed 08/16] util/mmap-alloc: Factor out calculation of pagesize to mmap_pagesize() David Hildenbrand
2020-02-19 22:46 ` Peter Xu
2020-02-24 10:50 ` David Hildenbrand
2020-02-24 10:57 ` David Hildenbrand
2020-02-24 14:16 ` Murilo Opsfelder Araújo
2020-02-24 14:25 ` Murilo Opsfelder Araújo
2020-02-24 14:39 ` David Hildenbrand
2020-02-26 17:36 ` David Hildenbrand
2020-02-24 17:36 ` Peter Xu
2020-02-24 18:37 ` David Hildenbrand
2020-02-12 13:42 ` [PATCH v2 fixed 09/16] util/mmap-alloc: Factor out reserving of a memory region to mmap_reserve() David Hildenbrand
2020-02-19 22:47 ` Peter Xu
2020-02-12 13:42 ` [PATCH v2 fixed 10/16] util/mmap-alloc: Factor out populating of memory to mmap_populate() David Hildenbrand
2020-02-19 22:49 ` Peter Xu
2020-02-24 10:54 ` David Hildenbrand
2020-02-12 13:42 ` [PATCH v2 fixed 11/16] util/mmap-alloc: Prepare for resizable mmaps David Hildenbrand
2020-02-19 22:50 ` Peter Xu
2020-02-24 11:00 ` David Hildenbrand
2020-02-12 13:42 ` [PATCH v2 fixed 12/16] util/mmap-alloc: Implement " David Hildenbrand
2020-02-12 13:42 ` [PATCH v2 fixed 13/16] numa: Teach ram block notifiers about resizable ram blocks David Hildenbrand
2020-02-13 12:41 ` Paul Durrant
2020-02-12 13:42 ` [PATCH v2 fixed 14/16] util: vfio-helpers: Implement ram_block_resized() David Hildenbrand
2020-02-12 13:42 ` [PATCH v2 fixed 15/16] util: oslib: Resizable anonymous allocations under POSIX David Hildenbrand
2020-02-12 13:42 ` [PATCH v2 fixed 16/16] exec: Ram blocks with resizable " David Hildenbrand
2020-02-12 18:03 ` [PATCH v2 fixed 00/16] " David Hildenbrand
2020-02-13 13:36 ` David Hildenbrand
2020-02-14 13:08 ` Dr. David Alan Gilbert [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=20200214130854.GF3283@work-vm \
--to=dgilbert@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=anthony.perard@citrix.com \
--cc=david@redhat.com \
--cc=ehabkost@redhat.com \
--cc=groug@kaod.org \
--cc=i.kotrasinsk@partner.samsung.com \
--cc=imammedo@redhat.com \
--cc=mst@redhat.com \
--cc=muriloo@linux.ibm.com \
--cc=paul@xen.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=rth@twiddle.net \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=sstabellini@kernel.org \
--cc=stefanha@redhat.com \
--cc=sw@weilnetz.de \
/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).