On Tue, 2023-01-10 at 14:00 +0100, Thomas Huth wrote: > On 05/01/2023 15.53, Pierre Morel wrote: > > The topology information are attributes of the CPU and are > > specified during the CPU device creation. > > > > On hot plug, we gather the topology information on the core, > > creates a list of topology entries, each entry contains a single > > core mask of each core with identical topology and finaly we > > orders the list in topological order. > > The topological order is, from higher to lower priority: > > - physical topology > > - drawer > > - book > > - socket > > - core origin, offset in 64bit increment from core 0. > > - modifier attributes > > - CPU type > > - polarization entitlement > > - dedication > > > > The possibility to insert a CPU in a mask is dependent on the > > number of cores allowed in a socket, a book or a drawer, the > > checking is done during the hot plug of the CPU to have an > > immediate answer. > > > > If the complete topology is not specified, the core is added > > in the physical topology based on its core ID and it gets > > defaults values for the modifier attributes. > > > > This way, starting QEMU without specifying the topology can > > still get some adventage of the CPU topology. > > s/adventage/advantage/ > > > Signed-off-by: Pierre Morel <pmorel@xxxxxxxxxxxxx> > > --- > > include/hw/s390x/cpu-topology.h | 48 ++++++ > > hw/s390x/cpu-topology.c | 293 ++++++++++++++++++++++++++++++++ > > hw/s390x/s390-virtio-ccw.c | 10 ++ > > hw/s390x/meson.build | 1 + > > 4 files changed, 352 insertions(+) > > create mode 100644 hw/s390x/cpu-topology.c > > > > diff --git a/include/hw/s390x/cpu-topology.h b/include/hw/s390x/cpu-topology.h > > index d945b57fc3..b3fd752d8d 100644 > > --- a/include/hw/s390x/cpu-topology.h > > +++ b/include/hw/s390x/cpu-topology.h > > [...] > > +typedef struct S390Topology { > > + QTAILQ_HEAD(, S390TopologyEntry) list; > > + uint8_t *sockets; > > So this "uint8_t" basically is a hidden limit of a maximum of 256 sockets > that can be used for per book? Do we check that limit somewhere? (I looked > for it, but I didn't spot such a check) S390_MAX_CPUS < 256. Might be a good idea to have a build time assert for that. And one cannot have more sockets that maxcpus. > > > + CpuTopology *smp; > > +} S390Topology; > > + > > +#ifdef CONFIG_KVM > > +bool s390_has_topology(void); > > +void s390_topology_set_cpu(MachineState *ms, S390CPU *cpu, Error **errp); > > +#else > > +static inline bool s390_has_topology(void) > > +{ > > + return false; > > +} > > +static inline void s390_topology_set_cpu(MachineState *ms, > > + S390CPU *cpu, > > + Error **errp) {} > > +#endif > > +extern S390Topology s390_topology; > > + > > #endif > > diff --git a/hw/s390x/cpu-topology.c b/hw/s390x/cpu-topology.c > > new file mode 100644 > > index 0000000000..438055c612 > > --- /dev/null > > +++ b/hw/s390x/cpu-topology.c > > @@ -0,0 +1,293 @@ > > +/* > > + * CPU Topology > > + * > > + * Copyright IBM Corp. 2022 > > Want to update to 2023 now? It's the year of first publication, and I'd guess this is a derivative work of what was published to the mailing list last year. >