s390x: split memory into 4TB chunks
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.
--- hw/s390x/s390-virtio-ccw.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
hw/s390x/s390-virtio-ccw.c +17 -3
@@ -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 ();
Signature · 1 line
2.9.4
Quoted 34 lines · 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 <[email protected]>--- hw/s390x/s390-virtio-ccw.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)hw/s390x/s390-virtio-ccw.c +9
-3@@ -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 ; + }
hw/s390x/s390-virtio-ccw.c static void virtio_ccw_register_hcalls(void) · line 180
Quoted 10 lines
hw/s390x/s390-virtio-ccw.c +7
-0+ 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 ();
This will most certainly break migration, no?
1. I remember the name being used for migration, I might be wrong.
2. Migration of guests > 4TB is certainly broken ;)
I wonder if this should rather be handled in the kvm_slot code. (silently create an manage two slots)
Signature · 3 lines
Thanks, David / dhildenb
Quoted 42 lines · David Hildenbrand
Quoted 41 lines · 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 <[email protected]>--- hw/s390x/s390-virtio-ccw.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)hw/s390x/s390-virtio-ccw.c +16
-3@@ -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); + }
Quoted 5 lines
hw/s390x/s390-virtio-ccw.c static void virtio_ccw_register_hcalls(void) · line 181
Quoted 3 lines
hw/s390x/s390-virtio-ccw.c +0
-0/* Initialize storage key device */ s390_skeys_init ();This will most certainly break migration, no?
Probably yes. Thats why the patch has RFC. I was looking for ideas.
Quoted 6 lines
1. I remember the name being used for migration, I might be wrong.
2. Migration of guests > 4TB is certainly broken ;)I wonder if this should rather be handled in the
kvm_slotcode. (silently create an manage two slots)
Quoted 45 lines · Christian Borntraeger
Quoted 42 lines · David Hildenbrand
Quoted 41 lines · 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 <[email protected]>--- hw/s390x/s390-virtio-ccw.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)hw/s390x/s390-virtio-ccw.c +16
-3@@ -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); + }
Quoted 7 lines
Quoted 5 lines
hw/s390x/s390-virtio-ccw.c static void virtio_ccw_register_hcalls(void) · line 181
Quoted 3 lines
hw/s390x/s390-virtio-ccw.c +0
-0/* Initialize storage key device */ s390_skeys_init ();This will most certainly break migration, no?
Probably yes. Thats why the patch has RFC. I was looking for ideas.
As other architectures might also run into this problem, wonder if
a) bumping up KVM_MEM_MAX_NR_PAGES makes sense.
b) as I said, transparently handle it in kvm slot handling code.
Quoted 7 lines
Quoted 6 lines
1. I remember the name being used for migration, I might be wrong.
2. Migration of guests > 4TB is certainly broken ;)I wonder if this should rather be handled in the
kvm_slotcode. (silently create an manage two slots)
Signature · 3 lines
Thanks, David / dhildenb
Quoted 52 lines · David Hildenbrand
Quoted 51 lines · Christian Borntraeger
Quoted 47 lines · David Hildenbrand
Quoted 34 lines · 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 <[email protected]>--- hw/s390x/s390-virtio-ccw.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)hw/s390x/s390-virtio-ccw.c +9
-3@@ -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 ; + }hw/s390x/s390-virtio-ccw.c static void virtio_ccw_register_hcalls(void) · line 180
Quoted 10 lines
hw/s390x/s390-virtio-ccw.c +7
-0+ 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 ();This will most certainly break migration, no?
Quoted 5 lines
Quoted 1 line
Probably yes. Thats why the patch has RFC. I was looking for ideas.
As other architectures might also run into this problem, wonder if
a) bumping up
KVM_MEM_MAX_NR_PAGESmakes sense.
The original limitation comes from the fact that this define is used to limit the number of bits in the dirty bitmap as some architectures do not provide bitops beyond 2^32.
Quoted 1 line
b) as I said, transparently handle it in kvm slot handling code.
adding Paolo to check what he thinks.
Quoted 10 lines
Quoted 8 lines
Quoted 7 lines
1. I remember the name being used for migration, I might be wrong.
2. Migration of guests > 4TB is certainly broken ;)I wonder if this should rather be handled in the
kvm_slotcode. (silently create an manage two slots)
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
This will most certainly break migration, no?
Probably yes. Thats why the patch has RFC. I was looking for ideas.
Quoted 7 lines
Quoted 3 lines
As other architectures might also run into this problem, wonder if
a) bumping up
KVM_MEM_MAX_NR_PAGESmakes sense.The original limitation comes from the fact that this define is used to limit the number of bits in the dirty bitmap as some architectures do not provide bitops beyond 2^32.
Then my question would be if we can bump it up for all architectures that support it.
Quoted 15 lines
Quoted 2 lines
b) as I said, transparently handle it in kvm slot handling code.
adding Paolo to check what he thinks.
Quoted 10 lines
Quoted 8 lines
Quoted 7 lines
1. I remember the name being used for migration, I might be wrong.
2. Migration of guests > 4TB is certainly broken ;)I wonder if this should rather be handled in the
kvm_slotcode. (silently create an manage two slots)
Signature · 3 lines
Thanks, David / dhildenb
Quoted 7 lines · David Hildenbrand
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
This will most certainly break migration, no?
Probably yes. Thats why the patch has RFC. I was looking for ideas.
As other architectures might also run into this problem, wonder if
Quoted 13 lines
Quoted 5 lines
Quoted 1 line
a) bumping up
KVM_MEM_MAX_NR_PAGESmakes sense.The original limitation comes from the fact that this define is used to limit the number of bits in the dirty bitmap as some architectures do not provide bitops beyond 2^32.
Then my question would be if we can bump it up for all architectures that support it.
Quoted 4 lines
Quoted 2 lines
b) as I said, transparently handle it in kvm slot handling code.
adding Paolo to check what he thinks.
Another quick variant would be to keep the name of the first memslot as is (to be compatible) and start a new one just after the maximum size of. After all migration will fail anyway for larger guests.
Quoted 13 lines
Quoted 11 lines
Quoted 10 lines
Quoted 8 lines
Quoted 7 lines
1. I remember the name being used for migration, I might be wrong.
2. Migration of guests > 4TB is certainly broken ;)I wonder if this should rather be handled in the
kvm_slotcode. (silently create an manage two slots)
Quoted 7 lines · Christian Borntraeger
Quoted 1 line
a) bumping up
KVM_MEM_MAX_NR_PAGESmakes sense.The original limitation comes from the fact that this define is used to limit the number of bits in the dirty bitmap as some architectures do not provide bitops beyond 2^32.
Quoted 1 line
b) as I said, transparently handle it in kvm slot handling code.
adding Paolo to check what he thinks.
It's a bit of a first-world problem, :) and working around it in QEMU makes is easy enough that it's okay in my opinion.
Bumping up KVM_MEM_MAX_NR_PAGES if the bitops allows it should be a good idea too, but it requires auditing the code for overflows and truncations.
Paolo
Quoted 10 lines · Paolo Bonzini
Quoted 7 lines · Christian Borntraeger
Quoted 1 line
a) bumping up
KVM_MEM_MAX_NR_PAGESmakes sense.The original limitation comes from the fact that this define is used to limit the number of bits in the dirty bitmap as some architectures do not provide bitops beyond 2^32.
Quoted 1 line
b) as I said, transparently handle it in kvm slot handling code.
adding Paolo to check what he thinks.
It's a bit of a first-world problem, :)
If a genie comes along and offers you to fufill 3 wishes, as an IT guy you say: "I want a memory cardridge that is never full".
The genie say "ok, what is your 2nd wish". You say "A 2nd memory cartridge"....
Quoted 2 lines
and working around it in QEMU
makes is easy enough that it's okay in my opinion.
Since the dirty logging is synched between the qemu memory regions and the KVM slots I will look into something like keep the original memslots and create a new one as soon as we cross the current KVM_MEM_MAX_NR_PAGES size.
Quoted 6 lines
Bumping up
KVM_MEM_MAX_NR_PAGESif the bitops allows it should be a good idea too, but it requires auditing the code for overflows and truncations.Paolo