diff options
author | Felipe Cerqueira <felipec@mpi-sws.org> | 2013-02-11 12:10:50 -0500 |
---|---|---|
committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2013-08-07 03:46:40 -0400 |
commit | 77c2b05c943abc0dfdb7b55a3d1d4a1a3fc53dcd (patch) | |
tree | c057af839cafc5c1be80b565dea70767ed14b5b4 /arch/x86 | |
parent | ee6ab6012870a6a3b60dc75560bb5118a37992d0 (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.
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/include/asm/processor.h | 4 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/intel_cacheinfo.c | 17 |
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 *); | |||
173 | extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c); | 173 | extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c); |
174 | extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c); | 174 | extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c); |
175 | extern void init_amd_cacheinfo(struct cpuinfo_x86 *c); | 175 | extern void init_amd_cacheinfo(struct cpuinfo_x86 *c); |
176 | #ifdef CONFIG_SYSFS | ||
177 | extern int get_shared_cpu_map(cpumask_var_t mask, | ||
178 | unsigned int cpu, int index); | ||
179 | #endif | ||
176 | 180 | ||
177 | extern void detect_extended_topology(struct cpuinfo_x86 *c); | 181 | extern void detect_extended_topology(struct cpuinfo_x86 *c); |
178 | extern void detect_ht(struct cpuinfo_x86 *c); | 182 | extern 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) | |||
744 | static DEFINE_PER_CPU(struct _cpuid4_info *, ici_cpuid4_info); | 744 | static 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 */ | ||
748 | int 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 | ||
749 | static int __cpuinit cache_shared_amd_cpu_map_setup(unsigned int cpu, int index) | 766 | static int __cpuinit cache_shared_amd_cpu_map_setup(unsigned int cpu, int index) |