From nobody Sun Oct 12 05:09:50 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1554349211633825.2801725821583; Wed, 3 Apr 2019 20:40:11 -0700 (PDT) Received: from localhost ([127.0.0.1]:49795 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBtEW-00032O-Hh for importer@patchew.org; Wed, 03 Apr 2019 23:40:08 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56960) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBtB4-0000xi-Tr for qemu-devel@nongnu.org; Wed, 03 Apr 2019 23:36:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hBtB3-0000Ak-KD for qemu-devel@nongnu.org; Wed, 03 Apr 2019 23:36:34 -0400 Received: from mga11.intel.com ([192.55.52.93]:25556) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hBtB3-00006n-87 for qemu-devel@nongnu.org; Wed, 03 Apr 2019 23:36:33 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Apr 2019 20:36:32 -0700 Received: from vmmtaopc.sh.intel.com ([10.239.13.92]) by orsmga003.jf.intel.com with ESMTP; 03 Apr 2019 20:36:30 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,306,1549958400"; d="scan'208";a="139836887" From: Tao Xu To: imammedo@redhat.com, ehabkost@redhat.com, pbonzini@redhat.com Date: Thu, 4 Apr 2019 11:34:28 +0800 Message-Id: <20190404033429.17232-3-tao3.xu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190404033429.17232-1-tao3.xu@intel.com> References: <20190404033429.17232-1-tao3.xu@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.93 Subject: [Qemu-devel] [PATCH 2/3] numa: move numa global variable have_numa_distance into MachineState 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: jingqi.liu@intel.com, tao3.xu@intel.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The aim of this patch is to move existing numa global have_numa_distance into NumaState. Suggested-by: Igor Mammedov Suggested-by: Eduardo Habkost Signed-off-by: Tao Xu --- hw/arm/virt-acpi-build.c | 1 + hw/arm/virt.c | 1 + hw/i386/acpi-build.c | 2 +- include/hw/boards.h | 3 +++ include/sysemu/numa.h | 2 -- numa.c | 7 +++++-- 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index f9b72333a9..2a6dab6706 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -784,6 +784,7 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTa= bles *tables) GArray *tables_blob =3D tables->table_data; MachineState *ms =3D MACHINE(vms); int nb_numa_nodes =3D ms->numa_state->nb_numa_nodes; + bool have_numa_distance =3D ms->numa_state->have_numa_distance; =20 table_offsets =3D g_array_new(false, true /* clear */, sizeof(uint32_t)); diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 430189af1a..8a07f0442f 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -197,6 +197,7 @@ static void create_fdt(VirtMachineState *vms) { MachineState *ms =3D MACHINE(vms); int nb_numa_nodes =3D ms->numa_state->nb_numa_nodes; + bool have_numa_distance =3D ms->numa_state->have_numa_distance; void *fdt =3D create_device_tree(&vms->fdt_size); =20 if (!fdt) { diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 416da318ae..d092eafd19 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2685,7 +2685,7 @@ void acpi_build(AcpiBuildTables *tables, MachineState= *machine) if (pcms->numa_nodes) { acpi_add_table(table_offsets, tables_blob); build_srat(tables_blob, tables->linker, machine); - if (have_numa_distance) { + if (machine->numa_state->have_numa_distance) { acpi_add_table(table_offsets, tables_blob); build_slit(tables_blob, tables->linker); } diff --git a/include/hw/boards.h b/include/hw/boards.h index 2d4536b1a0..cd7fe0f933 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -235,6 +235,9 @@ typedef struct DeviceMemoryState { typedef struct NumaState { /* Number of NUMA nodes */ int nb_numa_nodes; + + /* Allow setting NUMA distance for different NUMA nodes */ + bool have_numa_distance; } NumaState; =20 /** diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index 6c753f9ccf..0d3920767a 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -6,8 +6,6 @@ #include "sysemu/hostmem.h" #include "hw/boards.h" =20 -extern bool have_numa_distance; - struct NodeInfo { uint64_t node_mem; struct HostMemoryBackend *node_memdev; diff --git a/numa.c b/numa.c index ff40f6f04f..a6d9951145 100644 --- a/numa.c +++ b/numa.c @@ -52,7 +52,7 @@ static int have_memdevs =3D -1; static int max_numa_nodeid; /* Highest specified NUMA node ID, plus one. * For all nodes, nodeid < max_numa_nodeid */ -bool have_numa_distance; + NodeInfo numa_info[MAX_NODES]; =20 =20 @@ -143,6 +143,8 @@ 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; + MachineState *ms =3D MACHINE(qdev_get_machine()); + =20 if (src >=3D MAX_NODES || dst >=3D MAX_NODES) { error_setg(errp, "Parameter '%s' expects an integer between 0 and = %d", @@ -170,7 +172,7 @@ static void parse_numa_distance(NumaDistOptions *dist, = Error **errp) } =20 numa_info[src].distance[dst] =3D val; - have_numa_distance =3D true; + ms->numa_state->have_numa_distance =3D true; } =20 static @@ -359,6 +361,7 @@ void numa_complete_configuration(MachineState *ms) int i; MachineClass *mc =3D MACHINE_GET_CLASS(ms); int nb_numa_nodes =3D ms->numa_state->nb_numa_nodes; + bool have_numa_distance =3D ms->numa_state->have_numa_distance; =20 /* * If memory hotplug is enabled (slots > 0) but without '-numa' --=20 2.17.1