diff options
author | Felipe Cerqueira <felipec@mpi-sws.org> | 2013-02-11 12:10:50 -0500 |
---|---|---|
committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2014-06-07 05:30:30 -0400 |
commit | 588b6c96632ad0c9b5bfac55e90e14580d8ca377 (patch) | |
tree | 164a7229eac59dc079536dda09feab605f6dc8dd /arch | |
parent | 5459e2a7eacefe8555c92a8d7f969b87f0b3e276 (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')
-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) |