aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFenghua Yu <fenghua.yu@intel.com>2016-10-22 09:19:50 -0400
committerThomas Gleixner <tglx@linutronix.de>2016-10-26 17:12:37 -0400
commitd57e3ab7e34c51a8badeea1b500bfb738d0af66e (patch)
treea5446164f7da2555bd77674144415b67bc0054dc
parente9a2ea5a1ba09c35258f3663842fb8d8cf2e00c2 (diff)
x86/intel_cacheinfo: Enable cache id in cache info
Cache id is retrieved from APIC ID and CPUID leaf 4 on x86. For more details please see the section on "Cache ID Extraction Parameters" in "Intel 64 Architecture Processor Topology Enumeration". Also the documentation of the CPUID instruction in the "Intel 64 and IA-32 Architectures Software Developer's Manual" Signed-off-by: Fenghua Yu <fenghua.yu@intel.com> Cc: "Ravi V Shankar" <ravi.v.shankar@intel.com> Cc: "Tony Luck" <tony.luck@intel.com> Cc: "David Carrillo-Cisneros" <davidcc@google.com> Cc: "Sai Prakhya" <sai.praneeth.prakhya@intel.com> Cc: "Peter Zijlstra" <peterz@infradead.org> Cc: "Stephane Eranian" <eranian@google.com> Cc: "Dave Hansen" <dave.hansen@intel.com> Cc: "Shaohua Li" <shli@fb.com> Cc: "Nilay Vaish" <nilayvaish@gmail.com> Cc: "Vikas Shivappa" <vikas.shivappa@linux.intel.com> Cc: "Ingo Molnar" <mingo@elte.hu> Cc: "Borislav Petkov" <bp@suse.de> Cc: "H. Peter Anvin" <h.peter.anvin@intel.com> Link: http://lkml.kernel.org/r/1477142405-32078-4-git-send-email-fenghua.yu@intel.com Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--arch/x86/kernel/cpu/intel_cacheinfo.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
index de6626c18e42..8dc572085fb4 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -153,6 +153,7 @@ struct _cpuid4_info_regs {
153 union _cpuid4_leaf_eax eax; 153 union _cpuid4_leaf_eax eax;
154 union _cpuid4_leaf_ebx ebx; 154 union _cpuid4_leaf_ebx ebx;
155 union _cpuid4_leaf_ecx ecx; 155 union _cpuid4_leaf_ecx ecx;
156 unsigned int id;
156 unsigned long size; 157 unsigned long size;
157 struct amd_northbridge *nb; 158 struct amd_northbridge *nb;
158}; 159};
@@ -894,6 +895,8 @@ static void __cache_cpumap_setup(unsigned int cpu, int index,
894static void ci_leaf_init(struct cacheinfo *this_leaf, 895static void ci_leaf_init(struct cacheinfo *this_leaf,
895 struct _cpuid4_info_regs *base) 896 struct _cpuid4_info_regs *base)
896{ 897{
898 this_leaf->id = base->id;
899 this_leaf->attributes = CACHE_ID;
897 this_leaf->level = base->eax.split.level; 900 this_leaf->level = base->eax.split.level;
898 this_leaf->type = cache_type_map[base->eax.split.type]; 901 this_leaf->type = cache_type_map[base->eax.split.type];
899 this_leaf->coherency_line_size = 902 this_leaf->coherency_line_size =
@@ -920,6 +923,22 @@ static int __init_cache_level(unsigned int cpu)
920 return 0; 923 return 0;
921} 924}
922 925
926/*
927 * The max shared threads number comes from CPUID.4:EAX[25-14] with input
928 * ECX as cache index. Then right shift apicid by the number's order to get
929 * cache id for this cache node.
930 */
931static void get_cache_id(int cpu, struct _cpuid4_info_regs *id4_regs)
932{
933 struct cpuinfo_x86 *c = &cpu_data(cpu);
934 unsigned long num_threads_sharing;
935 int index_msb;
936
937 num_threads_sharing = 1 + id4_regs->eax.split.num_threads_sharing;
938 index_msb = get_count_order(num_threads_sharing);
939 id4_regs->id = c->apicid >> index_msb;
940}
941
923static int __populate_cache_leaves(unsigned int cpu) 942static int __populate_cache_leaves(unsigned int cpu)
924{ 943{
925 unsigned int idx, ret; 944 unsigned int idx, ret;
@@ -931,6 +950,7 @@ static int __populate_cache_leaves(unsigned int cpu)
931 ret = cpuid4_cache_lookup_regs(idx, &id4_regs); 950 ret = cpuid4_cache_lookup_regs(idx, &id4_regs);
932 if (ret) 951 if (ret)
933 return ret; 952 return ret;
953 get_cache_id(cpu, &id4_regs);
934 ci_leaf_init(this_leaf++, &id4_regs); 954 ci_leaf_init(this_leaf++, &id4_regs);
935 __cache_cpumap_setup(cpu, idx, &id4_regs); 955 __cache_cpumap_setup(cpu, idx, &id4_regs);
936 } 956 }