Skip to content

CPUCache (Linux): skips offline CPUs - #2737

Merged
CarterLi merged 2 commits into
fastfetch-cli:devfrom
Pratik-Kumar-Dhakar:fix/cpucache-offline-cpu
Nov 20, 2026
Merged

CarterLi merged 2 commits into
fastfetch-cli:devfrom
Pratik-Kumar-Dhakar:fix/cpucache-offline-cpu

Conversation

@Pratik-Kumar-Dhakar

@Pratik-Kumar-Dhakar Pratik-Kumar-Dhakar commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes the Linux CPU Cache module failing entirely when any CPU is offline. The kernel removes cpuX/cache/ for an offline CPU, so opendir() failed and the module returned an error instead of the caches of the online CPUs.

Related issue (required for new logos for new distros)

Fixes #2736

Changes

  • src/detection/cpucache/cpucache_linux.c: drop the early return in the CPU loop, as suggested in review. A CPU whose cache/ can't be read, such as an offline one, is skipped with an FF_DEBUG line instead of failing the module.
  • CHANGELOG.md: Bugfixes entry under Unreleased.

Screenshots

With cpu3 offline (cpu3/online = 0, no cpu3/cache/):

before: CPU Cache: opendir("/sys/devices/system/cpu/cpuX/cache/") == nullptr
after:  CPU Cache (L1): 4x64.00 KiB (I), 4x32.00 KiB (D), 6x32.00 KiB (I), 6x48.00 KiB (D)
        CPU Cache (L2): 2.00 MiB (U), 6x1.25 MiB (U)
        CPU Cache (L3): 24.00 MiB (U)

Checklist

  • I have tested my changes locally.
    • Taking a CPU offline needs root, so I tested inside unshare -rm with a copy of /sys/devices/system/cpu bind-mounted over the real one, with cpu3 offline as the kernel leaves it.
    • Output before the fix: the error above. After: full cache info.
    • The same copy with cpu3 online gives identical output before and after the fix, as does the real sysfs.
    • Built with clang 18. ctest passes 21/21.

I used an AI coding assistant (Claude) to help find this bug and prepare the fix, and I reviewed and tested it myself.

🤖 Generated with Claude Code

The kernel removes `cpuX/cache/` when a CPU goes offline, so opendir()
failed for that CPU and the whole module returned an error. Skip CPUs
whose `online` file reads 0; a CPU without an `online` file (usually
cpu0) is treated as online, as before.

Fixes fastfetch-cli#2736

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
}

const char* error = parseCpuCache(&path, result, &buffer, &added);
if (error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just remove the early return, I think.

Instead of checking `cpuX/online`, drop the early return: a CPU without a readable
`cache/` directory, such as an offline one, is skipped rather than failing the module.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Pratik-Kumar-Dhakar

Copy link
Copy Markdown
Contributor Author

Done. I removed the online check and the early return. A CPU whose cache can't be read is now skipped, with an FF_DEBUG line saying why, instead of failing the whole module.

I re-tested with a copy of /sys/devices/system/cpu mounted over the real one:

  • cpu3 offline, so no cpu3/cache/: full cache info.
  • All CPUs online: the same output as before.

One side effect: if no CPU's cache can be read at all, the module now prints nothing instead of an error. I can return an error in that case if you'd prefer.

@CarterLi
CarterLi merged commit 216d3b2 into fastfetch-cli:dev Nov 20, 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.

[BUG] CPU Cache module fails entirely on Linux when any CPU is offline

2 participants