From: Pierre Morel <pmorel@linux.ibm.com>
To: qemu-s390x@nongnu.org
Cc: thuth@redhat.com, ehabkost@redhat.com, david@redhat.com,
cohuck@redhat.com, richard.henderson@linaro.org,
qemu-devel@nongnu.org, armbru@redhat.com, pasic@linux.ibm.com,
borntraeger@de.ibm.com, pbonzini@redhat.com, eblake@redhat.com
Subject: [PATCH v1 9/9] s390x: numa: implement NUMA for S390x
Date: Wed, 14 Jul 2021 18:53:16 +0200 [thread overview]
Message-ID: <1626281596-31061-10-git-send-email-pmorel@linux.ibm.com> (raw)
In-Reply-To: <1626281596-31061-1-git-send-email-pmorel@linux.ibm.com>
We add the possibility to define the CPU topology to QEMU S390x.
This allows the user chose which CPU in the topology is active.
A NUMA node is considered to be a socket and chosing the NUMA node
leads to chose the specific socket in a book inside a drawer.
Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
---
hw/s390x/s390-virtio-ccw.c | 53 +++++++++++++++++++++++++++++++++-----
1 file changed, 46 insertions(+), 7 deletions(-)
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 3708ad3c46..0fd938fe3f 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -84,14 +84,37 @@ out:
static void s390_init_cpus(MachineState *machine)
{
MachineClass *mc = MACHINE_GET_CLASS(machine);
- int i;
+ const CPUArchId *slot;
+ int i, n = 1;
/* initialize possible_cpus */
mc->possible_cpu_arch_ids(machine);
s390_topology_setup(machine);
- for (i = 0; i < machine->smp.cpus; i++) {
+
+ /* Create CPU0 */
+ s390x_new_cpu(machine->cpu_type, 0, &error_fatal);
+
+ /* For NUMA configuration create defined nodes */
+ if (machine->numa_state->num_nodes) {
+ for (i = 1; i < machine->smp.max_cpus; i++) {
+ slot = &machine->possible_cpus->cpus[i];
+ if (slot->props.node_id) {
+ s390x_new_cpu(machine->cpu_type, i, &error_fatal);
+ n++;
+ }
+ }
+ }
+
+ /* create all remaining CPUs */
+ for (i = 1; n < machine->smp.cpus && i < machine->smp.max_cpus; i++) {
+ slot = &machine->possible_cpus->cpus[i];
+ /* For NUMA configuration skip defined nodes */
+ if (machine->numa_state->num_nodes && slot->props.node_id) {
+ continue;
+ }
s390x_new_cpu(machine->cpu_type, i, &error_fatal);
+ n++;
}
}
@@ -530,6 +553,7 @@ static const CPUArchIdList *s390_possible_cpu_arch_ids(MachineState *ms)
{
int i;
unsigned int max_cpus = ms->smp.max_cpus;
+ S390CcwMachineState *s390ms = S390_CCW_MACHINE(ms);
if (ms->possible_cpus) {
g_assert(ms->possible_cpus && ms->possible_cpus->len == max_cpus);
@@ -540,11 +564,20 @@ static const CPUArchIdList *s390_possible_cpu_arch_ids(MachineState *ms)
sizeof(CPUArchId) * max_cpus);
ms->possible_cpus->len = max_cpus;
for (i = 0; i < ms->possible_cpus->len; i++) {
- ms->possible_cpus->cpus[i].type = ms->cpu_type;
- ms->possible_cpus->cpus[i].vcpus_count = 1;
- ms->possible_cpus->cpus[i].arch_id = i;
- ms->possible_cpus->cpus[i].props.has_core_id = true;
- ms->possible_cpus->cpus[i].props.core_id = i;
+ CPUArchId *slot = &ms->possible_cpus->cpus[i];
+
+ slot->type = ms->cpu_type;
+ slot->vcpus_count = 1;
+ slot->arch_id = i;
+
+ slot->props.core_id = i;
+ slot->props.has_core_id = true;
+ slot->props.socket_id = i / ms->smp.cores;
+ slot->props.has_socket_id = true;
+ slot->props.book_id = slot->props.socket_id / ms->smp.sockets;
+ slot->props.has_book_id = true;
+ slot->props.drawer_id = slot->props.book_id / s390ms->books;
+ slot->props.has_drawer_id = true;
}
return ms->possible_cpus;
@@ -635,6 +668,11 @@ static void s390_smp_parse(MachineState *ms, QemuOpts *opts)
s390ms->books = books;
}
+static int64_t s390x_get_default_cpu_node_id(const MachineState *ms, int idx)
+{
+ return idx / ms->smp.cores;
+}
+
static void ccw_machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -666,6 +704,7 @@ static void ccw_machine_class_init(ObjectClass *oc, void *data)
nc->nmi_monitor_handler = s390_nmi;
mc->default_ram_id = "s390.ram";
mc->smp_parse = s390_smp_parse;
+ mc->get_default_cpu_node_id = s390x_get_default_cpu_node_id;
}
static inline bool machine_get_aes_key_wrap(Object *obj, Error **errp)
--
2.25.1
prev parent reply other threads:[~2021-07-14 16:58 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-14 16:53 [PATCH v1 0/9] s390x: CPU Topology Pierre Morel
2021-07-14 16:53 ` [PATCH v1 1/9] s390x: smp: s390x dedicated smp parsing Pierre Morel
2021-07-16 8:54 ` Cornelia Huck
2021-07-16 9:14 ` Daniel P. Berrangé
2021-07-16 10:59 ` Pierre Morel
[not found] ` <e4865ad6-f8ec-e7ba-66ef-9c95334ba9b3@linux.ibm.com>
2021-07-19 15:43 ` Cornelia Huck
2021-07-19 15:52 ` Daniel P. Berrangé
2021-07-20 7:37 ` Pierre Morel
2021-07-20 8:33 ` Pierre Morel
2021-07-16 10:47 ` Pierre Morel
2021-07-14 16:53 ` [PATCH v1 2/9] s390x: toplogy: adding drawers and books to " Pierre Morel
2021-07-15 6:16 ` Markus Armbruster
2021-07-15 8:19 ` Pierre Morel
2021-07-15 10:48 ` Markus Armbruster
2021-07-16 9:10 ` Cornelia Huck
2021-07-16 9:18 ` Daniel P. Berrangé
2021-07-16 10:44 ` Cornelia Huck
2021-07-16 10:49 ` Daniel P. Berrangé
2021-07-19 15:50 ` Cornelia Huck
2021-07-20 7:52 ` Pierre Morel
2021-07-20 8:20 ` Cornelia Huck
2021-07-20 8:46 ` Pierre Morel
2021-07-20 9:00 ` Cornelia Huck
2021-07-20 9:19 ` Daniel P. Berrangé
2021-07-20 12:29 ` Pierre Morel
2021-07-16 9:23 ` Daniel P. Berrangé
2021-07-16 11:08 ` Pierre Morel
2021-07-14 16:53 ` [PATCH v1 3/9] s390x: cpu topology: CPU topology objects and structures Pierre Morel
2021-07-14 16:53 ` [PATCH v1 4/9] s390x: Topology list entries and SYSIB 15.x.x Pierre Morel
2021-07-14 16:53 ` [PATCH v1 5/9] s390x: topology: implementating Store Topology System Information Pierre Morel
2021-07-14 16:53 ` [PATCH v1 6/9] s390x: kvm: topology: interception of PTF instruction Pierre Morel
2021-07-16 9:22 ` Cornelia Huck
2021-07-16 11:23 ` Pierre Morel
2021-07-16 11:56 ` Cornelia Huck
2021-07-14 16:53 ` [PATCH v1 7/9] s390x: SCLP: reporting the maximum nested topology entries Pierre Morel
2021-07-16 9:24 ` Cornelia Huck
2021-07-16 11:12 ` Pierre Morel
2021-07-14 16:53 ` [PATCH v1 8/9] s390x: numa: define drawers and books for NUMA Pierre Morel
2021-07-14 16:53 ` Pierre Morel [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=1626281596-31061-10-git-send-email-pmorel@linux.ibm.com \
--to=pmorel@linux.ibm.com \
--cc=armbru@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=eblake@redhat.com \
--cc=ehabkost@redhat.com \
--cc=pasic@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--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).