Skip to content

Fix Base::CpuCurrentFrequency on ARM/ARM64 Neoverse-N2 (Linux) - #854

Merged
ermig1979 merged 3 commits into
devfrom
cursor/fix-cpu-current-frequency-arm-2de4
Aug 13, 2026
Merged

Fix Base::CpuCurrentFrequency on ARM/ARM64 Neoverse-N2 (Linux)#854
ermig1979 merged 3 commits into
devfrom
cursor/fix-cpu-current-frequency-arm-2de4

Conversation

@ermig1979

@ermig1979 ermig1979 commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Summary

Base::CpuCurrentFrequency() returned 0 Hz on ARM/ARM64 Neoverse-N2 Linux.

Root causes addressed

  1. Idle-core AMU zero: scaling_cur_freq can be 0 on the current core; old code returned immediately without trying other CPUs / max freq.
  2. Round() overflow (prior revision): Round() returns int, so kHz * 1000 / MHz * 1e6 overflows around 2.1 GHz.
  3. Missing ARM sources: no MHz in /proc/cpuinfo; need CPPC / SMBIOS / other fallbacks.

Fix (SimdBaseCpu.cpp)

  1. Scan all cpu*/cpufreq + policy* files; take first value > 0 (kHz → Hz via 64-bit multiply)
  2. ACPI CPPC nominal_freq / lowest_freq (MHz)
  3. /proc/cpuinfo MHz
  4. SMBIOS Type 4 from /sys/firmware/dmi/... (no root)
  5. dmidecode / lscpu
  6. Device-tree clock-frequency
  7. perf_event_open cycle measurement (when permitted)

Also documents the fix in docs/2026.html release 7.2.165.

Test plan

  • Build libSimd.so (g++)
  • Frequency non-zero on this host (2400 MHz via /proc/cpuinfo)
  • awk '$1 > 0' skips leading idle 0 readings and selects 2600000
  • aarch64 cross-compile of SimdBaseCpu.cpp succeeds
  • Retest on Neoverse-N2 with commit 97aff938f

If still 0 on Neoverse-N2, please share:

ls /sys/devices/system/cpu/cpu0/cpufreq /sys/devices/system/cpu/cpu0/acpi_cppc 2>&1
cat /sys/devices/system/cpu/cpu*/cpufreq/*cur* /sys/devices/system/cpu/cpu*/cpufreq/*max* 2>/dev/null | head
cat /sys/devices/system/cpu/cpu0/acpi_cppc/nominal_freq 2>&1
ls /sys/firmware/dmi/tables 2>&1
dmidecode -t processor 2>&1 | head -40
lscpu | head -40
Open in Web Open in Cursor 

cursoragent and others added 3 commits August 13, 2026 07:32
Add fallbacks when cpufreq sysfs and /proc/cpuinfo MHz are unavailable
(dmidecode and lscpu BIOS model @ghz), and document the fix in 7.2.165.

Co-authored-by: igor.ermolaev <igor.ermolaev@altezza.org>
Read sysfs via ifstream, add ACPI CPPC/SMBIOS/device-tree fallbacks,
scan neighboring CPUs when AMU reports 0 on an idle core, and avoid
relying on root-only dmidecode or lscpu @ghz strings.

Co-authored-by: igor.ermolaev <igor.ermolaev@altezza.org>
Avoid int Round() on GHz-scale values, scan all CPUs/policies for the
first non-zero cpufreq/CPPC reading, and keep SMBIOS/dmidecode/lscpu
plus perf measurement as fallbacks when sysfs has no frequency.

Co-authored-by: igor.ermolaev <igor.ermolaev@altezza.org>
@ermig1979
ermig1979 marked this pull request as ready for review August 13, 2026 08:18
@ermig1979
ermig1979 merged commit ee166da into dev Aug 13, 2026
1 check passed
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