From nobody Mon Apr 29 10:55:11 2024 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.zohomail.com; dkim=fail; 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1516001329240499.4180384339385; Sun, 14 Jan 2018 23:28:49 -0800 (PST) Received: from localhost ([::1]:44024 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eazC5-0001NJ-Q9 for importer@patchew.org; Mon, 15 Jan 2018 02:28:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37881) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eazAy-0000ia-0c for qemu-devel@nongnu.org; Mon, 15 Jan 2018 02:27:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eazAw-0000cF-So for qemu-devel@nongnu.org; Mon, 15 Jan 2018 02:27:24 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:44785) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eazAw-0000aW-Ep; Mon, 15 Jan 2018 02:27:22 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3zKlKy5stzz9sBW; Mon, 15 Jan 2018 18:27:18 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1516001238; bh=SAz/BEajg7fxKHQnq2zUoWSrOaO1eMb8ytXRbT0SVbM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kO4ZWG9AKvTVA8JXaF1ii8TUlhZhsnxO0z0aNVLNtJsNbqZm5s/jyIucqAf9Kkbjc hxV1IqMojV0Zy7cBlimkd+PMLj1/R9Y/h67u4oJC1tBPHbvNbtB0E6s9ash0Yvvpks 8DxKTIdaWrDVRfu8toArKLsRqV4Jzk8/FtIt/yhM= From: David Gibson To: groug@kaod.org, joserz@linux.vnet.ibm.com, surajjs@au1.ibm.com, sam.bobroff@au1.ibm.com Date: Mon, 15 Jan 2018 18:27:14 +1100 Message-Id: <20180115072715.25921-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180115072715.25921-1-david@gibson.dropbear.id.au> References: <20180115072715.25921-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PATCH 1/2] target/ppc: Clarify compat mode max_threads value 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: lvivier@redhat.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We recently had some discussions that were sidetracked for a while, because nearly everyone misapprehended the purpose of the 'max_threads' field in the compatiblity modes table. It's all about guest expectations, not host expectations or support (that's handled elsewhere). In an attempt to avoid a repeat of that confusion, rename the field to 'max_vthreads' and add an explanatory comment. Signed-off-by: David Gibson Reviewed-by: Greg Kurz Reviewed-by: Jose Ricardo Ziviani Reviewed-by: Laurent Vivier --- hw/ppc/spapr.c | 4 ++-- target/ppc/compat.c | 25 +++++++++++++++++-------- target/ppc/cpu.h | 2 +- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 3e528fe91e..e35214bfc3 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -345,7 +345,7 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineSt= ate *spapr) PowerPCCPU *cpu =3D POWERPC_CPU(cs); DeviceClass *dc =3D DEVICE_GET_CLASS(cs); int index =3D spapr_vcpu_id(cpu); - int compat_smt =3D MIN(smp_threads, ppc_compat_max_threads(cpu)); + int compat_smt =3D MIN(smp_threads, ppc_compat_max_vthreads(cpu)); =20 if ((index % smt) !=3D 0) { continue; @@ -503,7 +503,7 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *f= dt, int offset, size_t page_sizes_prop_size; uint32_t vcpus_per_socket =3D smp_threads * smp_cores; uint32_t pft_size_prop[] =3D {0, cpu_to_be32(spapr->htab_shift)}; - int compat_smt =3D MIN(smp_threads, ppc_compat_max_threads(cpu)); + int compat_smt =3D MIN(smp_threads, ppc_compat_max_vthreads(cpu)); sPAPRDRConnector *drc; int drc_index; uint32_t radix_AP_encodings[PPC_PAGE_SIZES_MAX_SZ]; diff --git a/target/ppc/compat.c b/target/ppc/compat.c index 276b5b52c2..807c906f68 100644 --- a/target/ppc/compat.c +++ b/target/ppc/compat.c @@ -32,7 +32,16 @@ typedef struct { uint32_t pvr; uint64_t pcr; uint64_t pcr_level; - int max_threads; + + /* + * Maximum allowed virtual threads per virtual core + * + * This is to stop older guests getting confused by seeing more + * threads than they think the cpu can support. Usually it's + * equal to the number of threads supported on bare metal + * hardware, but not always (see POWER9). + */ + int max_vthreads; } CompatInfo; =20 static const CompatInfo compat_table[] =3D { @@ -45,28 +54,28 @@ static const CompatInfo compat_table[] =3D { .pcr =3D PCR_COMPAT_3_00 | PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_COMPAT_2_05 | PCR_TM_DIS | PCR_VSX_DIS, .pcr_level =3D PCR_COMPAT_2_05, - .max_threads =3D 2, + .max_vthreads =3D 2, }, { /* POWER7, ISA2.06 */ .name =3D "power7", .pvr =3D CPU_POWERPC_LOGICAL_2_06, .pcr =3D PCR_COMPAT_3_00 | PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR= _TM_DIS, .pcr_level =3D PCR_COMPAT_2_06, - .max_threads =3D 4, + .max_vthreads =3D 4, }, { .name =3D "power7+", .pvr =3D CPU_POWERPC_LOGICAL_2_06_PLUS, .pcr =3D PCR_COMPAT_3_00 | PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR= _TM_DIS, .pcr_level =3D PCR_COMPAT_2_06, - .max_threads =3D 4, + .max_vthreads =3D 4, }, { /* POWER8, ISA2.07 */ .name =3D "power8", .pvr =3D CPU_POWERPC_LOGICAL_2_07, .pcr =3D PCR_COMPAT_3_00 | PCR_COMPAT_2_07, .pcr_level =3D PCR_COMPAT_2_07, - .max_threads =3D 8, + .max_vthreads =3D 8, }, { /* POWER9, ISA3.00 */ .name =3D "power9", @@ -80,7 +89,7 @@ static const CompatInfo compat_table[] =3D { * confusing if half of the threads disappear from the guest * if it announces it's POWER9 aware at CAS time. */ - .max_threads =3D 8, + .max_vthreads =3D 8, }, }; =20 @@ -192,14 +201,14 @@ void ppc_set_compat_all(uint32_t compat_pvr, Error **= errp) } } =20 -int ppc_compat_max_threads(PowerPCCPU *cpu) +int ppc_compat_max_vthreads(PowerPCCPU *cpu) { const CompatInfo *compat =3D compat_by_pvr(cpu->compat_pvr); int n_threads =3D CPU(cpu)->nr_threads; =20 if (cpu->compat_pvr) { g_assert(compat); - n_threads =3D MIN(n_threads, compat->max_threads); + n_threads =3D MIN(n_threads, compat->max_vthreads); } =20 return n_threads; diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index a5e49f23e9..dc6820c5eb 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1395,7 +1395,7 @@ void ppc_set_compat(PowerPCCPU *cpu, uint32_t compat_= pvr, Error **errp); #if !defined(CONFIG_USER_ONLY) void ppc_set_compat_all(uint32_t compat_pvr, Error **errp); #endif -int ppc_compat_max_threads(PowerPCCPU *cpu); +int ppc_compat_max_vthreads(PowerPCCPU *cpu); void ppc_compat_add_property(Object *obj, const char *name, uint32_t *compat_pvr, const char *basedesc, Error **errp); --=20 2.14.3 From nobody Mon Apr 29 10:55:11 2024 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.zohomail.com; dkim=fail; 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 1516001484241227.40399470962438; Sun, 14 Jan 2018 23:31:24 -0800 (PST) Received: from localhost ([::1]:44170 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eazEp-0003AX-H1 for importer@patchew.org; Mon, 15 Jan 2018 02:31:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37898) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eazB0-0000iy-Rk for qemu-devel@nongnu.org; Mon, 15 Jan 2018 02:27:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eazAw-0000cN-Tq for qemu-devel@nongnu.org; Mon, 15 Jan 2018 02:27:26 -0500 Received: from ozlabs.org ([103.22.144.67]:34483) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eazAw-0000aZ-Ez; Mon, 15 Jan 2018 02:27:22 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3zKlKy4tzfz9s7n; Mon, 15 Jan 2018 18:27:18 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1516001238; bh=SkhGgLKBlI488aF70LWhT1PsfpqUlypbY/+hk8J+gBk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=At6u2v1lEzQerRetRR63kw8BpJZI+KN/qE7I9b6CfZGIfxwRqPJUkKLVNuglk/PXU mzow+hLzEsCT4ySn/FBKIlzQkHe540rwcyNXa+yj/VU1xTvlg3nPrevVggPFb6QGW2 NsnyuOEAkGCnC1z5I56DfjrSlu7Pl+HG6T6cPB5c= From: David Gibson To: groug@kaod.org, joserz@linux.vnet.ibm.com, surajjs@au1.ibm.com, sam.bobroff@au1.ibm.com Date: Mon, 15 Jan 2018 18:27:15 +1100 Message-Id: <20180115072715.25921-3-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180115072715.25921-1-david@gibson.dropbear.id.au> References: <20180115072715.25921-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PATCH 2/2] spapr: Adjust default VSMT value for better migration compatibility 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: lvivier@redhat.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" fa98fbfc "PC: KVM: Support machine option to set VSMT mode" introduced the "vsmt" parameter for the pseries machine type, which controls the spacing of the vcpu ids of thread 0 for each virtual core. This was done to bring some consistency and stability to how that was done, while still allowing backwards compatibility for migration and otherwise. The default value we used for vsmt was set to the max of the host's advertised default number of threads and the number of vthreads per vcore in the guest. This was done to continue running without extra parameters on older KVM versions which don't allow the VSMT value to be changed. Unfortunately, even that smaller than before leakage of host configuration into guest visible configuration still breaks things. Specifically a guest with 4 (or less) vthread/vcore will get a different vsmt value when running on a POWER8 (vsmt=3D=3D8) and POWER9 (vsmt=3D=3D4) host. That mean= s the vcpu ids don't line up so you can't migrate between them, though you should be able to. Long term we really want to make vsmt =3D=3D smp_threads for sufficiently new machine types. However, that means that qemu will then require a sufficiently recent KVM (one which supports changing VSMT) - that's still not widely enough deployed to be really comfortable to do. In the meantime we some default that will work as often as possible. This patch changes that default to 8 in all circumstances. This does change guest visible behaviour (including for existing machine versions) for many cases - just not the most common/important case. Following is case by case justification for why this is still the least worst option. Note that any of the old behaviours can still be duplicated after this patch, it's just that it requires manual intervention by setting the vsmt property on the command line. KVM HV on POWER8 host: This is the overwhelmingly common case in production setups, and is unchanged by design. POWER8 hosts will advertise a default VSMT mode of 8, and > 8 vthreads/vcore isn't permitted KVM HV on POWER7 host: Will break, but POWER7s allowing KVM were never released to the public. KVM HV on POWER9 host: Not yet released to the public, breaking this now will reduce other breakage later. KVM HV on PowerPC 970: Will theoretically break it, but it was barely supported to begin with and already required various user visible hacks to work. Also so old that I just don't care. TCG: This is the nastiest one; it means migration of TCG guests (without manual vsmt setting) will break. Since TCG is rarely used in production I think this is worth it for the other benefits. It does also remove one more barrier to TCG<->KVM migration which could be interesting for debugging applications. KVM PR: As with TCG, this will break migration of existing configurations, without adding extra manual vsmt options. As with TCG, it is rare in production so I think the benefits outweigh breakages. Signed-off-by: David Gibson Reviewed-by: Greg Kurz Reviewed-by: Jose Ricardo Ziviani Reviewed-by: Laurent Vivier --- hw/ppc/spapr.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index e35214bfc3..8e5ef7c9de 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2305,9 +2305,14 @@ static void spapr_set_vsmt_mode(sPAPRMachineState *s= papr, Error **errp) } /* In this case, spapr->vsmt has been set by the command line */ } else { - /* Choose a VSMT mode that may be higher than necessary but is - * likely to be compatible with hosts that don't have VSMT. */ - spapr->vsmt =3D MAX(kvm_smt, smp_threads); + /* + * Default VSMT value is tricky, because we need it to be as + * consistent as possible (for migration), but this requires + * changing it for at least some existing cases. We pick 8 as + * the value that we'd get with KVM on POWER8, the + * overwhelmingly common case in production systems. + */ + spapr->vsmt =3D 8; } =20 /* KVM: If necessary, set the SMT mode: */ --=20 2.14.3