From nobody Tue Feb 10 05:10:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494530874854949.7427045475797; Thu, 11 May 2017 12:27:54 -0700 (PDT) Received: from localhost ([::1]:49788 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tkf-00026e-96 for importer@patchew.org; Thu, 11 May 2017 15:27:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37776) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8tc4-0002MF-Un for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8tc3-0007mR-MJ for qemu-devel@nongnu.org; Thu, 11 May 2017 15:19:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47076) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8tc3-0007mB-DU for qemu-devel@nongnu.org; Thu, 11 May 2017 15:18:59 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6D00580F91; Thu, 11 May 2017 19:18:58 +0000 (UTC) Received: from localhost (ovpn-116-62.gru2.redhat.com [10.97.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 004EA17AE8; Thu, 11 May 2017 19:18:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6D00580F91 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6D00580F91 From: Eduardo Habkost To: Peter Maydell Date: Thu, 11 May 2017 16:18:20 -0300 Message-Id: <20170511191843.13784-7-ehabkost@redhat.com> In-Reply-To: <20170511191843.13784-1-ehabkost@redhat.com> References: <20170511191843.13784-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 11 May 2017 19:18:58 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 06/29] hw/arm/virt: extract mp-affinity calculation in separate function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Igor Mammedov , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Igor Mammedov Signed-off-by: Igor Mammedov Message-Id: <1493816238-33120-3-git-send-email-imammedo@redhat.com> Reviewed-by: Andrew Jones Signed-off-by: Eduardo Habkost --- target/arm/cpu.h | 2 ++ hw/arm/virt.c | 43 ++++++++++++++++++++++++++----------------- target/arm/cpu.c | 12 +++++++++--- 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 1055bfef3d..048faed9b9 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -710,6 +710,8 @@ static inline ARMCPU *arm_env_get_cpu(CPUARMState *env) return container_of(env, ARMCPU, env); } =20 +uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz); + #define ENV_GET_CPU(e) CPU(arm_env_get_cpu(e)) =20 #define ENV_OFFSET offsetof(ARMCPU, env) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 5f62a0321e..61ae43762a 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1194,6 +1194,29 @@ void virt_machine_done(Notifier *notifier, void *dat= a) virt_build_smbios(vms); } =20 +static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx) +{ + uint8_t clustersz =3D ARM_DEFAULT_CPUS_PER_CLUSTER; + VirtMachineClass *vmc =3D VIRT_MACHINE_GET_CLASS(vms); + + if (!vmc->disallow_affinity_adjustment) { + /* Adjust MPIDR like 64-bit KVM hosts, which incorporate the + * GIC's target-list limitations. 32-bit KVM hosts currently + * always create clusters of 4 CPUs, but that is expected to + * change when they gain support for gicv3. When KVM is enabled + * it will override the changes we make here, therefore our + * purposes are to make TCG consistent (with 64-bit KVM hosts) + * and to improve SGI efficiency. + */ + if (vms->gic_version =3D=3D 3) { + clustersz =3D GICV3_TARGETLIST_BITS; + } else { + clustersz =3D GIC_TARGETLIST_BITS; + } + } + return arm_cpu_mp_affinity(idx, clustersz); +} + static void machvirt_init(MachineState *machine) { VirtMachineState *vms =3D VIRT_MACHINE(machine); @@ -1210,7 +1233,6 @@ static void machvirt_init(MachineState *machine) CPUClass *cc; Error *err =3D NULL; bool firmware_loaded =3D bios_name || drive_get(IF_PFLASH, 0, 0); - uint8_t clustersz; =20 if (!cpu_model) { cpu_model =3D "cortex-a15"; @@ -1263,10 +1285,8 @@ static void machvirt_init(MachineState *machine) */ if (vms->gic_version =3D=3D 3) { virt_max_cpus =3D vms->memmap[VIRT_GIC_REDIST].size / 0x20000; - clustersz =3D GICV3_TARGETLIST_BITS; } else { virt_max_cpus =3D GIC_NCPU; - clustersz =3D GIC_TARGETLIST_BITS; } =20 if (max_cpus > virt_max_cpus) { @@ -1326,20 +1346,9 @@ static void machvirt_init(MachineState *machine) =20 for (n =3D 0; n < smp_cpus; n++) { Object *cpuobj =3D object_new(typename); - if (!vmc->disallow_affinity_adjustment) { - /* Adjust MPIDR like 64-bit KVM hosts, which incorporate the - * GIC's target-list limitations. 32-bit KVM hosts currently - * always create clusters of 4 CPUs, but that is expected to - * change when they gain support for gicv3. When KVM is enabled - * it will override the changes we make here, therefore our - * purposes are to make TCG consistent (with 64-bit KVM hosts) - * and to improve SGI efficiency. - */ - uint8_t aff1 =3D n / clustersz; - uint8_t aff0 =3D n % clustersz; - object_property_set_int(cpuobj, (aff1 << ARM_AFF1_SHIFT) | aff= 0, - "mp-affinity", NULL); - } + + object_property_set_int(cpuobj, virt_cpu_mp_affinity(vms, n), + "mp-affinity", NULL); =20 if (!vms->secure) { object_property_set_bool(cpuobj, false, "has_el3", NULL); diff --git a/target/arm/cpu.c b/target/arm/cpu.c index b357aee778..ee1406da12 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -458,6 +458,13 @@ static void arm_disas_set_info(CPUState *cpu, disassem= ble_info *info) } } =20 +uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz) +{ + uint32_t Aff1 =3D idx / clustersz; + uint32_t Aff0 =3D idx % clustersz; + return (Aff1 << ARM_AFF1_SHIFT) | Aff0; +} + static void arm_cpu_initfn(Object *obj) { CPUState *cs =3D CPU(obj); @@ -709,9 +716,8 @@ static void arm_cpu_realizefn(DeviceState *dev, Error *= *errp) * so these bits always RAZ. */ if (cpu->mp_affinity =3D=3D ARM64_AFFINITY_INVALID) { - uint32_t Aff1 =3D cs->cpu_index / ARM_DEFAULT_CPUS_PER_CLUSTER; - uint32_t Aff0 =3D cs->cpu_index % ARM_DEFAULT_CPUS_PER_CLUSTER; - cpu->mp_affinity =3D (Aff1 << ARM_AFF1_SHIFT) | Aff0; + cpu->mp_affinity =3D arm_cpu_mp_affinity(cs->cpu_index, + ARM_DEFAULT_CPUS_PER_CLUSTE= R); } =20 if (cpu->reset_hivecs) { --=20 2.11.0.259.g40922b1