Create cpu_sibling_map for PPC64
PATCH 1/1 Create cpu_sibling_map for PPC64
In light of some proposed changes in the sched_domains code, I coded up this little ditty that simply creates and populates a cpu_sibling_map for PPC64 machines. The patch just checks the CPU flags to determine if the CPU supports SMT (aka Hyper-Threading aka Multi-Threading aka ...) and fills in a mask of the siblings for each CPU in the system. This should allow us to build sched_domains for PPC64 with generic code in kernel/sched.c for the SMT systems. SMT is becoming more popular and is turning up in more and more architectures. I don't think it will be too long until this feature is supported by most arches...
[mcd@arrakis source]$ diffstat~/linux/patches/ppc64-cpu_sibling_map.patch
arch/ppc64/kernel/smp.c | 7 +++++++ include/asm-ppc64/smp.h | 1 + 2 files changed, 8 insertions(+)
-Matt
arch/ppc64/kernel/smp.c +7 -0
@@ -64,6 +64,7 @@ cpumask_t cpu_possible_map = CPU_MASK_NOcpumask_t cpu_online_map =CPU_MASK_NONE ;cpumask_t cpu_available_map =CPU_MASK_NONE ;cpumask_t cpu_present_at_boot =CPU_MASK_NONE ; +cpumask_t cpu_sibling_map[NR_CPUS] = { [0 .. NR_CPUS-1] = CPU_MASK_NONE };EXPORT_SYMBOL (cpu_online_map);EXPORT_SYMBOL (cpu_possible_map);
@@ -870,6 +871,12 @@ void __init smp_prepare_cpus(unsigned infor_each_cpu (cpu)if (cpu != boot_cpuid)smp_create_idle (cpu); + +for_each_cpu (cpu) { +cpu_set (cpu, cpu_sibling_map[cpu]); +if (cur_cpu_spec->cpu_features &CPU_FTR_SMT ) +cpu_set (cpu ^0x1 , cpu_sibling_map[cpu]); + } }void __devinit smp_prepare_boot_cpu (void )
include/asm-ppc64/smp.h +1 -0
@@ -49,6 +49,7 @@ extern cpumask_t cpu_present_at_boot;extern cpumask_t cpu_online_map;extern cpumask_t cpu_possible_map;extern cpumask_t cpu_available_map; +extern cpumask_t cpu_sibling_map[NR_CPUS ];#define cpu_present_at_boot (cpu) cpu_isset(cpu, cpu_present_at_boot)#define cpu_available (cpu) cpu_isset(cpu, cpu_available_map)
Quoted 4 lines · Matthew Dobson
In light of some proposed changes in the
sched_domainscode, I coded up
this little ditty that simply creates and populates acpu_sibling_mapfor PPC64 machines.
err, did you compile it?
arch/ppc64/kernel/smp.c renamed from arch/ppc64/kernel/smp.c~create-cpu_sibling_map-for-ppc64-fix +1 -1
@@ -64,7 +64,7 @@ cpumask_t cpu_possible_map = CPU_MASK_NOcpumask_t cpu_online_map =CPU_MASK_NONE ;cpumask_t cpu_available_map =CPU_MASK_NONE ;cpumask_t cpu_present_at_boot =CPU_MASK_NONE ; -cpumask_t cpu_sibling_map[NR_CPUS] = { [0 .. NR_CPUS-1] = CPU_MASK_NONE }; +cpumask_t cpu_sibling_map[NR_CPUS ] = { [0 ...NR_CPUS -1 ] =CPU_MASK_NONE };EXPORT_SYMBOL (cpu_online_map);EXPORT_SYMBOL (cpu_possible_map);
_
Quoted 7 lines · Andrew Morton
Quoted 4 lines · Matthew Dobson
In light of some proposed changes in the
sched_domainscode, I coded up
this little ditty that simply creates and populates acpu_sibling_mapfor PPC64 machines.err, did you compile it?
Oh, you wanted the version that compiles!?! ;) Besides me being really bad at counting dots, our lab was down for a bit and I didn't test or compile that before I sent it. I was sending it more as an RFC than a patch destined for acceptance (yet). I still don't have access to a machine to test it on, but I hope to snag some time soon. Glad to see *someone* is reading my code, though, since it obviously isn't me! ;)
-Matt
Quoted 7 lines · Andrew Morton
Quoted 4 lines · Matthew Dobson
In light of some proposed changes in the
sched_domainscode, I coded up
this little ditty that simply creates and populates acpu_sibling_mapfor PPC64 machines.err, did you compile it?
Ok... beyond not compiling it, I must have had my brain turned off when I pushed the patch forward from 2.6.7-mm? to 2.6.8-rc2-mm1, because cpu_sibling_map[] is already there, although only conditionally defined for CONFIG_SCHED_SMT. Talking to PPC developers at OLS, I think cpu_sibling_map[] has (or more properly, will have) uses outside sched_domains and thus deserves an unconditional definition. Here's a patch to change that.
[mcd@arrakis source]$ diffstat~/linux/patches/ppc64-cpu_sibling_map.patch
arch/ppc64/kernel/smp.c | 7 +------ include/asm-ppc64/smp.h | 4 +--- 2 files changed, 2 insertions(+), 9 deletions(-)
-Matt
arch/ppc64/kernel/smp.c +1 -6
@@ -55,15 +55,13 @@#include <asm/rtas.h> int smp_threads_ready; -#ifdef CONFIG_SCHED_SMT -cpumask_t cpu_sibling_map[NR_CPUS ]; -#endif unsigned long cache_decay_ticks;cpumask_t cpu_possible_map =CPU_MASK_NONE ;cpumask_t cpu_online_map =CPU_MASK_NONE ;cpumask_t cpu_available_map =CPU_MASK_NONE ;cpumask_t cpu_present_at_boot =CPU_MASK_NONE ; +cpumask_t cpu_sibling_map[NR_CPUS ] = { [0 ...NR_CPUS -1 ] =CPU_MASK_NONE };EXPORT_SYMBOL (cpu_online_map);EXPORT_SYMBOL (cpu_possible_map);
@@ -448,14 +446,11 @@ static inline void look_for_more_cpus(vofor (i =0 ; i < maxcpus; i++)cpu_set (i, cpu_possible_map); -#ifdef CONFIG_SCHED_SMT -memset (cpu_sibling_map,0 ,sizeof (cpu_sibling_map));for_each_cpu (i) {cpu_set (i, cpu_sibling_map[i]);if (cur_cpu_spec->cpu_features &CPU_FTR_SMT )cpu_set (i^1 , cpu_sibling_map[i]); } -#endif }#else /* ... CONFIG_HOTPLUG_CPU */ static inline int __devinit smp_startup_cpu (unsigned int lcpu)
include/asm-ppc64/smp.h +1 -3
@@ -49,6 +49,7 @@ extern cpumask_t cpu_present_at_boot;extern cpumask_t cpu_online_map;extern cpumask_t cpu_possible_map;extern cpumask_t cpu_available_map; +extern cpumask_t cpu_sibling_map[NR_CPUS ];#define cpu_present_at_boot (cpu) cpu_isset(cpu, cpu_present_at_boot)#define cpu_available (cpu) cpu_isset(cpu, cpu_available_map)
@@ -73,9 +74,6 @@ void smp_init_pSeries(void);extern int __cpu_disable (void );extern void __cpu_die (unsigned int cpu);extern void cpu_die (void ) __attribute__((noreturn)); -#ifdef CONFIG_SCHED_SMT -extern cpumask_t cpu_sibling_map[NR_CPUS ]; -#endif #endif /* !(CONFIG_SMP) */ #define get_hard_smp_processor_id (CPU ) (paca[(CPU)].hw_cpu_id)