From nobody Thu May 2 11:58:41 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 1494530443495779.2403629757108; Thu, 11 May 2017 12:20:43 -0700 (PDT) Received: from localhost ([::1]:49753 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tdi-0003X7-0l for importer@patchew.org; Thu, 11 May 2017 15:20:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37712) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tbw-0002Ef-09 for qemu-devel@nongnu.org; Thu, 11 May 2017 15:18:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tbu-0007j7-DG for qemu-devel@nongnu.org; Thu, 11 May 2017 15:18:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34918) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tbu-0007ik-6g for qemu-devel@nongnu.org; Thu, 11 May 2017 15:18:50 -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 1996E4E4C6; Thu, 11 May 2017 19:18:49 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id A67351710A; Thu, 11 May 2017 19:18:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1996E4E4C6 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1996E4E4C6 From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:15 -0300 Message-Id: <20170511191843.13784-2-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@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.38]); Thu, 11 May 2017 19:18:49 +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] [PULL 01/29] i386: rewrite way CPUID index is validated 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-devel@nongnu.org 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" From: "Daniel P. Berrange" Change the nested if statements into a flat format, to make it clearer what validation / capping is being performed on different CPUID index values. NB this changes behaviour when "index > env->cpuid_xlevel2". This won't have any guest-visible effect because no there is no CPUID[0xC0000001] feature supported by TCG, and KVM code will never call cpu_x86_cpuid() with such an index value. Reviewed-by: Eduardo Habkost Signed-off-by: Daniel P. Berrange Message-Id: <20170509132736.10071-2-berrange@redhat.com> Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 7e87031fad..e3182b296f 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -2635,28 +2635,23 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index= , uint32_t count, X86CPU *cpu =3D x86_env_get_cpu(env); CPUState *cs =3D CPU(cpu); uint32_t pkg_offset; + uint32_t limit; =20 - /* test if maximum index reached */ - if (index & 0x80000000) { - if (index > env->cpuid_xlevel) { - if (env->cpuid_xlevel2 > 0) { - /* Handle the Centaur's CPUID instruction. */ - if (index > env->cpuid_xlevel2) { - index =3D env->cpuid_xlevel2; - } else if (index < 0xC0000000) { - index =3D env->cpuid_xlevel; - } - } else { - /* Intel documentation states that invalid EAX input will - * return the same information as EAX=3Dcpuid_level - * (Intel SDM Vol. 2A - Instruction Set Reference - CPUID) - */ - index =3D env->cpuid_level; - } - } + /* Calculate & apply limits for different index ranges */ + if (index >=3D 0xC0000000) { + limit =3D env->cpuid_xlevel2; + } else if (index >=3D 0x80000000) { + limit =3D env->cpuid_xlevel; } else { - if (index > env->cpuid_level) - index =3D env->cpuid_level; + limit =3D env->cpuid_level; + } + + if (index > limit) { + /* Intel documentation states that invalid EAX input will + * return the same information as EAX=3Dcpuid_level + * (Intel SDM Vol. 2A - Instruction Set Reference - CPUID) + */ + index =3D env->cpuid_level; } =20 switch(index) { --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:41 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 1494530607812160.75848379616798; Thu, 11 May 2017 12:23:27 -0700 (PDT) Received: from localhost ([::1]:49767 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tgL-000683-CE for importer@patchew.org; Thu, 11 May 2017 15:23:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37730) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tby-0002GC-O3 for qemu-devel@nongnu.org; Thu, 11 May 2017 15:18:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tbw-0007kS-KX for qemu-devel@nongnu.org; Thu, 11 May 2017 15:18:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56860) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tbw-0007k6-B2 for qemu-devel@nongnu.org; Thu, 11 May 2017 15:18:52 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 45A863DBC0; Thu, 11 May 2017 19:18:51 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D68E71C35; Thu, 11 May 2017 19:18:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 45A863DBC0 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 45A863DBC0 From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:16 -0300 Message-Id: <20170511191843.13784-3-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 11 May 2017 19:18:51 +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] [PULL 02/29] numa: Allow setting NUMA distance for different NUMA nodes 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-devel@nongnu.org, He Chen 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" From: He Chen This patch is going to add SLIT table support in QEMU, and provides additional option `dist` for command `-numa` to allow user set vNUMA distance by QEMU command. With this patch, when a user wants to create a guest that contains several vNUMA nodes and also wants to set distance among those nodes, the QEMU command would like: ``` -numa node,nodeid=3D0,cpus=3D0 \ -numa node,nodeid=3D1,cpus=3D1 \ -numa node,nodeid=3D2,cpus=3D2 \ -numa node,nodeid=3D3,cpus=3D3 \ -numa dist,src=3D0,dst=3D1,val=3D21 \ -numa dist,src=3D0,dst=3D2,val=3D31 \ -numa dist,src=3D0,dst=3D3,val=3D41 \ -numa dist,src=3D1,dst=3D2,val=3D21 \ -numa dist,src=3D1,dst=3D3,val=3D31 \ -numa dist,src=3D2,dst=3D3,val=3D21 \ ``` Signed-off-by: He Chen Message-Id: <1493260558-20728-1-git-send-email-he.chen@linux.intel.com> Reviewed-by: Igor Mammedov Reviewed-by: Andrew Jones Signed-off-by: Eduardo Habkost --- qapi-schema.json | 30 +++++++++- include/hw/acpi/aml-build.h | 1 + include/sysemu/numa.h | 2 + include/sysemu/sysemu.h | 4 ++ hw/acpi/aml-build.c | 26 +++++++++ hw/i386/acpi-build.c | 4 ++ numa.c | 137 ++++++++++++++++++++++++++++++++++++++++= +++- qemu-options.hx | 16 +++++- 8 files changed, 215 insertions(+), 5 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index 5728b7f363..f4eef33a44 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -5682,10 +5682,14 @@ ## # @NumaOptionsType: # +# @node: NUMA nodes configuration +# +# @dist: NUMA distance configuration (since 2.10) +# # Since: 2.1 ## { 'enum': 'NumaOptionsType', - 'data': [ 'node' ] } + 'data': [ 'node', 'dist' ] } =20 ## # @NumaOptions: @@ -5698,7 +5702,8 @@ 'base': { 'type': 'NumaOptionsType' }, 'discriminator': 'type', 'data': { - 'node': 'NumaNodeOptions' }} + 'node': 'NumaNodeOptions', + 'dist': 'NumaDistOptions' }} =20 ## # @NumaNodeOptions: @@ -5727,6 +5732,27 @@ '*memdev': 'str' }} =20 ## +# @NumaDistOptions: +# +# Set the distance between 2 NUMA nodes. +# +# @src: source NUMA node. +# +# @dst: destination NUMA node. +# +# @val: NUMA distance from source node to destination node. +# When a node is unreachable from another node, set the distance +# between them to 255. +# +# Since: 2.10 +## +{ 'struct': 'NumaDistOptions', + 'data': { + 'src': 'uint16', + 'dst': 'uint16', + 'val': 'uint8' }} + +## # @HostMemPolicy: # # Host memory policy types diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 00c21f160c..329a0d0c90 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -389,4 +389,5 @@ GCC_FMT_ATTR(2, 3); void build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base, uint64_t len, int node, MemoryAffinityFlags flags); =20 +void build_slit(GArray *table_data, BIOSLinker *linker); #endif diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index 8f09dcf918..0ea1bc086e 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -8,6 +8,7 @@ #include "hw/boards.h" =20 extern int nb_numa_nodes; /* Number of NUMA nodes */ +extern bool have_numa_distance; =20 struct numa_addr_range { ram_addr_t mem_start; @@ -21,6 +22,7 @@ typedef struct node_info { struct HostMemoryBackend *node_memdev; bool present; QLIST_HEAD(, numa_addr_range) addr; /* List to store address ranges */ + uint8_t distance[MAX_NODES]; } NodeInfo; =20 extern NodeInfo numa_info[MAX_NODES]; diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 15656b7c36..be9e22c955 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -166,6 +166,10 @@ extern int mem_prealloc; =20 #define MAX_NODES 128 #define NUMA_NODE_UNASSIGNED MAX_NODES +#define NUMA_DISTANCE_MIN 10 +#define NUMA_DISTANCE_DEFAULT 20 +#define NUMA_DISTANCE_MAX 254 +#define NUMA_DISTANCE_UNREACHABLE 255 =20 #define MAX_OPTION_ROMS 16 typedef struct QEMUOptionRom { diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index c6f2032dec..be496c817c 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -24,6 +24,7 @@ #include "hw/acpi/aml-build.h" #include "qemu/bswap.h" #include "qemu/bitops.h" +#include "sysemu/numa.h" =20 static GArray *build_alloc_array(void) { @@ -1609,3 +1610,28 @@ void build_srat_memory(AcpiSratMemoryAffinity *numam= em, uint64_t base, numamem->base_addr =3D cpu_to_le64(base); numamem->range_length =3D cpu_to_le64(len); } + +/* + * ACPI spec 5.2.17 System Locality Distance Information Table + * (Revision 2.0 or later) + */ +void build_slit(GArray *table_data, BIOSLinker *linker) +{ + int slit_start, i, j; + slit_start =3D table_data->len; + + acpi_data_push(table_data, sizeof(AcpiTableHeader)); + + build_append_int_noprefix(table_data, nb_numa_nodes, 8); + for (i =3D 0; i < nb_numa_nodes; i++) { + for (j =3D 0; j < nb_numa_nodes; j++) { + assert(numa_info[i].distance[j]); + build_append_int_noprefix(table_data, numa_info[i].distance[j]= , 1); + } + } + + build_header(linker, table_data, + (void *)(table_data->data + slit_start), + "SLIT", + table_data->len - slit_start, 1, NULL, NULL); +} diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 1d8c645ed3..c7cc45cc4b 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2707,6 +2707,10 @@ void acpi_build(AcpiBuildTables *tables, MachineStat= e *machine) if (pcms->numa_nodes) { acpi_add_table(table_offsets, tables_blob); build_srat(tables_blob, tables->linker, machine); + if (have_numa_distance) { + acpi_add_table(table_offsets, tables_blob); + build_slit(tables_blob, tables->linker); + } } if (acpi_get_mcfg(&mcfg)) { acpi_add_table(table_offsets, tables_blob); diff --git a/numa.c b/numa.c index 6fc2393ddd..2b3fc69915 100644 --- a/numa.c +++ b/numa.c @@ -51,6 +51,7 @@ static int max_numa_nodeid; /* Highest specified NUMA nod= e ID, plus one. * For all nodes, nodeid < max_numa_nodeid */ int nb_numa_nodes; +bool have_numa_distance; NodeInfo numa_info[MAX_NODES]; =20 void numa_set_mem_node_id(ram_addr_t addr, uint64_t size, uint32_t node) @@ -140,7 +141,7 @@ uint32_t numa_get_node(ram_addr_t addr, Error **errp) return -1; } =20 -static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error *= *errp) +static void parse_numa_node(NumaNodeOptions *node, QemuOpts *opts, Error *= *errp) { uint16_t nodenr; uint16List *cpus =3D NULL; @@ -212,6 +213,43 @@ static void numa_node_parse(NumaNodeOptions *node, Qem= uOpts *opts, Error **errp) max_numa_nodeid =3D MAX(max_numa_nodeid, nodenr + 1); } =20 +static void parse_numa_distance(NumaDistOptions *dist, Error **errp) +{ + uint16_t src =3D dist->src; + uint16_t dst =3D dist->dst; + uint8_t val =3D dist->val; + + if (src >=3D MAX_NODES || dst >=3D MAX_NODES) { + error_setg(errp, + "Invalid node %" PRIu16 + ", max possible could be %" PRIu16, + MAX(src, dst), MAX_NODES); + return; + } + + if (!numa_info[src].present || !numa_info[dst].present) { + error_setg(errp, "Source/Destination NUMA node is missing. " + "Please use '-numa node' option to declare it first."); + return; + } + + if (val < NUMA_DISTANCE_MIN) { + error_setg(errp, "NUMA distance (%" PRIu8 ") is invalid, " + "it shouldn't be less than %d.", + val, NUMA_DISTANCE_MIN); + return; + } + + if (src =3D=3D dst && val !=3D NUMA_DISTANCE_MIN) { + error_setg(errp, "Local distance of node %d should be %d.", + src, NUMA_DISTANCE_MIN); + return; + } + + numa_info[src].distance[dst] =3D val; + have_numa_distance =3D true; +} + static int parse_numa(void *opaque, QemuOpts *opts, Error **errp) { NumaOptions *object =3D NULL; @@ -229,12 +267,18 @@ static int parse_numa(void *opaque, QemuOpts *opts, E= rror **errp) =20 switch (object->type) { case NUMA_OPTIONS_TYPE_NODE: - numa_node_parse(&object->u.node, opts, &err); + parse_numa_node(&object->u.node, opts, &err); if (err) { goto end; } nb_numa_nodes++; break; + case NUMA_OPTIONS_TYPE_DIST: + parse_numa_distance(&object->u.dist, &err); + if (err) { + goto end; + } + break; default: abort(); } @@ -294,6 +338,75 @@ static void validate_numa_cpus(void) g_free(seen_cpus); } =20 +/* If all node pair distances are symmetric, then only distances + * in one direction are enough. If there is even one asymmetric + * pair, though, then all distances must be provided. The + * distance from a node to itself is always NUMA_DISTANCE_MIN, + * so providing it is never necessary. + */ +static void validate_numa_distance(void) +{ + int src, dst; + bool is_asymmetrical =3D false; + + for (src =3D 0; src < nb_numa_nodes; src++) { + for (dst =3D src; dst < nb_numa_nodes; dst++) { + if (numa_info[src].distance[dst] =3D=3D 0 && + numa_info[dst].distance[src] =3D=3D 0) { + if (src !=3D dst) { + error_report("The distance between node %d and %d is " + "missing, at least one distance value " + "between each nodes should be provided.", + src, dst); + exit(EXIT_FAILURE); + } + } + + if (numa_info[src].distance[dst] !=3D 0 && + numa_info[dst].distance[src] !=3D 0 && + numa_info[src].distance[dst] !=3D + numa_info[dst].distance[src]) { + is_asymmetrical =3D true; + } + } + } + + if (is_asymmetrical) { + for (src =3D 0; src < nb_numa_nodes; src++) { + for (dst =3D 0; dst < nb_numa_nodes; dst++) { + if (src !=3D dst && numa_info[src].distance[dst] =3D=3D 0)= { + error_report("At least one asymmetrical pair of " + "distances is given, please provide distances " + "for both directions of all node pairs."); + exit(EXIT_FAILURE); + } + } + } + } +} + +static void complete_init_numa_distance(void) +{ + int src, dst; + + /* Fixup NUMA distance by symmetric policy because if it is an + * asymmetric distance table, it should be a complete table and + * there would not be any missing distance except local node, which + * is verified by validate_numa_distance above. + */ + for (src =3D 0; src < nb_numa_nodes; src++) { + for (dst =3D 0; dst < nb_numa_nodes; dst++) { + if (numa_info[src].distance[dst] =3D=3D 0) { + if (src =3D=3D dst) { + numa_info[src].distance[dst] =3D NUMA_DISTANCE_MIN; + } else { + numa_info[src].distance[dst] =3D numa_info[dst].distan= ce[src]; + } + } + } + } +} + void parse_numa_opts(MachineClass *mc) { int i; @@ -390,6 +503,26 @@ void parse_numa_opts(MachineClass *mc) } =20 validate_numa_cpus(); + + /* QEMU needs at least all unique node pair distances to build + * the whole NUMA distance table. QEMU treats the distance table + * as symmetric by default, i.e. distance A->B =3D=3D distance B->= A. + * Thus, QEMU is able to complete the distance table + * initialization even though only distance A->B is provided and + * distance B->A is not. QEMU knows the distance of a node to + * itself is always 10, so A->A distances may be omitted. When + * the distances of two nodes of a pair differ, i.e. distance + * A->B !=3D distance B->A, then that means the distance table is + * asymmetric. In this case, the distances for both directions + * of all node pairs are required. + */ + if (have_numa_distance) { + /* Validate enough NUMA distance information was provided. */ + validate_numa_distance(); + + /* Validation succeeded, now fill in any missing distances. */ + complete_init_numa_distance(); + } } else { numa_set_mem_node_id(0, ram_size, 0); } diff --git a/qemu-options.hx b/qemu-options.hx index 70c0ded12e..e10c1454d1 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -139,12 +139,15 @@ ETEXI =20 DEF("numa", HAS_ARG, QEMU_OPTION_numa, "-numa node[,mem=3Dsize][,cpus=3Dfirstcpu[-lastcpu]][,nodeid=3Dnode]\n" - "-numa node[,memdev=3Did][,cpus=3Dfirstcpu[-lastcpu]][,nodeid=3Dnode]\= n", QEMU_ARCH_ALL) + "-numa node[,memdev=3Did][,cpus=3Dfirstcpu[-lastcpu]][,nodeid=3Dnode]\= n" + "-numa dist,src=3Dsource,dst=3Ddestination,val=3Ddistance\n", QEMU_ARC= H_ALL) STEXI @item -numa node[,mem=3D@var{size}][,cpus=3D@var{firstcpu}[-@var{lastcpu}]= ][,nodeid=3D@var{node}] @itemx -numa node[,memdev=3D@var{id}][,cpus=3D@var{firstcpu}[-@var{lastcpu= }]][,nodeid=3D@var{node}] +@itemx -numa dist,src=3D@var{source},dst=3D@var{destination},val=3D@var{di= stance} @findex -numa Define a NUMA node and assign RAM and VCPUs to it. +Set the NUMA distance from a source node to a destination node. =20 @var{firstcpu} and @var{lastcpu} are CPU indexes. Each @samp{cpus} option represent a contiguous range of CPU indexes @@ -167,6 +170,17 @@ split equally between them. @samp{mem} and @samp{memdev} are mutually exclusive. Furthermore, if one node uses @samp{memdev}, all of them have to use it. =20 +@var{source} and @var{destination} are NUMA node IDs. +@var{distance} is the NUMA distance from @var{source} to @var{destination}. +The distance from a node to itself is always 10. If any pair of nodes is +given a distance, then all pairs must be given distances. Although, when +distances are only given in one direction for each pair of nodes, then +the distances in the opposite directions are assumed to be the same. If, +however, an asymmetrical pair of distances is given for even one node +pair, then all node pairs must be provided distance values for both +directions, even when they are symmetrical. When a node is unreachable +from another node, set the pair's distance to 255. + Note that the -@option{numa} option doesn't allocate any of the specified resources, it just assigns existing resources to NUMA nodes. This means that one still has to use the @option{-m}, --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:41 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 1494530451449151.55006008106432; Thu, 11 May 2017 12:20:51 -0700 (PDT) Received: from localhost ([::1]:49756 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tdq-0003eK-59 for importer@patchew.org; Thu, 11 May 2017 15:20:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37743) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tc0-0002HL-07 for qemu-devel@nongnu.org; Thu, 11 May 2017 15:18:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tby-0007ku-B1 for qemu-devel@nongnu.org; Thu, 11 May 2017 15:18:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46778) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tby-0007kg-1v for qemu-devel@nongnu.org; Thu, 11 May 2017 15:18:54 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1537080474; Thu, 11 May 2017 19:18:53 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D7C85DD65; Thu, 11 May 2017 19:18:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1537080474 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1537080474 From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:17 -0300 Message-Id: <20170511191843.13784-4-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 11 May 2017 19:18:53 +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] [PULL 03/29] numa: equally distribute memory on nodes 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 , qemu-devel@nongnu.org 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" From: Laurent Vivier When there are more nodes than available memory to put the minimum allowed memory by node, all the memory is put on the last node. This is because we put (ram_size / nb_numa_nodes) & ~((1 << mc->numa_mem_align_shift) - 1); on each node, and in this case the value is 0. This is particularly true with pseries, as the memory must be aligned to 256MB. To avoid this problem, this patch uses an error diffusion algorithm [1] to distribute equally the memory on nodes. We introduce numa_auto_assign_ram() function in MachineClass to keep compatibility between machine type versions. The legacy function is used with pseries-2.9, pc-q35-2.9 and pc-i440fx-2.9 (and previous), the new one with all others. Example: qemu-system-ppc64 -S -nographic -nodefaults -monitor stdio -m 1G -smp 8 \ -numa node -numa node -numa node \ -numa node -numa node -numa node Before: (qemu) info numa 6 nodes node 0 cpus: 0 6 node 0 size: 0 MB node 1 cpus: 1 7 node 1 size: 0 MB node 2 cpus: 2 node 2 size: 0 MB node 3 cpus: 3 node 3 size: 0 MB node 4 cpus: 4 node 4 size: 0 MB node 5 cpus: 5 node 5 size: 1024 MB After: (qemu) info numa 6 nodes node 0 cpus: 0 6 node 0 size: 0 MB node 1 cpus: 1 7 node 1 size: 256 MB node 2 cpus: 2 node 2 size: 0 MB node 3 cpus: 3 node 3 size: 256 MB node 4 cpus: 4 node 4 size: 256 MB node 5 cpus: 5 node 5 size: 256 MB [1] https://en.wikipedia.org/wiki/Error_diffusion Signed-off-by: Laurent Vivier Message-Id: <20170502162955.1610-2-lvivier@redhat.com> Reviewed-by: Eduardo Habkost [ehabkost: s/ram_size/size/ at numa_default_auto_assign_ram()] Signed-off-by: Eduardo Habkost --- include/hw/boards.h | 2 ++ include/qemu/typedefs.h | 1 + include/sysemu/numa.h | 9 +++++++-- hw/core/machine.c | 2 ++ hw/i386/pc_piix.c | 2 ++ hw/i386/pc_q35.c | 2 ++ hw/ppc/spapr.c | 1 + numa.c | 49 ++++++++++++++++++++++++++++++++++++++-------= ---- 8 files changed, 55 insertions(+), 13 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index 31d9c72fb0..99458eb859 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -136,6 +136,8 @@ struct MachineClass { int minimum_page_bits; bool has_hotpluggable_cpus; int numa_mem_align_shift; + void (*numa_auto_assign_ram)(MachineClass *mc, NodeInfo *nodes, + int nb_nodes, ram_addr_t size); =20 HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev); diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index f08d327aec..7d8505730c 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -97,5 +97,6 @@ typedef struct SSIBus SSIBus; typedef struct uWireSlave uWireSlave; typedef struct VirtIODevice VirtIODevice; typedef struct Visitor Visitor; +typedef struct node_info NodeInfo; =20 #endif /* QEMU_TYPEDEFS_H */ diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index 0ea1bc086e..70e56214e5 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -16,14 +16,14 @@ struct numa_addr_range { QLIST_ENTRY(numa_addr_range) entry; }; =20 -typedef struct node_info { +struct node_info { uint64_t node_mem; unsigned long *node_cpu; struct HostMemoryBackend *node_memdev; bool present; QLIST_HEAD(, numa_addr_range) addr; /* List to store address ranges */ uint8_t distance[MAX_NODES]; -} NodeInfo; +}; =20 extern NodeInfo numa_info[MAX_NODES]; void parse_numa_opts(MachineClass *mc); @@ -33,6 +33,11 @@ extern QemuOptsList qemu_numa_opts; void numa_set_mem_node_id(ram_addr_t addr, uint64_t size, uint32_t node); void numa_unset_mem_node_id(ram_addr_t addr, uint64_t size, uint32_t node); uint32_t numa_get_node(ram_addr_t addr, Error **errp); +void numa_legacy_auto_assign_ram(MachineClass *mc, NodeInfo *nodes, + int nb_nodes, ram_addr_t size); +void numa_default_auto_assign_ram(MachineClass *mc, NodeInfo *nodes, + int nb_nodes, ram_addr_t size); + =20 /* on success returns node index in numa_info, * on failure returns nb_numa_nodes */ diff --git a/hw/core/machine.c b/hw/core/machine.c index ada9eea483..2482c630c1 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -17,6 +17,7 @@ #include "qapi/visitor.h" #include "hw/sysbus.h" #include "sysemu/sysemu.h" +#include "sysemu/numa.h" #include "qemu/error-report.h" #include "qemu/cutils.h" =20 @@ -400,6 +401,7 @@ static void machine_class_init(ObjectClass *oc, void *d= ata) * On Linux, each node's border has to be 8MB aligned */ mc->numa_mem_align_shift =3D 23; + mc->numa_auto_assign_ram =3D numa_default_auto_assign_ram; =20 object_class_property_add_str(oc, "accel", machine_get_accel, machine_set_accel, &error_abort); diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 9f102aa388..d468b963fb 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -54,6 +54,7 @@ #endif #include "migration/migration.h" #include "kvm_i386.h" +#include "sysemu/numa.h" =20 #define MAX_IDE_BUS 2 =20 @@ -442,6 +443,7 @@ static void pc_i440fx_2_9_machine_options(MachineClass = *m) pc_i440fx_machine_options(m); m->alias =3D "pc"; m->is_default =3D 1; + m->numa_auto_assign_ram =3D numa_legacy_auto_assign_ram; } =20 DEFINE_I440FX_MACHINE(v2_9, "pc-i440fx-2.9", NULL, diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index dd792a8547..66303a78cf 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -47,6 +47,7 @@ #include "hw/usb.h" #include "qemu/error-report.h" #include "migration/migration.h" +#include "sysemu/numa.h" =20 /* ICH9 AHCI has 6 ports */ #define MAX_SATA_PORTS 6 @@ -305,6 +306,7 @@ static void pc_q35_2_9_machine_options(MachineClass *m) { pc_q35_machine_options(m); m->alias =3D "q35"; + m->numa_auto_assign_ram =3D numa_legacy_auto_assign_ram; } =20 DEFINE_Q35_MACHINE(v2_9, "pc-q35-2.9", NULL, diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 80d12d005c..bdc31ce56c 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3242,6 +3242,7 @@ static void spapr_machine_2_9_class_options(MachineCl= ass *mc) { spapr_machine_2_10_class_options(mc); SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_9); + mc->numa_auto_assign_ram =3D numa_legacy_auto_assign_ram; } =20 DEFINE_SPAPR_MACHINE(2_9, "2.9", false); diff --git a/numa.c b/numa.c index 2b3fc69915..d753687dec 100644 --- a/numa.c +++ b/numa.c @@ -407,6 +407,42 @@ static void complete_init_numa_distance(void) } } =20 +void numa_legacy_auto_assign_ram(MachineClass *mc, NodeInfo *nodes, + int nb_nodes, ram_addr_t size) +{ + int i; + uint64_t usedmem =3D 0; + + /* Align each node according to the alignment + * requirements of the machine class + */ + + for (i =3D 0; i < nb_nodes - 1; i++) { + nodes[i].node_mem =3D (size / nb_nodes) & + ~((1 << mc->numa_mem_align_shift) - 1); + usedmem +=3D nodes[i].node_mem; + } + nodes[i].node_mem =3D size - usedmem; +} + +void numa_default_auto_assign_ram(MachineClass *mc, NodeInfo *nodes, + int nb_nodes, ram_addr_t size) +{ + int i; + uint64_t usedmem =3D 0, node_mem; + uint64_t granularity =3D size / nb_nodes; + uint64_t propagate =3D 0; + + for (i =3D 0; i < nb_nodes - 1; i++) { + node_mem =3D (granularity + propagate) & + ~((1 << mc->numa_mem_align_shift) - 1); + propagate =3D granularity + propagate - node_mem; + nodes[i].node_mem =3D node_mem; + usedmem +=3D node_mem; + } + nodes[i].node_mem =3D size - usedmem; +} + void parse_numa_opts(MachineClass *mc) { int i; @@ -449,17 +485,8 @@ void parse_numa_opts(MachineClass *mc) } } if (i =3D=3D nb_numa_nodes) { - uint64_t usedmem =3D 0; - - /* 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 << mc->numa_mem_align_shift) = - 1); - usedmem +=3D numa_info[i].node_mem; - } - numa_info[i].node_mem =3D ram_size - usedmem; + assert(mc->numa_auto_assign_ram); + mc->numa_auto_assign_ram(mc, numa_info, nb_numa_nodes, ram_siz= e); } =20 numa_total =3D 0; --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:41 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 14945305862541.9908349991715113; Thu, 11 May 2017 12:23:06 -0700 (PDT) Received: from localhost ([::1]:49765 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tg0-0005pi-Nm for importer@patchew.org; Thu, 11 May 2017 15:23:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37758) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tc1-0002Iq-Av for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tc0-0007lY-37 for qemu-devel@nongnu.org; Thu, 11 May 2017 15:18:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47012) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tbz-0007lG-QX for qemu-devel@nongnu.org; Thu, 11 May 2017 15:18:56 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D09D283F3F; Thu, 11 May 2017 19:18:54 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6349771C23; Thu, 11 May 2017 19:18:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D09D283F3F Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D09D283F3F From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:18 -0300 Message-Id: <20170511191843.13784-5-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 11 May 2017 19:18:55 +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] [PULL 04/29] tests: acpi: extend cphp and memhp testcase with numa distance check 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-devel@nongnu.org, He Chen 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" From: He Chen Signed-off-by: He Chen Message-Id: <1493803036-4048-1-git-send-email-he.chen@linux.intel.com> Reviewed-by: Igor Mammedov [ehabkost: regenerated tests/acpi-tst-data, included SLIT table] Signed-off-by: Eduardo Habkost --- tests/bios-tables-test.c | 16 ++++++++++++---- tests/acpi-test-data/pc/SLIT.cphp | Bin 0 -> 48 bytes tests/acpi-test-data/pc/SLIT.memhp | Bin 0 -> 48 bytes tests/acpi-test-data/pc/SRAT.memhp | Bin 224 -> 264 bytes tests/acpi-test-data/q35/SLIT.cphp | Bin 0 -> 48 bytes tests/acpi-test-data/q35/SLIT.memhp | Bin 0 -> 48 bytes tests/acpi-test-data/q35/SRAT.memhp | Bin 224 -> 264 bytes 7 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 tests/acpi-test-data/pc/SLIT.cphp create mode 100644 tests/acpi-test-data/pc/SLIT.memhp create mode 100644 tests/acpi-test-data/q35/SLIT.cphp create mode 100644 tests/acpi-test-data/q35/SLIT.memhp diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c index 9c96a67053..4e5c65a022 100644 --- a/tests/bios-tables-test.c +++ b/tests/bios-tables-test.c @@ -723,7 +723,8 @@ static void test_acpi_piix4_tcg_cphp(void) data.machine =3D MACHINE_PC; data.variant =3D ".cphp"; test_acpi_one("-smp 2,cores=3D3,sockets=3D2,maxcpus=3D6" - " -numa node -numa node", + " -numa node -numa node" + " -numa dist,src=3D0,dst=3D1,val=3D21", &data); free_test_data(&data); } @@ -736,7 +737,8 @@ static void test_acpi_q35_tcg_cphp(void) data.machine =3D MACHINE_Q35; data.variant =3D ".cphp"; test_acpi_one(" -smp 2,cores=3D3,sockets=3D2,maxcpus=3D6" - " -numa node -numa node", + " -numa node -numa node" + " -numa dist,src=3D0,dst=3D1,val=3D21", &data); free_test_data(&data); } @@ -785,7 +787,10 @@ static void test_acpi_q35_tcg_memhp(void) memset(&data, 0, sizeof(data)); data.machine =3D MACHINE_Q35; data.variant =3D ".memhp"; - test_acpi_one(" -m 128,slots=3D3,maxmem=3D1G -numa node", &data); + test_acpi_one(" -m 128,slots=3D3,maxmem=3D1G" + " -numa node -numa node" + " -numa dist,src=3D0,dst=3D1,val=3D21", + &data); free_test_data(&data); } =20 @@ -796,7 +801,10 @@ static void test_acpi_piix4_tcg_memhp(void) memset(&data, 0, sizeof(data)); data.machine =3D MACHINE_PC; data.variant =3D ".memhp"; - test_acpi_one(" -m 128,slots=3D3,maxmem=3D1G -numa node", &data); + test_acpi_one(" -m 128,slots=3D3,maxmem=3D1G" + " -numa node -numa node" + " -numa dist,src=3D0,dst=3D1,val=3D21", + &data); free_test_data(&data); } =20 diff --git a/tests/acpi-test-data/pc/SLIT.cphp b/tests/acpi-test-data/pc/SL= IT.cphp new file mode 100644 index 0000000000000000000000000000000000000000..74ec3b4b461ffecca36d8537975= c202a5f011185 GIT binary patch literal 48 scmWIc@eDCwU|?X>aq@Te2v%^42yhMtiZKGkKx`1r1jHb~B`V4V0NaKK0RR91 literal 0 HcmV?d00001 diff --git a/tests/acpi-test-data/pc/SLIT.memhp b/tests/acpi-test-data/pc/S= LIT.memhp new file mode 100644 index 0000000000000000000000000000000000000000..74ec3b4b461ffecca36d8537975= c202a5f011185 GIT binary patch literal 48 scmWIc@eDCwU|?X>aq@Te2v%^42yhMtiZKGkKx`1r1jHb~B`V4V0NaKK0RR91 literal 0 HcmV?d00001 diff --git a/tests/acpi-test-data/pc/SRAT.memhp b/tests/acpi-test-data/pc/S= RAT.memhp index 66ce9a898191d1da961c0c968c04ec56810a5785..a7dddf7760698193819e60a3a96= f2a57cf367522 100644 GIT binary patch delta 63 scmaFB*ulgV9OM|n!N|bCxOgI0p(Zl}6aYowfKda^V}S~?Osq)(00EN*IRF3v delta 23 ecmeBRdcepP9OM}CfPsO5@%KcoLPqw9OHu$-0tYz& diff --git a/tests/acpi-test-data/q35/SLIT.cphp b/tests/acpi-test-data/q35/= SLIT.cphp new file mode 100644 index 0000000000000000000000000000000000000000..74ec3b4b461ffecca36d8537975= c202a5f011185 GIT binary patch literal 48 scmWIc@eDCwU|?X>aq@Te2v%^42yhMtiZKGkKx`1r1jHb~B`V4V0NaKK0RR91 literal 0 HcmV?d00001 diff --git a/tests/acpi-test-data/q35/SLIT.memhp b/tests/acpi-test-data/q35= /SLIT.memhp new file mode 100644 index 0000000000000000000000000000000000000000..74ec3b4b461ffecca36d8537975= c202a5f011185 GIT binary patch literal 48 scmWIc@eDCwU|?X>aq@Te2v%^42yhMtiZKGkKx`1r1jHb~B`V4V0NaKK0RR91 literal 0 HcmV?d00001 diff --git a/tests/acpi-test-data/q35/SRAT.memhp b/tests/acpi-test-data/q35= /SRAT.memhp index 66ce9a898191d1da961c0c968c04ec56810a5785..a7dddf7760698193819e60a3a96= f2a57cf367522 100644 GIT binary patch delta 63 scmaFB*ulgV9OM|n!N|bCxOgI0p(Zl}6aYowfKda^V}S~?Osq)(00EN*IRF3v delta 23 ecmeBRdcepP9OM}CfPsO5@%KcoLPqw9OHu$-0tYz& --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:41 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 1494530731073229.81072740377795; Thu, 11 May 2017 12:25:31 -0700 (PDT) Received: from localhost ([::1]:49776 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tiL-0007vB-Id for importer@patchew.org; Thu, 11 May 2017 15:25:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37772) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tc4-0002MC-HO for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tc1-0007m4-Tq for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49642) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tc1-0007ll-LI for qemu-devel@nongnu.org; Thu, 11 May 2017 15:18:57 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A2B247AE85; Thu, 11 May 2017 19:18:56 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 347525C885; Thu, 11 May 2017 19:18:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A2B247AE85 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=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A2B247AE85 From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:19 -0300 Message-Id: <20170511191843.13784-6-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 11 May 2017 19:18:56 +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] [PULL 05/29] tests: add CPUs to numa node mapping test 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: Igor Mammedov , qemu-devel@nongnu.org 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" From: Igor Mammedov Signed-off-by: Igor Mammedov Reviewed-by: David Gibson Message-Id: <1493816238-33120-2-git-send-email-imammedo@redhat.com> Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- tests/numa-test.c | 106 +++++++++++++++++++++++++++++++++++++++++++++= ++++ tests/Makefile.include | 5 +++ 2 files changed, 111 insertions(+) create mode 100644 tests/numa-test.c diff --git a/tests/numa-test.c b/tests/numa-test.c new file mode 100644 index 0000000000..f5da0c845b --- /dev/null +++ b/tests/numa-test.c @@ -0,0 +1,106 @@ +/* + * NUMA configuration test cases + * + * Copyright (c) 2017 Red Hat Inc. + * Authors: + * Igor Mammedov + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "libqtest.h" + +static char *make_cli(const char *generic_cli, const char *test_cli) +{ + return g_strdup_printf("%s %s", generic_cli ? generic_cli : "", test_c= li); +} + +static char *hmp_info_numa(void) +{ + QDict *resp; + char *s; + + resp =3D qmp("{ 'execute': 'human-monitor-command', 'arguments': " + "{ 'command-line': 'info numa '} }"); + g_assert(resp); + g_assert(qdict_haskey(resp, "return")); + s =3D g_strdup(qdict_get_str(resp, "return")); + g_assert(s); + QDECREF(resp); + return s; +} + +static void test_mon_explicit(const void *data) +{ + char *s; + char *cli; + + cli =3D make_cli(data, "-smp 8 " + "-numa node,nodeid=3D0,cpus=3D0-3 " + "-numa node,nodeid=3D1,cpus=3D4-7 "); + qtest_start(cli); + + s =3D hmp_info_numa(); + g_assert(strstr(s, "node 0 cpus: 0 1 2 3")); + g_assert(strstr(s, "node 1 cpus: 4 5 6 7")); + g_free(s); + + qtest_end(); + g_free(cli); +} + +static void test_mon_default(const void *data) +{ + char *s; + char *cli; + + cli =3D make_cli(data, "-smp 8 -numa node -numa node"); + qtest_start(cli); + + s =3D hmp_info_numa(); + g_assert(strstr(s, "node 0 cpus: 0 2 4 6")); + g_assert(strstr(s, "node 1 cpus: 1 3 5 7")); + g_free(s); + + qtest_end(); + g_free(cli); +} + +static void test_mon_partial(const void *data) +{ + char *s; + char *cli; + + cli =3D make_cli(data, "-smp 8 " + "-numa node,nodeid=3D0,cpus=3D0-1 " + "-numa node,nodeid=3D1,cpus=3D4-5 "); + qtest_start(cli); + + s =3D hmp_info_numa(); + g_assert(strstr(s, "node 0 cpus: 0 1 2 3 6 7")); + g_assert(strstr(s, "node 1 cpus: 4 5")); + g_free(s); + + qtest_end(); + g_free(cli); +} + +int main(int argc, char **argv) +{ + const char *args =3D NULL; + const char *arch =3D qtest_get_arch(); + + if (strcmp(arch, "aarch64") =3D=3D 0) { + args =3D "-machine virt"; + } + + g_test_init(&argc, &argv, NULL); + + qtest_add_data_func("/numa/mon/default", args, test_mon_default); + qtest_add_data_func("/numa/mon/cpus/explicit", args, test_mon_explicit= ); + qtest_add_data_func("/numa/mon/cpus/partial", args, test_mon_partial); + + return g_test_run(); +} diff --git a/tests/Makefile.include b/tests/Makefile.include index 31931c0d77..16ff8f399f 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -260,6 +260,7 @@ check-qtest-i386-y +=3D tests/test-filter-mirror$(EXESU= F) check-qtest-i386-y +=3D tests/test-filter-redirector$(EXESUF) check-qtest-i386-y +=3D tests/postcopy-test$(EXESUF) check-qtest-i386-y +=3D tests/test-x86-cpuid-compat$(EXESUF) +check-qtest-i386-y +=3D tests/numa-test$(EXESUF) check-qtest-x86_64-y +=3D $(check-qtest-i386-y) gcov-files-i386-y +=3D i386-softmmu/hw/timer/mc146818rtc.c gcov-files-x86_64-y =3D $(subst i386-softmmu/,x86_64-softmmu/,$(gcov-files= -i386-y)) @@ -300,6 +301,7 @@ check-qtest-ppc64-y +=3D tests/test-netfilter$(EXESUF) check-qtest-ppc64-y +=3D tests/test-filter-mirror$(EXESUF) check-qtest-ppc64-y +=3D tests/test-filter-redirector$(EXESUF) check-qtest-ppc64-y +=3D tests/display-vga-test$(EXESUF) +check-qtest-ppc64-y +=3D tests/numa-test$(EXESUF) check-qtest-ppc64-$(CONFIG_EVENTFD) +=3D tests/ivshmem-test$(EXESUF) =20 check-qtest-sh4-y =3D tests/endianness-test$(EXESUF) @@ -324,6 +326,8 @@ gcov-files-arm-y +=3D arm-softmmu/hw/block/virtio-blk.c check-qtest-arm-y +=3D tests/test-arm-mptimer$(EXESUF) gcov-files-arm-y +=3D hw/timer/arm_mptimer.c =20 +check-qtest-aarch64-y =3D tests/numa-test$(EXESUF) + check-qtest-microblazeel-y =3D $(check-qtest-microblaze-y) =20 check-qtest-xtensaeb-y =3D $(check-qtest-xtensa-y) @@ -753,6 +757,7 @@ tests/vhost-user-bridge$(EXESUF): tests/vhost-user-brid= ge.o contrib/libvhost-use tests/test-uuid$(EXESUF): tests/test-uuid.o $(test-util-obj-y) tests/test-arm-mptimer$(EXESUF): tests/test-arm-mptimer.o tests/test-qapi-util$(EXESUF): tests/test-qapi-util.o $(test-util-obj-y) +tests/numa-test$(EXESUF): tests/numa-test.o =20 tests/migration/stress$(EXESUF): tests/migration/stress.o $(call quiet-command, $(LINKPROG) -static -O3 $(PTHREAD_LIB) -o $@ $< ,"L= INK","$(TARGET_DIR)$@") --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:41 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 1494530874854949.7427045475797; Thu, 11 May 2017 12:27:54 -0700 (PDT) Received: from localhost ([::1]:49788 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tkf-00026e-96 for importer@patchew.org; Thu, 11 May 2017 15:27:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37776) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tc4-0002MF-Un for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tc3-0007mR-MJ for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47076) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tc3-0007mB-DU for qemu-devel@nongnu.org; Thu, 11 May 2017 15:18:59 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6D00580F91; Thu, 11 May 2017 19:18:58 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 004EA17AE8; Thu, 11 May 2017 19:18:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6D00580F91 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6D00580F91 From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:20 -0300 Message-Id: <20170511191843.13784-7-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 11 May 2017 19:18:58 +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] [PULL 06/29] hw/arm/virt: extract mp-affinity calculation in separate function 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: Igor Mammedov , qemu-devel@nongnu.org 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" From: Igor Mammedov Signed-off-by: Igor Mammedov Message-Id: <1493816238-33120-3-git-send-email-imammedo@redhat.com> Reviewed-by: Andrew Jones Signed-off-by: Eduardo Habkost --- target/arm/cpu.h | 2 ++ hw/arm/virt.c | 43 ++++++++++++++++++++++++++----------------- target/arm/cpu.c | 12 +++++++++--- 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 1055bfef3d..048faed9b9 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -710,6 +710,8 @@ static inline ARMCPU *arm_env_get_cpu(CPUARMState *env) return container_of(env, ARMCPU, env); } =20 +uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz); + #define ENV_GET_CPU(e) CPU(arm_env_get_cpu(e)) =20 #define ENV_OFFSET offsetof(ARMCPU, env) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 5f62a0321e..61ae43762a 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1194,6 +1194,29 @@ void virt_machine_done(Notifier *notifier, void *dat= a) virt_build_smbios(vms); } =20 +static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx) +{ + uint8_t clustersz =3D ARM_DEFAULT_CPUS_PER_CLUSTER; + VirtMachineClass *vmc =3D VIRT_MACHINE_GET_CLASS(vms); + + if (!vmc->disallow_affinity_adjustment) { + /* Adjust MPIDR like 64-bit KVM hosts, which incorporate the + * GIC's target-list limitations. 32-bit KVM hosts currently + * always create clusters of 4 CPUs, but that is expected to + * change when they gain support for gicv3. When KVM is enabled + * it will override the changes we make here, therefore our + * purposes are to make TCG consistent (with 64-bit KVM hosts) + * and to improve SGI efficiency. + */ + if (vms->gic_version =3D=3D 3) { + clustersz =3D GICV3_TARGETLIST_BITS; + } else { + clustersz =3D GIC_TARGETLIST_BITS; + } + } + return arm_cpu_mp_affinity(idx, clustersz); +} + static void machvirt_init(MachineState *machine) { VirtMachineState *vms =3D VIRT_MACHINE(machine); @@ -1210,7 +1233,6 @@ static void machvirt_init(MachineState *machine) CPUClass *cc; Error *err =3D NULL; bool firmware_loaded =3D bios_name || drive_get(IF_PFLASH, 0, 0); - uint8_t clustersz; =20 if (!cpu_model) { cpu_model =3D "cortex-a15"; @@ -1263,10 +1285,8 @@ static void machvirt_init(MachineState *machine) */ if (vms->gic_version =3D=3D 3) { virt_max_cpus =3D vms->memmap[VIRT_GIC_REDIST].size / 0x20000; - clustersz =3D GICV3_TARGETLIST_BITS; } else { virt_max_cpus =3D GIC_NCPU; - clustersz =3D GIC_TARGETLIST_BITS; } =20 if (max_cpus > virt_max_cpus) { @@ -1326,20 +1346,9 @@ static void machvirt_init(MachineState *machine) =20 for (n =3D 0; n < smp_cpus; n++) { Object *cpuobj =3D object_new(typename); - if (!vmc->disallow_affinity_adjustment) { - /* Adjust MPIDR like 64-bit KVM hosts, which incorporate the - * GIC's target-list limitations. 32-bit KVM hosts currently - * always create clusters of 4 CPUs, but that is expected to - * change when they gain support for gicv3. When KVM is enabled - * it will override the changes we make here, therefore our - * purposes are to make TCG consistent (with 64-bit KVM hosts) - * and to improve SGI efficiency. - */ - uint8_t aff1 =3D n / clustersz; - uint8_t aff0 =3D n % clustersz; - object_property_set_int(cpuobj, (aff1 << ARM_AFF1_SHIFT) | aff= 0, - "mp-affinity", NULL); - } + + object_property_set_int(cpuobj, virt_cpu_mp_affinity(vms, n), + "mp-affinity", NULL); =20 if (!vms->secure) { object_property_set_bool(cpuobj, false, "has_el3", NULL); diff --git a/target/arm/cpu.c b/target/arm/cpu.c index b357aee778..ee1406da12 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -458,6 +458,13 @@ static void arm_disas_set_info(CPUState *cpu, disassem= ble_info *info) } } =20 +uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz) +{ + uint32_t Aff1 =3D idx / clustersz; + uint32_t Aff0 =3D idx % clustersz; + return (Aff1 << ARM_AFF1_SHIFT) | Aff0; +} + static void arm_cpu_initfn(Object *obj) { CPUState *cs =3D CPU(obj); @@ -709,9 +716,8 @@ static void arm_cpu_realizefn(DeviceState *dev, Error *= *errp) * so these bits always RAZ. */ if (cpu->mp_affinity =3D=3D ARM64_AFFINITY_INVALID) { - uint32_t Aff1 =3D cs->cpu_index / ARM_DEFAULT_CPUS_PER_CLUSTER; - uint32_t Aff0 =3D cs->cpu_index % ARM_DEFAULT_CPUS_PER_CLUSTER; - cpu->mp_affinity =3D (Aff1 << ARM_AFF1_SHIFT) | Aff0; + cpu->mp_affinity =3D arm_cpu_mp_affinity(cs->cpu_index, + ARM_DEFAULT_CPUS_PER_CLUSTE= R); } =20 if (cpu->reset_hivecs) { --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:42 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 1494530654120710.4051780799622; Thu, 11 May 2017 12:24:14 -0700 (PDT) Received: from localhost ([::1]:49769 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8th6-0006mo-MW for importer@patchew.org; Thu, 11 May 2017 15:24:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37791) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tc7-0002OX-07 for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tc5-0007n2-Ia for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49716) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tc5-0007mj-9f for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:01 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4917F8AE75; Thu, 11 May 2017 19:19:00 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id C008017D46; Thu, 11 May 2017 19:18:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4917F8AE75 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=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4917F8AE75 From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:21 -0300 Message-Id: <20170511191843.13784-8-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 11 May 2017 19:19:00 +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] [PULL 07/29] hw/arm/virt: use machine->possible_cpus for storing possible topology info 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: Igor Mammedov , qemu-devel@nongnu.org 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" From: Igor Mammedov for now precalculate and store mp_afinity in possible_cpus as ARM cpus don't have socket/core/thread-id properties yet. In follow patches possible_cpus will be used for storing and setting NUMA node mapping and replace legacy bitmap based numa_info[node_id].node_cpu/numa_get_node_for_cpu() For the lack of better idea, this patch cannibalizes possible_cpus.cpus[x].props.thread_id so that *_cpu_index_to_props() callback could return addressable by props CPU which will be used by machine_set_cpu_numa_node() in follow up patches to assign a CPU to node. But cannibalizing is fine for now as that thread_id isn't exposed to users (no hotpluggable_cpus callback support for ARM yet) and it will be used only internally until 'device_add cpu' is supported where we can decide on which properties to use. Signed-off-by: Igor Mammedov Message-Id: <1493816238-33120-4-git-send-email-imammedo@redhat.com> Reviewed-by: Andrew Jones Signed-off-by: Eduardo Habkost --- hw/arm/virt.c | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 61ae43762a..e2c5626c52 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1221,6 +1221,8 @@ static void machvirt_init(MachineState *machine) { VirtMachineState *vms =3D VIRT_MACHINE(machine); VirtMachineClass *vmc =3D VIRT_MACHINE_GET_CLASS(machine); + MachineClass *mc =3D MACHINE_GET_CLASS(machine); + const CPUArchIdList *possible_cpus; qemu_irq pic[NUM_IRQS]; MemoryRegion *sysmem =3D get_system_memory(); MemoryRegion *secure_sysmem =3D NULL; @@ -1344,10 +1346,16 @@ static void machvirt_init(MachineState *machine) exit(1); } =20 - for (n =3D 0; n < smp_cpus; n++) { - Object *cpuobj =3D object_new(typename); + possible_cpus =3D mc->possible_cpu_arch_ids(machine); + for (n =3D 0; n < possible_cpus->len; n++) { + Object *cpuobj; =20 - object_property_set_int(cpuobj, virt_cpu_mp_affinity(vms, n), + if (n >=3D smp_cpus) { + break; + } + + cpuobj =3D object_new(typename); + object_property_set_int(cpuobj, possible_cpus->cpus[n].arch_id, "mp-affinity", NULL); =20 if (!vms->secure) { @@ -1527,6 +1535,31 @@ static void virt_set_gic_version(Object *obj, const = char *value, Error **errp) } } =20 +static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms) +{ + int n; + VirtMachineState *vms =3D VIRT_MACHINE(ms); + + if (ms->possible_cpus) { + assert(ms->possible_cpus->len =3D=3D max_cpus); + return ms->possible_cpus; + } + + ms->possible_cpus =3D g_malloc0(sizeof(CPUArchIdList) + + sizeof(CPUArchId) * max_cpus); + ms->possible_cpus->len =3D max_cpus; + for (n =3D 0; n < ms->possible_cpus->len; n++) { + ms->possible_cpus->cpus[n].arch_id =3D + virt_cpu_mp_affinity(vms, n); + ms->possible_cpus->cpus[n].props.has_thread_id =3D true; + ms->possible_cpus->cpus[n].props.thread_id =3D n; + + /* TODO: add 'has_node/node' here to describe + to which node core belongs */ + } + return ms->possible_cpus; +} + static void virt_machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); @@ -1543,6 +1576,7 @@ static void virt_machine_class_init(ObjectClass *oc, = void *data) mc->pci_allow_0_address =3D true; /* We know we will never create a pre-ARMv7 CPU which needs 1K pages */ mc->minimum_page_bits =3D 12; + mc->possible_cpu_arch_ids =3D virt_possible_cpu_arch_ids; } =20 static const TypeInfo virt_machine_info =3D { --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:42 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 1494530591904712.0605727107608; Thu, 11 May 2017 12:23:11 -0700 (PDT) Received: from localhost ([::1]:49766 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tg5-0005tx-9Q for importer@patchew.org; Thu, 11 May 2017 15:23:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37802) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tc8-0002Pv-8Y for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tc7-0007nY-8y for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57094) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tc7-0007nH-35 for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:03 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 21A4F3DBC0; Thu, 11 May 2017 19:19:02 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id A81DF71C39; Thu, 11 May 2017 19:19:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 21A4F3DBC0 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 21A4F3DBC0 From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:22 -0300 Message-Id: <20170511191843.13784-9-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 11 May 2017 19:19:02 +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] [PULL 08/29] hw/arm/virt: explicitly allocate cpu_index for cpus 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: Igor Mammedov , qemu-devel@nongnu.org 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" From: Igor Mammedov Currently cpu_index is implicitly auto assigned during cpu.realize() time cpu_exec_realizefn()->cpu_list_add(). It happens to match index in possible_cpus so take control over it and make board initialize cpu_index to possible_cpus index explicitly. It will at least document that board is in control of it and when '-device cpu' support comes it will keep cpu_index stable regardless of order cpus are created so it won't break migration. Within this series it will be used for internal conversion from storing cpu_index based NUMA node bitmaps to property based mapping with possible_cpus, And will allow map cpu_index to a CPU entry in possible_cpus array. Signed-off-by: Igor Mammedov Reviewed-by: Andrew Jones Message-Id: <1493816238-33120-5-git-send-email-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- hw/arm/virt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index e2c5626c52..acc748ec40 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1349,6 +1349,7 @@ static void machvirt_init(MachineState *machine) possible_cpus =3D mc->possible_cpu_arch_ids(machine); for (n =3D 0; n < possible_cpus->len; n++) { Object *cpuobj; + CPUState *cs; =20 if (n >=3D smp_cpus) { break; @@ -1358,6 +1359,9 @@ static void machvirt_init(MachineState *machine) object_property_set_int(cpuobj, possible_cpus->cpus[n].arch_id, "mp-affinity", NULL); =20 + cs =3D CPU(cpuobj); + cs->cpu_index =3D n; + if (!vms->secure) { object_property_set_bool(cpuobj, false, "has_el3", NULL); } --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:42 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 149453079755293.4937811154964; Thu, 11 May 2017 12:26:37 -0700 (PDT) Received: from localhost ([::1]:49782 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tjQ-0000Xz-7J for importer@patchew.org; Thu, 11 May 2017 15:26:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37813) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tcB-0002SN-0z for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tc9-0007oB-CY for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40750) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tc9-0007ns-2d for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:05 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 18DB0C059739; Thu, 11 May 2017 19:19:04 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 713B65C885; Thu, 11 May 2017 19:19:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 18DB0C059739 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 18DB0C059739 From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:23 -0300 Message-Id: <20170511191843.13784-10-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 11 May 2017 19:19:04 +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] [PULL 09/29] numa: move source of default CPUs to NUMA node mapping into boards 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: Igor Mammedov , qemu-devel@nongnu.org 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" From: Igor Mammedov Originally CPU threads were by default assigned in round-robin fashion. However it was causing issues in guest since CPU threads from the same socket/core could be placed on different NUMA nodes. Commit fb43b73b (pc: fix default VCPU to NUMA node mapping) fixed it by grouping threads within a socket on the same node introducing cpu_index_to_socket_id() callback and commit 20bb648d (spapr: Fix default NUMA node allocation for threads) reused callback to fix similar issues for SPAPR machine even though socket doesn't make much sense there. As result QEMU ended up having 3 default distribution rules used by 3 targets /virt-arm, spapr, pc/. In effort of moving NUMA mapping for CPUs into possible_cpus, generalize default mapping in numa.c by making boards decide on default mapping and let them explicitly tell generic numa code to which node a CPU thread belongs to by replacing cpu_index_to_socket_id() with @cpu_index_to_instance_props() which provides default node_id assigned by board to specified cpu_index. Signed-off-by: Igor Mammedov Reviewed-by: Eduardo Habkost Message-Id: <1494415802-227633-2-git-send-email-imammedo@redhat.com> Reviewed-by: David Gibson Signed-off-by: Eduardo Habkost --- include/hw/boards.h | 8 ++++++-- include/sysemu/numa.h | 2 +- hw/arm/virt.c | 20 ++++++++++++++++++-- hw/i386/pc.c | 23 +++++++++++++++++------ hw/ppc/spapr.c | 28 +++++++++++++++++++++------- numa.c | 24 +++++++++++------------- vl.c | 2 +- 7 files changed, 75 insertions(+), 32 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index 99458eb859..3ffa255fb8 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -74,7 +74,10 @@ typedef struct { * of HotplugHandler object, which handles hotplug operation * for a given @dev. It may return NULL if @dev doesn't require * any actions to be performed by hotplug handler. - * @cpu_index_to_socket_id: + * @cpu_index_to_instance_props: + * used to provide @cpu_index to socket/core/thread number mapping, all= owing + * legacy code to perform maping from cpu_index to topology properties + * Returns: tuple of socket/core/thread ids given cpu_index belongs to. * used to provide @cpu_index to socket number mapping, allowing * a machine to group CPU threads belonging to the same socket/package * Returns: socket number given cpu_index belongs to. @@ -141,7 +144,8 @@ struct MachineClass { =20 HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev); - unsigned (*cpu_index_to_socket_id)(unsigned cpu_index); + CpuInstanceProperties (*cpu_index_to_instance_props)(MachineState *mac= hine, + unsigned cpu_inde= x); const CPUArchIdList *(*possible_cpu_arch_ids)(MachineState *machine); }; =20 diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index 70e56214e5..027830cf7e 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -26,7 +26,7 @@ struct node_info { }; =20 extern NodeInfo numa_info[MAX_NODES]; -void parse_numa_opts(MachineClass *mc); +void parse_numa_opts(MachineState *ms); void numa_post_machine_init(void); void query_numa_node_mem(uint64_t node_mem[]); extern QemuOptsList qemu_numa_opts; diff --git a/hw/arm/virt.c b/hw/arm/virt.c index acc748ec40..dfd6fd446c 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1539,6 +1539,16 @@ static void virt_set_gic_version(Object *obj, const = char *value, Error **errp) } } =20 +static CpuInstanceProperties +virt_cpu_index_to_props(MachineState *ms, unsigned cpu_index) +{ + MachineClass *mc =3D MACHINE_GET_CLASS(ms); + const CPUArchIdList *possible_cpus =3D mc->possible_cpu_arch_ids(ms); + + assert(cpu_index < possible_cpus->len); + return possible_cpus->cpus[cpu_index].props; +} + static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms) { int n; @@ -1558,8 +1568,13 @@ static const CPUArchIdList *virt_possible_cpu_arch_i= ds(MachineState *ms) ms->possible_cpus->cpus[n].props.has_thread_id =3D true; ms->possible_cpus->cpus[n].props.thread_id =3D n; =20 - /* TODO: add 'has_node/node' here to describe - to which node core belongs */ + /* default distribution of CPUs over NUMA nodes */ + if (nb_numa_nodes) { + /* preset values but do not enable them i.e. 'has_node_id =3D = false', + * numa init code will enable them later if manual mapping was= n't + * present on CLI */ + ms->possible_cpus->cpus[n].props.node_id =3D n % nb_numa_nodes; + } } return ms->possible_cpus; } @@ -1581,6 +1596,7 @@ static void virt_machine_class_init(ObjectClass *oc, = void *data) /* We know we will never create a pre-ARMv7 CPU which needs 1K pages */ mc->minimum_page_bits =3D 12; mc->possible_cpu_arch_ids =3D virt_possible_cpu_arch_ids; + mc->cpu_index_to_instance_props =3D virt_cpu_index_to_props; } =20 static const TypeInfo virt_machine_info =3D { diff --git a/hw/i386/pc.c b/hw/i386/pc.c index f3b372a18f..01693d54ca 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -2243,12 +2243,14 @@ static void pc_machine_reset(void) } } =20 -static unsigned pc_cpu_index_to_socket_id(unsigned cpu_index) +static CpuInstanceProperties +pc_cpu_index_to_props(MachineState *ms, unsigned cpu_index) { - X86CPUTopoInfo topo; - x86_topo_ids_from_idx(smp_cores, smp_threads, cpu_index, - &topo); - return topo.pkg_id; + MachineClass *mc =3D MACHINE_GET_CLASS(ms); + const CPUArchIdList *possible_cpus =3D mc->possible_cpu_arch_ids(ms); + + assert(cpu_index < possible_cpus->len); + return possible_cpus->cpus[cpu_index].props; } =20 static const CPUArchIdList *pc_possible_cpu_arch_ids(MachineState *ms) @@ -2280,6 +2282,15 @@ static const CPUArchIdList *pc_possible_cpu_arch_ids= (MachineState *ms) ms->possible_cpus->cpus[i].props.core_id =3D topo.core_id; ms->possible_cpus->cpus[i].props.has_thread_id =3D true; ms->possible_cpus->cpus[i].props.thread_id =3D topo.smt_id; + + /* default distribution of CPUs over NUMA nodes */ + if (nb_numa_nodes) { + /* preset values but do not enable them i.e. 'has_node_id =3D = false', + * numa init code will enable them later if manual mapping was= n't + * present on CLI */ + ms->possible_cpus->cpus[i].props.node_id =3D + topo.pkg_id % nb_numa_nodes; + } } return ms->possible_cpus; } @@ -2322,7 +2333,7 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) pcmc->acpi_data_size =3D 0x20000 + 0x8000; pcmc->save_tsc_khz =3D true; mc->get_hotplug_handler =3D pc_get_hotpug_handler; - mc->cpu_index_to_socket_id =3D pc_cpu_index_to_socket_id; + mc->cpu_index_to_instance_props =3D pc_cpu_index_to_props; mc->possible_cpu_arch_ids =3D pc_possible_cpu_arch_ids; mc->has_hotpluggable_cpus =3D true; mc->default_boot_order =3D "cad"; diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index bdc31ce56c..2077e4b3c6 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2981,11 +2981,18 @@ static HotplugHandler *spapr_get_hotplug_handler(Ma= chineState *machine, return NULL; } =20 -static unsigned spapr_cpu_index_to_socket_id(unsigned cpu_index) +static CpuInstanceProperties +spapr_cpu_index_to_props(MachineState *machine, unsigned cpu_index) { - /* Allocate to NUMA nodes on a "socket" basis (not that concept of - * socket means much for the paravirtualized PAPR platform) */ - return cpu_index / smp_threads / smp_cores; + CPUArchId *core_slot; + MachineClass *mc =3D MACHINE_GET_CLASS(machine); + + /* make sure possible_cpu are intialized */ + mc->possible_cpu_arch_ids(machine); + /* get CPU core slot containing thread that matches cpu_index */ + core_slot =3D spapr_find_cpu_slot(machine, cpu_index, NULL); + assert(core_slot); + return core_slot->props; } =20 static const CPUArchIdList *spapr_possible_cpu_arch_ids(MachineState *mach= ine) @@ -3012,8 +3019,15 @@ static const CPUArchIdList *spapr_possible_cpu_arch_= ids(MachineState *machine) machine->possible_cpus->cpus[i].arch_id =3D core_id; machine->possible_cpus->cpus[i].props.has_core_id =3D true; machine->possible_cpus->cpus[i].props.core_id =3D core_id; - /* TODO: add 'has_node/node' here to describe - to which node core belongs */ + + /* default distribution of CPUs over NUMA nodes */ + if (nb_numa_nodes) { + /* preset values but do not enable them i.e. 'has_node_id =3D = false', + * numa init code will enable them later if manual mapping was= n't + * present on CLI */ + machine->possible_cpus->cpus[i].props.node_id =3D + core_id / smp_threads / smp_cores % nb_numa_nodes; + } } return machine->possible_cpus; } @@ -3138,7 +3152,7 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) hc->pre_plug =3D spapr_machine_device_pre_plug; hc->plug =3D spapr_machine_device_plug; hc->unplug =3D spapr_machine_device_unplug; - mc->cpu_index_to_socket_id =3D spapr_cpu_index_to_socket_id; + mc->cpu_index_to_instance_props =3D spapr_cpu_index_to_props; mc->possible_cpu_arch_ids =3D spapr_possible_cpu_arch_ids; hc->unplug_request =3D spapr_machine_device_unplug_request; =20 diff --git a/numa.c b/numa.c index d753687dec..bcdfca2309 100644 --- a/numa.c +++ b/numa.c @@ -443,9 +443,10 @@ void numa_default_auto_assign_ram(MachineClass *mc, No= deInfo *nodes, nodes[i].node_mem =3D size - usedmem; } =20 -void parse_numa_opts(MachineClass *mc) +void parse_numa_opts(MachineState *ms) { int i; + MachineClass *mc =3D MACHINE_GET_CLASS(ms); =20 for (i =3D 0; i < MAX_NODES; i++) { numa_info[i].node_cpu =3D bitmap_new(max_cpus); @@ -511,21 +512,18 @@ void parse_numa_opts(MachineClass *mc) break; } } - /* Historically VCPUs were assigned in round-robin order to NUMA - * nodes. However it causes issues with guest not handling it nice - * in case where cores/threads from a multicore CPU appear on - * different nodes. So allow boards to override default distributi= on - * rule grouping VCPUs by socket so that VCPUs from the same socket - * would be on the same node. - */ + + /* assign CPUs to nodes using board provided default mapping */ + if (!mc->cpu_index_to_instance_props) { + error_report("default CPUs to NUMA node mapping isn't supporte= d"); + exit(1); + } if (i =3D=3D nb_numa_nodes) { for (i =3D 0; i < max_cpus; i++) { - unsigned node_id =3D i % nb_numa_nodes; - if (mc->cpu_index_to_socket_id) { - node_id =3D mc->cpu_index_to_socket_id(i) % nb_numa_no= des; - } + CpuInstanceProperties props; + props =3D mc->cpu_index_to_instance_props(ms, i); =20 - set_bit(i, numa_info[node_id].node_cpu); + set_bit(i, numa_info[props.node_id].node_cpu); } } =20 diff --git a/vl.c b/vl.c index 58023fca02..c4705b3335 100644 --- a/vl.c +++ b/vl.c @@ -4503,7 +4503,7 @@ int main(int argc, char **argv, char **envp) default_drive(default_floppy, snapshot, IF_FLOPPY, 0, FD_OPTS); default_drive(default_sdcard, snapshot, IF_SD, 0, SD_OPTS); =20 - parse_numa_opts(machine_class); + parse_numa_opts(current_machine); =20 if (qemu_opts_foreach(qemu_find_opts("mon"), mon_init_func, NULL, NULL)) { --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:42 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 1494530892572835.94344221968; Thu, 11 May 2017 12:28:12 -0700 (PDT) Received: from localhost ([::1]:49790 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tkw-0002Lg-1C for importer@patchew.org; Thu, 11 May 2017 15:28:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tcE-0002Vo-B0 for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tcB-0007oe-6U for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47000) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tcA-0007oN-UL for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:07 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E837C80484; Thu, 11 May 2017 19:19:05 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7214B60F8A; Thu, 11 May 2017 19:19:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E837C80484 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E837C80484 From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:24 -0300 Message-Id: <20170511191843.13784-11-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 11 May 2017 19:19:06 +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] [PULL 10/29] spapr: add node-id property to sPAPR core 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: Igor Mammedov , qemu-devel@nongnu.org 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" From: Igor Mammedov it will allow switching from cpu_index to core based numa mapping in follow up patches. Signed-off-by: Igor Mammedov Reviewed-by: David Gibson Message-Id: <1494415802-227633-3-git-send-email-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- include/hw/ppc/spapr_cpu_core.h | 1 + include/qom/cpu.h | 2 ++ hw/ppc/spapr.c | 17 +++++++++++++++++ hw/ppc/spapr_cpu_core.c | 11 ++++++++--- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/include/hw/ppc/spapr_cpu_core.h b/include/hw/ppc/spapr_cpu_cor= e.h index 3c35665221..93051e9ecf 100644 --- a/include/hw/ppc/spapr_cpu_core.h +++ b/include/hw/ppc/spapr_cpu_core.h @@ -27,6 +27,7 @@ typedef struct sPAPRCPUCore { =20 /*< public >*/ void *threads; + int node_id; } sPAPRCPUCore; =20 typedef struct sPAPRCPUCoreClass { diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 5d10359c8f..55214ce131 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -258,6 +258,8 @@ typedef void (*run_on_cpu_func)(CPUState *cpu, run_on_c= pu_data data); =20 struct qemu_work_item; =20 +#define CPU_UNSET_NUMA_NODE_ID -1 + /** * CPUState: * @cpu_index: CPU index (informative). diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 2077e4b3c6..a952a39836 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2824,9 +2824,11 @@ static void spapr_core_pre_plug(HotplugHandler *hotp= lug_dev, DeviceState *dev, MachineClass *mc =3D MACHINE_GET_CLASS(hotplug_dev); Error *local_err =3D NULL; CPUCore *cc =3D CPU_CORE(dev); + sPAPRCPUCore *sc =3D SPAPR_CPU_CORE(dev); char *base_core_type =3D spapr_get_cpu_core_type(machine->cpu_model); const char *type =3D object_get_typename(OBJECT(dev)); CPUArchId *core_slot; + int node_id; int index; =20 if (dev->hotplugged && !mc->has_hotpluggable_cpus) { @@ -2861,6 +2863,21 @@ static void spapr_core_pre_plug(HotplugHandler *hotp= lug_dev, DeviceState *dev, goto out; } =20 + node_id =3D numa_get_node_for_cpu(cc->core_id); + if (node_id =3D=3D nb_numa_nodes) { + /* by default CPUState::numa_node was 0 if it's not set via CLI + * keep it this way for now but in future we probably should + * refuse to start up with incomplete numa mapping */ + node_id =3D 0; + } + if (sc->node_id =3D=3D CPU_UNSET_NUMA_NODE_ID) { + sc->node_id =3D node_id; + } else if (sc->node_id !=3D node_id) { + error_setg(&local_err, "node-id %d must match numa node specified" + "with -numa option for cpu-index %d", sc->node_id, cc->core_id= ); + goto out; + } + out: g_free(base_core_type); error_propagate(errp, local_err); diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 4389ef4c2a..9de7a5610c 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -176,7 +176,6 @@ static void spapr_cpu_core_realize(DeviceState *dev, Er= ror **errp) const char *typename =3D object_class_get_name(scc->cpu_class); size_t size =3D object_type_get_instance_size(typename); Error *local_err =3D NULL; - int core_node_id =3D numa_get_node_for_cpu(cc->core_id);; void *obj; int i, j; =20 @@ -194,10 +193,10 @@ static void spapr_cpu_core_realize(DeviceState *dev, = Error **errp) =20 /* Set NUMA node for the added CPUs */ node_id =3D numa_get_node_for_cpu(cs->cpu_index); - if (node_id !=3D core_node_id) { + if (node_id !=3D sc->node_id) { error_setg(&local_err, "Invalid node-id=3D%d of thread[cpu-ind= ex: %d]" " on CPU[core-id: %d, node-id: %d], node-id must be the sa= me", - node_id, cs->cpu_index, cc->core_id, core_node_id); + node_id, cs->cpu_index, cc->core_id, sc->node_id); goto err; } if (node_id < nb_numa_nodes) { @@ -263,6 +262,11 @@ static const char *spapr_core_models[] =3D { "POWER9_v1.0", }; =20 +static Property spapr_cpu_core_properties[] =3D { + DEFINE_PROP_INT32("node-id", sPAPRCPUCore, node_id, CPU_UNSET_NUMA_NOD= E_ID), + DEFINE_PROP_END_OF_LIST() +}; + void spapr_cpu_core_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); @@ -270,6 +274,7 @@ void spapr_cpu_core_class_init(ObjectClass *oc, void *d= ata) =20 dc->realize =3D spapr_cpu_core_realize; dc->unrealize =3D spapr_cpu_core_unrealizefn; + dc->props =3D spapr_cpu_core_properties; scc->cpu_class =3D cpu_class_by_name(TYPE_POWERPC_CPU, data); g_assert(scc->cpu_class); } --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:42 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 1494530749236264.62066846055825; Thu, 11 May 2017 12:25:49 -0700 (PDT) Received: from localhost ([::1]:49781 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tid-0008Fg-RX for importer@patchew.org; Thu, 11 May 2017 15:25:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37829) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tcE-0002Vn-Ar for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tcD-0007p4-0I for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40212) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tcC-0007oq-N5 for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:08 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B640EC04B94B; Thu, 11 May 2017 19:19:07 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A94778F26; Thu, 11 May 2017 19:19:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B640EC04B94B Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B640EC04B94B From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:25 -0300 Message-Id: <20170511191843.13784-12-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 11 May 2017 19:19:07 +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] [PULL 11/29] pc: add node-id property to CPU 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: Igor Mammedov , qemu-devel@nongnu.org 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" From: Igor Mammedov it will allow switching from cpu_index to property based numa mapping in follow up patches. PS: patch changes default value of CPUState::numa_node from 0 to CPU_UNSET_NUMA_NODE_ID. The only place for x86 that would affected is monitor's 'infor numa' command which uses that field. However legacy 0 value is still preserved by pc_cpu_pre_plug() in this patch if user/numa.c hasn't set it explicitly, so there is no change in behavior. Signed-off-by: Igor Mammedov Message-Id: <1494415802-227633-4-git-send-email-imammedo@redhat.com> Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- hw/i386/pc.c | 17 +++++++++++++++++ target/i386/cpu.c | 1 + 2 files changed, 18 insertions(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 01693d54ca..455300f776 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1893,6 +1893,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, DeviceState *dev, Error **errp) { int idx; + int node_id; CPUState *cs; CPUArchId *cpu_slot; X86CPUTopoInfo topo; @@ -1982,6 +1983,22 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_= dev, =20 cs =3D CPU(cpu); cs->cpu_index =3D idx; + + node_id =3D numa_get_node_for_cpu(cs->cpu_index); + if (node_id =3D=3D nb_numa_nodes) { + /* by default CPUState::numa_node was 0 if it's not set via CLI + * keep it this way for now but in future we probably should + * refuse to start up with incomplete numa mapping */ + node_id =3D 0; + } + if (cs->numa_node =3D=3D CPU_UNSET_NUMA_NODE_ID) { + cs->numa_node =3D node_id; + } else if (cs->numa_node !=3D node_id) { + error_setg(errp, "node-id %d must match numa node specified" + "with -numa option for cpu-index %d", + cs->numa_node, cs->cpu_index); + return; + } } =20 static void pc_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, diff --git a/target/i386/cpu.c b/target/i386/cpu.c index e3182b296f..5e768404a1 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3986,6 +3986,7 @@ static Property x86_cpu_properties[] =3D { DEFINE_PROP_INT32("core-id", X86CPU, core_id, -1), DEFINE_PROP_INT32("socket-id", X86CPU, socket_id, -1), #endif + DEFINE_PROP_INT32("node-id", CPUState, numa_node, CPU_UNSET_NUMA_NODE_= ID), DEFINE_PROP_BOOL("pmu", X86CPU, enable_pmu, false), { .name =3D "hv-spinlocks", .info =3D &qdev_prop_spinlocks }, DEFINE_PROP_BOOL("hv-relaxed", X86CPU, hyperv_relaxed_timing, false), --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:42 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 149453102153041.72847267590191; Thu, 11 May 2017 12:30:21 -0700 (PDT) Received: from localhost ([::1]:49796 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tn1-0004JU-9Q for importer@patchew.org; Thu, 11 May 2017 15:30:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tcG-0002Xl-8n for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tcF-0007pq-7e for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35242) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tcF-0007pY-1O for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:11 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0EAEF4ACAA; Thu, 11 May 2017 19:19:10 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 181C460F88; Thu, 11 May 2017 19:19:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0EAEF4ACAA Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0EAEF4ACAA From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:26 -0300 Message-Id: <20170511191843.13784-13-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 11 May 2017 19:19:10 +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] [PULL 12/29] virt-arm: add node-id property to CPU 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: Igor Mammedov , qemu-devel@nongnu.org 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" From: Igor Mammedov it will allow switching from cpu_index to property based numa mapping in follow up patches. Signed-off-by: Igor Mammedov Reviewed-by: Andrew Jones Message-Id: <1494415802-227633-5-git-send-email-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- hw/arm/virt.c | 15 +++++++++++++++ target/arm/cpu.c | 1 + 2 files changed, 16 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index dfd6fd446c..653b4d76fd 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1350,6 +1350,7 @@ static void machvirt_init(MachineState *machine) for (n =3D 0; n < possible_cpus->len; n++) { Object *cpuobj; CPUState *cs; + int node_id; =20 if (n >=3D smp_cpus) { break; @@ -1362,6 +1363,20 @@ static void machvirt_init(MachineState *machine) cs =3D CPU(cpuobj); cs->cpu_index =3D n; =20 + node_id =3D numa_get_node_for_cpu(cs->cpu_index); + if (node_id =3D=3D nb_numa_nodes) { + /* by default CPUState::numa_node was 0 if it's not set via CLI + * keep it this way for now but in future we probably should + * refuse to start up with incomplete numa mapping */ + node_id =3D 0; + } + if (cs->numa_node =3D=3D CPU_UNSET_NUMA_NODE_ID) { + cs->numa_node =3D node_id; + } else { + /* CPU isn't device_add compatible yet, this shouldn't happen = */ + error_setg(&error_abort, "user set node-id not implemented"); + } + if (!vms->secure) { object_property_set_bool(cpuobj, false, "has_el3", NULL); } diff --git a/target/arm/cpu.c b/target/arm/cpu.c index ee1406da12..c185eb19ac 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1573,6 +1573,7 @@ static Property arm_cpu_properties[] =3D { DEFINE_PROP_UINT32("midr", ARMCPU, midr, 0), DEFINE_PROP_UINT64("mp-affinity", ARMCPU, mp_affinity, ARM64_AFFINITY_INVALID), + DEFINE_PROP_INT32("node-id", CPUState, numa_node, CPU_UNSET_NUMA_NODE_= ID), DEFINE_PROP_END_OF_LIST() }; =20 --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:42 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 1494530940002779.1406881387177; Thu, 11 May 2017 12:29:00 -0700 (PDT) Received: from localhost ([::1]:49791 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tli-0003Am-FF for importer@patchew.org; Thu, 11 May 2017 15:28:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37858) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tcI-0002Zc-2R for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tcH-0007qp-1M for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47292) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tcG-0007qE-R8 for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:12 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D62EA81127; Thu, 11 May 2017 19:19:11 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6CFE571C39; Thu, 11 May 2017 19:19:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D62EA81127 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D62EA81127 From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:27 -0300 Message-Id: <20170511191843.13784-14-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 11 May 2017 19:19:12 +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] [PULL 13/29] numa: add check that board supports cpu_index to node mapping 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: Igor Mammedov , qemu-devel@nongnu.org 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" From: Igor Mammedov Default node mapping initialization already checks that board supports cpu_index to node mapping and refuses to start if it's not supported. Do the same for explicitly provided mapping "-numa node,cpus=3D..." Signed-off-by: Igor Mammedov Reviewed-by: Andrew Jones Reviewed-by: David Gibson Message-Id: <1494415802-227633-6-git-send-email-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- numa.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/numa.c b/numa.c index bcdfca2309..718248161c 100644 --- a/numa.c +++ b/numa.c @@ -141,10 +141,12 @@ uint32_t numa_get_node(ram_addr_t addr, Error **errp) return -1; } =20 -static void parse_numa_node(NumaNodeOptions *node, QemuOpts *opts, Error *= *errp) +static void parse_numa_node(MachineState *ms, NumaNodeOptions *node, + QemuOpts *opts, Error **errp) { uint16_t nodenr; uint16List *cpus =3D NULL; + MachineClass *mc =3D MACHINE_GET_CLASS(ms); =20 if (node->has_nodeid) { nodenr =3D node->nodeid; @@ -163,6 +165,10 @@ static void parse_numa_node(NumaNodeOptions *node, Qem= uOpts *opts, Error **errp) return; } =20 + if (!mc->cpu_index_to_instance_props) { + error_report("NUMA is not supported by this machine-type"); + exit(1); + } for (cpus =3D node->cpus; cpus; cpus =3D cpus->next) { if (cpus->value >=3D max_cpus) { error_setg(errp, @@ -253,6 +259,7 @@ static void parse_numa_distance(NumaDistOptions *dist, = Error **errp) static int parse_numa(void *opaque, QemuOpts *opts, Error **errp) { NumaOptions *object =3D NULL; + MachineState *ms =3D opaque; Error *err =3D NULL; =20 { @@ -267,7 +274,7 @@ static int parse_numa(void *opaque, QemuOpts *opts, Err= or **errp) =20 switch (object->type) { case NUMA_OPTIONS_TYPE_NODE: - parse_numa_node(&object->u.node, opts, &err); + parse_numa_node(ms, &object->u.node, opts, &err); if (err) { goto end; } @@ -452,7 +459,7 @@ void parse_numa_opts(MachineState *ms) numa_info[i].node_cpu =3D bitmap_new(max_cpus); } =20 - if (qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, NULL, NULL))= { + if (qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, ms, NULL)) { exit(1); } =20 --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:42 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 149453073540565.93165213731652; Thu, 11 May 2017 12:25:35 -0700 (PDT) Received: from localhost ([::1]:49780 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tiQ-00082A-2n for importer@patchew.org; Thu, 11 May 2017 15:25:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37879) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tcK-0002bm-E4 for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tcJ-0007rn-2V for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40306) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tcI-0007rF-PP for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:14 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C5FA0C04B320; Thu, 11 May 2017 19:19:13 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3007760F88; Thu, 11 May 2017 19:19:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C5FA0C04B320 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C5FA0C04B320 From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:28 -0300 Message-Id: <20170511191843.13784-15-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 11 May 2017 19:19:13 +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] [PULL 14/29] numa: mirror cpu to node mapping in MachineState::possible_cpus 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: Igor Mammedov , qemu-devel@nongnu.org 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" From: Igor Mammedov Introduce machine_set_cpu_numa_node() helper that stores node mapping for CPU in MachineState::possible_cpus. CPU and node it belongs to is specified by 'props' argument. Patch doesn't remove old way of storing mapping in numa_info[X].node_cpu as removing it at the same time makes patch rather big. Instead it just mirrors mapping in possible_cpus and follow up per target patches will switch to possible_cpus and numa_info[X].node_cpu will be removed once there isn't any users left. Signed-off-by: Igor Mammedov Reviewed-by: David Gibson Reviewed-by: Andrew Jones Message-Id: <1494415802-227633-7-git-send-email-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- include/hw/boards.h | 3 ++ hw/core/machine.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++= ++++ numa.c | 8 +++++ 3 files changed, 107 insertions(+) diff --git a/include/hw/boards.h b/include/hw/boards.h index 3ffa255fb8..4e14ff060e 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -42,6 +42,9 @@ bool machine_dump_guest_core(MachineState *machine); bool machine_mem_merge(MachineState *machine); void machine_register_compat_props(MachineState *machine); HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine= ); +void machine_set_cpu_numa_node(MachineState *machine, + const CpuInstanceProperties *props, + Error **errp); =20 /** * CPUArchId: diff --git a/hw/core/machine.c b/hw/core/machine.c index 2482c630c1..420c8c4d16 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -389,6 +389,102 @@ HotpluggableCPUList *machine_query_hotpluggable_cpus(= MachineState *machine) return head; } =20 +/** + * machine_set_cpu_numa_node: + * @machine: machine object to modify + * @props: specifies which cpu objects to assign to + * numa node specified by @props.node_id + * @errp: if an error occurs, a pointer to an area to store the error + * + * Associate NUMA node specified by @props.node_id with cpu slots that + * match socket/core/thread-ids specified by @props. It's recommended to u= se + * query-hotpluggable-cpus.props values to specify affected cpu slots, + * which would lead to exact 1:1 mapping of cpu slots to NUMA node. + * + * However for CLI convenience it's possible to pass in subset of properti= es, + * which would affect all cpu slots that match it. + * Ex for pc machine: + * -smp 4,cores=3D2,sockets=3D2 -numa node,nodeid=3D0 -numa node,nodeid= =3D1 \ + * -numa cpu,node-id=3D0,socket_id=3D0 \ + * -numa cpu,node-id=3D1,socket_id=3D1 + * will assign all child cores of socket 0 to node 0 and + * of socket 1 to node 1. + * + * On attempt of reassigning (already assigned) cpu slot to another NUMA n= ode, + * return error. + * Empty subset is disallowed and function will return with error in this = case. + */ +void machine_set_cpu_numa_node(MachineState *machine, + const CpuInstanceProperties *props, Error *= *errp) +{ + MachineClass *mc =3D MACHINE_GET_CLASS(machine); + bool match =3D false; + int i; + + if (!mc->possible_cpu_arch_ids) { + error_setg(errp, "mapping of CPUs to NUMA node is not supported"); + return; + } + + /* disabling node mapping is not supported, forbid it */ + assert(props->has_node_id); + + /* force board to initialize possible_cpus if it hasn't been done yet = */ + mc->possible_cpu_arch_ids(machine); + + for (i =3D 0; i < machine->possible_cpus->len; i++) { + CPUArchId *slot =3D &machine->possible_cpus->cpus[i]; + + /* reject unsupported by board properties */ + if (props->has_thread_id && !slot->props.has_thread_id) { + error_setg(errp, "thread-id is not supported"); + return; + } + + if (props->has_core_id && !slot->props.has_core_id) { + error_setg(errp, "core-id is not supported"); + return; + } + + if (props->has_socket_id && !slot->props.has_socket_id) { + error_setg(errp, "socket-id is not supported"); + return; + } + + /* skip slots with explicit mismatch */ + if (props->has_thread_id && props->thread_id !=3D slot->props.thre= ad_id) { + continue; + } + + if (props->has_core_id && props->core_id !=3D slot->props.core_id)= { + continue; + } + + if (props->has_socket_id && props->socket_id !=3D slot->props.sock= et_id) { + continue; + } + + /* reject assignment if slot is already assigned, for compatibility + * of legacy cpu_index mapping with SPAPR core based mapping do not + * error out if cpu thread and matched core have the same node-id = */ + if (slot->props.has_node_id && + slot->props.node_id !=3D props->node_id) { + error_setg(errp, "CPU is already assigned to node-id: %" PRId6= 4, + slot->props.node_id); + return; + } + + /* assign slot to node as it's matched '-numa cpu' key */ + match =3D true; + slot->props.node_id =3D props->node_id; + slot->props.has_node_id =3D props->has_node_id; + } + + if (!match) { + error_setg(errp, "no match found"); + } +} + static void machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); diff --git a/numa.c b/numa.c index 718248161c..7db5dde873 100644 --- a/numa.c +++ b/numa.c @@ -170,6 +170,7 @@ static void parse_numa_node(MachineState *ms, NumaNodeO= ptions *node, exit(1); } for (cpus =3D node->cpus; cpus; cpus =3D cpus->next) { + CpuInstanceProperties props; if (cpus->value >=3D max_cpus) { error_setg(errp, "CPU index (%" PRIu16 ")" @@ -178,6 +179,10 @@ static void parse_numa_node(MachineState *ms, NumaNode= Options *node, return; } bitmap_set(numa_info[nodenr].node_cpu, cpus->value, 1); + props =3D mc->cpu_index_to_instance_props(ms, cpus->value); + props.node_id =3D nodenr; + props.has_node_id =3D true; + machine_set_cpu_numa_node(ms, &props, &error_fatal); } =20 if (node->has_mem && node->has_memdev) { @@ -528,9 +533,12 @@ void parse_numa_opts(MachineState *ms) if (i =3D=3D nb_numa_nodes) { for (i =3D 0; i < max_cpus; i++) { CpuInstanceProperties props; + /* fetch default mapping from board and enable it */ props =3D mc->cpu_index_to_instance_props(ms, i); + props.has_node_id =3D true; =20 set_bit(i, numa_info[props.node_id].node_cpu); + machine_set_cpu_numa_node(ms, &props, &error_fatal); } } =20 --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:42 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 1494531032712337.585329554062; Thu, 11 May 2017 12:30:32 -0700 (PDT) Received: from localhost ([::1]:49803 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tnD-0004Ww-By for importer@patchew.org; Thu, 11 May 2017 15:30:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37909) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tcN-0002eW-Lv for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tcK-0007sf-OI for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:4524) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tcK-0007s9-Ij for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:16 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 947AE80C0C; Thu, 11 May 2017 19:19:15 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 29D2C6031C; Thu, 11 May 2017 19:19:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 947AE80C0C Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 947AE80C0C From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:29 -0300 Message-Id: <20170511191843.13784-16-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 11 May 2017 19:19:15 +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] [PULL 15/29] numa: do default mapping based on possible_cpus instead of node_cpu bitmaps 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: Igor Mammedov , qemu-devel@nongnu.org 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" From: Igor Mammedov Signed-off-by: Igor Mammedov Reviewed-by: David Gibson Reviewed-by: Andrew Jones Message-Id: <1494415802-227633-8-git-send-email-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- numa.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/numa.c b/numa.c index 7db5dde873..c89fc2d4a5 100644 --- a/numa.c +++ b/numa.c @@ -458,6 +458,7 @@ void numa_default_auto_assign_ram(MachineClass *mc, Nod= eInfo *nodes, void parse_numa_opts(MachineState *ms) { int i; + const CPUArchIdList *possible_cpus; MachineClass *mc =3D MACHINE_GET_CLASS(ms); =20 for (i =3D 0; i < MAX_NODES; i++) { @@ -519,18 +520,21 @@ void parse_numa_opts(MachineState *ms) =20 numa_set_mem_ranges(); =20 - for (i =3D 0; i < nb_numa_nodes; i++) { - if (!bitmap_empty(numa_info[i].node_cpu, max_cpus)) { - break; - } - } - /* assign CPUs to nodes using board provided default mapping */ - if (!mc->cpu_index_to_instance_props) { + if (!mc->cpu_index_to_instance_props || !mc->possible_cpu_arch_ids= ) { error_report("default CPUs to NUMA node mapping isn't supporte= d"); exit(1); } - if (i =3D=3D nb_numa_nodes) { + + possible_cpus =3D mc->possible_cpu_arch_ids(ms); + for (i =3D 0; i < possible_cpus->len; i++) { + if (possible_cpus->cpus[i].props.has_node_id) { + break; + } + } + + /* no CPUs are assigned to NUMA nodes */ + if (i =3D=3D possible_cpus->len) { for (i =3D 0; i < max_cpus; i++) { CpuInstanceProperties props; /* fetch default mapping from board and enable it */ --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:42 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 1494531179134575.9135999557507; Thu, 11 May 2017 12:32:59 -0700 (PDT) Received: from localhost ([::1]:49810 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tpZ-0006vv-Mb for importer@patchew.org; Thu, 11 May 2017 15:32:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37911) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tcN-0002eY-Mf for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tcM-0007td-KQ for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35360) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tcM-0007t7-B7 for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:18 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5A36E4DD4B; Thu, 11 May 2017 19:19:17 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id E3F885DD65; Thu, 11 May 2017 19:19:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5A36E4DD4B Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5A36E4DD4B From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:30 -0300 Message-Id: <20170511191843.13784-17-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 11 May 2017 19:19:17 +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] [PULL 16/29] pc: get numa node mapping from possible_cpus instead of numa_get_node_for_cpu() 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: Igor Mammedov , qemu-devel@nongnu.org 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" From: Igor Mammedov Signed-off-by: Igor Mammedov Reviewed-by: Andrew Jones Message-Id: <1494415802-227633-9-git-send-email-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- hw/acpi/cpu.c | 7 +++---- hw/i386/acpi-build.c | 11 ++++------- hw/i386/pc.c | 18 ++++++++++-------- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c index 8c719d3f9d..a233fe17cf 100644 --- a/hw/acpi/cpu.c +++ b/hw/acpi/cpu.c @@ -503,7 +503,6 @@ void build_cpus_aml(Aml *table, MachineState *machine, = CPUHotplugFeatures opts, =20 /* build Processor object for each processor */ for (i =3D 0; i < arch_ids->len; i++) { - int j; Aml *dev; Aml *uid =3D aml_int(i); GArray *madt_buf =3D g_array_new(0, 1, 1); @@ -557,9 +556,9 @@ void build_cpus_aml(Aml *table, MachineState *machine, = CPUHotplugFeatures opts, * as a result _PXM is required for all CPUs which might * be hot-plugged. For simplicity, add it for all CPUs. */ - j =3D numa_get_node_for_cpu(i); - if (j < nb_numa_nodes) { - aml_append(dev, aml_name_decl("_PXM", aml_int(j))); + if (arch_ids->cpus[i].props.has_node_id) { + aml_append(dev, aml_name_decl("_PXM", + aml_int(arch_ids->cpus[i].props.node_id))); } =20 aml_append(cpus_dev, dev); diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index c7cc45cc4b..cc0418f327 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2335,7 +2335,8 @@ build_srat(GArray *table_data, BIOSLinker *linker, Ma= chineState *machine) srat->reserved1 =3D cpu_to_le32(1); =20 for (i =3D 0; i < apic_ids->len; i++) { - int j =3D numa_get_node_for_cpu(i); + int node_id =3D apic_ids->cpus[i].props.has_node_id ? + apic_ids->cpus[i].props.node_id : 0; uint32_t apic_id =3D apic_ids->cpus[i].arch_id; =20 if (apic_id < 255) { @@ -2345,9 +2346,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, Ma= chineState *machine) core->type =3D ACPI_SRAT_PROCESSOR_APIC; core->length =3D sizeof(*core); core->local_apic_id =3D apic_id; - if (j < nb_numa_nodes) { - core->proximity_lo =3D j; - } + core->proximity_lo =3D node_id; memset(core->proximity_hi, 0, 3); core->local_sapic_eid =3D 0; core->flags =3D cpu_to_le32(1); @@ -2358,9 +2357,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, Ma= chineState *machine) core->type =3D ACPI_SRAT_PROCESSOR_x2APIC; core->length =3D sizeof(*core); core->x2apic_id =3D cpu_to_le32(apic_id); - if (j < nb_numa_nodes) { - core->proximity_domain =3D cpu_to_le32(j); - } + core->proximity_domain =3D cpu_to_le32(node_id); core->flags =3D cpu_to_le32(1); } } diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 455300f776..e36a375683 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -747,7 +747,9 @@ static FWCfgState *bochs_bios_init(AddressSpace *as, PC= MachineState *pcms) { FWCfgState *fw_cfg; uint64_t *numa_fw_cfg; - int i, j; + int i; + const CPUArchIdList *cpus; + MachineClass *mc =3D MACHINE_GET_CLASS(pcms); =20 fw_cfg =3D fw_cfg_init_io_dma(FW_CFG_IO_BASE, FW_CFG_IO_BASE + 4, as); fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, pcms->boot_cpus); @@ -782,12 +784,12 @@ static FWCfgState *bochs_bios_init(AddressSpace *as, = PCMachineState *pcms) */ numa_fw_cfg =3D g_new0(uint64_t, 1 + pcms->apic_id_limit + nb_numa_nod= es); numa_fw_cfg[0] =3D cpu_to_le64(nb_numa_nodes); - for (i =3D 0; i < max_cpus; i++) { - unsigned int apic_id =3D x86_cpu_apic_id_from_index(i); + cpus =3D mc->possible_cpu_arch_ids(MACHINE(pcms)); + for (i =3D 0; i < cpus->len; i++) { + unsigned int apic_id =3D cpus->cpus[i].arch_id; assert(apic_id < pcms->apic_id_limit); - j =3D numa_get_node_for_cpu(i); - if (j < nb_numa_nodes) { - numa_fw_cfg[apic_id + 1] =3D cpu_to_le64(j); + if (cpus->cpus[i].props.has_node_id) { + numa_fw_cfg[apic_id + 1] =3D cpu_to_le64(cpus->cpus[i].props.n= ode_id); } } for (i =3D 0; i < nb_numa_nodes; i++) { @@ -1984,8 +1986,8 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, cs =3D CPU(cpu); cs->cpu_index =3D idx; =20 - node_id =3D numa_get_node_for_cpu(cs->cpu_index); - if (node_id =3D=3D nb_numa_nodes) { + node_id =3D cpu_slot->props.node_id; + if (!cpu_slot->props.has_node_id) { /* by default CPUState::numa_node was 0 if it's not set via CLI * keep it this way for now but in future we probably should * refuse to start up with incomplete numa mapping */ --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:42 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 1494531087965693.95934978292; Thu, 11 May 2017 12:31:27 -0700 (PDT) Received: from localhost ([::1]:49804 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8to6-0005JB-Mh for importer@patchew.org; Thu, 11 May 2017 15:31:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tcP-0002g9-A9 for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tcO-0007uR-BO for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47408) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tcO-0007tx-5G for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:20 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3319183F3F; Thu, 11 May 2017 19:19:19 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD3135DD65; Thu, 11 May 2017 19:19:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3319183F3F Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3319183F3F From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:31 -0300 Message-Id: <20170511191843.13784-18-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 11 May 2017 19:19:19 +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] [PULL 17/29] spapr: get numa node mapping from possible_cpus instead of numa_get_node_for_cpu() 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: Igor Mammedov , qemu-devel@nongnu.org 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" From: Igor Mammedov it's safe to remove thread node_id !=3D core node_id error branch as machine_set_cpu_numa_node() also does mismatch check and is called even before any CPU is created. Signed-off-by: Igor Mammedov Acked-by: David Gibson Message-Id: <1494415802-227633-10-git-send-email-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- hw/ppc/spapr.c | 4 ++-- hw/ppc/spapr_cpu_core.c | 14 ++------------ 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index a952a39836..504161fa45 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2863,8 +2863,8 @@ static void spapr_core_pre_plug(HotplugHandler *hotpl= ug_dev, DeviceState *dev, goto out; } =20 - node_id =3D numa_get_node_for_cpu(cc->core_id); - if (node_id =3D=3D nb_numa_nodes) { + node_id =3D core_slot->props.node_id; + if (!core_slot->props.has_node_id) { /* by default CPUState::numa_node was 0 if it's not set via CLI * keep it this way for now but in future we probably should * refuse to start up with incomplete numa mapping */ diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 9de7a5610c..a17ea07ef1 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -181,7 +181,6 @@ static void spapr_cpu_core_realize(DeviceState *dev, Er= ror **errp) =20 sc->threads =3D g_malloc0(size * cc->nr_threads); for (i =3D 0; i < cc->nr_threads; i++) { - int node_id; char id[32]; CPUState *cs; =20 @@ -191,17 +190,8 @@ static void spapr_cpu_core_realize(DeviceState *dev, E= rror **errp) cs =3D CPU(obj); cs->cpu_index =3D cc->core_id + i; =20 - /* Set NUMA node for the added CPUs */ - node_id =3D numa_get_node_for_cpu(cs->cpu_index); - if (node_id !=3D sc->node_id) { - error_setg(&local_err, "Invalid node-id=3D%d of thread[cpu-ind= ex: %d]" - " on CPU[core-id: %d, node-id: %d], node-id must be the sa= me", - node_id, cs->cpu_index, cc->core_id, sc->node_id); - goto err; - } - if (node_id < nb_numa_nodes) { - cs->numa_node =3D node_id; - } + /* Set NUMA node for the threads belonged to core */ + cs->numa_node =3D sc->node_id; =20 snprintf(id, sizeof(id), "thread[%d]", i); object_property_add_child(OBJECT(sc), id, obj, &local_err); --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:42 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 1494531329467316.36930411901403; Thu, 11 May 2017 12:35:29 -0700 (PDT) Received: from localhost ([::1]:49841 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8ts0-0000aa-4N for importer@patchew.org; Thu, 11 May 2017 15:35:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37959) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tcR-0002gf-G1 for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tcQ-0007vc-9a for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35406) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tcQ-0007v3-0j for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:22 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0DE1C76FF; Thu, 11 May 2017 19:19:21 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9950D5DD65; Thu, 11 May 2017 19:19:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0DE1C76FF Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0DE1C76FF From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:32 -0300 Message-Id: <20170511191843.13784-19-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 11 May 2017 19:19:21 +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] [PULL 18/29] virt-arm: get numa node mapping from possible_cpus instead of numa_get_node_for_cpu() 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: Igor Mammedov , qemu-devel@nongnu.org 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" From: Igor Mammedov Signed-off-by: Igor Mammedov Reviewed-by: Andrew Jones Message-Id: <1494415802-227633-11-git-send-email-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- hw/arm/virt-acpi-build.c | 19 +++++++------------ hw/arm/virt.c | 13 +++++++------ 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 0835e59bb2..ce7499c9ca 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -486,30 +486,25 @@ build_srat(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) AcpiSystemResourceAffinityTable *srat; AcpiSratProcessorGiccAffinity *core; AcpiSratMemoryAffinity *numamem; - int i, j, srat_start; + int i, srat_start; uint64_t mem_base; - uint32_t *cpu_node =3D g_malloc0(vms->smp_cpus * sizeof(uint32_t)); - - for (i =3D 0; i < vms->smp_cpus; i++) { - j =3D numa_get_node_for_cpu(i); - if (j < nb_numa_nodes) { - cpu_node[i] =3D j; - } - } + MachineClass *mc =3D MACHINE_GET_CLASS(vms); + const CPUArchIdList *cpu_list =3D mc->possible_cpu_arch_ids(MACHINE(vm= s)); =20 srat_start =3D table_data->len; srat =3D acpi_data_push(table_data, sizeof(*srat)); srat->reserved1 =3D cpu_to_le32(1); =20 - for (i =3D 0; i < vms->smp_cpus; ++i) { + for (i =3D 0; i < cpu_list->len; ++i) { + int node_id =3D cpu_list->cpus[i].props.has_node_id ? + cpu_list->cpus[i].props.node_id : 0; core =3D acpi_data_push(table_data, sizeof(*core)); core->type =3D ACPI_SRAT_PROCESSOR_GICC; core->length =3D sizeof(*core); - core->proximity =3D cpu_to_le32(cpu_node[i]); + core->proximity =3D cpu_to_le32(node_id); core->acpi_processor_uid =3D cpu_to_le32(i); core->flags =3D cpu_to_le32(1); } - g_free(cpu_node); =20 mem_base =3D vms->memmap[VIRT_MEM].base; for (i =3D 0; i < nb_numa_nodes; ++i) { diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 653b4d76fd..c7c8159dfd 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -338,7 +338,7 @@ static void fdt_add_cpu_nodes(const VirtMachineState *v= ms) { int cpu; int addr_cells =3D 1; - unsigned int i; + const MachineState *ms =3D MACHINE(vms); =20 /* * From Documentation/devicetree/bindings/arm/cpus.txt @@ -369,6 +369,7 @@ static void fdt_add_cpu_nodes(const VirtMachineState *v= ms) for (cpu =3D vms->smp_cpus - 1; cpu >=3D 0; cpu--) { char *nodename =3D g_strdup_printf("/cpus/cpu@%d", cpu); ARMCPU *armcpu =3D ARM_CPU(qemu_get_cpu(cpu)); + CPUState *cs =3D CPU(armcpu); =20 qemu_fdt_add_subnode(vms->fdt, nodename); qemu_fdt_setprop_string(vms->fdt, nodename, "device_type", "cpu"); @@ -389,9 +390,9 @@ static void fdt_add_cpu_nodes(const VirtMachineState *v= ms) armcpu->mp_affinity); } =20 - i =3D numa_get_node_for_cpu(cpu); - if (i < nb_numa_nodes) { - qemu_fdt_setprop_cell(vms->fdt, nodename, "numa-node-id", i); + if (ms->possible_cpus->cpus[cs->cpu_index].props.has_node_id) { + qemu_fdt_setprop_cell(vms->fdt, nodename, "numa-node-id", + ms->possible_cpus->cpus[cs->cpu_index].props.node_id); } =20 g_free(nodename); @@ -1363,8 +1364,8 @@ static void machvirt_init(MachineState *machine) cs =3D CPU(cpuobj); cs->cpu_index =3D n; =20 - node_id =3D numa_get_node_for_cpu(cs->cpu_index); - if (node_id =3D=3D nb_numa_nodes) { + node_id =3D possible_cpus->cpus[cs->cpu_index].props.node_id; + if (!possible_cpus->cpus[cs->cpu_index].props.has_node_id) { /* by default CPUState::numa_node was 0 if it's not set via CLI * keep it this way for now but in future we probably should * refuse to start up with incomplete numa mapping */ --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:42 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 149453147986094.30068497554191; Thu, 11 May 2017 12:37:59 -0700 (PDT) Received: from localhost ([::1]:49851 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tuQ-0002g9-Hz for importer@patchew.org; Thu, 11 May 2017 15:37:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37980) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tcT-0002iZ-AD for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tcS-0007wD-2o for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60602) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tcR-0007vt-Pz for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:24 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C7402448D65; Thu, 11 May 2017 19:19:22 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5BE9A60F88; Thu, 11 May 2017 19:19:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C7402448D65 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C7402448D65 From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:33 -0300 Message-Id: <20170511191843.13784-20-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 11 May 2017 19:19:22 +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] [PULL 19/29] QMP: include CpuInstanceProperties into query_cpus output output 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: Igor Mammedov , qemu-devel@nongnu.org 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" From: Igor Mammedov if board supports CpuInstanceProperties, report them for each CPU thread listed. Main motivation for this is to provide these properties introspection via QMP interface for using in test cases to verify numa node to cpu mapping, which includes not only boards that support cpu hotplug and have this info in query-hotpluggable-cpus (pc/spapr) but also for boards that don't not support hotpluggable-cpus but support numa mapping (virt-arm). Signed-off-by: Igor Mammedov Reviewed-by: Eric Blake Message-Id: <1494415802-227633-12-git-send-email-imammedo@redhat.com> Reviewed-by: David Gibson Signed-off-by: Eduardo Habkost --- qapi-schema.json | 6 +++++- cpus.c | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/qapi-schema.json b/qapi-schema.json index f4eef33a44..c3051fb901 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1325,6 +1325,9 @@ # # @thread_id: ID of the underlying host thread # +# @props: properties describing to which node/socket/core/thread +# virtual CPU belongs to, provided if supported by board (since 2.= 10) +# # @arch: architecture of the cpu, which determines which additional fields # will be listed (since 2.6) # @@ -1335,7 +1338,8 @@ ## { 'union': 'CpuInfo', 'base': {'CPU': 'int', 'current': 'bool', 'halted': 'bool', - 'qom_path': 'str', 'thread_id': 'int', 'arch': 'CpuInfoArch' }, + 'qom_path': 'str', 'thread_id': 'int', + '*props': 'CpuInstanceProperties', 'arch': 'CpuInfoArch' }, 'discriminator': 'arch', 'data': { 'x86': 'CpuInfoX86', 'sparc': 'CpuInfoSPARC', diff --git a/cpus.c b/cpus.c index 740b8dc3f8..4f91d25513 100644 --- a/cpus.c +++ b/cpus.c @@ -50,6 +50,7 @@ #include "qapi-event.h" #include "hw/nmi.h" #include "sysemu/replay.h" +#include "hw/boards.h" =20 #ifdef CONFIG_LINUX =20 @@ -1859,6 +1860,8 @@ void list_cpus(FILE *f, fprintf_function cpu_fprintf,= const char *optarg) =20 CpuInfoList *qmp_query_cpus(Error **errp) { + MachineState *ms =3D MACHINE(qdev_get_machine()); + MachineClass *mc =3D MACHINE_GET_CLASS(ms); CpuInfoList *head =3D NULL, *cur_item =3D NULL; CPUState *cpu; =20 @@ -1909,6 +1912,13 @@ CpuInfoList *qmp_query_cpus(Error **errp) #else info->value->arch =3D CPU_INFO_ARCH_OTHER; #endif + info->value->has_props =3D !!mc->cpu_index_to_instance_props; + if (info->value->has_props) { + CpuInstanceProperties *props; + props =3D g_malloc0(sizeof(*props)); + *props =3D mc->cpu_index_to_instance_props(ms, cpu->cpu_index); + info->value->props =3D props; + } =20 /* XXX: waiting for the qapi to support GSList */ if (!cur_item) { --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:42 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 1494531598436354.44775485843513; Thu, 11 May 2017 12:39:58 -0700 (PDT) Received: from localhost ([::1]:49859 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8twL-0004g1-46 for importer@patchew.org; Thu, 11 May 2017 15:39:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38009) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tcW-0002lV-GV for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tcU-0007xG-3S for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59650) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tcT-0007wZ-MA for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:26 -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 AFCEF73056; Thu, 11 May 2017 19:19:24 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 29CE0173BF; Thu, 11 May 2017 19:19:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AFCEF73056 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com AFCEF73056 From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:34 -0300 Message-Id: <20170511191843.13784-21-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@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.39]); Thu, 11 May 2017 19:19:24 +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] [PULL 20/29] tests: numa: add case for QMP command query-cpus 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: Igor Mammedov , qemu-devel@nongnu.org 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" From: Igor Mammedov Signed-off-by: Igor Mammedov Reviewed-by: David Gibson Message-Id: <1494415802-227633-13-git-send-email-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- numa.c | 14 -------------- tests/numa-test.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/numa.c b/numa.c index c89fc2d4a5..f16a6a8ade 100644 --- a/numa.c +++ b/numa.c @@ -737,20 +737,6 @@ MemdevList *qmp_query_memdev(Error **errp) return list; } =20 -int numa_get_node_for_cpu(int idx) -{ - int i; - - assert(idx < max_cpus); - - for (i =3D 0; i < nb_numa_nodes; i++) { - if (test_bit(idx, numa_info[i].node_cpu)) { - break; - } - } - return i; -} - void ram_block_notifier_add(RAMBlockNotifier *n) { QLIST_INSERT_HEAD(&ram_list.ramblock_notifiers, n, next); diff --git a/tests/numa-test.c b/tests/numa-test.c index f5da0c845b..27226877af 100644 --- a/tests/numa-test.c +++ b/tests/numa-test.c @@ -87,6 +87,50 @@ static void test_mon_partial(const void *data) g_free(cli); } =20 +static QList *get_cpus(QDict **resp) +{ + *resp =3D qmp("{ 'execute': 'query-cpus' }"); + g_assert(*resp); + g_assert(qdict_haskey(*resp, "return")); + return qdict_get_qlist(*resp, "return"); +} + +static void test_query_cpus(const void *data) +{ + char *cli; + QDict *resp; + QList *cpus; + const QObject *e; + + cli =3D make_cli(data, "-smp 8 -numa node,cpus=3D0-3 -numa node,cpus= =3D4-7"); + qtest_start(cli); + cpus =3D get_cpus(&resp); + g_assert(cpus); + + while ((e =3D qlist_pop(cpus))) { + QDict *cpu, *props; + int64_t cpu_idx, node; + + cpu =3D qobject_to_qdict(e); + g_assert(qdict_haskey(cpu, "CPU")); + g_assert(qdict_haskey(cpu, "props")); + + cpu_idx =3D qdict_get_int(cpu, "CPU"); + props =3D qdict_get_qdict(cpu, "props"); + g_assert(qdict_haskey(props, "node-id")); + node =3D qdict_get_int(props, "node-id"); + if (cpu_idx >=3D 0 && cpu_idx < 4) { + g_assert_cmpint(node, =3D=3D, 0); + } else { + g_assert_cmpint(node, =3D=3D, 1); + } + } + + QDECREF(resp); + qtest_end(); + g_free(cli); +} + int main(int argc, char **argv) { const char *args =3D NULL; @@ -101,6 +145,7 @@ int main(int argc, char **argv) qtest_add_data_func("/numa/mon/default", args, test_mon_default); qtest_add_data_func("/numa/mon/cpus/explicit", args, test_mon_explicit= ); qtest_add_data_func("/numa/mon/cpus/partial", args, test_mon_partial); + qtest_add_data_func("/numa/qmp/cpus/query-cpus", args, test_query_cpus= ); =20 return g_test_run(); } --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:42 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 1494531189237129.8715726116992; Thu, 11 May 2017 12:33:09 -0700 (PDT) Received: from localhost ([::1]:49812 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tpj-00075k-VR for importer@patchew.org; Thu, 11 May 2017 15:33:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38012) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tcW-0002lr-Tf for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tcW-0007xp-1g for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50066) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tcV-0007xf-RS for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:27 -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 D8B3B7F3F8; Thu, 11 May 2017 19:19:26 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E693173D4; Thu, 11 May 2017 19:19:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D8B3B7F3F8 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=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D8B3B7F3F8 From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:35 -0300 Message-Id: <20170511191843.13784-22-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@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]); Thu, 11 May 2017 19:19:27 +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] [PULL 21/29] numa: remove no longer need numa_post_machine_init() 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: Igor Mammedov , qemu-devel@nongnu.org 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" From: Igor Mammedov CPUState::numa_node is still in use but now it's set by board when it creates CPU objects. So there isn't any need to set it again after all CPU's are created, since it's been already set. Signed-off-by: Igor Mammedov Reviewed-by: David Gibson Reviewed-by: Andrew Jones Message-Id: <1494415802-227633-14-git-send-email-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- include/sysemu/numa.h | 6 ------ numa.c | 15 --------------- vl.c | 2 -- 3 files changed, 23 deletions(-) diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index 027830cf7e..8cb3ebc233 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -27,7 +27,6 @@ struct node_info { =20 extern NodeInfo numa_info[MAX_NODES]; void parse_numa_opts(MachineState *ms); -void numa_post_machine_init(void); void query_numa_node_mem(uint64_t node_mem[]); extern QemuOptsList qemu_numa_opts; void numa_set_mem_node_id(ram_addr_t addr, uint64_t size, uint32_t node); @@ -37,9 +36,4 @@ void numa_legacy_auto_assign_ram(MachineClass *mc, NodeIn= fo *nodes, int nb_nodes, ram_addr_t size); void numa_default_auto_assign_ram(MachineClass *mc, NodeInfo *nodes, int nb_nodes, ram_addr_t size); - - -/* on success returns node index in numa_info, - * on failure returns nb_numa_nodes */ -int numa_get_node_for_cpu(int idx); #endif diff --git a/numa.c b/numa.c index f16a6a8ade..dc739eadfa 100644 --- a/numa.c +++ b/numa.c @@ -572,21 +572,6 @@ void parse_numa_opts(MachineState *ms) } } =20 -void numa_post_machine_init(void) -{ - CPUState *cpu; - int i; - - CPU_FOREACH(cpu) { - for (i =3D 0; i < nb_numa_nodes; i++) { - assert(cpu->cpu_index < max_cpus); - if (test_bit(cpu->cpu_index, numa_info[i].node_cpu)) { - cpu->numa_node =3D i; - } - } - } -} - static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner, const char *name, uint64_t ram_size) diff --git a/vl.c b/vl.c index c4705b3335..5cd0c17ba0 100644 --- a/vl.c +++ b/vl.c @@ -4592,8 +4592,6 @@ int main(int argc, char **argv, char **envp) =20 cpu_synchronize_all_post_init(); =20 - numa_post_machine_init(); - rom_reset_order_override(); =20 /* --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:42 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 1494531343647982.3530120409309; Thu, 11 May 2017 12:35:43 -0700 (PDT) Received: from localhost ([::1]:49844 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tsE-0000mI-2m for importer@patchew.org; Thu, 11 May 2017 15:35:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38027) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tcY-0002n0-Ty for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tcY-0007zc-17 for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50104) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tcX-0007zV-RU for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:29 -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 D9B5E80E7C; Thu, 11 May 2017 19:19:28 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73D00173BF; Thu, 11 May 2017 19:19:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D9B5E80E7C 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=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D9B5E80E7C From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:36 -0300 Message-Id: <20170511191843.13784-23-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@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]); Thu, 11 May 2017 19:19:29 +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] [PULL 22/29] machine: call machine init from wrapper 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: Igor Mammedov , qemu-devel@nongnu.org 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" From: Igor Mammedov add machine_run_board_init() wrapper that calls machine init for now but in follow up patches it will be used to run generic machine code that should run before machine init. Signed-off-by: Igor Mammedov Reviewed-by: Andrew Jones Reviewed-by: David Gibson Reviewed-by: Eduardo Habkost Message-Id: <1494415802-227633-15-git-send-email-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- include/hw/boards.h | 1 + hw/core/machine.c | 6 ++++++ vl.c | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index 4e14ff060e..76ce0219ff 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -32,6 +32,7 @@ void memory_region_allocate_system_memory(MemoryRegion *m= r, Object *owner, MachineClass *find_default_machine(void); extern MachineState *current_machine; =20 +void machine_run_board_init(MachineState *machine); bool machine_usb(MachineState *machine); bool machine_kernel_irqchip_allowed(MachineState *machine); bool machine_kernel_irqchip_required(MachineState *machine); diff --git a/hw/core/machine.c b/hw/core/machine.c index 420c8c4d16..64e2a4ff2c 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -678,6 +678,12 @@ bool machine_mem_merge(MachineState *machine) return machine->mem_merge; } =20 +void machine_run_board_init(MachineState *machine) +{ + MachineClass *machine_class =3D MACHINE_GET_CLASS(machine); + machine_class->init(machine); +} + static void machine_class_finalize(ObjectClass *klass, void *data) { MachineClass *mc =3D MACHINE_CLASS(klass); diff --git a/vl.c b/vl.c index 5cd0c17ba0..3d8c140011 100644 --- a/vl.c +++ b/vl.c @@ -4559,7 +4559,7 @@ int main(int argc, char **argv, char **envp) current_machine->boot_order =3D boot_order; current_machine->cpu_model =3D cpu_model; =20 - machine_class->init(current_machine); + machine_run_board_init(current_machine); =20 realtime_init(); =20 --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:42 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 1494531766603804.7891447234941; Thu, 11 May 2017 12:42:46 -0700 (PDT) Received: from localhost ([::1]:49886 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tz3-0006zW-9f for importer@patchew.org; Thu, 11 May 2017 15:42:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38039) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tcb-0002pa-HH for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tca-000802-Ee for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41026) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tca-0007zs-5z for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:32 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3A45BC05AA42; Thu, 11 May 2017 19:19:31 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9BA0171C49; Thu, 11 May 2017 19:19:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3A45BC05AA42 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3A45BC05AA42 From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:37 -0300 Message-Id: <20170511191843.13784-24-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 11 May 2017 19:19:31 +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] [PULL 23/29] numa: use possible_cpus for not mapped CPUs check 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: Igor Mammedov , qemu-devel@nongnu.org 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" From: Igor Mammedov and remove corresponding part in numa.c that uses node_cpu bitmaps. Signed-off-by: Igor Mammedov Reviewed-by: David Gibson Reviewed-by: Andrew Jones Message-Id: <1494415802-227633-16-git-send-email-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- hw/core/machine.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ numa.c | 10 ---------- 2 files changed, 58 insertions(+), 10 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 64e2a4ff2c..fd6a436064 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -20,6 +20,7 @@ #include "sysemu/numa.h" #include "qemu/error-report.h" #include "qemu/cutils.h" +#include "sysemu/numa.h" =20 static char *machine_get_accel(Object *obj, Error **errp) { @@ -678,9 +679,66 @@ bool machine_mem_merge(MachineState *machine) return machine->mem_merge; } =20 +static char *cpu_slot_to_string(const CPUArchId *cpu) +{ + GString *s =3D g_string_new(NULL); + if (cpu->props.has_socket_id) { + g_string_append_printf(s, "socket-id: %"PRId64, cpu->props.socket_= id); + } + if (cpu->props.has_core_id) { + if (s->len) { + g_string_append_printf(s, ", "); + } + g_string_append_printf(s, "core-id: %"PRId64, cpu->props.core_id); + } + if (cpu->props.has_thread_id) { + if (s->len) { + g_string_append_printf(s, ", "); + } + g_string_append_printf(s, "thread-id: %"PRId64, cpu->props.thread_= id); + } + return g_string_free(s, false); +} + +static void machine_numa_validate(MachineState *machine) +{ + int i; + GString *s =3D g_string_new(NULL); + MachineClass *mc =3D MACHINE_GET_CLASS(machine); + const CPUArchIdList *possible_cpus =3D mc->possible_cpu_arch_ids(machi= ne); + + assert(nb_numa_nodes); + for (i =3D 0; i < possible_cpus->len; i++) { + const CPUArchId *cpu_slot =3D &possible_cpus->cpus[i]; + + /* at this point numa mappings are initilized by CLI options + * or with default mappings so it's sufficient to list + * all not yet mapped CPUs here */ + /* TODO: make it hard error in future */ + if (!cpu_slot->props.has_node_id) { + char *cpu_str =3D cpu_slot_to_string(cpu_slot); + g_string_append_printf(s, "%sCPU %d [%s]", s->len ? ", " : "",= i, + cpu_str); + g_free(cpu_str); + } + } + if (s->len) { + error_report("warning: CPU(s) not present in any NUMA nodes: %s", + s->str); + error_report("warning: All CPU(s) up to maxcpus should be describe= d " + "in NUMA config, ability to start up with partial NUM= A " + "mappings is obsoleted and will be removed in future"= ); + } + g_string_free(s, true); +} + void machine_run_board_init(MachineState *machine) { MachineClass *machine_class =3D MACHINE_GET_CLASS(machine); + + if (nb_numa_nodes) { + machine_numa_validate(machine); + } machine_class->init(machine); } =20 diff --git a/numa.c b/numa.c index dc739eadfa..63bff5a54d 100644 --- a/numa.c +++ b/numa.c @@ -337,16 +337,6 @@ static void validate_numa_cpus(void) bitmap_or(seen_cpus, seen_cpus, numa_info[i].node_cpu, max_cpus); } - - if (!bitmap_full(seen_cpus, max_cpus)) { - char *msg; - bitmap_complement(seen_cpus, seen_cpus, max_cpus); - msg =3D enumerate_cpus(seen_cpus, max_cpus); - error_report("warning: CPU(s) not present in any NUMA nodes: %s", = msg); - error_report("warning: All CPU(s) up to maxcpus should be describe= d " - "in NUMA config"); - g_free(msg); - } g_free(seen_cpus); } =20 --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:42 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 1494531246183872.9849908149794; Thu, 11 May 2017 12:34:06 -0700 (PDT) Received: from localhost ([::1]:49813 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tqe-0007oj-Iv for importer@patchew.org; Thu, 11 May 2017 15:34:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38073) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tcf-0002rJ-Jm for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tcc-00080O-DJ for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57608) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tcc-00080C-3m for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:34 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 234093DBFC; Thu, 11 May 2017 19:19:33 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 89D4578F28; Thu, 11 May 2017 19:19:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 234093DBFC Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 234093DBFC From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:38 -0300 Message-Id: <20170511191843.13784-25-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 11 May 2017 19:19:33 +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] [PULL 24/29] numa: remove node_cpu bitmaps as they are no longer used 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: Igor Mammedov , qemu-devel@nongnu.org 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" From: Igor Mammedov Postfactum "CPU(s) present in multiple NUMA nodes" check was the last user of node_cpu bitmaps, but it's not need as machine_set_cpu_numa_node() does the similar check at the time mapping is set for cpus (i.e. when -numa cpus=3D is parsed) and ensures that cpu can be mapped only to one node. Remove duplicate check based on node_cpu bitmaps and since the last user is gone remove node_cpu as well, which completes internal transition from legacy bitmap based mapping storage to possible_cpus storage. Signed-off-by: Igor Mammedov Reviewed-by: David Gibson Reviewed-by: Andrew Jones Message-Id: <1494415802-227633-17-git-send-email-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- include/sysemu/numa.h | 1 - numa.c | 43 ------------------------------------------- 2 files changed, 44 deletions(-) diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index 8cb3ebc233..7ffde5b119 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -18,7 +18,6 @@ struct numa_addr_range { =20 struct node_info { uint64_t node_mem; - unsigned long *node_cpu; struct HostMemoryBackend *node_memdev; bool present; QLIST_HEAD(, numa_addr_range) addr; /* List to store address ranges */ diff --git a/numa.c b/numa.c index 63bff5a54d..ca122ccb13 100644 --- a/numa.c +++ b/numa.c @@ -178,7 +178,6 @@ static void parse_numa_node(MachineState *ms, NumaNodeO= ptions *node, cpus->value, max_cpus); return; } - bitmap_set(numa_info[nodenr].node_cpu, cpus->value, 1); props =3D mc->cpu_index_to_instance_props(ms, cpus->value); props.node_id =3D nodenr; props.has_node_id =3D true; @@ -305,41 +304,6 @@ end: return 0; } =20 -static char *enumerate_cpus(unsigned long *cpus, int max_cpus) -{ - int cpu; - bool first =3D true; - GString *s =3D g_string_new(NULL); - - for (cpu =3D find_first_bit(cpus, max_cpus); - cpu < max_cpus; - cpu =3D find_next_bit(cpus, max_cpus, cpu + 1)) { - g_string_append_printf(s, "%s%d", first ? "" : " ", cpu); - first =3D false; - } - return g_string_free(s, FALSE); -} - -static void validate_numa_cpus(void) -{ - int i; - unsigned long *seen_cpus =3D bitmap_new(max_cpus); - - for (i =3D 0; i < nb_numa_nodes; i++) { - if (bitmap_intersects(seen_cpus, numa_info[i].node_cpu, max_cpus))= { - bitmap_and(seen_cpus, seen_cpus, - numa_info[i].node_cpu, max_cpus); - error_report("CPU(s) present in multiple NUMA nodes: %s", - enumerate_cpus(seen_cpus, max_cpus)); - g_free(seen_cpus); - exit(EXIT_FAILURE); - } - bitmap_or(seen_cpus, seen_cpus, - numa_info[i].node_cpu, max_cpus); - } - g_free(seen_cpus); -} - /* If all node pair distances are symmetric, then only distances * in one direction are enough. If there is even one asymmetric * pair, though, then all distances must be provided. The @@ -451,10 +415,6 @@ void parse_numa_opts(MachineState *ms) const CPUArchIdList *possible_cpus; MachineClass *mc =3D MACHINE_GET_CLASS(ms); =20 - for (i =3D 0; i < MAX_NODES; i++) { - numa_info[i].node_cpu =3D bitmap_new(max_cpus); - } - if (qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, ms, NULL)) { exit(1); } @@ -531,13 +491,10 @@ void parse_numa_opts(MachineState *ms) props =3D mc->cpu_index_to_instance_props(ms, i); props.has_node_id =3D true; =20 - set_bit(i, numa_info[props.node_id].node_cpu); machine_set_cpu_numa_node(ms, &props, &error_fatal); } } =20 - validate_numa_cpus(); - /* QEMU needs at least all unique node pair distances to build * the whole NUMA distance table. QEMU treats the distance table * as symmetric by default, i.e. distance A->B =3D=3D distance B->= A. --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:42 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 1494530879029412.3732669979894; Thu, 11 May 2017 12:27:59 -0700 (PDT) Received: from localhost ([::1]:49789 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tkj-0002A7-DL for importer@patchew.org; Thu, 11 May 2017 15:27:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38079) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tcf-0002rY-Rg for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tce-00080v-Cs for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47404) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tce-00080m-3Y for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:36 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1F59F80474; Thu, 11 May 2017 19:19:35 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8167C78F26; Thu, 11 May 2017 19:19:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1F59F80474 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1F59F80474 From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:39 -0300 Message-Id: <20170511191843.13784-26-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 11 May 2017 19:19:35 +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] [PULL 25/29] numa: add '-numa cpu, ...' option for property based node mapping 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: Igor Mammedov , qemu-devel@nongnu.org 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" From: Igor Mammedov legacy cpu to node mapping is using cpu index values to map VCPU to node with help of '-numa node,nodeid=3Dnode,cpus=3Dx[-y]' option. However cpu index is internal concept and QEMU users have to guess /reimplement qemu's logic/ to map it to a concrete cpu socket/core/thread to make sane CPUs placement across numa nodes. This patch allows to map cpu objects to numa nodes using the same properties as used for cpus with -device/device_add (socket-id/core-id/thread-id/node-id). At present valid properties/values to address CPUs could be fetched using hotpluggable-cpus monitor/qmp command, it will require user to start qemu twice when creating domain to fetch possible CPUs for a machine type/-smp layout first and then the second time with numa explicit mapping for actual usage. The first step results could be saved and reused to set/change mapping later as far as machine type/-smp stays the same. Proposed impl. supports exact and wildcard matching to simplify CLI and allow to set mapping for a specific cpu or group of cpu objects specified by matched properties. For example: # exact mapping x86 -numa cpu,node-id=3Dx,socket-id=3Dy,core-id=3Dz,thread-id=3Dn # exact mapping SPAPR -numa cpu,node-id=3Dx,core-id=3Dy # wildcard mapping, all cpu objects that match socket-id=3Dy # are mapped to node-id=3Dx -numa cpu,node-id=3Dx,socket-id=3Dy Signed-off-by: Igor Mammedov Message-Id: <1494415802-227633-18-git-send-email-imammedo@redhat.com> Reviewed-by: David Gibson Signed-off-by: Eduardo Habkost --- qapi-schema.json | 21 +++++++++++++++++++-- numa.c | 15 +++++++++++++++ qemu-options.hx | 20 ++++++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index c3051fb901..80603cfc51 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -5690,10 +5690,12 @@ # # @dist: NUMA distance configuration (since 2.10) # +# @cpu: property based CPU(s) to node mapping (Since: 2.10) +# # Since: 2.1 ## { 'enum': 'NumaOptionsType', - 'data': [ 'node', 'dist' ] } + 'data': [ 'node', 'dist', 'cpu' ] } =20 ## # @NumaOptions: @@ -5707,7 +5709,8 @@ 'discriminator': 'type', 'data': { 'node': 'NumaNodeOptions', - 'dist': 'NumaDistOptions' }} + 'dist': 'NumaDistOptions', + 'cpu': 'NumaCpuOptions' }} =20 ## # @NumaNodeOptions: @@ -5757,6 +5760,20 @@ 'val': 'uint8' }} =20 ## +# @NumaCpuOptions: +# +# Option "-numa cpu" overrides default cpu to node mapping. +# It accepts the same set of cpu properties as returned by +# query-hotpluggable-cpus[].props, where node-id could be used to +# override default node mapping. +# +# Since: 2.10 +## +{ 'struct': 'NumaCpuOptions', + 'base': 'CpuInstanceProperties', + 'data' : {} } + +## # @HostMemPolicy: # # Host memory policy types diff --git a/numa.c b/numa.c index ca122ccb13..84ce2af9b4 100644 --- a/numa.c +++ b/numa.c @@ -290,6 +290,21 @@ static int parse_numa(void *opaque, QemuOpts *opts, Er= ror **errp) goto end; } break; + case NUMA_OPTIONS_TYPE_CPU: + if (!object->u.cpu.has_node_id) { + error_setg(&err, "Missing mandatory node-id property"); + goto end; + } + if (!numa_info[object->u.cpu.node_id].present) { + error_setg(&err, "Invalid node-id=3D%" PRId64 ", NUMA node mus= t be " + "defined with -numa node,nodeid=3DID before it's used with= " + "-numa cpu,node-id=3DID", object->u.cpu.node_id); + goto end; + } + + machine_set_cpu_numa_node(ms, qapi_NumaCpuOptions_base(&object->u.= cpu), + &err); + break; default: abort(); } diff --git a/qemu-options.hx b/qemu-options.hx index e10c1454d1..6ffa98097d 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -145,10 +145,12 @@ STEXI @item -numa node[,mem=3D@var{size}][,cpus=3D@var{firstcpu}[-@var{lastcpu}]= ][,nodeid=3D@var{node}] @itemx -numa node[,memdev=3D@var{id}][,cpus=3D@var{firstcpu}[-@var{lastcpu= }]][,nodeid=3D@var{node}] @itemx -numa dist,src=3D@var{source},dst=3D@var{destination},val=3D@var{di= stance} +@itemx -numa cpu,node-id=3D@var{node}[,socket-id=3D@var{x}][,core-id=3D@va= r{y}][,thread-id=3D@var{z}] @findex -numa Define a NUMA node and assign RAM and VCPUs to it. Set the NUMA distance from a source node to a destination node. =20 +Legacy VCPU assignment uses @samp{cpus} option where @var{firstcpu} and @var{lastcpu} are CPU indexes. Each @samp{cpus} option represent a contiguous range of CPU indexes (or a single VCPU if @var{lastcpu} is omitted). A non-contiguous @@ -162,6 +164,24 @@ a NUMA node: -numa node,cpus=3D0-2,cpus=3D5 @end example =20 +@samp{cpu} option is a new alternative to @samp{cpus} option +which uses @samp{socket-id|core-id|thread-id} properties to assign +CPU objects to a @var{node} using topology layout properties of CPU. +The set of properties is machine specific, and depends on used +machine type/@samp{smp} options. It could be queried with +@samp{hotpluggable-cpus} monitor command. +@samp{node-id} property specifies @var{node} to which CPU object +will be assigned, it's required for @var{node} to be declared +with @samp{node} option before it's used with @samp{cpu} option. + +For example: +@example +-M pc \ +-smp 1,sockets=3D2,maxcpus=3D2 \ +-numa node,nodeid=3D0 -numa node,nodeid=3D1 \ +-numa cpu,node-id=3D0,socket-id=3D0 -numa cpu,node-id=3D1,socket-id=3D1 +@end example + @samp{mem} assigns a given RAM amount to a node. @samp{memdev} assigns RAM from a given memory backend device to a node. If @samp{mem} and @samp{memdev} are omitted in all nodes, RAM is --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:42 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 1494531022270738.8405084569617; Thu, 11 May 2017 12:30:22 -0700 (PDT) Received: from localhost ([::1]:49797 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tn2-0004MN-R5 for importer@patchew.org; Thu, 11 May 2017 15:30:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38108) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tch-0002tH-Ey for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tcg-00081d-8j for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59888) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tcg-00081D-00 for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:38 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 07EC19D0DB; Thu, 11 May 2017 19:19:37 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 75A5517DB0; Thu, 11 May 2017 19:19:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 07EC19D0DB Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 07EC19D0DB From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:40 -0300 Message-Id: <20170511191843.13784-27-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 11 May 2017 19:19:37 +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] [PULL 26/29] tests: check -numa node, cpu=props_list usecase 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: Igor Mammedov , qemu-devel@nongnu.org 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" From: Igor Mammedov Signed-off-by: Igor Mammedov Reviewed-by: David Gibson Message-Id: <1494415802-227633-19-git-send-email-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- tests/numa-test.c | 151 ++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 151 insertions(+) diff --git a/tests/numa-test.c b/tests/numa-test.c index 27226877af..c3475d6d5e 100644 --- a/tests/numa-test.c +++ b/tests/numa-test.c @@ -131,6 +131,144 @@ static void test_query_cpus(const void *data) g_free(cli); } =20 +static void pc_numa_cpu(const void *data) +{ + char *cli; + QDict *resp; + QList *cpus; + const QObject *e; + + cli =3D make_cli(data, "-cpu pentium -smp 8,sockets=3D2,cores=3D2,thre= ads=3D2 " + "-numa node,nodeid=3D0 -numa node,nodeid=3D1 " + "-numa cpu,node-id=3D1,socket-id=3D0 " + "-numa cpu,node-id=3D0,socket-id=3D1,core-id=3D0 " + "-numa cpu,node-id=3D0,socket-id=3D1,core-id=3D1,thread-id=3D0 " + "-numa cpu,node-id=3D1,socket-id=3D1,core-id=3D1,thread-id=3D1"); + qtest_start(cli); + cpus =3D get_cpus(&resp); + g_assert(cpus); + + while ((e =3D qlist_pop(cpus))) { + QDict *cpu, *props; + int64_t socket, core, thread, node; + + cpu =3D qobject_to_qdict(e); + g_assert(qdict_haskey(cpu, "props")); + props =3D qdict_get_qdict(cpu, "props"); + + g_assert(qdict_haskey(props, "node-id")); + node =3D qdict_get_int(props, "node-id"); + g_assert(qdict_haskey(props, "socket-id")); + socket =3D qdict_get_int(props, "socket-id"); + g_assert(qdict_haskey(props, "core-id")); + core =3D qdict_get_int(props, "core-id"); + g_assert(qdict_haskey(props, "thread-id")); + thread =3D qdict_get_int(props, "thread-id"); + + if (socket =3D=3D 0) { + g_assert_cmpint(node, =3D=3D, 1); + } else if (socket =3D=3D 1 && core =3D=3D 0) { + g_assert_cmpint(node, =3D=3D, 0); + } else if (socket =3D=3D 1 && core =3D=3D 1 && thread =3D=3D 0) { + g_assert_cmpint(node, =3D=3D, 0); + } else if (socket =3D=3D 1 && core =3D=3D 1 && thread =3D=3D 1) { + g_assert_cmpint(node, =3D=3D, 1); + } else { + g_assert(false); + } + } + + QDECREF(resp); + qtest_end(); + g_free(cli); +} + +static void spapr_numa_cpu(const void *data) +{ + char *cli; + QDict *resp; + QList *cpus; + const QObject *e; + + cli =3D make_cli(data, "-smp 4,cores=3D4 " + "-numa node,nodeid=3D0 -numa node,nodeid=3D1 " + "-numa cpu,node-id=3D0,core-id=3D0 " + "-numa cpu,node-id=3D0,core-id=3D1 " + "-numa cpu,node-id=3D0,core-id=3D2 " + "-numa cpu,node-id=3D1,core-id=3D3"); + qtest_start(cli); + cpus =3D get_cpus(&resp); + g_assert(cpus); + + while ((e =3D qlist_pop(cpus))) { + QDict *cpu, *props; + int64_t core, node; + + cpu =3D qobject_to_qdict(e); + g_assert(qdict_haskey(cpu, "props")); + props =3D qdict_get_qdict(cpu, "props"); + + g_assert(qdict_haskey(props, "node-id")); + node =3D qdict_get_int(props, "node-id"); + g_assert(qdict_haskey(props, "core-id")); + core =3D qdict_get_int(props, "core-id"); + + if (core >=3D 0 && core < 3) { + g_assert_cmpint(node, =3D=3D, 0); + } else if (core =3D=3D 3) { + g_assert_cmpint(node, =3D=3D, 1); + } else { + g_assert(false); + } + } + + QDECREF(resp); + qtest_end(); + g_free(cli); +} + +static void aarch64_numa_cpu(const void *data) +{ + char *cli; + QDict *resp; + QList *cpus; + const QObject *e; + + cli =3D make_cli(data, "-smp 2 " + "-numa node,nodeid=3D0 -numa node,nodeid=3D1 " + "-numa cpu,node-id=3D1,thread-id=3D0 " + "-numa cpu,node-id=3D0,thread-id=3D1"); + qtest_start(cli); + cpus =3D get_cpus(&resp); + g_assert(cpus); + + while ((e =3D qlist_pop(cpus))) { + QDict *cpu, *props; + int64_t thread, node; + + cpu =3D qobject_to_qdict(e); + g_assert(qdict_haskey(cpu, "props")); + props =3D qdict_get_qdict(cpu, "props"); + + g_assert(qdict_haskey(props, "node-id")); + node =3D qdict_get_int(props, "node-id"); + g_assert(qdict_haskey(props, "thread-id")); + thread =3D qdict_get_int(props, "thread-id"); + + if (thread =3D=3D 0) { + g_assert_cmpint(node, =3D=3D, 1); + } else if (thread =3D=3D 1) { + g_assert_cmpint(node, =3D=3D, 0); + } else { + g_assert(false); + } + } + + QDECREF(resp); + qtest_end(); + g_free(cli); +} + int main(int argc, char **argv) { const char *args =3D NULL; @@ -147,5 +285,18 @@ int main(int argc, char **argv) qtest_add_data_func("/numa/mon/cpus/partial", args, test_mon_partial); qtest_add_data_func("/numa/qmp/cpus/query-cpus", args, test_query_cpus= ); =20 + if (!strcmp(arch, "i386") || !strcmp(arch, "x86_64")) { + qtest_add_data_func("/numa/pc/cpu/explicit", args, pc_numa_cpu); + } + + if (!strcmp(arch, "ppc64")) { + qtest_add_data_func("/numa/spapr/cpu/explicit", args, spapr_numa_c= pu); + } + + if (!strcmp(arch, "aarch64")) { + qtest_add_data_func("/numa/aarch64/cpu/explicit", args, + aarch64_numa_cpu); + } + return g_test_run(); } --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:42 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 1494531179638853.6516223157478; Thu, 11 May 2017 12:32:59 -0700 (PDT) Received: from localhost ([::1]:49811 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tpa-0006wS-5Y for importer@patchew.org; Thu, 11 May 2017 15:32:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tcj-0002vK-AH for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tci-000829-4A for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28127) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tch-00081u-SL for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:40 -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 D91B67F4BC; Thu, 11 May 2017 19:19:38 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 625BE8A8C1; Thu, 11 May 2017 19:19:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D91B67F4BC Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D91B67F4BC From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:41 -0300 Message-Id: <20170511191843.13784-28-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@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.26]); Thu, 11 May 2017 19:19:39 +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] [PULL 27/29] migration/i386: Remove old non-softfloat 64bit FP support 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-devel@nongnu.org, "Dr. David Alan Gilbert" 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" From: "Dr. David Alan Gilbert" Long long ago, we used to support storing the x86 FP registers in a 64bit format. Then c31da136a0bf8caad70c348f5ffc283206e9c7fc in v0.14-rc0 removed the last support for writing that in the migration format. Even before that, it was only used if you had softfloat disabled (i.e. !USE_X86LDOUBLE) so in practice use of it in even earlier qemu is unlikely for most users. Kill it off, it's complicated, and possibly broken. Signed-off-by: Dr. David Alan Gilbert Message-Id: <20170405190024.27581-2-dgilbert@redhat.com> Reviewed-by: Juan Quintela Signed-off-by: Eduardo Habkost --- target/i386/machine.c | 107 +++-------------------------------------------= ---- 1 file changed, 6 insertions(+), 101 deletions(-) diff --git a/target/i386/machine.c b/target/i386/machine.c index 78ae2f986b..bf9567cbd4 100644 --- a/target/i386/machine.c +++ b/target/i386/machine.c @@ -136,36 +136,6 @@ static const VMStateDescription vmstate_mtrr_var =3D { #define VMSTATE_MTRR_VARS(_field, _state, _n, _v) \ VMSTATE_STRUCT_ARRAY(_field, _state, _n, _v, vmstate_mtrr_var, MTRRVar) =20 -static int put_fpreg_error(QEMUFile *f, void *opaque, size_t size, - VMStateField *field, QJSON *vmdesc) -{ - fprintf(stderr, "call put_fpreg() with invalid arguments\n"); - exit(0); - return 0; -} - -/* XXX: add that in a FPU generic layer */ -union x86_longdouble { - uint64_t mant; - uint16_t exp; -}; - -#define MANTD1(fp) (fp & ((1LL << 52) - 1)) -#define EXPBIAS1 1023 -#define EXPD1(fp) ((fp >> 52) & 0x7FF) -#define SIGND1(fp) ((fp >> 32) & 0x80000000) - -static void fp64_to_fp80(union x86_longdouble *p, uint64_t temp) -{ - int e; - /* mantissa */ - p->mant =3D (MANTD1(temp) << 11) | (1LL << 63); - /* exponent + sign */ - e =3D EXPD1(temp) - EXPBIAS1 + 16383; - e |=3D SIGND1(temp) >> 16; - p->exp =3D e; -} - static int get_fpreg(QEMUFile *f, void *opaque, size_t size, VMStateField *field) { @@ -200,76 +170,6 @@ static const VMStateInfo vmstate_fpreg =3D { .put =3D put_fpreg, }; =20 -static int get_fpreg_1_mmx(QEMUFile *f, void *opaque, size_t size, - VMStateField *field) -{ - union x86_longdouble *p =3D opaque; - uint64_t mant; - - qemu_get_be64s(f, &mant); - p->mant =3D mant; - p->exp =3D 0xffff; - return 0; -} - -static const VMStateInfo vmstate_fpreg_1_mmx =3D { - .name =3D "fpreg_1_mmx", - .get =3D get_fpreg_1_mmx, - .put =3D put_fpreg_error, -}; - -static int get_fpreg_1_no_mmx(QEMUFile *f, void *opaque, size_t size, - VMStateField *field) -{ - union x86_longdouble *p =3D opaque; - uint64_t mant; - - qemu_get_be64s(f, &mant); - fp64_to_fp80(p, mant); - return 0; -} - -static const VMStateInfo vmstate_fpreg_1_no_mmx =3D { - .name =3D "fpreg_1_no_mmx", - .get =3D get_fpreg_1_no_mmx, - .put =3D put_fpreg_error, -}; - -static bool fpregs_is_0(void *opaque, int version_id) -{ - X86CPU *cpu =3D opaque; - CPUX86State *env =3D &cpu->env; - - return (env->fpregs_format_vmstate =3D=3D 0); -} - -static bool fpregs_is_1_mmx(void *opaque, int version_id) -{ - X86CPU *cpu =3D opaque; - CPUX86State *env =3D &cpu->env; - int guess_mmx; - - guess_mmx =3D ((env->fptag_vmstate =3D=3D 0xff) && - (env->fpus_vmstate & 0x3800) =3D=3D 0); - return (guess_mmx && (env->fpregs_format_vmstate =3D=3D 1)); -} - -static bool fpregs_is_1_no_mmx(void *opaque, int version_id) -{ - X86CPU *cpu =3D opaque; - CPUX86State *env =3D &cpu->env; - int guess_mmx; - - guess_mmx =3D ((env->fptag_vmstate =3D=3D 0xff) && - (env->fpus_vmstate & 0x3800) =3D=3D 0); - return (!guess_mmx && (env->fpregs_format_vmstate =3D=3D 1)); -} - -#define VMSTATE_FP_REGS(_field, _state, _n) \ - VMSTATE_ARRAY_TEST(_field, _state, _n, fpregs_is_0, vmstate_fpreg, FPR= eg), \ - VMSTATE_ARRAY_TEST(_field, _state, _n, fpregs_is_1_mmx, vmstate_fpreg_= 1_mmx, FPReg), \ - VMSTATE_ARRAY_TEST(_field, _state, _n, fpregs_is_1_no_mmx, vmstate_fpr= eg_1_no_mmx, FPReg) - static bool version_is_5(void *opaque, int version_id) { return version_id =3D=3D 5; @@ -356,6 +256,10 @@ static int cpu_post_load(void *opaque, int version_id) return -EINVAL; } =20 + if (env->fpregs_format_vmstate) { + error_report("Unsupported old non-softfloat CPU state"); + return -EINVAL; + } /* * Real mode guest segments register DPL should be zero. * Older KVM version were setting it wrongly. @@ -943,7 +847,8 @@ VMStateDescription vmstate_x86_cpu =3D { VMSTATE_UINT16(env.fpus_vmstate, X86CPU), VMSTATE_UINT16(env.fptag_vmstate, X86CPU), VMSTATE_UINT16(env.fpregs_format_vmstate, X86CPU), - VMSTATE_FP_REGS(env.fpregs, X86CPU, 8), + + VMSTATE_STRUCT_ARRAY(env.fpregs, X86CPU, 8, 0, vmstate_fpreg, FPRe= g), =20 VMSTATE_SEGMENT_ARRAY(env.segs, X86CPU, 6), VMSTATE_SEGMENT(env.ldt, X86CPU), --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:42 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 1494531490232726.1020760207655; Thu, 11 May 2017 12:38:10 -0700 (PDT) Received: from localhost ([::1]:49852 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tua-0002pp-RA for importer@patchew.org; Thu, 11 May 2017 15:38:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38154) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tcl-0002xU-7Z for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tck-00082c-3D for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47538) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tcj-00082O-Qd for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:42 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D04DE8049D; Thu, 11 May 2017 19:19:40 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48F3217AD4; Thu, 11 May 2017 19:19:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D04DE8049D Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D04DE8049D From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:42 -0300 Message-Id: <20170511191843.13784-29-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 11 May 2017 19:19:41 +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] [PULL 28/29] vmstatification: i386 FPReg 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-devel@nongnu.org, "Dr. David Alan Gilbert" 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" From: "Dr. David Alan Gilbert" Convert the fpreg save/restore to use VMSTATE_ macros rather than .get/.put. Signed-off-by: Dr. David Alan Gilbert Message-Id: <20170405190024.27581-3-dgilbert@redhat.com> Reviewed-by: Juan Quintela Signed-off-by: Eduardo Habkost --- target/i386/machine.c | 52 +++++++++++++++++++++++++++++------------------= ---- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/target/i386/machine.c b/target/i386/machine.c index bf9567cbd4..0b4756b35f 100644 --- a/target/i386/machine.c +++ b/target/i386/machine.c @@ -136,38 +136,46 @@ static const VMStateDescription vmstate_mtrr_var =3D { #define VMSTATE_MTRR_VARS(_field, _state, _n, _v) \ VMSTATE_STRUCT_ARRAY(_field, _state, _n, _v, vmstate_mtrr_var, MTRRVar) =20 -static int get_fpreg(QEMUFile *f, void *opaque, size_t size, - VMStateField *field) +typedef struct x86_FPReg_tmp { + FPReg *parent; + uint64_t tmp_mant; + uint16_t tmp_exp; +} x86_FPReg_tmp; + +static void fpreg_pre_save(void *opaque) { - FPReg *fp_reg =3D opaque; - uint64_t mant; - uint16_t exp; + x86_FPReg_tmp *tmp =3D opaque; =20 - qemu_get_be64s(f, &mant); - qemu_get_be16s(f, &exp); - fp_reg->d =3D cpu_set_fp80(mant, exp); - return 0; + /* we save the real CPU data (in case of MMX usage only 'mant' + contains the MMX register */ + cpu_get_fp80(&tmp->tmp_mant, &tmp->tmp_exp, tmp->parent->d); } =20 -static int put_fpreg(QEMUFile *f, void *opaque, size_t size, - VMStateField *field, QJSON *vmdesc) +static int fpreg_post_load(void *opaque, int version) { - FPReg *fp_reg =3D opaque; - uint64_t mant; - uint16_t exp; - /* we save the real CPU data (in case of MMX usage only 'mant' - contains the MMX register */ - cpu_get_fp80(&mant, &exp, fp_reg->d); - qemu_put_be64s(f, &mant); - qemu_put_be16s(f, &exp); + x86_FPReg_tmp *tmp =3D opaque; =20 + tmp->parent->d =3D cpu_set_fp80(tmp->tmp_mant, tmp->tmp_exp); return 0; } =20 -static const VMStateInfo vmstate_fpreg =3D { +static const VMStateDescription vmstate_fpreg_tmp =3D { + .name =3D "fpreg_tmp", + .post_load =3D fpreg_post_load, + .pre_save =3D fpreg_pre_save, + .fields =3D (VMStateField[]) { + VMSTATE_UINT64(tmp_mant, x86_FPReg_tmp), + VMSTATE_UINT16(tmp_exp, x86_FPReg_tmp), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_fpreg =3D { .name =3D "fpreg", - .get =3D get_fpreg, - .put =3D put_fpreg, + .fields =3D (VMStateField[]) { + VMSTATE_WITH_TMP(FPReg, x86_FPReg_tmp, vmstate_fpreg_tmp), + VMSTATE_END_OF_LIST() + } }; =20 static bool version_is_5(void *opaque, int version_id) --=20 2.11.0.259.g40922b1 From nobody Thu May 2 11:58:42 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 1494531611256868.3114228897515; Thu, 11 May 2017 12:40:11 -0700 (PDT) Received: from localhost ([::1]:49860 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8twX-0004p0-S5 for importer@patchew.org; Thu, 11 May 2017 15:40:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38179) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tco-00030Y-Eh for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tcl-00083H-Sh for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41218) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tcl-00082v-Iz for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:43 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8C477C059739; Thu, 11 May 2017 19:19:42 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1FA3917D9F; Thu, 11 May 2017 19:19:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8C477C059739 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8C477C059739 From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:43 -0300 Message-Id: <20170511191843.13784-30-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 11 May 2017 19:19:42 +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] [PULL 29/29] migration/i386: Remove support for pre-0.12 formats 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-devel@nongnu.org, "Dr. David Alan Gilbert" 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" From: "Dr. David Alan Gilbert" Remove support for versions of the CPU state prior to 11 which is the version used in qemu 0.12 - you'd be pretty lucky if you got a migration stream to work from anything that old anyway. This doesn't affect the machine type definition in any way. My main reason for doing this is the hack for sysenter_esp/eip that uses .get/.put's in state versions less than 7 (that's prior to somewhere before 0.10). Signed-off-by: Dr. David Alan Gilbert Message-Id: <20170405190024.27581-4-dgilbert@redhat.com> Reviewed-by: Juan Quintela Signed-off-by: Eduardo Habkost --- target/i386/machine.c | 115 +++++++++++++++-------------------------------= ---- 1 file changed, 34 insertions(+), 81 deletions(-) diff --git a/target/i386/machine.c b/target/i386/machine.c index 0b4756b35f..3cb272948e 100644 --- a/target/i386/machine.c +++ b/target/i386/machine.c @@ -178,44 +178,6 @@ static const VMStateDescription vmstate_fpreg =3D { } }; =20 -static bool version_is_5(void *opaque, int version_id) -{ - return version_id =3D=3D 5; -} - -#ifdef TARGET_X86_64 -static bool less_than_7(void *opaque, int version_id) -{ - return version_id < 7; -} - -static int get_uint64_as_uint32(QEMUFile *f, void *pv, size_t size, - VMStateField *field) -{ - uint64_t *v =3D pv; - *v =3D qemu_get_be32(f); - return 0; -} - -static int put_uint64_as_uint32(QEMUFile *f, void *pv, size_t size, - VMStateField *field, QJSON *vmdesc) -{ - uint64_t *v =3D pv; - qemu_put_be32(f, *v); - - return 0; -} - -static const VMStateInfo vmstate_hack_uint64_as_uint32 =3D { - .name =3D "uint64_as_uint32", - .get =3D get_uint64_as_uint32, - .put =3D put_uint64_as_uint32, -}; - -#define VMSTATE_HACK_UINT32(_f, _s, _t) \ - VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_hack_uint64_as_uint32, uint= 64_t) -#endif - static void cpu_pre_save(void *opaque) { X86CPU *cpu =3D opaque; @@ -842,7 +804,7 @@ static const VMStateDescription vmstate_mcg_ext_ctl =3D= { VMStateDescription vmstate_x86_cpu =3D { .name =3D "cpu", .version_id =3D 12, - .minimum_version_id =3D 3, + .minimum_version_id =3D 11, .pre_save =3D cpu_pre_save, .post_load =3D cpu_post_load, .fields =3D (VMStateField[]) { @@ -865,16 +827,8 @@ VMStateDescription vmstate_x86_cpu =3D { VMSTATE_SEGMENT(env.idt, X86CPU), =20 VMSTATE_UINT32(env.sysenter_cs, X86CPU), -#ifdef TARGET_X86_64 - /* Hack: In v7 size changed from 32 to 64 bits on x86_64 */ - VMSTATE_HACK_UINT32(env.sysenter_esp, X86CPU, less_than_7), - VMSTATE_HACK_UINT32(env.sysenter_eip, X86CPU, less_than_7), - VMSTATE_UINTTL_V(env.sysenter_esp, X86CPU, 7), - VMSTATE_UINTTL_V(env.sysenter_eip, X86CPU, 7), -#else VMSTATE_UINTTL(env.sysenter_esp, X86CPU), VMSTATE_UINTTL(env.sysenter_eip, X86CPU), -#endif =20 VMSTATE_UINTTL(env.cr[0], X86CPU), VMSTATE_UINTTL(env.cr[2], X86CPU), @@ -895,46 +849,45 @@ VMStateDescription vmstate_x86_cpu =3D { VMSTATE_UINT64(env.fmask, X86CPU), VMSTATE_UINT64(env.kernelgsbase, X86CPU), #endif - VMSTATE_UINT32_V(env.smbase, X86CPU, 4), - - VMSTATE_UINT64_V(env.pat, X86CPU, 5), - VMSTATE_UINT32_V(env.hflags2, X86CPU, 5), - - VMSTATE_UINT32_TEST(parent_obj.halted, X86CPU, version_is_5), - VMSTATE_UINT64_V(env.vm_hsave, X86CPU, 5), - VMSTATE_UINT64_V(env.vm_vmcb, X86CPU, 5), - VMSTATE_UINT64_V(env.tsc_offset, X86CPU, 5), - VMSTATE_UINT64_V(env.intercept, X86CPU, 5), - VMSTATE_UINT16_V(env.intercept_cr_read, X86CPU, 5), - VMSTATE_UINT16_V(env.intercept_cr_write, X86CPU, 5), - VMSTATE_UINT16_V(env.intercept_dr_read, X86CPU, 5), - VMSTATE_UINT16_V(env.intercept_dr_write, X86CPU, 5), - VMSTATE_UINT32_V(env.intercept_exceptions, X86CPU, 5), - VMSTATE_UINT8_V(env.v_tpr, X86CPU, 5), + VMSTATE_UINT32(env.smbase, X86CPU), + + VMSTATE_UINT64(env.pat, X86CPU), + VMSTATE_UINT32(env.hflags2, X86CPU), + + VMSTATE_UINT64(env.vm_hsave, X86CPU), + VMSTATE_UINT64(env.vm_vmcb, X86CPU), + VMSTATE_UINT64(env.tsc_offset, X86CPU), + VMSTATE_UINT64(env.intercept, X86CPU), + VMSTATE_UINT16(env.intercept_cr_read, X86CPU), + VMSTATE_UINT16(env.intercept_cr_write, X86CPU), + VMSTATE_UINT16(env.intercept_dr_read, X86CPU), + VMSTATE_UINT16(env.intercept_dr_write, X86CPU), + VMSTATE_UINT32(env.intercept_exceptions, X86CPU), + VMSTATE_UINT8(env.v_tpr, X86CPU), /* MTRRs */ - VMSTATE_UINT64_ARRAY_V(env.mtrr_fixed, X86CPU, 11, 8), - VMSTATE_UINT64_V(env.mtrr_deftype, X86CPU, 8), + VMSTATE_UINT64_ARRAY(env.mtrr_fixed, X86CPU, 11), + VMSTATE_UINT64(env.mtrr_deftype, X86CPU), VMSTATE_MTRR_VARS(env.mtrr_var, X86CPU, MSR_MTRRcap_VCNT, 8), /* KVM-related states */ - VMSTATE_INT32_V(env.interrupt_injected, X86CPU, 9), - VMSTATE_UINT32_V(env.mp_state, X86CPU, 9), - VMSTATE_UINT64_V(env.tsc, X86CPU, 9), - VMSTATE_INT32_V(env.exception_injected, X86CPU, 11), - VMSTATE_UINT8_V(env.soft_interrupt, X86CPU, 11), - VMSTATE_UINT8_V(env.nmi_injected, X86CPU, 11), - VMSTATE_UINT8_V(env.nmi_pending, X86CPU, 11), - VMSTATE_UINT8_V(env.has_error_code, X86CPU, 11), - VMSTATE_UINT32_V(env.sipi_vector, X86CPU, 11), + VMSTATE_INT32(env.interrupt_injected, X86CPU), + VMSTATE_UINT32(env.mp_state, X86CPU), + VMSTATE_UINT64(env.tsc, X86CPU), + VMSTATE_INT32(env.exception_injected, X86CPU), + VMSTATE_UINT8(env.soft_interrupt, X86CPU), + VMSTATE_UINT8(env.nmi_injected, X86CPU), + VMSTATE_UINT8(env.nmi_pending, X86CPU), + VMSTATE_UINT8(env.has_error_code, X86CPU), + VMSTATE_UINT32(env.sipi_vector, X86CPU), /* MCE */ - VMSTATE_UINT64_V(env.mcg_cap, X86CPU, 10), - VMSTATE_UINT64_V(env.mcg_status, X86CPU, 10), - VMSTATE_UINT64_V(env.mcg_ctl, X86CPU, 10), - VMSTATE_UINT64_ARRAY_V(env.mce_banks, X86CPU, MCE_BANKS_DEF * 4, 1= 0), + VMSTATE_UINT64(env.mcg_cap, X86CPU), + VMSTATE_UINT64(env.mcg_status, X86CPU), + VMSTATE_UINT64(env.mcg_ctl, X86CPU), + VMSTATE_UINT64_ARRAY(env.mce_banks, X86CPU, MCE_BANKS_DEF * 4), /* rdtscp */ - VMSTATE_UINT64_V(env.tsc_aux, X86CPU, 11), + VMSTATE_UINT64(env.tsc_aux, X86CPU), /* KVM pvclock msr */ - VMSTATE_UINT64_V(env.system_time_msr, X86CPU, 11), - VMSTATE_UINT64_V(env.wall_clock_msr, X86CPU, 11), + VMSTATE_UINT64(env.system_time_msr, X86CPU), + VMSTATE_UINT64(env.wall_clock_msr, X86CPU), /* XSAVE related fields */ VMSTATE_UINT64_V(env.xcr0, X86CPU, 12), VMSTATE_UINT64_V(env.xstate_bv, X86CPU, 12), --=20 2.11.0.259.g40922b1