All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH/RFC] s390x: split memory into 4TB chunks
@ 2017-12-06 12:00 Christian Borntraeger
  2017-12-06 12:04 ` David Hildenbrand
  0 siblings, 1 reply; 9+ messages in thread
From: Christian Borntraeger @ 2017-12-06 12:00 UTC (permalink / raw)
  To: Cornelia Huck
  Cc: qemu-devel, qemu-s390x, Halil Pasic, Alexander Graf, Thomas Huth,
	David Hildenbrand, Richard Henderson, Christian Borntraeger

KVM does not allow memory regions > KVM_MEM_MAX_NR_PAGES, basically
limiting the memory per slot to 7.999TB. Lets split the base memory
into 4TB chunks to allow go beyond 8TB for a guest. With that (and
optimistic overcommitment in the kernel) I was able to start  a 59TB
guest on a 1TB system.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 hw/s390x/s390-virtio-ccw.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 8425534..6735bbb 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -157,11 +157,25 @@ static void virtio_ccw_register_hcalls(void)
 static void s390_memory_init(ram_addr_t mem_size)
 {
     MemoryRegion *sysmem = get_system_memory();
-    MemoryRegion *ram = g_new(MemoryRegion, 1);
+    ram_addr_t chunk, offset;
+    gchar *name;
 
     /* allocate RAM for core */
-    memory_region_allocate_system_memory(ram, NULL, "s390.ram", mem_size);
-    memory_region_add_subregion(sysmem, 0, ram);
+    offset = 0;
+    while (mem_size) {
+        MemoryRegion *ram = g_new(MemoryRegion, 1);
+        chunk = mem_size;
+        /* KVM does not allow memslots >= 8 TB. Lets split into 4TB chunks */
+        if (chunk > 4UL * 1024 * 1024 * 1024 * 1024) {
+            chunk = 4UL * 1024 * 1024 * 1024 * 1024;
+        }
+        name = g_strdup_printf("s390.ram[0x%lx]", offset);
+        memory_region_allocate_system_memory(ram, NULL, name, chunk);
+        memory_region_add_subregion(sysmem, offset, ram);
+        mem_size -= chunk;
+        offset += chunk;
+        g_free(name);
+    }
 
     /* Initialize storage key device */
     s390_skeys_init();
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-12-06 13:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-06 12:00 [Qemu-devel] [PATCH/RFC] s390x: split memory into 4TB chunks Christian Borntraeger
2017-12-06 12:04 ` David Hildenbrand
2017-12-06 12:06   ` Christian Borntraeger
2017-12-06 12:12     ` David Hildenbrand
2017-12-06 12:15       ` Christian Borntraeger
2017-12-06 12:19         ` David Hildenbrand
2017-12-06 12:52           ` Christian Borntraeger
2017-12-06 13:35         ` Paolo Bonzini
2017-12-06 13:48           ` Christian Borntraeger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.