Skip to content

Commit 812af43

Browse files
ssuthiku-amdKAGA-KOKO
authored andcommitted
perf/events/amd/uncore: Fix amd_uncore_llc ID to use pre-defined cpu_llc_id
Current logic iterates over CPUID Fn8000001d leafs (Cache Properties) to detect the last level cache, and derive the last-level cache ID. However, this information is already available in the cpu_llc_id. Therefore, make use of it instead. Signed-off-by: Suravee Suthikulpanit <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: "Peter Zijlstra (Intel)" <[email protected]> Cc: Janakarajan Natarajan <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
1 parent f8b64d0 commit 812af43

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

arch/x86/events/amd/uncore.c

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <asm/cpufeature.h>
2020
#include <asm/perf_event.h>
2121
#include <asm/msr.h>
22+
#include <asm/smp.h>
2223

2324
#define NUM_COUNTERS_NB 4
2425
#define NUM_COUNTERS_L2 4
@@ -399,26 +400,8 @@ static int amd_uncore_cpu_starting(unsigned int cpu)
399400
}
400401

401402
if (amd_uncore_llc) {
402-
unsigned int apicid = cpu_data(cpu).apicid;
403-
unsigned int nshared, subleaf, prev_eax = 0;
404-
405403
uncore = *per_cpu_ptr(amd_uncore_llc, cpu);
406-
/*
407-
* Iterate over Cache Topology Definition leaves until no
408-
* more cache descriptions are available.
409-
*/
410-
for (subleaf = 0; subleaf < 5; subleaf++) {
411-
cpuid_count(0x8000001d, subleaf, &eax, &ebx, &ecx, &edx);
412-
413-
/* EAX[0:4] gives type of cache */
414-
if (!(eax & 0x1f))
415-
break;
416-
417-
prev_eax = eax;
418-
}
419-
nshared = ((prev_eax >> 14) & 0xfff) + 1;
420-
421-
uncore->id = apicid - (apicid % nshared);
404+
uncore->id = per_cpu(cpu_llc_id, cpu);
422405

423406
uncore = amd_uncore_find_online_sibling(uncore, amd_uncore_llc);
424407
*per_cpu_ptr(amd_uncore_llc, cpu) = uncore;

0 commit comments

Comments
 (0)