Skip to content

fix: correctly parse multiple cache instances via sysfs#64

Open
dadealus wants to merge 1 commit intolevel1techs:mainfrom
dadealus:fix-cpu-cache-topology
Open

fix: correctly parse multiple cache instances via sysfs#64
dadealus wants to merge 1 commit intolevel1techs:mainfrom
dadealus:fix-cpu-cache-topology

Conversation

@dadealus
Copy link
Copy Markdown

@dadealus dadealus commented Apr 9, 2026

Summary

  • Fixes an issue where raw_cpuid only queried the core it was running on, leading to incomplete L3 cache reporting on asymmetric NUMA processors (like the Ryzen 9 9950X3D).
  • Replaces the single-threaded CPUID cache parser with a robust sysfs-based cache reader (/sys/devices/system/cpu/cpu*/cache/index*) that correctly aggregates topology across all distinct cache instances.

Description

While testing siomon on an ASUS X870E ProArt motherboard with a Ryzen 9 9950X3D, we noticed that it was only detecting 96MB of L3 cache instead of the full 128MB.

The original gather_cache function utilized the raw_cpuid crate, which only reads the CPU instruction data for the thread the program starts on. On a 9950X3D, if it lands on the 3D V-Cache CCD, it reports 96MB and assumes it applies across the whole CPU, completely missing the 32MB standard L3 cache on the second CCD.

This PR introduces a new gather_cache_sysfs function that acts similarly to lscpu. It iterates through the Linux kernel's sysfs cache directories and maps out every distinct instance using the shared_cpu_list. This correctly aggregates the total L3 cache size and identifies the distinct instances across multiple NUMA nodes.


Disclaimer: This Pull Request was built with AI assistance to help diagnose the issue and formulate the sysfs parsing logic.

The raw_cpuid parser only queried the core it was running on, leading to
incorrect topology maps on asymmetric processors like the Ryzen 9 9950X3D
where one CCD has 96MB of L3 and the other has 32MB.

This implements a sysfs-based cache reader similar to lscpu that correctly
aggregates the topology across all distinct cache instances.
@wendelltron wendelltron self-assigned this Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants