From nobody Mon Apr 29 09:04:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14900193036431012.4870458861773; Mon, 20 Mar 2017 07:15:03 -0700 (PDT) Received: from localhost ([::1]:33234 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cpy5O-0004yw-2j for importer@patchew.org; Mon, 20 Mar 2017 10:15:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39457) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cpy3N-0003wS-C5 for qemu-devel@nongnu.org; Mon, 20 Mar 2017 10:12:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cpy3I-000279-E5 for qemu-devel@nongnu.org; Mon, 20 Mar 2017 10:12:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38586) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cpy3I-000251-5E; Mon, 20 Mar 2017 10:12:52 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 11C6275725; Mon, 20 Mar 2017 14:12:52 +0000 (UTC) Received: from thinkpad.redhat.com (ovpn-116-101.ams2.redhat.com [10.36.116.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id E047762931; Mon, 20 Mar 2017 14:12:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 11C6275725 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lvivier@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 11C6275725 From: Laurent Vivier To: Eduardo Habkost Date: Mon, 20 Mar 2017 15:12:44 +0100 Message-Id: <20170320141244.20737-1-lvivier@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 20 Mar 2017 14:12:52 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2] numa, spapr: align default numa node memory size to 256MB 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: Laurent Vivier , Thomas Huth , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Since commit 224245b ("spapr: Add LMB DR connectors"), NUMA node memory size must be aligned to 256MB (SPAPR_MEMORY_BLOCK_SIZE). But when "-numa" option is provided without "mem" parameter, the memory is equally divided between nodes, but 8MB aligned. This can be not valid for pseries. In that case we can have: $ ./ppc64-softmmu/qemu-system-ppc64 -m 4G -numa node -numa node -numa node qemu-system-ppc64: Node 0 memory size 0x55000000 is not aligned to 256 MiB With this patch, we have: (qemu) info numa 3 nodes node 0 cpus: 0 node 0 size: 1280 MB node 1 cpus: node 1 size: 1280 MB node 2 cpus: node 2 size: 1536 MB Signed-off-by: Laurent Vivier Acked-by: Eduardo Habkost Reviewed-by: David Gibson --- v2: - remove dtc - Add a field in MachineClass to only modify the numa node memory alignment value for pseries-2.9 and upper. hw/core/machine.c | 3 +++ hw/ppc/spapr.c | 2 ++ include/hw/boards.h | 1 + numa.c | 4 ++-- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 0d92672..2ad5ab5 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -396,6 +396,9 @@ static void machine_class_init(ObjectClass *oc, void *d= ata) mc->default_ram_size =3D 128 * M_BYTE; mc->rom_file_has_mr =3D true; =20 + /* numa node memory size aligned on 8MB by default */ + mc->numa_mem_align_shift =3D 23; + object_class_property_add_str(oc, "accel", machine_get_accel, machine_set_accel, &error_abort); object_class_property_set_description(oc, "accel", diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 6ee566d..1e72fe8 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3096,6 +3096,7 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) xic->ics_resend =3D spapr_ics_resend; xic->icp_get =3D spapr_icp_get; ispc->print_info =3D spapr_pic_print_info; + mc->numa_mem_align_shift =3D 28; } =20 static const TypeInfo spapr_machine_info =3D { @@ -3180,6 +3181,7 @@ static void spapr_machine_2_8_class_options(MachineCl= ass *mc) { spapr_machine_2_9_class_options(mc); SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_8); + mc->numa_mem_align_shift =3D 23; } =20 DEFINE_SPAPR_MACHINE(2_8, "2.8", false); diff --git a/include/hw/boards.h b/include/hw/boards.h index 269d0ba..31d9c72 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -135,6 +135,7 @@ struct MachineClass { bool rom_file_has_mr; int minimum_page_bits; bool has_hotpluggable_cpus; + int numa_mem_align_shift; =20 HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev); diff --git a/numa.c b/numa.c index e01cb54..98e4d02 100644 --- a/numa.c +++ b/numa.c @@ -338,12 +338,12 @@ void parse_numa_opts(MachineClass *mc) if (i =3D=3D nb_numa_nodes) { uint64_t usedmem =3D 0; =20 - /* On Linux, each node's border has to be 8MB aligned, + /* On Linux, each node's border has to be aligned, * the final node gets the rest. */ for (i =3D 0; i < nb_numa_nodes - 1; i++) { numa_info[i].node_mem =3D (ram_size / nb_numa_nodes) & - ~((1 << 23UL) - 1); + ~((1 << mc->numa_mem_align_shift) = - 1); usedmem +=3D numa_info[i].node_mem; } numa_info[i].node_mem =3D ram_size - usedmem; --=20 2.9.3