arch/x86/kernel/cpu/cacheinfo.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
Hi,
While working on the x86-cpuid-db CPUID model on top of the CPUID(2) and
CPUID(4) cleanups at tip/x86/cpu,[*] I've discovered some L1/2/3 cache
associativity parsing issues for the AMD CPUID(4) emulation logic .
Here are the fixes on top of -rc1.
* Summary:
The AMD CPUID(4) emulation logic, uses CPUID(0x80000005) and
CPUID(0x80000006) for extracting the L1/L2/L3 cache info. It then uses
an assocs[] associativity mapping array to map the extracted
associativity values to their CPUID(4) equivalents.
Using the same associativity mapping array for both leaves is invalid.
Per the AMD manuals, the associativity field semantics between
CPUID(0x80000005) and CPUID(0x80000006) is different. The first patch
fixes that for the former leaf. For the latter leaf, the second patch
completes the associativity mapping array and handles the special case of
an L2/L3 associativity of 9, which is just a marker — not a real cache
associativity value.
* Example testing for L1d cacheinfo:
On a Qemu-emulated AMD machine without CPUID(0x8000001d) topology
extensions, and with below cpuid(1) view:
L1 data cache information (0x80000005/ecx):
line size (bytes) = 0x40 (64)
lines per tag = 0x1 (1)
associativity = 0x8 (8)
size (KB) = 0x20 (32)
L1 instruction cache information (0x80000005/edx):
line size (bytes) = 0x40 (64)
lines per tag = 0x1 (1)
associativity = 0x4 (4)
size (KB) = 0x40 (64)
L2 unified cache information (0x80000006/ecx):
line size (bytes) = 0x40 (64)
lines per tag = 0x1 (1)
associativity = 8-way (6)
size (KB) = 0x200 (512)
L3 cache information (0x80000006/edx):
line size (bytes) = 0x40 (64)
lines per tag = 0x1 (1)
associativity = 16-way (8)
size (in 512KB units) = 0x10 (16)
Before applying this PQ, we get:
/sys/devices/system/cpu/cpu[0-8]/cache/index0/ways_of_associativity: 16
/sys/devices/system/cpu/cpu[0-8]/cache/index0/number_of_sets: 32
and after:
/sys/devices/system/cpu/cpu[0-8]/cache/index0/ways_of_associativity: 8
/sys/devices/system/cpu/cpu[0-8]/cache/index0/number_of_sets: 64
Thanks,
[*] https://lore.kernel.org/lkml/20250304085152.51092-1-darwi@linutronix.de
https://lore.kernel.org/lkml/20250324133324.23458-1-darwi@linutronix.de
8<--
Ahmed S. Darwish (2):
x86/cacheinfo: Properly parse CPUID(0x80000005) L1d/L1i associativity
x86/cacheinfo: Properly parse CPUID(0x80000006) L2/L3 associativity
arch/x86/kernel/cpu/cacheinfo.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8
--
2.49.0
* Ahmed S. Darwish <darwi@linutronix.de> wrote: > Hi, > > While working on the x86-cpuid-db CPUID model on top of the CPUID(2) and > CPUID(4) cleanups at tip/x86/cpu,[*] I've discovered some L1/2/3 cache > associativity parsing issues for the AMD CPUID(4) emulation logic . > > Here are the fixes on top of -rc1. Could you please send these against tip:master? tip:x86/cpu already has your previous series, and I don't see the need to create a version skew between v6.15 and the x86 tree for v6.16. Thanks, Ingo
Hi, On Wed, 09 Apr 2025, Ingo Molnar wrote: > > * Ahmed S. Darwish <darwi@linutronix.de> wrote: > > > While working on the x86-cpuid-db CPUID model on top of the CPUID(2) and > > CPUID(4) cleanups at tip/x86/cpu,[*] I've discovered some L1/2/3 cache > > associativity parsing issues for the AMD CPUID(4) emulation logic . > > > > Here are the fixes on top of -rc1. > > Could you please send these against tip:master? > > tip:x86/cpu already has your previous series, and I don't see the need > to create a version skew between v6.15 and the x86 tree for v6.16. > Sure, I've just sent v2 over tip:master here: https://lore.kernel.org/lkml/20250409122233.1058601-1-darwi@linutronix.de Ironically, this PQ was originally on top of tip:x86/cpu, but I was not sure if the tip:x86/cpu CPUID refactorings will be sent to Linus at this merge window or the next — so I thought I'd make everyone's life "easier" by just basing on -rc1 instead. (The -stable trees will have trouble merging this v2 -- but at least v1 shows the same PQ before the CPUID refactorings at tip:x86/cpu.) Thanks a lot, -- Ahmed S. Darwish Linutronix GmbH
* Ahmed S. Darwish <darwi@linutronix.de> wrote: > Hi, > > On Wed, 09 Apr 2025, Ingo Molnar wrote: > > > > * Ahmed S. Darwish <darwi@linutronix.de> wrote: > > > > > While working on the x86-cpuid-db CPUID model on top of the CPUID(2) and > > > CPUID(4) cleanups at tip/x86/cpu,[*] I've discovered some L1/2/3 cache > > > associativity parsing issues for the AMD CPUID(4) emulation logic . > > > > > > Here are the fixes on top of -rc1. > > > > Could you please send these against tip:master? > > > > tip:x86/cpu already has your previous series, and I don't see the need > > to create a version skew between v6.15 and the x86 tree for v6.16. > > > > Sure, I've just sent v2 over tip:master here: > > https://lore.kernel.org/lkml/20250409122233.1058601-1-darwi@linutronix.de Applied, thanks! Ingo
© 2016 - 2026 Red Hat, Inc.