From patchwork Tue Jul 9 07:15:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao Xu X-Patchwork-Id: 11036497 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9CBA813B1 for ; Tue, 9 Jul 2019 07:23:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8565728724 for ; Tue, 9 Jul 2019 07:23:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 799072872F; Tue, 9 Jul 2019 07:23:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0D1A928726 for ; Tue, 9 Jul 2019 07:23:00 +0000 (UTC) Received: from localhost ([::1]:47358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkkSq-00034C-A3 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 09 Jul 2019 03:23:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43350) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkkOE-0006bG-Bm for qemu-devel@nongnu.org; Tue, 09 Jul 2019 03:18:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hkkOD-0007W9-3O for qemu-devel@nongnu.org; Tue, 09 Jul 2019 03:18:14 -0400 Received: from mga17.intel.com ([192.55.52.151]:58442) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hkkOC-0007Ul-Nn for qemu-devel@nongnu.org; Tue, 09 Jul 2019 03:18:13 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jul 2019 00:18:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,469,1557212400"; d="scan'208";a="165681650" Received: from tao-optiplex-7060.sh.intel.com ([10.239.13.104]) by fmsmga008.fm.intel.com with ESMTP; 09 Jul 2019 00:18:10 -0700 From: Tao Xu To: imammedo@redhat.com, eblake@redhat.com, ehabkost@redhat.com Date: Tue, 9 Jul 2019 15:15:09 +0800 Message-Id: <20190709071520.8745-4-tao3.xu@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190709071520.8745-1-tao3.xu@intel.com> References: <20190709071520.8745-1-tao3.xu@intel.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.151 Subject: [Qemu-devel] [PATCH RESEND v6 03/14] numa: move numa global variable have_numa_distance into MachineState X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jingqi.liu@intel.com, tao3.xu@intel.com, fan.du@intel.com, qemu-devel@nongnu.org, jonathan.cameron@huawei.com, dan.j.williams@intel.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Move existing numa global have_numa_distance into NumaState. Reviewed-by: Igor Mammedov Reviewed-by: Liu Jingqi Suggested-by: Igor Mammedov Suggested-by: Eduardo Habkost Signed-off-by: Tao Xu --- Changes in v6: - rebase to upstream, move globals in arm/sbsa-ref --- hw/arm/sbsa-ref.c | 2 +- hw/arm/virt-acpi-build.c | 2 +- hw/arm/virt.c | 2 +- hw/core/numa.c | 5 ++--- hw/i386/acpi-build.c | 2 +- include/sysemu/numa.h | 4 ++-- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c index 22847909bf..7e4c471717 100644 --- a/hw/arm/sbsa-ref.c +++ b/hw/arm/sbsa-ref.c @@ -158,7 +158,7 @@ static void create_fdt(SBSAMachineState *sms) qemu_fdt_setprop_cell(fdt, "/", "#address-cells", 0x2); qemu_fdt_setprop_cell(fdt, "/", "#size-cells", 0x2); - if (have_numa_distance) { + if (ms->numa_state->have_numa_distance) { int size = nb_numa_nodes * nb_numa_nodes * 3 * sizeof(uint32_t); uint32_t *matrix = g_malloc0(size); int idx, i, j; diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index a2cc4b84fe..461a44b5b0 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -797,7 +797,7 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) if (ms->numa_state->num_nodes > 0) { acpi_add_table(table_offsets, tables_blob); build_srat(tables_blob, tables->linker, vms); - if (have_numa_distance) { + if (ms->numa_state->have_numa_distance) { acpi_add_table(table_offsets, tables_blob); build_slit(tables_blob, tables->linker, ms); } diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 01a32272b4..984f162531 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -232,7 +232,7 @@ static void create_fdt(VirtMachineState *vms) "clk24mhz"); qemu_fdt_setprop_cell(fdt, "/apb-pclk", "phandle", vms->clock_phandle); - if (have_numa_distance) { + if (nb_numa_nodes > 0 && ms->numa_state->have_numa_distance) { int size = nb_numa_nodes * nb_numa_nodes * 3 * sizeof(uint32_t); uint32_t *matrix = g_malloc0(size); int idx, i, j; diff --git a/hw/core/numa.c b/hw/core/numa.c index 4d5e308bf1..2142ec29e8 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -50,7 +50,6 @@ static int have_mem; 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]; @@ -168,7 +167,7 @@ void parse_numa_distance(MachineState *ms, NumaDistOptions *dist, Error **errp) } numa_info[src].distance[dst] = val; - have_numa_distance = true; + ms->numa_state->have_numa_distance = true; } void set_numa_options(MachineState *ms, NumaOptions *object, Error **errp) @@ -441,7 +440,7 @@ void numa_complete_configuration(MachineState *ms) * asymmetric. In this case, the distances for both directions * of all node pairs are required. */ - if (have_numa_distance) { + if (ms->numa_state->have_numa_distance) { /* Validate enough NUMA distance information was provided. */ validate_numa_distance(ms); diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 83a8551af6..243c5b85c8 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2683,7 +2683,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, machine); } diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index 3e8dbf20c1..2e5e998adb 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -6,8 +6,6 @@ #include "sysemu/hostmem.h" #include "hw/boards.h" -extern bool have_numa_distance; - struct NodeInfo { uint64_t node_mem; struct HostMemoryBackend *node_memdev; @@ -26,6 +24,8 @@ struct NumaState { /* Number of NUMA nodes */ int num_nodes; + /* Allow setting NUMA distance for different NUMA nodes */ + bool have_numa_distance; }; typedef struct NumaState NumaState;