From: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
To: Pierre Morel <pmorel@linux.ibm.com>, qemu-s390x@nongnu.org
Cc: qemu-devel@nongnu.org, borntraeger@de.ibm.com,
pasic@linux.ibm.com, richard.henderson@linaro.org,
david@redhat.com, thuth@redhat.com, cohuck@redhat.com,
mst@redhat.com, pbonzini@redhat.com, kvm@vger.kernel.org,
ehabkost@redhat.com, marcel.apfelbaum@gmail.com,
eblake@redhat.com, armbru@redhat.com, seiden@linux.ibm.com,
nrb@linux.ibm.com, frankja@linux.ibm.com, berrange@redhat.com,
clg@kaod.org
Subject: Re: [PATCH v12 2/7] s390x/cpu topology: reporting the CPU topology to the guest
Date: Tue, 06 Dec 2022 10:48:05 +0100 [thread overview]
Message-ID: <be6e4c3a2a3b1b4a944ce0558d3e852f78bd9645.camel@linux.ibm.com> (raw)
In-Reply-To: <20221129174206.84882-3-pmorel@linux.ibm.com>
On Tue, 2022-11-29 at 18:42 +0100, Pierre Morel wrote:
> The guest uses the STSI instruction to get information on the
> CPU topology.
>
> Let us implement the STSI instruction for the basis CPU topology
> level, level 2.
>
> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
> ---
> target/s390x/cpu.h | 77 +++++++++++++++
> hw/s390x/s390-virtio-ccw.c | 12 +--
> target/s390x/cpu_topology.c | 186 ++++++++++++++++++++++++++++++++++++
> target/s390x/kvm/kvm.c | 6 +-
> target/s390x/meson.build | 1 +
> 5 files changed, 274 insertions(+), 8 deletions(-)
> create mode 100644 target/s390x/cpu_topology.c
>
> diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
> index 7d6d01325b..dd878ac916 100644
> --- a/target/s390x/cpu.h
> +++ b/target/s390x/cpu.h
>
[...]
> +/* Configuration topology */
> +typedef struct SysIB_151x {
> + uint8_t reserved0[2];
> + uint16_t length;
> + uint8_t mag[S390_TOPOLOGY_MAG];
> + uint8_t reserved1;
> + uint8_t mnest;
> + uint32_t reserved2;
> + char tle[0];
AFAIK [] is preferred over [0].
> +} QEMU_PACKED QEMU_ALIGNED(8) SysIB_151x;
> +QEMU_BUILD_BUG_ON(sizeof(SysIB_151x) != 16);
[...]
>
> +/*
> + * s390_topology_add_cpu:
> + * @topo: pointer to the topology
> + * @cpu : pointer to the new CPU
> + *
> + * The topology pointed by S390CPU, gives us the CPU topology
> + * established by the -smp QEMU aruments.
> + * The core-id is used to calculate the position of the CPU inside
> + * the topology:
> + * - the socket, container TLE, containing the CPU, we have one socket
> + * for every num_cores cores.
> + * - the CPU TLE inside the socket, we have potentionly up to 4 CPU TLE
> + * in a container TLE with the assumption that all CPU are identical
> + * with the same polarity and entitlement because we have maximum 256
> + * CPUs and each TLE can hold up to 64 identical CPUs.
> + * - the bit in the 64 bit CPU TLE core mask
> + */
> +static void s390_topology_add_cpu(S390Topology *topo, S390CPU *cpu)
> +{
> + int core_id = cpu->env.core_id;
> + int bit, origin;
> + int socket_id;
> +
> + cpu->machine_data = topo;
> + socket_id = core_id / topo->num_cores;
> + /*
> + * At the core level, each CPU is represented by a bit in a 64bit
> + * uint64_t which represent the presence of a CPU.
> + * The firmware assume that all CPU in a CPU TLE have the same
> + * type, polarization and are all dedicated or shared.
> + * In that case the origin variable represents the offset of the first
> + * CPU in the CPU container.
> + * More than 64 CPUs per socket are represented in several CPU containers
> + * inside the socket container.
> + * The only reason to have several S390TopologyCores inside a socket is
> + * to have more than 64 CPUs.
> + * In that case the origin variable represents the offset of the first CPU
> + * in the CPU container. More than 64 CPUs per socket are represented in
> + * several CPU containers inside the socket container.
> + */
This comment still contains redundant sentences.
Did you have a look at my suggestion in v10 patch 1?
> + bit = core_id;
> + origin = bit / 64;
> + bit %= 64;
> + bit = 63 - bit;
> +
> + topo->socket[socket_id].active_count++;
> + set_bit(bit, &topo->socket[socket_id].mask[origin]);
> +}
> +
> +/*
> + * s390_prepare_topology:
> + * @s390ms : pointer to the S390CcwMachite State
> + *
> + * Calls s390_topology_add_cpu to organize the topology
> + * inside the topology device before writing the SYSIB.
> + *
> + * The topology is currently fixed on boot and do not change
does not change
> + * even on migration.
> + */
> +static void s390_prepare_topology(S390CcwMachineState *s390ms)
> +{
> + const MachineState *ms = MACHINE(s390ms);
> + static bool done;
> + int i;
> +
> + if (done) {
> + return;
> + }
> +
> + for (i = 0; i < ms->possible_cpus->len; i++) {
> + if (ms->possible_cpus->cpus[i].cpu) {
> + s390_topology_add_cpu(S390_CPU_TOPOLOGY(s390ms->topology),
> + S390_CPU(ms->possible_cpus->cpus[i].cpu));
> + }
> + }
> +
> + done = true;
> +}
> +
>
[...]
next prev parent reply other threads:[~2022-12-06 9:49 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-29 17:41 [PATCH v12 0/7] s390x: CPU Topology Pierre Morel
2022-11-29 17:42 ` [PATCH v12 1/7] s390x/cpu topology: Creating CPU topology device Pierre Morel
2022-12-01 9:08 ` Thomas Huth
2022-12-01 9:37 ` Pierre Morel
2022-12-06 9:31 ` Janis Schoetterl-Glausch
2022-12-06 10:32 ` Pierre Morel
2022-12-06 13:35 ` Janis Schoetterl-Glausch
2022-12-06 14:35 ` Pierre Morel
2022-12-06 21:06 ` Janis Schoetterl-Glausch
2022-12-07 10:00 ` Pierre Morel
2022-12-07 11:38 ` Janis Schoetterl-Glausch
2022-12-07 11:52 ` Pierre Morel
2022-11-29 17:42 ` [PATCH v12 2/7] s390x/cpu topology: reporting the CPU topology to the guest Pierre Morel
2022-12-06 9:48 ` Janis Schoetterl-Glausch [this message]
2022-12-06 10:38 ` Pierre Morel
2022-12-06 14:44 ` Pierre Morel
2022-12-07 9:12 ` Cédric Le Goater
2022-12-07 9:58 ` Pierre Morel
2022-11-29 17:42 ` [PATCH v12 3/7] s390x/cpu_topology: resetting the Topology-Change-Report Pierre Morel
2022-12-06 9:50 ` Janis Schoetterl-Glausch
2022-12-06 11:51 ` Pierre Morel
2022-11-29 17:42 ` [PATCH v12 4/7] s390x/cpu_topology: CPU topology migration Pierre Morel
2022-11-29 17:42 ` [PATCH v12 5/7] s390x/cpu_topology: interception of PTF instruction Pierre Morel
2022-11-29 17:42 ` [PATCH v12 6/7] s390x/cpu_topology: activating CPU topology Pierre Morel
2022-12-01 10:15 ` Thomas Huth
2022-12-01 11:52 ` Pierre Morel
2022-12-02 9:05 ` Thomas Huth
2022-12-02 14:08 ` Pierre Morel
2022-12-02 14:26 ` Thomas Huth
2022-12-05 13:29 ` Pierre Morel
2022-11-29 17:42 ` [PATCH v12 7/7] docs/s390x: document s390x cpu topology Pierre Morel
2022-12-01 8:45 ` [PATCH v12 0/7] s390x: CPU Topology Cédric Le Goater
2022-12-01 13:23 ` Pierre Morel
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=be6e4c3a2a3b1b4a944ce0558d3e852f78bd9645.camel@linux.ibm.com \
--to=scgl@linux.ibm.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=clg@kaod.org \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=eblake@redhat.com \
--cc=ehabkost@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=nrb@linux.ibm.com \
--cc=pasic@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=pmorel@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=seiden@linux.ibm.com \
--cc=thuth@redhat.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).