From nobody Sat Apr 27 18:55:35 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; dkim=fail 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 1490263938791917.310032258199; Thu, 23 Mar 2017 03:12:18 -0700 (PDT) Received: from localhost ([::1]:55282 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cqzj7-0005iJ-7u for importer@patchew.org; Thu, 23 Mar 2017 06:12:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35187) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cqzhw-0004ic-Id for qemu-devel@nongnu.org; Thu, 23 Mar 2017 06:11:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cqzhq-000698-9h for qemu-devel@nongnu.org; Thu, 23 Mar 2017 06:11:04 -0400 Received: from ozlabs.org ([103.22.144.67]:54279) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cqzhp-00066d-PQ; Thu, 23 Mar 2017 06:10:58 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3vpj4F6S7lz9s2s; Thu, 23 Mar 2017 21:10:53 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1490263853; bh=nqcVMqSM7tLqKeiM62ToG+8bMp62bsGLKCWv5Wol83Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NCGSHCFyx0SXGuKhhegc06rHvABm8nNJ3QWgCrlCAOUwdM8Hd8jhGJtR+EpQlKl9V XR49QueEv+ZZfUgZ7DDOUDsVDLtLoWKM06Tm/3lNl78u5iXGAg+f56V6ncFMC6BSBh A6aIadEWe7QGESlvfm7hni40VDdh2Vc+TyD6Cs8A= From: David Gibson To: peter.maydell@linaro.org Date: Thu, 23 Mar 2017 21:10:48 +1100 Message-Id: <20170323101048.24848-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170323101048.24848-1-david@gibson.dropbear.id.au> References: <20170323101048.24848-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 1/1] 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: lvivier@redhat.com, thuth@redhat.com, ehabkost@redhat.com, aik@ozlabs.ru, mdroth@linux.vnet.ibm.com, 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-DKIM: fail (Header signature does not verify) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Laurent Vivier 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 Signed-off-by: David Gibson --- hw/core/machine.c | 5 +++++ hw/ppc/spapr.c | 6 ++++++ include/hw/boards.h | 1 + numa.c | 6 +++--- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 0d92672..ada9eea 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -396,6 +396,11 @@ static void machine_class_init(ObjectClass *oc, void *= data) 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. + * On Linux, each node's border has to be 8MB aligned + */ + 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..8aecea3 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3096,6 +3096,11 @@ 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; + /* Force NUMA node memory size to be a multiple of + * SPAPR_MEMORY_BLOCK_SIZE (256M) since that's the granularity + * in which LMBs are represented and hot-added + */ + mc->numa_mem_align_shift =3D 28; } =20 static const TypeInfo spapr_machine_info =3D { @@ -3180,6 +3185,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..6fc2393 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, - * the final node gets the rest. + /* Align each node according to the alignment + * requirements of the machine class */ 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