Received: from eggs.gnu.org ([2001:4830:134:3::10]:36286) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMYbi-0004wb-NF for qemu-devel@nongnu.org; Wed, 06 Dec 2017 07:15:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eMYbc-0005xs-Jz for qemu-devel@nongnu.org; Wed, 06 Dec 2017 07:15:22 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:37554) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eMYbc-0005wG-CI for qemu-devel@nongnu.org; Wed, 06 Dec 2017 07:15:16 -0500 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vB6CDtG7143402 for ; Wed, 6 Dec 2017 07:15:12 -0500 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 2epgc683ad-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 06 Dec 2017 07:15:12 -0500 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 6 Dec 2017 12:15:09 -0000 References: <20171206120000.63822-1-borntraeger@de.ibm.com> <0b60c788-0470-1fa0-390c-472d75aef0dc@redhat.com> <8c5f5393-9191-fdae-e852-196163d42d50@de.ibm.com> <48792114-6784-249d-0e5f-3b1f1ace7a75@redhat.com> From: Christian Borntraeger Date: Wed, 6 Dec 2017 13:15:04 +0100 MIME-Version: 1.0 In-Reply-To: <48792114-6784-249d-0e5f-3b1f1ace7a75@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Message-Id: Subject: Re: [Qemu-devel] [PATCH/RFC] s390x: split memory into 4TB chunks List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Hildenbrand , Cornelia Huck Cc: qemu-devel , qemu-s390x , Halil Pasic , Alexander Graf , Thomas Huth , Richard Henderson , Paolo Bonzini On 12/06/2017 01:12 PM, David Hildenbrand wrote: > On 06.12.2017 13:06, Christian Borntraeger wrote: >> >> >> On 12/06/2017 01:04 PM, David Hildenbrand wrote: >>> On 06.12.2017 13:00, Christian Borntraeger wrote: >>>> 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 >>>> --- >>>> 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(); >>>> >>> >>> 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. 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. > b) as I said, transparently handle it in kvm slot handling code. adding Paolo to check what he thinks. > >>> >>> 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) >> > >