From patchwork Fri Aug 10 14:06:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 956262 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41n6Sb2Ctnz9s4Z for ; Sat, 11 Aug 2018 00:09:35 +1000 (AEST) Received: from localhost ([::1]:56447 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fo86e-0004r1-VU for incoming@patchwork.ozlabs.org; Fri, 10 Aug 2018 10:09:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39447) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fo84P-0003SY-Kt for qemu-devel@nongnu.org; Fri, 10 Aug 2018 10:07:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fo84M-0002oQ-Eq for qemu-devel@nongnu.org; Fri, 10 Aug 2018 10:07:13 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34418 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fo84M-0002nr-8r; Fri, 10 Aug 2018 10:07:10 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 42C2C40216F5; Fri, 10 Aug 2018 14:07:09 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 744287C50; Fri, 10 Aug 2018 14:07:06 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 10 Aug 2018 16:06:57 +0200 Message-Id: <1533910017-55158-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 10 Aug 2018 14:07:09 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 10 Aug 2018 14:07:09 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'imammedo@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH] acpi: SRAT: do not create reserved gap entries X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-stable@nongnu.org, lersek@redhat.com, ehabkost@redhat.com, mst@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Commit 848a1cc1e8b04 while introducing SRAT entries for DIMM and NVDIMM also introduced fake entries for gaps between memory devices, assuming that we need all possible range covered with SRAT entries. And it did it wrong since gap would overlap with preceeding entry. Reproduced with following CLI: -m 1G,slots=4,maxmem=8 \ -object memory-backend-ram,size=1G,id=m0 \ -device pc-dimm,memdev=m0,addr=0x101000000 \ -object memory-backend-ram,size=1G,id=m1 \ -device pc-dimm,memdev=m1 However recent development (10efd7e108) showed that gap entries might be not need. And indeed testing with WS2008DC-WS2016DC guests range shows that memory hotplug works just fine without gap entries. So rather than fixing gap entry borders, just drop them altogether and simplify code around it. Spotted-by: Laszlo Ersek Signed-off-by: Igor Mammedov --- There is no need to update reference blobs since gaps beween dimms aren't generated by any exsting test case. Considering issue is not visible by default lets just merge it into 3.1 and stable 3.0.1 --- hw/i386/acpi-build.c | 62 +++++++++++++++++++--------------------------------- 1 file changed, 22 insertions(+), 40 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index e1ee8ae..d3d690f 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2254,48 +2254,16 @@ build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog) static void build_srat_hotpluggable_memory(GArray *table_data, uint64_t base, uint64_t len, int default_node) { - MemoryDeviceInfoList *info_list = qmp_memory_device_list(); MemoryDeviceInfoList *info; - MemoryDeviceInfo *mi; - PCDIMMDeviceInfo *di; - uint64_t end = base + len, cur, size; - bool is_nvdimm; AcpiSratMemoryAffinity *numamem; - MemoryAffinityFlags flags; + MemoryDeviceInfoList *info_list = qmp_memory_device_list();; - for (cur = base, info = info_list; - cur < end; - cur += size, info = info->next) { - numamem = acpi_data_push(table_data, sizeof *numamem); - - if (!info) { - /* - * Entry is required for Windows to enable memory hotplug in OS - * and for Linux to enable SWIOTLB when booted with less than - * 4G of RAM. Windows works better if the entry sets proximity - * to the highest NUMA node in the machine at the end of the - * reserved space. - * Memory devices may override proximity set by this entry, - * providing _PXM method if necessary. - */ - build_srat_memory(numamem, end - 1, 1, default_node, - MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED); - break; - } - - mi = info->value; - is_nvdimm = (mi->type == MEMORY_DEVICE_INFO_KIND_NVDIMM); - di = !is_nvdimm ? mi->u.dimm.data : mi->u.nvdimm.data; - - if (cur < di->addr) { - build_srat_memory(numamem, cur, di->addr - cur, default_node, - MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED); - numamem = acpi_data_push(table_data, sizeof *numamem); - } - - size = di->size; + for (info = info_list; info != NULL; info = info->next) { + MemoryAffinityFlags flags = MEM_AFFINITY_ENABLED; + MemoryDeviceInfo *mi = info->value; + bool is_nvdimm = (mi->type == MEMORY_DEVICE_INFO_KIND_NVDIMM); + PCDIMMDeviceInfo *di = !is_nvdimm ? mi->u.dimm.data : mi->u.nvdimm.data; - flags = MEM_AFFINITY_ENABLED; if (di->hotpluggable) { flags |= MEM_AFFINITY_HOTPLUGGABLE; } @@ -2303,10 +2271,24 @@ static void build_srat_hotpluggable_memory(GArray *table_data, uint64_t base, flags |= MEM_AFFINITY_NON_VOLATILE; } - build_srat_memory(numamem, di->addr, size, di->node, flags); + numamem = acpi_data_push(table_data, sizeof *numamem); + build_srat_memory(numamem, di->addr, di->size, di->node, flags); } - qapi_free_MemoryDeviceInfoList(info_list); + + /* + * Entry is required for Windows to enable memory hotplug in OS + * and for Linux to enable SWIOTLB when booted with less than + * 4G of RAM. Windows works better if the entry sets proximity + * to the highest NUMA node in the machine at the end of the + * reserved space. + * Memory devices may override proximity set by this entry, + * providing _PXM method if necessary. + */ + numamem = acpi_data_push(table_data, sizeof *numamem); + build_srat_memory(numamem, base + len - 1, 1, default_node, + MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED); + } static void