From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34632) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c3z4X-0000Hr-Pb for qemu-devel@nongnu.org; Tue, 08 Nov 2016 00:35:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c3z4T-0002ER-Oh for qemu-devel@nongnu.org; Tue, 08 Nov 2016 00:35:49 -0500 Date: Tue, 8 Nov 2016 16:13:09 +1100 From: David Gibson Message-ID: <20161108051309.GQ28688@umbus.fritz.box> References: <1477825928-10803-1-git-send-email-david@gibson.dropbear.id.au> <1477825928-10803-9-git-send-email-david@gibson.dropbear.id.au> <3bd40861-0420-aedb-60da-9e13b0ac832e@ozlabs.ru> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="KHqYxKoy+XnO4RVf" Content-Disposition: inline In-Reply-To: <3bd40861-0420-aedb-60da-9e13b0ac832e@ozlabs.ru> Subject: Re: [Qemu-devel] [RFC 08/17] ppc: Rewrite ppc_get_compat_smt_threads() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexey Kardashevskiy Cc: nikunj@linux.vnet.ibm.com, mdroth@linux.vnet.ibm.com, thuth@redhat.com, lvivier@redhat.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org --KHqYxKoy+XnO4RVf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Nov 04, 2016 at 02:37:18PM +1100, Alexey Kardashevskiy wrote: > On 30/10/16 22:11, David Gibson wrote: > > To continue consolidation of compatibility mode information, this rewri= tes > > the ppc_get_compat_smt_threads() function using the table of compatibli= ty > > modes in target-ppc/compat.c. > >=20 > > It's not a direct replacement, the new ppc_compat_max_threads() function > > has simpler semantics - it just returns the number of threads the cpu > > model has, taking into account any compatiblity mode it is in. > >=20 > > This no longer takes into account kvmppc_smt_threads() as the previous > > version did. That check wasn't useful because we check elsewhere that >=20 > Nit: s/elsewhere/in ppc_cpu_realizefn()/ Changed. >=20 >=20 > Reviewed-by: Alexey Kardashevskiy >=20 >=20 >=20 >=20 > > CPUs aren't instantiated with more threads than kvm allows (or if we di= dn't > > things will already be broken and this won't make it any worse). > >=20 > > Signed-off-by: David Gibson > > --- > > hw/ppc/spapr.c | 8 ++++---- > > target-ppc/compat.c | 18 ++++++++++++++++++ > > target-ppc/cpu.h | 2 +- > > target-ppc/translate_init.c | 20 -------------------- > > 4 files changed, 23 insertions(+), 25 deletions(-) > >=20 > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > > index 276cefa..6c78889 100644 > > --- a/hw/ppc/spapr.c > > +++ b/hw/ppc/spapr.c > > @@ -207,6 +207,7 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachi= neState *spapr) > > PowerPCCPU *cpu =3D POWERPC_CPU(cs); > > DeviceClass *dc =3D DEVICE_GET_CLASS(cs); > > int index =3D ppc_get_vcpu_dt_id(cpu); > > + int compat_smt =3D MIN(smp_threads, ppc_compat_max_threads(cpu= )); > > =20 > > if ((index % smt) !=3D 0) { > > continue; > > @@ -241,8 +242,7 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachi= neState *spapr) > > return ret; > > } > > =20 > > - ret =3D spapr_fixup_cpu_smt_dt(fdt, offset, cpu, > > - ppc_get_compat_smt_threads(cpu)); > > + ret =3D spapr_fixup_cpu_smt_dt(fdt, offset, cpu, compat_smt); > > if (ret < 0) { > > return ret; > > } > > @@ -408,6 +408,7 @@ static void spapr_populate_cpu_dt(CPUState *cs, voi= d *fdt, 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)); > > sPAPRDRConnector *drc; > > sPAPRDRConnectorClass *drck; > > int drc_index; > > @@ -495,8 +496,7 @@ static void spapr_populate_cpu_dt(CPUState *cs, voi= d *fdt, int offset, > > =20 > > _FDT(spapr_fixup_cpu_numa_dt(fdt, offset, cs)); > > =20 > > - _FDT(spapr_fixup_cpu_smt_dt(fdt, offset, cpu, > > - ppc_get_compat_smt_threads(cpu))); > > + _FDT(spapr_fixup_cpu_smt_dt(fdt, offset, cpu, compat_smt)); > > } > > =20 > > static void spapr_populate_cpus_dt_node(void *fdt, sPAPRMachineState *= spapr) > > diff --git a/target-ppc/compat.c b/target-ppc/compat.c > > index f3fd9c6..66529a6 100644 > > --- a/target-ppc/compat.c > > +++ b/target-ppc/compat.c > > @@ -28,6 +28,7 @@ > > typedef struct { > > uint32_t pvr; > > uint64_t pcr; > > + int max_threads; > > } CompatInfo; > > =20 > > static const CompatInfo compat_table[] =3D { > > @@ -35,18 +36,22 @@ static const CompatInfo compat_table[] =3D { > > .pvr =3D CPU_POWERPC_LOGICAL_2_05, > > .pcr =3D PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_COMPAT_2_05 > > | PCR_TM_DIS | PCR_VSX_DIS, > > + .max_threads =3D 2, > > }, > > { /* POWER7, ISA2.06 */ > > .pvr =3D CPU_POWERPC_LOGICAL_2_06, > > .pcr =3D PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_TM_DIS, > > + .max_threads =3D 4, > > }, > > { > > .pvr =3D CPU_POWERPC_LOGICAL_2_06_PLUS, > > .pcr =3D PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_TM_DIS, > > + .max_threads =3D 4, > > }, > > { /* POWER8, ISA2.07 */ > > .pvr =3D CPU_POWERPC_LOGICAL_2_07, > > .pcr =3D PCR_COMPAT_2_07, > > + .max_threads =3D 8, > > }, > > }; > > =20 > > @@ -89,3 +94,16 @@ void ppc_set_compat(PowerPCCPU *cpu, uint32_t compat= _pvr, Error **errp) > > } > > } > > } > > + > > +int ppc_compat_max_threads(PowerPCCPU *cpu) > > +{ > > + const CompatInfo *compat =3D compat_by_pvr(cpu->compat_pvr); > > + int n_threads =3D CPU(cpu)->nr_threads; > > + > > + if (cpu->compat_pvr) { > > + g_assert(compat); > > + n_threads =3D MIN(n_threads, compat->max_threads); > > + } > > + > > + return n_threads; > > +} > > diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h > > index 15d5e4b..cfda7b2 100644 > > --- a/target-ppc/cpu.h > > +++ b/target-ppc/cpu.h > > @@ -1241,7 +1241,6 @@ void ppc_store_sdr1 (CPUPPCState *env, target_ulo= ng value); > > void ppc_store_msr (CPUPPCState *env, target_ulong value); > > =20 > > void ppc_cpu_list (FILE *f, fprintf_function cpu_fprintf); > > -int ppc_get_compat_smt_threads(PowerPCCPU *cpu); > > #if defined(TARGET_PPC64) > > #endif > > =20 > > @@ -1316,6 +1315,7 @@ static inline int cpu_mmu_index (CPUPPCState *env= , bool ifetch) > > /* Compatibility modes */ > > #if defined(TARGET_PPC64) > > void ppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr, Error **errp= ); > > +int ppc_compat_max_threads(PowerPCCPU *cpu); > > #endif /* defined(TARGET_PPC64) */ > > =20 > > #include "exec/cpu-all.h" > > diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c > > index a70eafb..ba48242 100644 > > --- a/target-ppc/translate_init.c > > +++ b/target-ppc/translate_init.c > > @@ -9952,26 +9952,6 @@ static void ppc_cpu_unrealizefn(DeviceState *dev= , Error **errp) > > } > > } > > =20 > > -int ppc_get_compat_smt_threads(PowerPCCPU *cpu) > > -{ > > - CPUState *cs =3D CPU(cpu); > > - int ret =3D MIN(cs->nr_threads, kvmppc_smt_threads()); > > - > > - switch (cpu->compat_pvr) { > > - case CPU_POWERPC_LOGICAL_2_05: > > - ret =3D MIN(ret, 2); > > - break; > > - case CPU_POWERPC_LOGICAL_2_06: > > - ret =3D MIN(ret, 4); > > - break; > > - case CPU_POWERPC_LOGICAL_2_07: > > - ret =3D MIN(ret, 8); > > - break; > > - } > > - > > - return ret; > > -} > > - > > static gint ppc_cpu_compare_class_pvr(gconstpointer a, gconstpointer b) > > { > > ObjectClass *oc =3D (ObjectClass *)a; > >=20 >=20 >=20 --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --KHqYxKoy+XnO4RVf Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYIV7jAAoJEGw4ysog2bOSQ2kP/3N8ph477BvgGA7vgIvIPpuX UJ/45gXLDAU7WpBm2PNjhsFniYKVlodJRORfB1DCXI/JLNNkH6OZ4bWqPAoBX7je MA7FF9BsoRTrsJRerxmtTRXT6bnw6gPFP47Q0RdA6YOnC/iTy75SebcB8ll+8J/T Y/9ajzilV4usWx/Z3M+rqcYJ1wrIfjoiGrCHm8lDkueEa885USO1p/7Jw3rdmTD8 6RQOjo4UucxV6oZJRIn9CfV6CfYQNDyWe3euxiX4hXi0befeAt/EspC4nxpMP1jG ljsNDEjpyKJhPUwoE5GtzpG9TBfP76QTzazWB1r1eTE3DywRn91S6AFMnp+K+zRS tD1FLzytPVi+itTY2MYKvDo1m0usmVNioz51XVhUrLRvNkrFnEBOKtslOt7ZMVUQ QuwuyrNYQ2DuhtKY7hQWTn+2zxBLOfJy45RJVY/5qsWRTTgif8VDUP/sjmzgQWjA UfqGVavmb4J7NokwAUFdPsykjwL2M29jWvGt86W9dk9l46Lmp+xmEiLOR9P7k4Eg nW8rJoX+ZU8yVzPaEWxBR9J1v0qurhThuNc+uCDL6roJcKXHCKmu35oinoK1YNAi Rt9LRvAqQ9s3FjfaUcEpKXXpgDWVTWNICIzVQl7dzlgWfAu8Q/m6jdYxIxp/lTAs c5t02WSPagKCMBr2tJTd =7IWe -----END PGP SIGNATURE----- --KHqYxKoy+XnO4RVf--