From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55977) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkFEF-0006fK-SE for qemu-devel@nongnu.org; Fri, 31 Oct 2014 12:39:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XkFE8-0002kN-M0 for qemu-devel@nongnu.org; Fri, 31 Oct 2014 12:39:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38245) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkFE8-0002jw-Ee for qemu-devel@nongnu.org; Fri, 31 Oct 2014 12:39:04 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9VGd3wh029476 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 31 Oct 2014 12:39:04 -0400 From: Igor Mammedov Date: Fri, 31 Oct 2014 16:38:42 +0000 Message-Id: <1414773522-7756-12-git-send-email-imammedo@redhat.com> In-Reply-To: <1414773522-7756-1-git-send-email-imammedo@redhat.com> References: <1414773522-7756-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH 11/11] pc: count in 1Gb hugepage alignment when sizing hotplug-memory container List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, mst@redhat.com if DIMMs with mized size/alignment are interleaved in creation order it could lead hotplug-memory container fragmentation and following inability to use all RAM upto maxmem. For example: -m 4G,slots=3,maxmem=7G -object memory-backend-file,id=mem-1,size=256M,mem-path=/pagesize-2MB -device pc-dimm,id=mem1,memdev=mem-1 -object memory-backend-file,id=mem-2,size=1G,mem-path=/pagesize-1GB -device pc-dimm,id=mem2,memdev=mem-2 -object memory-backend-file,id=mem-3,size=256M,mem-path=/pagesize-2MB -device pc-dimm,id=mem3,memdev=mem-3 creates fragment hotplug-memory container and doesn't allow to use 1GB hugepage backend to cosume remainig 1Gb. To ease managment factor in max 1Gb alignment for each memory slot when sizing hotplug-memory region so that regadless of fragmentaion it would be possible to add max aligned DIMM. Signed-off-by: Igor Mammedov --- hw/i386/pc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 0d9681e..9d2f800 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1288,6 +1288,11 @@ FWCfgState *pc_memory_init(MachineState *machine, pcms->hotplug_memory_base = ROUND_UP(0x100000000ULL + above_4g_mem_size, 1ULL << 30); + if (pcms->enforce_aligned_dimm) { + /* size hotplug region assuming 1G page max alignment per slot */ + hotplug_mem_size += (1ULL << 30) * machine->ram_slots; + } + if ((pcms->hotplug_memory_base + hotplug_mem_size) < hotplug_mem_size) { error_report("unsupported amount of maximum memory: " RAM_ADDR_FMT, -- 1.8.3.1