Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1658578 > unrolled thread
| Started by | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| First post | 2017-06-06 12:20 +0200 |
| Last post | 2017-06-06 19:50 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH 2/2] amd: uncore: Get correct number of cores sharing last level cache Peter Zijlstra <peterz@infradead.org> - 2017-06-06 12:20 +0200
Re: [PATCH 2/2] amd: uncore: Get correct number of cores sharing last level cache Borislav Petkov <bp@alien8.de> - 2017-06-06 19:50 +0200
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2017-06-06 12:20 +0200 |
| Subject | Re: [PATCH 2/2] amd: uncore: Get correct number of cores sharing last level cache |
| Message-ID | <tPjKF-7nW-11@gated-at.bofh.it> |
On Mon, Jun 05, 2017 at 11:13:19AM -0500, Janakarajan Natarajan wrote:
> + /*
> + * Iterate over Cache Topology Definition leaves until no
> + * more cache descriptions are available
> + */
> + while (1) {
> + cpuid_count(0x8000001d, cache_level,
> + &eax, &ebx, &ecx, &edx);
> + /*
> + * EAX[0:4] gives type of cache. 0 = No more caches
> + */
> + if ((eax & 0x1f) == 0)
> + break;
> + cache_level++;
> + prev_eax = eax;
> + }
> + nshared = ((prev_eax >> 14) & 0xfff) + 1;
Egads, could we pretty please write that in a less horrible fashion?
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 */
break;
prev_eax = eax;
}
That way we'll not run off into the woods if CPUID goes funny (never
trust a BIOS/virt monkey).
[toc] | [next] | [standalone]
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2017-06-06 19:50 +0200 |
| Message-ID | <tPqM9-3tE-13@gated-at.bofh.it> |
| In reply to | #1658578 |
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.
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web