All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] target-ppc: Fix number of threads per core limit
@ 2014-07-09 14:40 Alexey Kardashevskiy
  2014-07-10 10:33 ` Alexander Graf
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Kardashevskiy @ 2014-07-09 14:40 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alexey Kardashevskiy, qemu-ppc, Alexander Graf

The number of threads per core is different for POWER6/7/8 CPUs.
Guest systems do not expect to see more threads per core than
a specific CPU supports so we need to limit this number.
This limit is implemented by ppc_get_compat_smt_threads().

However it has a problem as it checks for PCR (Processor Compatibility
Register) mask, 2.05 means 2 threads per core, 2.06 - 4 threads.
For POWER8 one would expect PCR_COMPAT_2_07 bit set and
ppc_get_compat_smt_threads() checking for it to return 8 threads
per core. But the latest PowerISA spec now is 2.07 and there is
no 2.07 compatibility mode defined, QEMU does not define it either
(will be in PowerISA 2.08).

Instead of relying on a PCR mask, this uses kvmppc_smt_threads()
which returns the maximum supported threads number for KVM or
1 for TCG.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---

It does not look like that we really need a max_threads parameter
in the PowerPCCPUClass.
---
 target-ppc/translate_init.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 5eacd46..48177ed 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -9098,29 +9098,21 @@ static void ppc_cpu_unrealizefn(DeviceState *dev, Error **errp)
 
 int ppc_get_compat_smt_threads(PowerPCCPU *cpu)
 {
-    int ret = smp_threads;
-    PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
+    int ret = MIN(smp_threads, kvmppc_smt_threads());
 
     switch (cpu->cpu_version) {
     case CPU_POWERPC_LOGICAL_2_05:
-        ret = 2;
+        ret = MIN(ret, 2);
         break;
     case CPU_POWERPC_LOGICAL_2_06:
-        ret = 4;
+        ret = MIN(ret, 4);
         break;
     case CPU_POWERPC_LOGICAL_2_07:
-        ret = 8;
-        break;
-    default:
-        if (pcc->pcr_mask & PCR_COMPAT_2_06) {
-            ret = 4;
-        } else if (pcc->pcr_mask & PCR_COMPAT_2_05) {
-            ret = 2;
-        }
+        ret = MIN(ret, 8);
         break;
     }
 
-    return MIN(ret, smp_threads);
+    return ret;
 }
 
 int ppc_set_compat(PowerPCCPU *cpu, uint32_t cpu_version)
-- 
2.0.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] target-ppc: Fix number of threads per core limit
  2014-07-09 14:40 [Qemu-devel] [PATCH] target-ppc: Fix number of threads per core limit Alexey Kardashevskiy
@ 2014-07-10 10:33 ` Alexander Graf
  0 siblings, 0 replies; 2+ messages in thread
From: Alexander Graf @ 2014-07-10 10:33 UTC (permalink / raw)
  To: Alexey Kardashevskiy, qemu-devel; +Cc: qemu-ppc


On 09.07.14 16:40, Alexey Kardashevskiy wrote:
> The number of threads per core is different for POWER6/7/8 CPUs.
> Guest systems do not expect to see more threads per core than
> a specific CPU supports so we need to limit this number.
> This limit is implemented by ppc_get_compat_smt_threads().
>
> However it has a problem as it checks for PCR (Processor Compatibility
> Register) mask, 2.05 means 2 threads per core, 2.06 - 4 threads.
> For POWER8 one would expect PCR_COMPAT_2_07 bit set and
> ppc_get_compat_smt_threads() checking for it to return 8 threads
> per core. But the latest PowerISA spec now is 2.07 and there is
> no 2.07 compatibility mode defined, QEMU does not define it either
> (will be in PowerISA 2.08).
>
> Instead of relying on a PCR mask, this uses kvmppc_smt_threads()
> which returns the maximum supported threads number for KVM or
> 1 for TCG.
>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>

Thanks, applied to ppc-next (for 2.1).


Alex

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-07-10 10:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-09 14:40 [Qemu-devel] [PATCH] target-ppc: Fix number of threads per core limit Alexey Kardashevskiy
2014-07-10 10:33 ` Alexander Graf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.