From nobody Mon Feb 9 07:55:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626281945460687.2219566633487; Wed, 14 Jul 2021 09:59:05 -0700 (PDT) Received: from localhost ([::1]:48544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m3iDw-0002Uw-EZ for importer@patchew.org; Wed, 14 Jul 2021 12:59:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44520) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3i8c-0007Zp-PF; Wed, 14 Jul 2021 12:53:34 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:28014) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3i8a-00013s-UQ; Wed, 14 Jul 2021 12:53:34 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16EGY0JD092692; Wed, 14 Jul 2021 12:53:31 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 39sufyfvt8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 14 Jul 2021 12:53:30 -0400 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 16EGY1bv093404; Wed, 14 Jul 2021 12:53:30 -0400 Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 39sufyfvse-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 14 Jul 2021 12:53:30 -0400 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 16EGrRu6016057; Wed, 14 Jul 2021 16:53:27 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma03fra.de.ibm.com with ESMTP id 39q368900q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 14 Jul 2021 16:53:27 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 16EGrOC833161646 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Jul 2021 16:53:24 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 86FC5A405B; Wed, 14 Jul 2021 16:53:24 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EA056A4054; Wed, 14 Jul 2021 16:53:23 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.181.132]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 14 Jul 2021 16:53:23 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=p237IXSNq5MmPJ7hErlDwR7UDrXesCekuLRXxTpCS9U=; b=HQd8oQ0X/CGkKMKAP1ZLZZdsmQhUCWf2JVHwkbAFDnDAb5Ye+QKJTeTeaYc7X+QknEkS 5v7n8kb5M1bpjqJAwEdsCUu0sHP311nTAKmtVElzuXrwEJOfU9X3TEf/x5ll1Q5gTGgx FuMtIQqMwgkp0gcW/ztSGOBESNKKJqXd7sG9jcJ97Z7b3V2XzlYBBFFdiJB35Scad1JA 6vyZEe0hTi/G+zm5F6BA+oXvUiQoGA2Jomgsu1T24ocpFErA0vqfbAdBmosVB94iZmz4 gcS2xQ6j0wzxIiS0rGS4Y9IsXibWiObM862rqBAGsrHfhN8TJnBW2P3F05FTyQO1rnO+ 8Q== From: Pierre Morel To: qemu-s390x@nongnu.org Subject: [PATCH v1 9/9] s390x: numa: implement NUMA for S390x Date: Wed, 14 Jul 2021 18:53:16 +0200 Message-Id: <1626281596-31061-10-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1626281596-31061-1-git-send-email-pmorel@linux.ibm.com> References: <1626281596-31061-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: mRKx2CtRPN8QYtxeTuI0Qm19-8gTg1RN X-Proofpoint-ORIG-GUID: 6xShHy2mw0fbccIQ8ZL1AsZvRuaoc2ee X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-07-14_08:2021-07-14, 2021-07-14 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 mlxscore=0 adultscore=0 phishscore=0 priorityscore=1501 impostorscore=0 suspectscore=0 clxscore=1015 malwarescore=0 lowpriorityscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107140096 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=pmorel@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1626281946272100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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 =3D MACHINE_GET_CLASS(machine); - int i; + const CPUArchId *slot; + int i, n =3D 1; =20 /* initialize possible_cpus */ mc->possible_cpu_arch_ids(machine); =20 s390_topology_setup(machine); - for (i =3D 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 =3D 1; i < machine->smp.max_cpus; i++) { + slot =3D &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 =3D 1; n < machine->smp.cpus && i < machine->smp.max_cpus; i++)= { + slot =3D &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++; } } =20 @@ -530,6 +553,7 @@ static const CPUArchIdList *s390_possible_cpu_arch_ids(= MachineState *ms) { int i; unsigned int max_cpus =3D ms->smp.max_cpus; + S390CcwMachineState *s390ms =3D S390_CCW_MACHINE(ms); =20 if (ms->possible_cpus) { g_assert(ms->possible_cpus && ms->possible_cpus->len =3D=3D max_cp= us); @@ -540,11 +564,20 @@ static const CPUArchIdList *s390_possible_cpu_arch_id= s(MachineState *ms) sizeof(CPUArchId) * max_cpus); ms->possible_cpus->len =3D max_cpus; for (i =3D 0; i < ms->possible_cpus->len; i++) { - ms->possible_cpus->cpus[i].type =3D ms->cpu_type; - ms->possible_cpus->cpus[i].vcpus_count =3D 1; - ms->possible_cpus->cpus[i].arch_id =3D i; - ms->possible_cpus->cpus[i].props.has_core_id =3D true; - ms->possible_cpus->cpus[i].props.core_id =3D i; + CPUArchId *slot =3D &ms->possible_cpus->cpus[i]; + + slot->type =3D ms->cpu_type; + slot->vcpus_count =3D 1; + slot->arch_id =3D i; + + slot->props.core_id =3D i; + slot->props.has_core_id =3D true; + slot->props.socket_id =3D i / ms->smp.cores; + slot->props.has_socket_id =3D true; + slot->props.book_id =3D slot->props.socket_id / ms->smp.sockets; + slot->props.has_book_id =3D true; + slot->props.drawer_id =3D slot->props.book_id / s390ms->books; + slot->props.has_drawer_id =3D true; } =20 return ms->possible_cpus; @@ -635,6 +668,11 @@ static void s390_smp_parse(MachineState *ms, QemuOpts = *opts) s390ms->books =3D books; } =20 +static int64_t s390x_get_default_cpu_node_id(const MachineState *ms, int i= dx) +{ + return idx / ms->smp.cores; +} + static void ccw_machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); @@ -666,6 +704,7 @@ static void ccw_machine_class_init(ObjectClass *oc, voi= d *data) nc->nmi_monitor_handler =3D s390_nmi; mc->default_ram_id =3D "s390.ram"; mc->smp_parse =3D s390_smp_parse; + mc->get_default_cpu_node_id =3D s390x_get_default_cpu_node_id; } =20 static inline bool machine_get_aes_key_wrap(Object *obj, Error **errp) --=20 2.25.1