aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelipe Cerqueira <felipec@mpi-sws.org>2013-02-11 12:10:50 -0500
committerBjoern Brandenburg <bbb@mpi-sws.org>2013-08-07 03:46:40 -0400
commit77c2b05c943abc0dfdb7b55a3d1d4a1a3fc53dcd (patch)
treec057af839cafc5c1be80b565dea70767ed14b5b4
parentee6ab6012870a6a3b60dc75560bb5118a37992d0 (diff)
Export x86 cache topology
This patch adds get_shared_cpu_map(), which allows the caller to infer which CPUs share a cache at a given level.
-rw-r--r--arch/x86/include/asm/processor.h4
-rw-r--r--arch/x86/kernel/cpu/intel_cacheinfo.c17
2 files changed, 21 insertions, 0 deletions
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 22224b3b43bb..254dd2b81632 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -173,6 +173,10 @@ void print_cpu_msr(struct cpuinfo_x86 *);
173extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c); 173extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c);
174extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c); 174extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c);
175extern void init_amd_cacheinfo(struct cpuinfo_x86 *c); 175extern void init_amd_cacheinfo(struct cpuinfo_x86 *c);
176#ifdef CONFIG_SYSFS
177extern int get_shared_cpu_map(cpumask_var_t mask,
178 unsigned int cpu, int index);
179#endif
176 180
177extern void detect_extended_topology(struct cpuinfo_x86 *c); 181extern void detect_extended_topology(struct cpuinfo_x86 *c);
178extern void detect_ht(struct cpuinfo_x86 *c); 182extern void detect_ht(struct cpuinfo_x86 *c);
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
index 7c6f7d548c0f..033939ba4782 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -744,6 +744,23 @@ unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c)
744static DEFINE_PER_CPU(struct _cpuid4_info *, ici_cpuid4_info); 744static DEFINE_PER_CPU(struct _cpuid4_info *, ici_cpuid4_info);
745#define CPUID4_INFO_IDX(x, y) (&((per_cpu(ici_cpuid4_info, x))[y])) 745#define CPUID4_INFO_IDX(x, y) (&((per_cpu(ici_cpuid4_info, x))[y]))
746 746
747/* returns CPUs that share the index cache with cpu */
748int get_shared_cpu_map(cpumask_var_t mask, unsigned int cpu, int index)
749{
750 int ret = 0;
751 struct _cpuid4_info *this_leaf;
752
753 if (index >= num_cache_leaves) {
754 index = num_cache_leaves - 1;
755 ret = index;
756 }
757
758 this_leaf = CPUID4_INFO_IDX(cpu,index);
759 cpumask_copy(mask, to_cpumask(this_leaf->shared_cpu_map));
760
761 return ret;
762}
763
747#ifdef CONFIG_SMP 764#ifdef CONFIG_SMP
748 765
749static int __cpuinit cache_shared_amd_cpu_map_setup(unsigned int cpu, int index) 766static int __cpuinit cache_shared_amd_cpu_map_setup(unsigned int cpu, int index)