From: Zhao Liu <zhao1.liu@linux.intel.com>
To: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: "Eduardo Habkost" <eduardo@habkost.net>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Yanan Wang" <wangyanan55@huawei.com>,
"Michael S . Tsirkin" <mst@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Eric Blake" <eblake@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
qemu-devel@nongnu.org, "Zhenyu Wang" <zhenyu.z.wang@intel.com>,
"Dapeng Mi" <dapeng1.mi@intel.com>,
"Zhuocheng Ding" <zhuocheng.ding@intel.com>,
"Robert Hoo" <robert.hu@linux.intel.com>,
"Sean Christopherson" <seanjc@google.com>,
"Like Xu" <like.xu.linux@gmail.com>,
"Zhao Liu" <zhao1.liu@intel.com>
Subject: Re: [RFC 00/52] Introduce hybrid CPU topology
Date: Fri, 4 Aug 2023 21:43:11 +0800 [thread overview]
Message-ID: <ZM0Ab1sJJFhYJSP4@liuzhao-OptiPlex-7080> (raw)
In-Reply-To: <Y+o9VIV64mjXTcpF@redhat.com>
Hi Daniel and folks,
Let me pick up this thread again to discuss some updates from my work
on QOM CPU topology. I would like to know if I'm on the right track. :-)
On Mon, Feb 13, 2023 at 01:38:28PM +0000, Daniel P. Berrangé wrote:
>
[snip]
>
> IIUC the functionality offered by -hybrid should be a superset
> of the -smp functionality. IOW, -smp ought to be possible to
> re-implement -smp as an alias for -hybrid, such that internally
> code only ever has to deal with the modern approach. Having to
> keep support for both -smp and -hybrid throughout the code is
> undesirable IMHO. Keeping the compat at the CLI parsing level
> limits the burden.
>
>
> As a more general thought, rather than introducing a new top level
> command line argument -hybrid, I'm thinking we should possibly just
> define this all using QOM and thus re-use the existing -object
> argument.
>
> I'm also finding the above example command lines quite difficult
> to understand, as there is alot of implicit linkage and expansion
> between the different levels. With devices we're much more
> explicitly with the parent/child relationships, and have to
> express everything with no automatic expansion, linking it all
> together via the id=/bus= properties. This is quite a bit more
> verbose, but it is also very effective at letting us express
> arbitrarily complex relationships.
>
> I think it would be worth exploring that approach for the CPU
> topology expression too.
>
> If we followed the more explicit device approach to modelling
> then instead of:
>
> -cpu core,...
> -cpu atom,...
> -hybrid socket,sockets=1
> -hybrid die,dies=1
> -hybrid cluster,clusters=4
> -hybrid core,cores=1,coretype="core",threads=2,clusterid=0-2
> -hybrid core,cores=4,coretype="atom",threads=1
>
> we would end up with something like
>
> -object cpu-socket,id=sock0
> -object cpu-die,id=die0,parent=sock0
> -object cpu-cluster,id=cluster0,parent=die0
> -object cpu-cluster,id=cluster1,parent=die0
> -object cpu-cluster,id=cluster2,parent=die0
> -object cpu-cluster,id=cluster3,parent=die0
> -object x86-cpu-model-atom,id=cpu0,parent=cluster0
> -object x86-cpu-model-atom,id=cpu1,parent=cluster0
> -object x86-cpu-model-atom,id=cpu2,parent=cluster0
> -object x86-cpu-model-atom,id=cpu3,parent=cluster0
> -object x86-cpu-model-core,id=cpu4,parent=cluster0,threads=2
> -object x86-cpu-model-atom,id=cpu5,parent=cluster1
> -object x86-cpu-model-atom,id=cpu6,parent=cluster1
> -object x86-cpu-model-atom,id=cpu7,parent=cluster1
> -object x86-cpu-model-atom,id=cpu8,parent=cluster1
> -object x86-cpu-model-core,id=cpu9,parent=cluster1,threads=2
> -object x86-cpu-model-atom,id=cpu10,parent=cluster2
> -object x86-cpu-model-atom,id=cpu11,parent=cluster2
> -object x86-cpu-model-atom,id=cpu12,parent=cluster2
> -object x86-cpu-model-atom,id=cpu13,parent=cluster2
> -object x86-cpu-model-core,id=cpu14,parent=cluster2,threads=2
> -object x86-cpu-model-atom,id=cpu15,parent=cluster3
> -object x86-cpu-model-atom,id=cpu16,parent=cluster3
> -object x86-cpu-model-atom,id=cpu17,parent=cluster3
> -object x86-cpu-model-atom,id=cpu18,parent=cluster3
> -object x86-cpu-model-core,id=cpu19,parent=cluster3,threads=2
>
> The really obvious downside is that it is much more verbose.
I find the "core" and "cluster" already have the abstraction as the
device, and Andreas also tried to abstract "socket" as the device.
So I find in this QOM way, all CPU topology levels should be
abstracted to devices and created via "-device". And I also need to
extend "cluster" device to support VM case as a general CPU topology
abstraction, not only just used in TCG emulation.
I've done a preliminary POC so far, where I can create the CPU topology
via "-device", and also added the ability to create the "child"
relationship in "-device" (since neither the "link" relationship nor
the bus looks like a good representation of the CPU hierarchy).
There's an example:
-device cpu-socket,id=sock0 \
-device cpu-die,id=die0,parent=sock0 \
-device cpu-die,id=die1,parent=sock0 \
-device cpu-cluster,id=cluster0,parent=die0 \
-device cpu-cluster,id=cluster1,parent=die0 \
-device cpu-cluster,id=cluster2,parent=die1 \
-device x86-intel-core,id=core0,parent=cluster0,threads=3 \
-device x86-intel-atom,id=core1,parent=cluster0,threads=2 \
-device x86-core,id=core2,parent=cluster1,threads=1 \
-device x86-intel-core,id=core3,parent=cluster2,threads=5 \
with the above format, I could build the the more accurate canonical
path for CPUs like this:
(QEMU) query-hotpluggable-cpus
{
"arguments": {},
"execute": "query-hotpluggable-cpus"
}
{
"return": [
{
"props": {
"cluster-id": 0,
"core-id": 0,
"die-id": 1,
"socket-id": 0,
"thread-id": 4
},
"qom-path": "/machine/peripheral/cpu-slot/sock0/die1/cluster2/core3/host-x86_64-cpu[10]",
"type": "host-x86_64-cpu",
"vcpus-count": 1
},
{
"props": {
"cluster-id": 0,
"core-id": 0,
"die-id": 1,
"socket-id": 0,
"thread-id": 3
},
"qom-path": "/machine/peripheral/cpu-slot/sock0/die1/cluster2/core3/host-x86_64-cpu[9]",
"type": "host-x86_64-cpu",
"vcpus-count": 1
},
{
"props": {
"cluster-id": 0,
"core-id": 0,
"die-id": 1,
"socket-id": 0,
"thread-id": 2
},
"qom-path": "/machine/peripheral/cpu-slot/sock0/die1/cluster2/core3/host-x86_64-cpu[8]",
"type": "host-x86_64-cpu",
"vcpus-count": 1
},
{
"props": {
"cluster-id": 0,
"core-id": 0,
"die-id": 1,
"socket-id": 0,
"thread-id": 1
},
"qom-path": "/machine/peripheral/cpu-slot/sock0/die1/cluster2/core3/host-x86_64-cpu[7]",
"type": "host-x86_64-cpu",
"vcpus-count": 1
},
{
"props": {
"cluster-id": 0,
"core-id": 0,
"die-id": 1,
"socket-id": 0,
"thread-id": 0
},
"qom-path": "/machine/peripheral/cpu-slot/sock0/die1/cluster2/core3/host-x86_64-cpu[6]",
"type": "host-x86_64-cpu",
"vcpus-count": 1
},
{
"props": {
"cluster-id": 1,
"core-id": 0,
"die-id": 0,
"socket-id": 0,
"thread-id": 0
},
"qom-path": "/machine/peripheral/cpu-slot/sock0/die0/cluster1/core2/host-x86_64-cpu[5]",
"type": "host-x86_64-cpu",
"vcpus-count": 1
},
{
"props": {
"cluster-id": 0,
"core-id": 1,
"die-id": 0,
"socket-id": 0,
"thread-id": 1
},
"qom-path": "/machine/peripheral/cpu-slot/sock0/die0/cluster0/core1/host-x86_64-cpu[4]",
"type": "host-x86_64-cpu",
"vcpus-count": 1
},
{
"props": {
"cluster-id": 0,
"core-id": 1,
"die-id": 0,
"socket-id": 0,
"thread-id": 0
},
"qom-path": "/machine/peripheral/cpu-slot/sock0/die0/cluster0/core1/host-x86_64-cpu[3]",
"type": "host-x86_64-cpu",
"vcpus-count": 1
},
{
"props": {
"cluster-id": 0,
"core-id": 0,
"die-id": 0,
"socket-id": 0,
"thread-id": 2
},
"qom-path": "/machine/peripheral/cpu-slot/sock0/die0/cluster0/core0/host-x86_64-cpu[2]",
"type": "host-x86_64-cpu",
"vcpus-count": 1
},
{
"props": {
"cluster-id": 0,
"core-id": 0,
"die-id": 0,
"socket-id": 0,
"thread-id": 1
},
"qom-path": "/machine/peripheral/cpu-slot/sock0/die0/cluster0/core0/host-x86_64-cpu[1]",
"type": "host-x86_64-cpu",
"vcpus-count": 1
},
{
"props": {
"cluster-id": 0,
"core-id": 0,
"die-id": 0,
"socket-id": 0,
"thread-id": 0
},
"qom-path": "/machine/peripheral/cpu-slot/sock0/die0/cluster0/core0/host-x86_64-cpu[0]",
"type": "host-x86_64-cpu",
"vcpus-count": 1
}
]
}
Of course, I'm still a bit far from the full QOM topology support, but
would like to hear comments at the POC stage as well! :-)
Thanks and BR,
Zhao
>
> This example only has 20 CPUs. For a VM with say 1000 CPUs
> this will be very big, but that doesn't neccesarily make it
> wrong.
>
> On the flipside
>
> * It is really clear exactly how many CPUs I've added
>
> * The relationship between the topology levels is clear
>
> * Every CPU has a unique ID given that can be used in
> later QMP commands
>
> * Whether or not 'threads' are permitted is now a property
> of the specific CPU model implementation, not the global
> config. IOW we can express that some CPU models allowing
> for threads, and some don't.
>
> * The -cpu arg is also obsoleted, replaced by the
> -object x86-cpu-model-core. This might facilitate the
> modelling of machines with CPUs from different architectures.
>
>
> We could potentially compress the leaf node level by expressing
> how many instances of an object we want. it we want. ie, define
> a more convenient shorthand syntax to creating many instances of
> an object. so eg
>
> -object-set $TYPE,$PROPS,idbase=foo,count=4
>
> would be functionally identical to
>
> -object $TYPE,$PROPS,id=foo.0
> -object $TYPE,$PROPS,id=foo.1
> -object $TYPE,$PROPS,id=foo.2
> -object $TYPE,$PROPS,id=foo.3
>
> QEMU just expands it and creates all the objects internally.
>
> So the huge example I have above for 20 cpus would become much
> shorter: e.g.
>
> -object cpu-socket,id=sock0
> -object cpu-die,id=die0,parent=sock0
> -object cpu-cluster,id=cluster0,parent=die0
> -object cpu-cluster,id=cluster1,parent=die0
> -object cpu-cluster,id=cluster2,parent=die0
> -object cpu-cluster,id=cluster3,parent=die0
> -object-set x86-cpu-core-atom,idbase=cpu0,parent=cluster0,count=4
> -object-set x86-cpu-core-core,id=cpu1,parent=cluster0,threads=2,count=1
> -object-set x86-cpu-core-atom,idbase=cpu2,parent=cluster1,count=4
> -object-set x86-cpu-core-core,id=cpu3,parent=cluster1,threads=2,count=1
> -object-set x86-cpu-core-atom,idbase=cpu4,parent=cluster2,count=4
> -object-set x86-cpu-core-core,id=cpu5,parent=cluster2,threads=2,count=1
> -object-set x86-cpu-core-atom,idbase=cpu6,parent=cluster3,count=4
> -object-set x86-cpu-core-core,id=cpu7,parent=cluster3,threads=2,count=1
>
> IOW, the size of the CLI config only depends on the number of elements
> in the hierarchy, and is independant of the number of leaf CPU cores.
>
> Obviously in describing all of the above, I've ignored any complexity
> of dealing with our existing code implementation and pain of getting
> it converted to the new model.
>
> With regards,
> Daniel
> --
> |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org -o- https://fstop138.berrange.com :|
> |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
>
prev parent reply other threads:[~2023-08-04 13:33 UTC|newest]
Thread overview: 113+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-13 9:49 [RFC 00/52] Introduce hybrid CPU topology Zhao Liu
2023-02-13 9:49 ` [RFC 01/52] hw/smbios: Fix smbios_smp_sockets caculation Zhao Liu
2023-02-13 9:49 ` [RFC 02/52] hw/smbios: Fix thread count in type4 Zhao Liu
2023-02-13 9:49 ` [RFC 03/52] hw/smbios: Fix core " Zhao Liu
2023-02-13 9:49 ` [RFC 04/52] i386/WHPX: Fix error message when fail to set ProcessorCount Zhao Liu
2023-02-13 13:41 ` Daniel P. Berrangé
2023-02-15 2:29 ` Zhao Liu
2023-02-13 9:49 ` [RFC 05/52] hw/core/machine: Rename machine-smp.c to machine-topo.c Zhao Liu
2023-02-13 12:52 ` wangyanan (Y) via
2023-02-14 8:50 ` Zhao Liu
2023-02-13 9:49 ` [RFC 06/52] hw/cpu: Introduce hybrid CPU topology Zhao Liu
2023-02-13 13:10 ` Philippe Mathieu-Daudé
2023-02-14 9:30 ` Zhao Liu
2023-02-14 9:27 ` Philippe Mathieu-Daudé
2023-02-15 3:15 ` Zhao Liu
2023-02-13 13:18 ` wangyanan (Y) via
2023-02-14 10:16 ` Zhao Liu
2023-02-14 11:23 ` wangyanan (Y) via
2023-02-15 3:22 ` Zhao Liu
2023-02-13 9:49 ` [RFC 07/52] hw/core/machine: Add the new topology support in MachineState Zhao Liu
2023-02-13 9:49 ` [RFC 08/52] machine: Add helpers to get cpu topology info from MachineState.topo Zhao Liu
2023-02-14 1:12 ` Mi, Dapeng1
2023-02-15 2:31 ` Zhao Liu
2023-02-16 8:38 ` wangyanan (Y) via
2023-02-17 3:07 ` Zhao Liu
2023-02-17 7:41 ` wangyanan (Y) via
2023-02-17 9:07 ` Zhao Liu
2023-02-13 9:49 ` [RFC 09/52] hw/machine: Introduce core type for hybrid topology Zhao Liu
2023-02-13 13:13 ` Philippe Mathieu-Daudé
2023-02-14 9:41 ` Zhao Liu
2023-02-14 1:14 ` Mi, Dapeng1
2023-02-15 2:40 ` Zhao Liu
2023-02-13 9:49 ` [RFC 10/52] machine: Replace MachineState.topo.smp access with topology helpers Zhao Liu
2023-02-13 9:49 ` [RFC 11/52] accel/kvm: Add hybrid info when check cpu num Zhao Liu
2023-02-13 9:49 ` [RFC 12/52] hw/acpi: Replace MachineState.smp access with topology helpers Zhao Liu
2023-02-16 9:31 ` wangyanan (Y) via
2023-02-17 3:14 ` Zhao Liu
2023-02-17 7:54 ` wangyanan (Y) via
2023-02-13 9:49 ` [RFC 13/52] cpu/core: Use generic topology helper for "help" to set nr_threads Zhao Liu
2023-02-13 9:49 ` [RFC 14/52] hw/smbios: Use generic topology name and helper Zhao Liu
2023-02-13 9:49 ` [RFC 15/52] migration/postcopy-ram: " Zhao Liu
2023-02-13 10:07 ` Juan Quintela
2023-02-14 8:12 ` Zhao Liu
2023-02-13 10:16 ` Juan Quintela
2023-02-14 8:16 ` Zhao Liu
2023-02-13 9:49 ` [RFC 16/52] plugins: " Zhao Liu
2023-02-13 9:50 ` [RFC 17/52] softmmu/cpus: Use generic topology helper in vcpus initialization Zhao Liu
2023-02-13 9:50 ` [RFC 18/52] general: Replace MachineState.smp access with topology helpers Zhao Liu
2023-02-13 9:50 ` [RFC 19/52] i386: " Zhao Liu
2023-02-13 9:50 ` [RFC 20/52] s390x: " Zhao Liu
2023-02-16 13:38 ` Thomas Huth
2023-02-17 3:38 ` Zhao Liu
2023-02-13 9:50 ` [RFC 21/52] ppc: " Zhao Liu
2023-02-13 9:50 ` [RFC 22/52] riscv: " Zhao Liu
2023-02-14 2:17 ` Mi, Dapeng1
2023-02-15 2:57 ` Zhao Liu
2023-03-01 23:43 ` Palmer Dabbelt
2023-02-13 9:50 ` [RFC 23/52] arm: " Zhao Liu
2023-02-16 10:46 ` wangyanan (Y) via
2023-02-17 3:21 ` Zhao Liu
2023-02-13 9:50 ` [RFC 24/52] loongarch: " Zhao Liu
2023-02-13 9:50 ` [RFC 25/52] mips: " Zhao Liu
2023-02-14 3:40 ` Mi, Dapeng1
2023-02-15 3:08 ` Zhao Liu
2023-02-13 9:50 ` [RFC 26/52] hw: Replace MachineState.smp access with topology helpers for all remaining archs Zhao Liu
2023-02-13 9:50 ` [RFC 27/52] test/test-smp-parse: Check fields of MachineState.topo.smp Zhao Liu
2023-02-13 9:50 ` [RFC 28/52] hw/core/machine: Remove support of MachineState.smp Zhao Liu
2023-02-13 9:50 ` [RFC 29/52] hw/core/cpu: Introduce TopologyState in CPUState Zhao Liu
2023-02-13 9:50 ` [RFC 30/52] i386: Drop nr_dies and nr_modules CPUX86State Zhao Liu
2023-02-13 13:22 ` Philippe Mathieu-Daudé
2023-02-13 9:50 ` [RFC 31/52] i386/cpu: Use CPUState.topo to replace X86CPUTopoInfo to get topology info Zhao Liu
2023-02-13 9:50 ` [RFC 32/52] i386: Rename X86CPUTopoInfo and its members to reflect relationship with APIC ID Zhao Liu
2023-02-13 13:25 ` Philippe Mathieu-Daudé
2023-02-13 9:50 ` [RFC 33/52] i386: Rename init_topo_info() to init_apic_topo_info() Zhao Liu
2023-02-13 13:27 ` Philippe Mathieu-Daudé
2023-02-14 10:20 ` Zhao Liu
2023-02-13 9:50 ` [RFC 34/52] i386: Rename variable topo_info to apicid_topo Zhao Liu
2023-02-13 13:28 ` Philippe Mathieu-Daudé
2023-02-14 10:18 ` Zhao Liu
2023-02-13 9:50 ` [RFC 35/52] i386: Support APIC ID topology for hybrid CPU topology Zhao Liu
2023-02-13 9:50 ` [RFC 36/52] i386: Use init_apicid_topo_info() to initialize APIC ID topology for system emulator Zhao Liu
2023-02-13 9:50 ` [RFC 37/52] i386: Update X86CPUTopoIDs generating rule for hybrid topology Zhao Liu
2023-02-13 9:50 ` [RFC 38/52] i386: Introduce hybrid_core_type to CPUX86State Zhao Liu
2023-02-13 9:50 ` [RFC 39/52] i386/cpu: Add Intel hybrid related CPUID support Zhao Liu
2023-02-13 9:50 ` [RFC 40/52] qapi: Introduce hybrid options Zhao Liu
2023-02-13 9:50 ` [RFC 41/52] machine: Introduce core_type() hook Zhao Liu
2023-02-13 13:33 ` Philippe Mathieu-Daudé
2023-02-14 14:33 ` Zhao Liu
2023-02-13 13:35 ` Philippe Mathieu-Daudé
2023-02-14 14:51 ` Zhao Liu
2023-02-16 12:15 ` wangyanan (Y) via
2023-02-17 3:26 ` Zhao Liu
2023-02-17 7:51 ` wangyanan (Y) via
2023-02-13 9:50 ` [RFC 42/52] hw/machine: Add hybrid_supported in generic topo properties Zhao Liu
2023-02-14 1:46 ` wangyanan (Y) via
2023-02-15 2:53 ` Zhao Liu
2023-02-16 12:28 ` wangyanan (Y) via
2023-02-17 3:28 ` Zhao Liu
2023-02-13 9:50 ` [RFC 43/52] hw/machine: Rename MachineClass.smp_props to MachineClass.topo_props Zhao Liu
2023-02-13 9:50 ` [RFC 44/52] machine: Add "-hybrid" parsing rule Zhao Liu
2023-02-13 9:50 ` [RFC 45/52] hw/machine: Add hybrid cpu topology validation Zhao Liu
2023-02-13 9:50 ` [RFC 46/52] hw/machine: build core level hybrid topology form HybridCorePack Zhao Liu
2023-02-13 9:50 ` [RFC 47/52] hw/machine: Use opts_visitor to parse hybrid topo Zhao Liu
2023-02-13 9:50 ` [RFC 48/52] machine: Support "-hybrid" command Zhao Liu
2023-02-13 9:50 ` [RFC 49/52] i386/pc: Support hybrid cpu topology Zhao Liu
2023-02-13 9:50 ` [RFC 50/52] qemu-options: Add the document of hybrid command Zhao Liu
2023-02-13 9:50 ` [RFC 51/52] qapi: Expose CPU topology info in query_cpus_fast Zhao Liu
2023-02-13 9:50 ` [RFC 52/52] i386: Support cpu_index_to_core_type() for x86 Zhao Liu
2023-02-13 10:14 ` [RFC 00/52] Introduce hybrid CPU topology Alex Bennée
2023-02-14 8:48 ` Zhao Liu
2023-02-13 13:38 ` Daniel P. Berrangé
2023-02-14 17:14 ` Zhao Liu
2023-08-04 13:43 ` Zhao Liu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZM0Ab1sJJFhYJSP4@liuzhao-OptiPlex-7080 \
--to=zhao1.liu@linux.intel.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=dapeng1.mi@intel.com \
--cc=eblake@redhat.com \
--cc=eduardo@habkost.net \
--cc=like.xu.linux@gmail.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=robert.hu@linux.intel.com \
--cc=seanjc@google.com \
--cc=wangyanan55@huawei.com \
--cc=zhao1.liu@intel.com \
--cc=zhenyu.z.wang@intel.com \
--cc=zhuocheng.ding@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).