Re: [PATCH 2/2] amd: uncore: Get correct number of cores sharing last level cache

From: Janakarajan Natarajan
Date: Tue Jun 06 2017 - 19:03:36 EST



On 06/06/2017 12:45 PM, Borislav Petkov wrote:
On Tue, Jun 06, 2017 at 12:15:30PM +0200, Peter Zijlstra wrote:
Maybe something like:

for (cache_level = 0; cache_level < 3; cache_level++) {
cpuid_count(0x8000001d, cache_level, &eax, &ebx, &ecx, &edx);

if ((eax & 0x1f) == 0) /* EAX[0:4] gives cache type */
if (!(eax & 0x1f))

break;

prev_eax = eax;
}

That way we'll not run off into the woods if CPUID goes funny (never
trust a BIOS/virt monkey).
Yap, especially if there are CPUID functions with subleafs with holes in
them.
Okay. I can send a v2 with the changes.