From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1C2E1C61DA4 for ; Tue, 14 Feb 2023 10:09:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRsFE-0007Qy-2Q; Tue, 14 Feb 2023 05:09:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRsFB-0007Ql-DA for qemu-devel@nongnu.org; Tue, 14 Feb 2023 05:09:01 -0500 Received: from mga11.intel.com ([192.55.52.93]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRsF9-0008Eo-3l for qemu-devel@nongnu.org; Tue, 14 Feb 2023 05:09:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676369339; x=1707905339; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=ebYvYw9pVnyII/JGEnNQONePy4TuldpZDtvzGZqPceo=; b=PYMZA1iN5ylqcUX9Z7H7EepJS0RquimoglHRN37DALcG+53O9t4Ok4sQ FKQdxRMaabEP+PAG6R5sjzDpPLJoOqWQmU+c6II8FAtdDJtRmM7ihsH0a 0CwM4DZenlE6jh2zfuStOHVEZigCbO3ZcRGTfGk1v5paBpC0UiOg29v7w pL4PYaQUDPsuUFld3hX1GClsOY9SnAf2uQ1RuR1IWyruFapmUKsvHySNG 8JPSWC9NZGbVRikCp8btSJbFzPbeuG71qMjFxit1Qj6ukdlY3bVismVTv VEbF53O15InHtioRwhWqFU6Ac7JDbRBJWThtoEsMpyUXEpLOKfJrg6twr A==; X-IronPort-AV: E=McAfee;i="6500,9779,10620"; a="328836563" X-IronPort-AV: E=Sophos;i="5.97,296,1669104000"; d="scan'208";a="328836563" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2023 02:08:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10620"; a="646709129" X-IronPort-AV: E=Sophos;i="5.97,296,1669104000"; d="scan'208";a="646709129" Received: from liuzhao-optiplex-7080.sh.intel.com (HELO localhost) ([10.239.160.112]) by orsmga006.jf.intel.com with ESMTP; 14 Feb 2023 02:08:50 -0800 Date: Tue, 14 Feb 2023 18:16:36 +0800 From: Zhao Liu To: "wangyanan (Y)" Cc: qemu-devel@nongnu.org, Zhenyu Wang , Dapeng Mi , Zhuocheng Ding , Robert Hoo , Sean Christopherson , Like Xu , Zhao Liu , Eduardo Habkost , Marcel Apfelbaum , Philippe =?iso-8859-1?Q?Mathieu-Daud=E9?= , "Michael S . Tsirkin" , Richard Henderson , Paolo Bonzini , Eric Blake , Markus Armbruster Subject: Re: [RFC 06/52] hw/cpu: Introduce hybrid CPU topology Message-ID: References: <20230213095035.158240-1-zhao1.liu@linux.intel.com> <20230213095035.158240-7-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=gb2312 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Received-SPF: none client-ip=192.55.52.93; envelope-from=zhao1.liu@linux.intel.com; helo=mga11.intel.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, MIME_CHARSET_FARAWAY=2.45, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org On Mon, Feb 13, 2023 at 09:18:05PM +0800, wangyanan (Y) wrote: > Date: Mon, 13 Feb 2023 21:18:05 +0800 > From: "wangyanan (Y)" > Subject: Re: [RFC 06/52] hw/cpu: Introduce hybrid CPU topology > > Hi Zhao, > > ÔÚ 2023/2/13 17:49, Zhao Liu дµÀ: > > From: Zhao Liu > > > > For smp systems, the parts in one topology level are the same. But now > > there are more and more systems with hybrid architectures. Different > > parts of the same topology level may have differences. For example, > > Intel's Alder Lake series CPU has two types of cores, so the CPU > > topology is no longer symmetrical. > > > > The hybrid topology is compatible with the smp topology type, that is, > > different parts on the same level of the hybrid topology can set to be > > the same, but the hybrid topology will introduce more complexity (need > > to allocate more memory, organized with array or linked-list), so the > > original smp topology support is retained while introducing the hybrid > > topology, and the hybrid topology is only built when the hybrid is > > explicitly required. > > > > Therefore, we introduce the definition support of hybrid cpu topology > > here. At the same time, in order to unify with the original smp, we > > introduce a new cpu topology structure that can support smp topology > > or hybrid topology. This structure will replace the CpuTopology type (in > > include/hw/boards.h) used by MachineState.smp. > > > > As for now, we only support two hybrid topology levels: core and > > cluster. > > > > Signed-off-by: Zhao Liu > > --- > > MAINTAINERS | 1 + > > include/hw/cpu/cpu-topology.h | 117 ++++++++++++++++++++++++++++++++++ > > qapi/machine.json | 12 ++++ > > 3 files changed, 130 insertions(+) > > create mode 100644 include/hw/cpu/cpu-topology.h > > > > diff --git a/MAINTAINERS b/MAINTAINERS > > index 58794885ced3..918a9418d98e 100644 > > --- a/MAINTAINERS > > +++ b/MAINTAINERS > > @@ -1742,6 +1742,7 @@ F: qapi/machine-target.json > > F: include/hw/boards.h > > F: include/hw/core/cpu.h > > F: include/hw/cpu/cluster.h > > +F: include/hw/cpu/cpu-topology.h > Should't it be in include/hw/core/* directory£¿ Yes, I'll move it to the correct place. > > F: include/sysemu/numa.h > > F: tests/unit/test-smp-parse.c > > T: git https://gitlab.com/ehabkost/qemu.git machine-next > > diff --git a/include/hw/cpu/cpu-topology.h b/include/hw/cpu/cpu-topology.h > > new file mode 100644 > > index 000000000000..8268ea3a8569 > > --- /dev/null > > +++ b/include/hw/cpu/cpu-topology.h > > @@ -0,0 +1,117 @@ > > +/* > > + * CPU topology defination for Machine core > > + * > > + * Copyright (c) 2023 Intel Corporation > > + * Author: Zhao Liu > > + * > > + * This program is free software; you can redistribute it and/or modify > > + * it under the terms of the GNU General Public License as published by > > + * the Free Software Foundation; either version 2 of the License, > > + * or (at your option) any later version. > > + * > > + * This program is distributed in the hope that it will be useful, > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > > + * GNU General Public License for more details. > > + * > > + * You should have received a copy of the GNU General Public License > > + * along with this program; if not, see . > > + */ > > + > > +#ifndef CPU_TOPOLOGY_H > > +#define CPU_TOPOLOGY_H > > + > > +#include "qemu/queue.h" > > + > > +/** > > + * SmpCpuTopology - smp cpu topology defination. > > + * > > + * For smp system, the parts in one topology level are the same. > > + * > > + * @sockets: the number of sockets on the machine > > + * @dies: the number of dies in one socket > > + * @clusters: the number of clusters in one die > > + * @cores: the number of cores in one cluster > > + * @threads: the number of threads in one core > > + */ > > +typedef struct SmpCpuTopology { > > + unsigned int sockets; > > + unsigned int dies; > > + unsigned int clusters; > > + unsigned int cores; > > + unsigned int threads; > > +} SmpCpuTopology; > > + > > +/** > > + * HybridCore - hybrid core topology defination: > > + * @threads: the number of threads in one core. > > + */ > > +typedef struct HybridCore { > > + unsigned int threads; > > +} HybridCore; > > + > > +/** > > + * HybridCluster - hybrid cluster topology defination: > > + * @cores: the number of cores in current cluster. > > + * @core_list: the array includes all the cores that belong to current > > + * cluster. > > + */ > > +typedef struct HybridCluster { > > + unsigned int cores; > > + HybridCore *core_list; > > +} HybridCluster; > > + > > +/** > > + * HybridCpuTopology - hybrid cpu topology defination. > > + * > > + * At present we only support two heterogeneous topology levels: core > > + * and cluster. For heterogeneous levels, we need additional structs > > + * to define their custom internal topology. So here we defines > > + * symmetric topology levels, and use a list to point to heterogeneous > > + * levels. > > + * > > + * @sockets: the number of sockets on the machine. All sockets are the > > + * same. > > + * @dies: the number of dies in one socket. All dies are the same. > > + * @clusters: the number of clusters in one die. Cluster may be > > + * different. This field indicates the length of > > + * cluster_list. > > + * @cluster_list: the array includes all the clusters in one die. > > + */ > > +typedef struct HybridCpuTopology { > > + unsigned int sockets; > > + unsigned int dies; > > + unsigned int clusters; > > + HybridCluster *cluster_list; > > +} HybridCpuTopology; > > + > > +/** > > + * GeneralCpuTopology - General cpu topology defination. > > + * > > + * It supports one of two topologies: smp topology or hybrid topology. > > + * > > + * @cpus: the number of present logical processors on the machine > > + * @max_cpus: the maximum number of logical processors on the machine > > + * @topo_type: the topology type of the machine and this decides which > > + * member of the union to visit: smp or hybrid. > > + * @smp: the smp cpu topology informantion. Only valid when topo_type is > > + * CPU_TOPO_TYPE_SMP. > > + * @hybrid: the hybrid cpu topology informantion. Only valid when > > + * topo_type is CPU_TOPO_TYPE_HYBRID. > > + */ > > +typedef struct GeneralCpuTopology { > > + unsigned int cpus; > > + unsigned int max_cpus; > > + CpuTopoType topo_type; > > + union { > > + SmpCpuTopology smp; > > + HybridCpuTopology hybrid; > > + }; > > +} GeneralCpuTopology; /* > > + * TODO: This name is temporary, just to distinguish it > > + * from the CpuTopology in boards.h. When CpuTopology in > > + * boards.h is merged here, it will be uniformly named as > > + * CpuTopology. > > + */ > > + > A suggestion: > 1¡¢Move definition of CpuTopology from boards.h to cpu-topology.h > and re-structure it to include SmpCpuTopology, being a generic cpu > topology structure. > 2¡¢Rename "CpuTopology smp" in MachineState to a generic name > "CpuTopology topo". Here we need to change the access to MachineState.smp to MachineState.topo.smp in other modules. If replacement of MachineState.topo is in a single patch, do we also need to include the modification of access to MachineState.topo.smp in other modules? Otherwise, it will break the compilation. In this way, the patch seems be too large. Thanks, Zhao > 3¡¢Adapt all the code in QEMU to above change. > > If you can pack above into a single patch, and then add the hybird > topology extansion in a next patch, we will not need the temporary > thing "GeneralCpuTopology" and the TODO comments, which makes > code clearer. > > Thanks, > Yanan > > +#endif /* CPU_TOPOLOGY_H */ > > diff --git a/qapi/machine.json b/qapi/machine.json > > index b9228a5e4616..bd7303f34497 100644 > > --- a/qapi/machine.json > > +++ b/qapi/machine.json > > @@ -36,6 +36,18 @@ > > 'sh4eb', 'sparc', 'sparc64', 'tricore', > > 'x86_64', 'xtensa', 'xtensaeb' ] } > > +## > > +# @CpuTopoType: > > +# > > +# An enumeration of cpu topology type > > +# TODO: Expose topology type in query-cpus-fast > > +# > > +# Since: 8.0 > > +## > > +{ 'enum': 'CpuTopoType', > > + 'prefix': 'CPU_TOPO_TYPE', > > + 'data': [ 'smp', 'hybrid' ] } > > + > > ## > > # @CpuS390State: > > # >