Browse Source

powerpc: Add threads_per_subcore

On POWER8 we have a new concept of a subcore. This is what happens when
you take a regular core and split it. A subcore is a grouping of two or
four SMT threads, as well as a handfull of SPRs which allows the subcore
to appear as if it were a core from the point of view of a guest.

Unlike threads_per_core which is fixed at boot, threads_per_subcore can
change while the system is running. Most code will not want to use
threads_per_subcore.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Michael Neuling <mikey@neuling.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Michael Ellerman 11 years ago
parent
commit
5853aef1ac
2 changed files with 10 additions and 1 deletions
  1. 7 0
      arch/powerpc/include/asm/cputhreads.h
  2. 3 1
      arch/powerpc/kernel/setup-common.c

+ 7 - 0
arch/powerpc/include/asm/cputhreads.h

@@ -18,10 +18,12 @@
 
 
 #ifdef CONFIG_SMP
 #ifdef CONFIG_SMP
 extern int threads_per_core;
 extern int threads_per_core;
+extern int threads_per_subcore;
 extern int threads_shift;
 extern int threads_shift;
 extern cpumask_t threads_core_mask;
 extern cpumask_t threads_core_mask;
 #else
 #else
 #define threads_per_core	1
 #define threads_per_core	1
+#define threads_per_subcore	1
 #define threads_shift		0
 #define threads_shift		0
 #define threads_core_mask	(CPU_MASK_CPU0)
 #define threads_core_mask	(CPU_MASK_CPU0)
 #endif
 #endif
@@ -74,6 +76,11 @@ static inline int cpu_thread_in_core(int cpu)
 	return cpu & (threads_per_core - 1);
 	return cpu & (threads_per_core - 1);
 }
 }
 
 
+static inline int cpu_thread_in_subcore(int cpu)
+{
+	return cpu & (threads_per_subcore - 1);
+}
+
 static inline int cpu_first_thread_sibling(int cpu)
 static inline int cpu_first_thread_sibling(int cpu)
 {
 {
 	return cpu & ~(threads_per_core - 1);
 	return cpu & ~(threads_per_core - 1);

+ 3 - 1
arch/powerpc/kernel/setup-common.c

@@ -390,9 +390,10 @@ void __init check_for_initrd(void)
 
 
 #ifdef CONFIG_SMP
 #ifdef CONFIG_SMP
 
 
-int threads_per_core, threads_shift;
+int threads_per_core, threads_per_subcore, threads_shift;
 cpumask_t threads_core_mask;
 cpumask_t threads_core_mask;
 EXPORT_SYMBOL_GPL(threads_per_core);
 EXPORT_SYMBOL_GPL(threads_per_core);
+EXPORT_SYMBOL_GPL(threads_per_subcore);
 EXPORT_SYMBOL_GPL(threads_shift);
 EXPORT_SYMBOL_GPL(threads_shift);
 EXPORT_SYMBOL_GPL(threads_core_mask);
 EXPORT_SYMBOL_GPL(threads_core_mask);
 
 
@@ -401,6 +402,7 @@ static void __init cpu_init_thread_core_maps(int tpc)
 	int i;
 	int i;
 
 
 	threads_per_core = tpc;
 	threads_per_core = tpc;
+	threads_per_subcore = tpc;
 	cpumask_clear(&threads_core_mask);
 	cpumask_clear(&threads_core_mask);
 
 
 	/* This implementation only supports power of 2 number of threads
 	/* This implementation only supports power of 2 number of threads