Message ID | 20230201132051.126868-2-pmorel@linux.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | s390x: CPU Topology | expand |
On 01/02/2023 14.20, Pierre Morel wrote: > S390 adds two new SMP levels, drawers and books to the CPU > topology. > The S390 CPU have specific toplogy features like dedication Nit: s/toplogy/topology/ > and polarity to give to the guest indications on the host > vCPUs scheduling and help the guest take the best decisions > on the scheduling of threads on the vCPUs. > > Let us provide the SMP properties with books and drawers levels > and S390 CPU with dedication and polarity, > > Signed-off-by: Pierre Morel <pmorel@linux.ibm.com> > --- Apart from the nit: Reviewed-by: Thomas Huth <thuth@redhat.com>
On 2/2/23 11:44, Thomas Huth wrote: > On 01/02/2023 14.20, Pierre Morel wrote: >> S390 adds two new SMP levels, drawers and books to the CPU >> topology. >> The S390 CPU have specific toplogy features like dedication > > Nit: s/toplogy/topology/ > >> and polarity to give to the guest indications on the host >> vCPUs scheduling and help the guest take the best decisions >> on the scheduling of threads on the vCPUs. >> >> Let us provide the SMP properties with books and drawers levels >> and S390 CPU with dedication and polarity, >> >> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com> >> --- > > Apart from the nit: > Reviewed-by: Thomas Huth <thuth@redhat.com> > Thanks, Pierre
Nit patch title: s390x/cpu topology: add s390 specifics to CPU topology ? On Wed, 2023-02-01 at 14:20 +0100, Pierre Morel wrote: > S390 adds two new SMP levels, drawers and books to the CPU > topology. > The S390 CPU have specific toplogy features like dedication ^o > and polarity to give to the guest indications on the host > vCPUs scheduling and help the guest take the best decisions > on the scheduling of threads on the vCPUs. > > Let us provide the SMP properties with books and drawers levels > and S390 CPU with dedication and polarity, > > Signed-off-by: Pierre Morel <pmorel@linux.ibm.com> > --- > qapi/machine.json | 14 ++++++++-- > include/hw/boards.h | 10 ++++++- > include/hw/s390x/cpu-topology.h | 24 +++++++++++++++++ > target/s390x/cpu.h | 5 ++++ > hw/core/machine-smp.c | 48 ++++++++++++++++++++++++++++----- > hw/core/machine.c | 4 +++ > hw/s390x/s390-virtio-ccw.c | 2 ++ > softmmu/vl.c | 6 +++++ > target/s390x/cpu.c | 7 +++++ > qemu-options.hx | 7 +++-- > 10 files changed, 115 insertions(+), 12 deletions(-) > create mode 100644 include/hw/s390x/cpu-topology.h > [...] > > diff --git a/include/hw/s390x/cpu-topology.h b/include/hw/s390x/cpu-topology.h > new file mode 100644 > index 0000000000..7a84b30a21 > --- /dev/null > +++ b/include/hw/s390x/cpu-topology.h > @@ -0,0 +1,24 @@ > +/* > + * CPU Topology > + * > + * Copyright IBM Corp. 2022 > + * > + * This work is licensed under the terms of the GNU GPL, version 2 or (at > + * your option) any later version. See the COPYING file in the top-level > + * directory. > + */ > +#ifndef HW_S390X_CPU_TOPOLOGY_H > +#define HW_S390X_CPU_TOPOLOGY_H > + > +#define S390_TOPOLOGY_CPU_IFL 0x03 > + > +enum s390_topology_polarity { > + POLARITY_HORIZONTAL, > + POLARITY_VERTICAL, > + POLARITY_VERTICAL_LOW = 1, > + POLARITY_VERTICAL_MEDIUM, > + POLARITY_VERTICAL_HIGH, > + POLARITY_MAX, > +}; Probably a good idea to keep the S390 prefix. This works, but aliasing VERTICAL and VERTICAL_LOW is not entirely straight forward. Why not have two enum? enum s390_topology_polarity { S390_POLARITY_HORIZONTAL, S390_POLARITY_VERTICAL, }; enum s390_topology_entitlement { S390_ENTITLEMENT_LOW = 1, S390_ENTITLEMENT_MEDIUM, S390_ENTITLEMENT_HIGH, S390_ENTITLEMENT_MAX, }; Maybe add an ENTITLEMENT_INVALID/NONE, if you need that, as first value. > +#endif > [...]
@Thomas, these changes look good to me. What do you think, do I make the change and keep your RB ? On 2/2/23 17:05, Nina Schoetterl-Glausch wrote: > Nit patch title: s390x/cpu topology: add s390 specifics to CPU topology ? > OK > On Wed, 2023-02-01 at 14:20 +0100, Pierre Morel wrote: >> S390 adds two new SMP levels, drawers and books to the CPU >> topology. >> The S390 CPU have specific toplogy features like dedication > ^o Yes thx >> and polarity to give to the guest indications on the host >> vCPUs scheduling and help the guest take the best decisions >> on the scheduling of threads on the vCPUs. >> >> Let us provide the SMP properties with books and drawers levels >> and S390 CPU with dedication and polarity, >> >> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com> >> --- >> qapi/machine.json | 14 ++++++++-- >> include/hw/boards.h | 10 ++++++- >> include/hw/s390x/cpu-topology.h | 24 +++++++++++++++++ >> target/s390x/cpu.h | 5 ++++ >> hw/core/machine-smp.c | 48 ++++++++++++++++++++++++++++----- >> hw/core/machine.c | 4 +++ >> hw/s390x/s390-virtio-ccw.c | 2 ++ >> softmmu/vl.c | 6 +++++ >> target/s390x/cpu.c | 7 +++++ >> qemu-options.hx | 7 +++-- >> 10 files changed, 115 insertions(+), 12 deletions(-) >> create mode 100644 include/hw/s390x/cpu-topology.h >> > [...] >> >> diff --git a/include/hw/s390x/cpu-topology.h b/include/hw/s390x/cpu-topology.h >> new file mode 100644 >> index 0000000000..7a84b30a21 >> --- /dev/null >> +++ b/include/hw/s390x/cpu-topology.h >> @@ -0,0 +1,24 @@ >> +/* >> + * CPU Topology >> + * >> + * Copyright IBM Corp. 2022 >> + * >> + * This work is licensed under the terms of the GNU GPL, version 2 or (at >> + * your option) any later version. See the COPYING file in the top-level >> + * directory. >> + */ >> +#ifndef HW_S390X_CPU_TOPOLOGY_H >> +#define HW_S390X_CPU_TOPOLOGY_H >> + >> +#define S390_TOPOLOGY_CPU_IFL 0x03 >> + >> +enum s390_topology_polarity { >> + POLARITY_HORIZONTAL, >> + POLARITY_VERTICAL, >> + POLARITY_VERTICAL_LOW = 1, >> + POLARITY_VERTICAL_MEDIUM, >> + POLARITY_VERTICAL_HIGH, >> + POLARITY_MAX, >> +}; > > Probably a good idea to keep the S390 prefix. > This works, but aliasing VERTICAL and VERTICAL_LOW is not > entirely straight forward. > > Why not have two enum? > enum s390_topology_polarity { > S390_POLARITY_HORIZONTAL, > S390_POLARITY_VERTICAL, > }; > > enum s390_topology_entitlement { > S390_ENTITLEMENT_LOW = 1, > S390_ENTITLEMENT_MEDIUM, > S390_ENTITLEMENT_HIGH, > S390_ENTITLEMENT_MAX, > }; > Maybe add an ENTITLEMENT_INVALID/NONE, if you need that, as first value. > If Thomas agree, I do the changes. Regards, Pierre
On 03/02/2023 10.39, Pierre Morel wrote: > > @Thomas, these changes look good to me. > What do you think, do I make the change and keep your RB ? Yes, splitting that enum sounds cleaner, indeed. Thomas > On 2/2/23 17:05, Nina Schoetterl-Glausch wrote: >> Nit patch title: s390x/cpu topology: add s390 specifics to CPU topology ? >> > > OK > >> On Wed, 2023-02-01 at 14:20 +0100, Pierre Morel wrote: >>> S390 adds two new SMP levels, drawers and books to the CPU >>> topology. >>> The S390 CPU have specific toplogy features like dedication >> ^o > > Yes thx > >>> and polarity to give to the guest indications on the host >>> vCPUs scheduling and help the guest take the best decisions >>> on the scheduling of threads on the vCPUs. >>> >>> Let us provide the SMP properties with books and drawers levels >>> and S390 CPU with dedication and polarity, >>> >>> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com> >>> --- >>> qapi/machine.json | 14 ++++++++-- >>> include/hw/boards.h | 10 ++++++- >>> include/hw/s390x/cpu-topology.h | 24 +++++++++++++++++ >>> target/s390x/cpu.h | 5 ++++ >>> hw/core/machine-smp.c | 48 ++++++++++++++++++++++++++++----- >>> hw/core/machine.c | 4 +++ >>> hw/s390x/s390-virtio-ccw.c | 2 ++ >>> softmmu/vl.c | 6 +++++ >>> target/s390x/cpu.c | 7 +++++ >>> qemu-options.hx | 7 +++-- >>> 10 files changed, 115 insertions(+), 12 deletions(-) >>> create mode 100644 include/hw/s390x/cpu-topology.h >>> >> [...] >>> >>> diff --git a/include/hw/s390x/cpu-topology.h >>> b/include/hw/s390x/cpu-topology.h >>> new file mode 100644 >>> index 0000000000..7a84b30a21 >>> --- /dev/null >>> +++ b/include/hw/s390x/cpu-topology.h >>> @@ -0,0 +1,24 @@ >>> +/* >>> + * CPU Topology >>> + * >>> + * Copyright IBM Corp. 2022 >>> + * >>> + * This work is licensed under the terms of the GNU GPL, version 2 or (at >>> + * your option) any later version. See the COPYING file in the top-level >>> + * directory. >>> + */ >>> +#ifndef HW_S390X_CPU_TOPOLOGY_H >>> +#define HW_S390X_CPU_TOPOLOGY_H >>> + >>> +#define S390_TOPOLOGY_CPU_IFL 0x03 >>> + >>> +enum s390_topology_polarity { >>> + POLARITY_HORIZONTAL, >>> + POLARITY_VERTICAL, >>> + POLARITY_VERTICAL_LOW = 1, >>> + POLARITY_VERTICAL_MEDIUM, >>> + POLARITY_VERTICAL_HIGH, >>> + POLARITY_MAX, >>> +}; >> >> Probably a good idea to keep the S390 prefix. >> This works, but aliasing VERTICAL and VERTICAL_LOW is not >> entirely straight forward. >> >> Why not have two enum? >> enum s390_topology_polarity { >> S390_POLARITY_HORIZONTAL, >> S390_POLARITY_VERTICAL, >> }; >> >> enum s390_topology_entitlement { >> S390_ENTITLEMENT_LOW = 1, >> S390_ENTITLEMENT_MEDIUM, >> S390_ENTITLEMENT_HIGH, >> S390_ENTITLEMENT_MAX, >> }; >> Maybe add an ENTITLEMENT_INVALID/NONE, if you need that, as first value. >> > > If Thomas agree, I do the changes. > > Regards, > Pierre > >
On Wed, 2023-02-01 at 14:20 +0100, Pierre Morel wrote: > S390 adds two new SMP levels, drawers and books to the CPU > topology. > The S390 CPU have specific toplogy features like dedication > and polarity to give to the guest indications on the host > vCPUs scheduling and help the guest take the best decisions > on the scheduling of threads on the vCPUs. > > Let us provide the SMP properties with books and drawers levels > and S390 CPU with dedication and polarity, > > Signed-off-by: Pierre Morel <pmorel@linux.ibm.com> > --- > qapi/machine.json | 14 ++++++++-- > include/hw/boards.h | 10 ++++++- > include/hw/s390x/cpu-topology.h | 24 +++++++++++++++++ > target/s390x/cpu.h | 5 ++++ > hw/core/machine-smp.c | 48 ++++++++++++++++++++++++++++----- > hw/core/machine.c | 4 +++ > hw/s390x/s390-virtio-ccw.c | 2 ++ > softmmu/vl.c | 6 +++++ > target/s390x/cpu.c | 7 +++++ > qemu-options.hx | 7 +++-- > 10 files changed, 115 insertions(+), 12 deletions(-) > create mode 100644 include/hw/s390x/cpu-topology.h > [...] > > diff --git a/include/hw/s390x/cpu-topology.h b/include/hw/s390x/cpu-topology.h > new file mode 100644 > index 0000000000..7a84b30a21 > --- /dev/null > +++ b/include/hw/s390x/cpu-topology.h > @@ -0,0 +1,24 @@ > +/* > + * CPU Topology > + * > + * Copyright IBM Corp. 2022 > + * > + * This work is licensed under the terms of the GNU GPL, version 2 or (at > + * your option) any later version. See the COPYING file in the top-level > + * directory. > + */ > +#ifndef HW_S390X_CPU_TOPOLOGY_H > +#define HW_S390X_CPU_TOPOLOGY_H > + > +#define S390_TOPOLOGY_CPU_IFL 0x03 > + > +enum s390_topology_polarity { > + POLARITY_HORIZONTAL, > + POLARITY_VERTICAL, > + POLARITY_VERTICAL_LOW = 1, > + POLARITY_VERTICAL_MEDIUM, > + POLARITY_VERTICAL_HIGH, > + POLARITY_MAX, > +}; IMO you should define the polarization and entitlement enums as qapi enums. The polarization is passed as data in the qapi event when the polarization changes. And the entitlement is passed to qemu when modifying the topology. [...]
On 2/8/23 18:50, Nina Schoetterl-Glausch wrote: > On Wed, 2023-02-01 at 14:20 +0100, Pierre Morel wrote: >> S390 adds two new SMP levels, drawers and books to the CPU >> topology. >> The S390 CPU have specific toplogy features like dedication >> and polarity to give to the guest indications on the host >> vCPUs scheduling and help the guest take the best decisions >> on the scheduling of threads on the vCPUs. >> >> Let us provide the SMP properties with books and drawers levels >> and S390 CPU with dedication and polarity, >> >> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com> >> --- >> qapi/machine.json | 14 ++++++++-- >> include/hw/boards.h | 10 ++++++- >> include/hw/s390x/cpu-topology.h | 24 +++++++++++++++++ >> target/s390x/cpu.h | 5 ++++ >> hw/core/machine-smp.c | 48 ++++++++++++++++++++++++++++----- >> hw/core/machine.c | 4 +++ >> hw/s390x/s390-virtio-ccw.c | 2 ++ >> softmmu/vl.c | 6 +++++ >> target/s390x/cpu.c | 7 +++++ >> qemu-options.hx | 7 +++-- >> 10 files changed, 115 insertions(+), 12 deletions(-) >> create mode 100644 include/hw/s390x/cpu-topology.h >> > [...] >> >> diff --git a/include/hw/s390x/cpu-topology.h b/include/hw/s390x/cpu-topology.h >> new file mode 100644 >> index 0000000000..7a84b30a21 >> --- /dev/null >> +++ b/include/hw/s390x/cpu-topology.h >> @@ -0,0 +1,24 @@ >> +/* >> + * CPU Topology >> + * >> + * Copyright IBM Corp. 2022 >> + * >> + * This work is licensed under the terms of the GNU GPL, version 2 or (at >> + * your option) any later version. See the COPYING file in the top-level >> + * directory. >> + */ >> +#ifndef HW_S390X_CPU_TOPOLOGY_H >> +#define HW_S390X_CPU_TOPOLOGY_H >> + >> +#define S390_TOPOLOGY_CPU_IFL 0x03 >> + >> +enum s390_topology_polarity { >> + POLARITY_HORIZONTAL, >> + POLARITY_VERTICAL, >> + POLARITY_VERTICAL_LOW = 1, >> + POLARITY_VERTICAL_MEDIUM, >> + POLARITY_VERTICAL_HIGH, >> + POLARITY_MAX, >> +}; > > IMO you should define the polarization and entitlement enums as > qapi enums. > The polarization is passed as data in the qapi event when the polarization > changes. > And the entitlement is passed to qemu when modifying the topology. (Thought I already answered but... seems no.) looks good, thanks, I change this. Regards, Pierre
diff --git a/qapi/machine.json b/qapi/machine.json index b9228a5e46..3036117059 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -900,13 +900,15 @@ # a CPU is being hotplugged. # # @node-id: NUMA node ID the CPU belongs to -# @socket-id: socket number within node/board the CPU belongs to +# @drawer-id: drawer number within node/board the CPU belongs to (since 8.0) +# @book-id: book number within drawer/node/board the CPU belongs to (since 8.0) +# @socket-id: socket number within book/node/board the CPU belongs to # @die-id: die number within socket the CPU belongs to (since 4.1) # @cluster-id: cluster number within die the CPU belongs to (since 7.1) # @core-id: core number within cluster the CPU belongs to # @thread-id: thread number within core the CPU belongs to # -# Note: currently there are 6 properties that could be present +# Note: currently there are 8 properties that could be present # but management should be prepared to pass through other # properties with device_add command to allow for future # interface extension. This also requires the filed names to be kept in @@ -916,6 +918,8 @@ ## { 'struct': 'CpuInstanceProperties', 'data': { '*node-id': 'int', + '*drawer-id': 'int', + '*book-id': 'int', '*socket-id': 'int', '*die-id': 'int', '*cluster-id': 'int', @@ -1465,6 +1469,10 @@ # # @cpus: number of virtual CPUs in the virtual machine # +# @drawers: number of drawers in the CPU topology (since 8.0) +# +# @books: number of books in the CPU topology (since 8.0) +# # @sockets: number of sockets in the CPU topology # # @dies: number of dies per socket in the CPU topology @@ -1481,6 +1489,8 @@ ## { 'struct': 'SMPConfiguration', 'data': { '*cpus': 'int', + '*drawers': 'int', + '*books': 'int', '*sockets': 'int', '*dies': 'int', '*clusters': 'int', diff --git a/include/hw/boards.h b/include/hw/boards.h index 6fbbfd56c8..9ef0bb76cf 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -131,12 +131,16 @@ typedef struct { * @clusters_supported - whether clusters are supported by the machine * @has_clusters - whether clusters are explicitly specified in the user * provided SMP configuration + * @books_supported - whether books are supported by the machine + * @drawers_supported - whether drawers are supported by the machine */ typedef struct { bool prefer_sockets; bool dies_supported; bool clusters_supported; bool has_clusters; + bool books_supported; + bool drawers_supported; } SMPCompatProps; /** @@ -301,7 +305,9 @@ typedef struct DeviceMemoryState { /** * CpuTopology: * @cpus: the number of present logical processors on the machine - * @sockets: the number of sockets on the machine + * @drawers: the number of drawers on the machine + * @books: the number of books in one drawer + * @sockets: the number of sockets in one book * @dies: the number of dies in one socket * @clusters: the number of clusters in one die * @cores: the number of cores in one cluster @@ -310,6 +316,8 @@ typedef struct DeviceMemoryState { */ typedef struct CpuTopology { unsigned int cpus; + unsigned int drawers; + unsigned int books; unsigned int sockets; unsigned int dies; unsigned int clusters; diff --git a/include/hw/s390x/cpu-topology.h b/include/hw/s390x/cpu-topology.h new file mode 100644 index 0000000000..7a84b30a21 --- /dev/null +++ b/include/hw/s390x/cpu-topology.h @@ -0,0 +1,24 @@ +/* + * CPU Topology + * + * Copyright IBM Corp. 2022 + * + * This work is licensed under the terms of the GNU GPL, version 2 or (at + * your option) any later version. See the COPYING file in the top-level + * directory. + */ +#ifndef HW_S390X_CPU_TOPOLOGY_H +#define HW_S390X_CPU_TOPOLOGY_H + +#define S390_TOPOLOGY_CPU_IFL 0x03 + +enum s390_topology_polarity { + POLARITY_HORIZONTAL, + POLARITY_VERTICAL, + POLARITY_VERTICAL_LOW = 1, + POLARITY_VERTICAL_MEDIUM, + POLARITY_VERTICAL_HIGH, + POLARITY_MAX, +}; + +#endif diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 7d6d01325b..d654267a71 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -131,6 +131,11 @@ struct CPUArchState { #if !defined(CONFIG_USER_ONLY) uint32_t core_id; /* PoP "CPU address", same as cpu_index */ + int32_t socket_id; + int32_t book_id; + int32_t drawer_id; + bool dedicated; + uint8_t entitlement; /* Used only for vertical polarization */ uint64_t cpuid; #endif diff --git a/hw/core/machine-smp.c b/hw/core/machine-smp.c index c3dab007da..b8233df5a9 100644 --- a/hw/core/machine-smp.c +++ b/hw/core/machine-smp.c @@ -31,6 +31,14 @@ static char *cpu_hierarchy_to_string(MachineState *ms) MachineClass *mc = MACHINE_GET_CLASS(ms); GString *s = g_string_new(NULL); + if (mc->smp_props.drawers_supported) { + g_string_append_printf(s, " * drawers (%u)", ms->smp.drawers); + } + + if (mc->smp_props.books_supported) { + g_string_append_printf(s, " * books (%u)", ms->smp.books); + } + g_string_append_printf(s, "sockets (%u)", ms->smp.sockets); if (mc->smp_props.dies_supported) { @@ -73,6 +81,8 @@ void machine_parse_smp_config(MachineState *ms, { MachineClass *mc = MACHINE_GET_CLASS(ms); unsigned cpus = config->has_cpus ? config->cpus : 0; + unsigned drawers = config->has_drawers ? config->drawers : 0; + unsigned books = config->has_books ? config->books : 0; unsigned sockets = config->has_sockets ? config->sockets : 0; unsigned dies = config->has_dies ? config->dies : 0; unsigned clusters = config->has_clusters ? config->clusters : 0; @@ -85,6 +95,8 @@ void machine_parse_smp_config(MachineState *ms, * explicit configuration like "cpus=0" is not allowed. */ if ((config->has_cpus && config->cpus == 0) || + (config->has_drawers && config->drawers == 0) || + (config->has_books && config->books == 0) || (config->has_sockets && config->sockets == 0) || (config->has_dies && config->dies == 0) || (config->has_clusters && config->clusters == 0) || @@ -111,6 +123,19 @@ void machine_parse_smp_config(MachineState *ms, dies = dies > 0 ? dies : 1; clusters = clusters > 0 ? clusters : 1; + if (!mc->smp_props.books_supported && books > 1) { + error_setg(errp, "books not supported by this machine's CPU topology"); + return; + } + books = books > 0 ? books : 1; + + if (!mc->smp_props.drawers_supported && drawers > 1) { + error_setg(errp, + "drawers not supported by this machine's CPU topology"); + return; + } + drawers = drawers > 0 ? drawers : 1; + /* compute missing values based on the provided ones */ if (cpus == 0 && maxcpus == 0) { sockets = sockets > 0 ? sockets : 1; @@ -124,33 +149,41 @@ void machine_parse_smp_config(MachineState *ms, if (sockets == 0) { cores = cores > 0 ? cores : 1; threads = threads > 0 ? threads : 1; - sockets = maxcpus / (dies * clusters * cores * threads); + sockets = maxcpus / + (drawers * books * dies * clusters * cores * threads); } else if (cores == 0) { threads = threads > 0 ? threads : 1; - cores = maxcpus / (sockets * dies * clusters * threads); + cores = maxcpus / + (drawers * books * sockets * dies * clusters * threads); } } else { /* prefer cores over sockets since 6.2 */ if (cores == 0) { sockets = sockets > 0 ? sockets : 1; threads = threads > 0 ? threads : 1; - cores = maxcpus / (sockets * dies * clusters * threads); + cores = maxcpus / + (drawers * books * sockets * dies * clusters * threads); } else if (sockets == 0) { threads = threads > 0 ? threads : 1; - sockets = maxcpus / (dies * clusters * cores * threads); + sockets = maxcpus / + (drawers * books * dies * clusters * cores * threads); } } /* try to calculate omitted threads at last */ if (threads == 0) { - threads = maxcpus / (sockets * dies * clusters * cores); + threads = maxcpus / + (drawers * books * sockets * dies * clusters * cores); } } - maxcpus = maxcpus > 0 ? maxcpus : sockets * dies * clusters * cores * threads; + maxcpus = maxcpus > 0 ? maxcpus : drawers * books * sockets * dies * + clusters * cores * threads; cpus = cpus > 0 ? cpus : maxcpus; ms->smp.cpus = cpus; + ms->smp.drawers = drawers; + ms->smp.books = books; ms->smp.sockets = sockets; ms->smp.dies = dies; ms->smp.clusters = clusters; @@ -161,7 +194,8 @@ void machine_parse_smp_config(MachineState *ms, mc->smp_props.has_clusters = config->has_clusters; /* sanity-check of the computed topology */ - if (sockets * dies * clusters * cores * threads != maxcpus) { + if (drawers * books * sockets * dies * clusters * cores * threads != + maxcpus) { g_autofree char *topo_msg = cpu_hierarchy_to_string(ms); error_setg(errp, "Invalid CPU topology: " "product of the hierarchy must match maxcpus: " diff --git a/hw/core/machine.c b/hw/core/machine.c index 616f3a207c..e38f99230b 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -828,6 +828,8 @@ static void machine_get_smp(Object *obj, Visitor *v, const char *name, MachineState *ms = MACHINE(obj); SMPConfiguration *config = &(SMPConfiguration){ .has_cpus = true, .cpus = ms->smp.cpus, + .has_drawers = true, .drawers = ms->smp.drawers, + .has_books = true, .books = ms->smp.books, .has_sockets = true, .sockets = ms->smp.sockets, .has_dies = true, .dies = ms->smp.dies, .has_clusters = true, .clusters = ms->smp.clusters, @@ -1093,6 +1095,8 @@ static void machine_initfn(Object *obj) /* default to mc->default_cpus */ ms->smp.cpus = mc->default_cpus; ms->smp.max_cpus = mc->default_cpus; + ms->smp.drawers = 1; + ms->smp.books = 1; ms->smp.sockets = 1; ms->smp.dies = 1; ms->smp.clusters = 1; diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index f22f61b8b6..f3cc845d3b 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -733,6 +733,8 @@ static void ccw_machine_class_init(ObjectClass *oc, void *data) mc->no_sdcard = 1; mc->max_cpus = S390_MAX_CPUS; mc->has_hotpluggable_cpus = true; + mc->smp_props.books_supported = true; + mc->smp_props.drawers_supported = true; assert(!mc->get_hotplug_handler); mc->get_hotplug_handler = s390_get_hotplug_handler; mc->cpu_index_to_instance_props = s390_cpu_index_to_props; diff --git a/softmmu/vl.c b/softmmu/vl.c index 9177d95d4e..05e1f33fa5 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -727,6 +727,12 @@ static QemuOptsList qemu_smp_opts = { { .name = "cpus", .type = QEMU_OPT_NUMBER, + }, { + .name = "drawers", + .type = QEMU_OPT_NUMBER, + }, { + .name = "books", + .type = QEMU_OPT_NUMBER, }, { .name = "sockets", .type = QEMU_OPT_NUMBER, diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index b10a8541ff..828e8b8fce 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -37,6 +37,7 @@ #ifndef CONFIG_USER_ONLY #include "sysemu/reset.h" #endif +#include "hw/s390x/cpu-topology.h" #define CR0_RESET 0xE0UL #define CR14_RESET 0xC2000000UL; @@ -259,6 +260,12 @@ static gchar *s390_gdb_arch_name(CPUState *cs) static Property s390x_cpu_properties[] = { #if !defined(CONFIG_USER_ONLY) DEFINE_PROP_UINT32("core-id", S390CPU, env.core_id, 0), + DEFINE_PROP_INT32("socket-id", S390CPU, env.socket_id, -1), + DEFINE_PROP_INT32("book-id", S390CPU, env.book_id, -1), + DEFINE_PROP_INT32("drawer-id", S390CPU, env.drawer_id, -1), + DEFINE_PROP_BOOL("dedicated", S390CPU, env.dedicated, false), + DEFINE_PROP_UINT8("polarity", S390CPU, env.entitlement, + POLARITY_VERTICAL_MEDIUM), #endif DEFINE_PROP_END_OF_LIST() }; diff --git a/qemu-options.hx b/qemu-options.hx index d59d19704b..131687c6dc 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -250,11 +250,14 @@ SRST ERST DEF("smp", HAS_ARG, QEMU_OPTION_smp, - "-smp [[cpus=]n][,maxcpus=maxcpus][,sockets=sockets][,dies=dies][,clusters=clusters][,cores=cores][,threads=threads]\n" + "-smp [[cpus=]n][,maxcpus=maxcpus][,drawers=drawers][,books=books][,sockets=sockets]\n" + " [,dies=dies][,clusters=clusters][,cores=cores][,threads=threads]\n" " set the number of initial CPUs to 'n' [default=1]\n" " maxcpus= maximum number of total CPUs, including\n" " offline CPUs for hotplug, etc\n" - " sockets= number of sockets on the machine board\n" + " drawers= number of drawers on the machine board\n" + " books= number of books in one drawer\n" + " sockets= number of sockets in one book\n" " dies= number of dies in one socket\n" " clusters= number of clusters in one die\n" " cores= number of cores in one cluster\n"
S390 adds two new SMP levels, drawers and books to the CPU topology. The S390 CPU have specific toplogy features like dedication and polarity to give to the guest indications on the host vCPUs scheduling and help the guest take the best decisions on the scheduling of threads on the vCPUs. Let us provide the SMP properties with books and drawers levels and S390 CPU with dedication and polarity, Signed-off-by: Pierre Morel <pmorel@linux.ibm.com> --- qapi/machine.json | 14 ++++++++-- include/hw/boards.h | 10 ++++++- include/hw/s390x/cpu-topology.h | 24 +++++++++++++++++ target/s390x/cpu.h | 5 ++++ hw/core/machine-smp.c | 48 ++++++++++++++++++++++++++++----- hw/core/machine.c | 4 +++ hw/s390x/s390-virtio-ccw.c | 2 ++ softmmu/vl.c | 6 +++++ target/s390x/cpu.c | 7 +++++ qemu-options.hx | 7 +++-- 10 files changed, 115 insertions(+), 12 deletions(-) create mode 100644 include/hw/s390x/cpu-topology.h