qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
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
Subject: Re: [Qemu-devel] [RFC 08/17] ppc: Rewrite ppc_get_compat_smt_threads()
Date: Tue, 8 Nov 2016 16:13:09 +1100	[thread overview]
Message-ID: <20161108051309.GQ28688@umbus.fritz.box> (raw)
In-Reply-To: <3bd40861-0420-aedb-60da-9e13b0ac832e@ozlabs.ru>

[-- Attachment #1: Type: text/plain, Size: 6936 bytes --]

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 rewrites
> > the ppc_get_compat_smt_threads() function using the table of compatiblity
> > modes in target-ppc/compat.c.
> > 
> > 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.
> > 
> > This no longer takes into account kvmppc_smt_threads() as the previous
> > version did.  That check wasn't useful because we check elsewhere that
> 
> Nit: s/elsewhere/in ppc_cpu_realizefn()/

Changed.

> 
> 
> Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> 
> 
> 
> 
> > CPUs aren't instantiated with more threads than kvm allows (or if we didn't
> > things will already be broken and this won't make it any worse).
> > 
> > Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> > ---
> >  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(-)
> > 
> > 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, sPAPRMachineState *spapr)
> >          PowerPCCPU *cpu = POWERPC_CPU(cs);
> >          DeviceClass *dc = DEVICE_GET_CLASS(cs);
> >          int index = ppc_get_vcpu_dt_id(cpu);
> > +        int compat_smt = MIN(smp_threads, ppc_compat_max_threads(cpu));
> >  
> >          if ((index % smt) != 0) {
> >              continue;
> > @@ -241,8 +242,7 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineState *spapr)
> >              return ret;
> >          }
> >  
> > -        ret = spapr_fixup_cpu_smt_dt(fdt, offset, cpu,
> > -                                     ppc_get_compat_smt_threads(cpu));
> > +        ret = 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, void *fdt, int offset,
> >      size_t page_sizes_prop_size;
> >      uint32_t vcpus_per_socket = smp_threads * smp_cores;
> >      uint32_t pft_size_prop[] = {0, cpu_to_be32(spapr->htab_shift)};
> > +    int compat_smt = 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, void *fdt, int offset,
> >  
> >      _FDT(spapr_fixup_cpu_numa_dt(fdt, offset, cs));
> >  
> > -    _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));
> >  }
> >  
> >  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;
> >  
> >  static const CompatInfo compat_table[] = {
> > @@ -35,18 +36,22 @@ static const CompatInfo compat_table[] = {
> >          .pvr = CPU_POWERPC_LOGICAL_2_05,
> >          .pcr = PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_COMPAT_2_05
> >                 | PCR_TM_DIS | PCR_VSX_DIS,
> > +        .max_threads = 2,
> >      },
> >      { /* POWER7, ISA2.06 */
> >          .pvr = CPU_POWERPC_LOGICAL_2_06,
> >          .pcr = PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_TM_DIS,
> > +        .max_threads = 4,
> >      },
> >      {
> >          .pvr = CPU_POWERPC_LOGICAL_2_06_PLUS,
> >          .pcr = PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_TM_DIS,
> > +        .max_threads = 4,
> >      },
> >      { /* POWER8, ISA2.07 */
> >          .pvr = CPU_POWERPC_LOGICAL_2_07,
> >          .pcr = PCR_COMPAT_2_07,
> > +        .max_threads = 8,
> >      },
> >  };
> >  
> > @@ -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 = compat_by_pvr(cpu->compat_pvr);
> > +    int n_threads = CPU(cpu)->nr_threads;
> > +
> > +    if (cpu->compat_pvr) {
> > +        g_assert(compat);
> > +        n_threads = 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_ulong value);
> >  void ppc_store_msr (CPUPPCState *env, target_ulong value);
> >  
> >  void ppc_cpu_list (FILE *f, fprintf_function cpu_fprintf);
> > -int ppc_get_compat_smt_threads(PowerPCCPU *cpu);
> >  #if defined(TARGET_PPC64)
> >  #endif
> >  
> > @@ -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) */
> >  
> >  #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)
> >      }
> >  }
> >  
> > -int ppc_get_compat_smt_threads(PowerPCCPU *cpu)
> > -{
> > -    CPUState *cs = CPU(cpu);
> > -    int ret = MIN(cs->nr_threads, kvmppc_smt_threads());
> > -
> > -    switch (cpu->compat_pvr) {
> > -    case CPU_POWERPC_LOGICAL_2_05:
> > -        ret = MIN(ret, 2);
> > -        break;
> > -    case CPU_POWERPC_LOGICAL_2_06:
> > -        ret = MIN(ret, 4);
> > -        break;
> > -    case CPU_POWERPC_LOGICAL_2_07:
> > -        ret = MIN(ret, 8);
> > -        break;
> > -    }
> > -
> > -    return ret;
> > -}
> > -
> >  static gint ppc_cpu_compare_class_pvr(gconstpointer a, gconstpointer b)
> >  {
> >      ObjectClass *oc = (ObjectClass *)a;
> > 
> 
> 

-- 
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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2016-11-08  5:35 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-30 11:11 [Qemu-devel] [RFC 00/17] Clean up compatibility mode handling David Gibson
2016-10-30 11:11 ` [Qemu-devel] [RFC 01/17] ppc: Remove some stub POWER6 models David Gibson
2016-10-31  7:38   ` Thomas Huth
2016-10-31  8:37     ` David Gibson
2016-11-08  3:40   ` David Gibson
2016-10-30 11:11 ` [Qemu-devel] [RFC 02/17] powernv: CPU compatibility modes don't make sense for powernv David Gibson
2016-10-31  7:46   ` Thomas Huth
2016-10-31  8:38     ` David Gibson
2016-10-31 10:35   ` Greg Kurz
2016-10-30 11:11 ` [Qemu-devel] [RFC 03/17] pseries: Always use core objects for CPU construction David Gibson
2016-11-03  8:11   ` Alexey Kardashevskiy
2016-11-04  9:51     ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2016-11-08  5:34       ` David Gibson
2016-10-30 11:11 ` [Qemu-devel] [RFC 04/17] pseries: Make cpu_update during CAS unconditional David Gibson
2016-11-03  8:24   ` Alexey Kardashevskiy
2016-11-04 10:45   ` Thomas Huth
2016-11-08  3:44     ` David Gibson
2016-10-30 11:11 ` [Qemu-devel] [RFC 05/17] ppc: Clean up and QOMify hypercall emulation David Gibson
2016-11-03  8:50   ` Alexey Kardashevskiy
2016-10-30 11:11 ` [Qemu-devel] [RFC 06/17] ppc: Rename cpu_version to compat_pvr David Gibson
2016-11-04  2:26   ` Alexey Kardashevskiy
2016-11-08  3:48     ` David Gibson
2016-11-04 10:51   ` Thomas Huth
2016-10-30 11:11 ` [Qemu-devel] [RFC 07/17] ppc: Rewrite ppc_set_compat() David Gibson
2016-11-04  2:57   ` Alexey Kardashevskiy
2016-11-08  3:49     ` David Gibson
2016-10-30 11:11 ` [Qemu-devel] [RFC 08/17] ppc: Rewrite ppc_get_compat_smt_threads() David Gibson
2016-11-04  3:37   ` Alexey Kardashevskiy
2016-11-08  5:13     ` David Gibson [this message]
2016-10-30 11:12 ` [Qemu-devel] [RFC 09/17] ppc: Validate compatibility modes when setting David Gibson
2016-10-31  5:55   ` Alexey Kardashevskiy
2016-10-31  8:39     ` David Gibson
2016-11-04  3:45       ` Alexey Kardashevskiy
2016-11-08  5:14         ` David Gibson
2016-10-30 11:12 ` [Qemu-devel] [RFC 10/17] pseries: Rewrite CAS PVR compatibility logic David Gibson
2016-10-31  5:00   ` Alexey Kardashevskiy
2016-10-31  5:44     ` David Gibson
2016-11-10 17:54   ` Michael Roth
2016-11-10 23:50     ` David Gibson
2016-10-30 11:12 ` [Qemu-devel] [RFC 11/17] ppc: Add ppc_set_compat_all() David Gibson
2016-11-04  4:01   ` Alexey Kardashevskiy
2016-11-08  5:18     ` David Gibson
2016-11-09  1:27       ` Alexey Kardashevskiy
2016-11-09  3:52         ` David Gibson
2016-11-09  5:18           ` Alexey Kardashevskiy
2016-11-10  3:13             ` David Gibson
2016-10-30 11:12 ` [Qemu-devel] [RFC 12/17] ppc: Migrate compatibility mode David Gibson
2016-11-04  5:58   ` Alexey Kardashevskiy
2016-11-08  5:19     ` David Gibson
2016-11-08  5:51       ` Alexey Kardashevskiy
2016-11-10  1:59         ` David Gibson
2016-11-10 23:55           ` Michael Roth
2016-11-14  1:15             ` David Gibson
2016-10-30 11:12 ` [Qemu-devel] [RFC 13/17] pseries: Move CPU compatibility property to machine David Gibson
2016-11-04  7:43   ` Alexey Kardashevskiy
2016-11-08  5:26     ` David Gibson
2016-11-08  5:56       ` Alexey Kardashevskiy
2016-11-09  4:41         ` David Gibson
2016-10-30 11:12 ` [Qemu-devel] [RFC 14/17] pseries: Reset CPU compatibility mode David Gibson
2016-11-04  7:50   ` Alexey Kardashevskiy
2016-10-30 11:12 ` [Qemu-devel] [RFC 15/17] ppc: Check that CPU model stays consistent across migration David Gibson
2016-11-04  7:54   ` Alexey Kardashevskiy
2016-11-08  5:29     ` David Gibson
2016-11-08  6:03       ` Alexey Kardashevskiy
2016-11-09  4:24         ` David Gibson
2016-11-09  6:06           ` Alexey Kardashevskiy
2016-11-09  6:40             ` David Gibson
2016-10-30 11:12 ` [Qemu-devel] [RFC 16/17] ppc: Remove counter-productive "sanity checks" in migration David Gibson
2016-11-04  5:52   ` Alexey Kardashevskiy
2016-11-08  5:31     ` David Gibson
2016-11-11 18:13       ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2016-11-14  2:34         ` Alexey Kardashevskiy
2016-11-14  6:08           ` David Gibson
2016-10-30 11:12 ` [Qemu-devel] [RFC 17/17] pseries: Default to POWER8 compatibility mode David Gibson
2016-10-30 11:58   ` David Gibson

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=20161108051309.GQ28688@umbus.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=aik@ozlabs.ru \
    --cc=lvivier@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=nikunj@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.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).