From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, mst@redhat.com
Subject: [Qemu-devel] [RFC 2/2] pc: fix QEMU crashing when more than ~50 memory hotplugged
Date: Wed, 3 Jun 2015 14:22:37 +0200 [thread overview]
Message-ID: <1433334157-37665-3-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1433334157-37665-1-git-send-email-imammedo@redhat.com>
QEMU assert in vhost due to hitting vhost bachend limit
on number of supported memory regions.
Instead of increasing limit in backends, describe all hotlugged
memory as one continuos range to vhost that implements linear
1:1 HVA->GPA mapping in backend.
It allows to avoid increasing VHOST_MEMORY_MAX_NREGIONS limit
in kernel and refactoring current region lookup algorithm
to a faster/scalable datastructure. The same applies to
vhost user which has even lower limit.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
hw/i386/pc.c | 4 ++--
hw/virtio/vhost.c | 15 ++++++++++++---
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 1eb1db0..c722339 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1306,8 +1306,8 @@ FWCfgState *pc_memory_init(MachineState *machine,
exit(EXIT_FAILURE);
}
- memory_region_init(&pcms->hotplug_memory, OBJECT(pcms),
- "hotplug-memory", hotplug_mem_size);
+ memory_region_init_rsvd_hva(&pcms->hotplug_memory, OBJECT(pcms),
+ "hotplug-memory", hotplug_mem_size);
memory_region_add_subregion(system_memory, pcms->hotplug_memory_base,
&pcms->hotplug_memory);
}
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 54851b7..44cfaab 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -380,6 +380,7 @@ static void vhost_set_memory(MemoryListener *listener,
bool log_dirty = memory_region_is_logging(section->mr);
int s = offsetof(struct vhost_memory, regions) +
(dev->mem->nregions + 1) * sizeof dev->mem->regions[0];
+ MemoryRegionSection rsvd_hva;
void *ram;
dev->mem = g_realloc(dev->mem, s);
@@ -388,17 +389,25 @@ static void vhost_set_memory(MemoryListener *listener,
add = false;
}
+ rsvd_hva = memory_region_find_rsvd_hva(section->mr);
+ if (rsvd_hva.mr) {
+ start_addr = rsvd_hva.offset_within_address_space;
+ size = int128_get64(rsvd_hva.size);
+ ram = memory_region_get_ram_ptr(rsvd_hva.mr);
+ } else {
+ ram = memory_region_get_ram_ptr(section->mr) + section->offset_within_region;
+ }
+
assert(size);
/* Optimize no-change case. At least cirrus_vga does this a lot at this time. */
- ram = memory_region_get_ram_ptr(section->mr) + section->offset_within_region;
if (add) {
- if (!vhost_dev_cmp_memory(dev, start_addr, size, (uintptr_t)ram)) {
+ if (!rsvd_hva.mr && !vhost_dev_cmp_memory(dev, start_addr, size, (uintptr_t)ram)) {
/* Region exists with same address. Nothing to do. */
return;
}
} else {
- if (!vhost_dev_find_reg(dev, start_addr, size)) {
+ if (!rsvd_hva.mr && !vhost_dev_find_reg(dev, start_addr, size)) {
/* Removing region that we don't access. Nothing to do. */
return;
}
--
1.8.3.1
next prev parent reply other threads:[~2015-06-03 12:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-03 12:22 [Qemu-devel] [RFC 0/2] Fix QEMU crash during memory hotplug with vhost=on Igor Mammedov
2015-06-03 12:22 ` [Qemu-devel] [RFC 1/2] memory: introduce MemoryRegion container with reserved HVA range Igor Mammedov
2015-06-03 12:45 ` Paolo Bonzini
2015-06-03 13:43 ` Igor Mammedov
2015-06-03 12:22 ` Igor Mammedov [this message]
2015-06-03 12:48 ` [Qemu-devel] [RFC 2/2] pc: fix QEMU crashing when more than ~50 memory hotplugged Paolo Bonzini
2015-06-03 14:05 ` Igor Mammedov
2015-06-03 15:08 ` Paolo Bonzini
2015-06-03 15:23 ` Igor Mammedov
2015-06-03 16:11 ` Paolo Bonzini
2015-06-03 16:30 ` Michael S. Tsirkin
2015-06-03 15:05 ` [Qemu-devel] [RFC 0/2] Fix QEMU crash during memory hotplug with vhost=on Michael S. Tsirkin
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=1433334157-37665-3-git-send-email-imammedo@redhat.com \
--to=imammedo@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).