Repository navigation
Description
MacCentralProcessor.queryNominalFrequencies() reads the nominal cluster frequencies from two hardcoded IORegistry properties on the pmgr AppleARMIODevice node — voltage-states5-sram (performance) and voltage-states1-sram (efficiency) — and returns the last entry's first uint32 verbatim as Hz.
Three separate assumptions in that sentence stopped holding on recent chips. All of them are exercised by the fixture in vladkens/macmon#47, captured from an M5 Max (Mac17,6, macOS 26.4), reproduced below.
1. The units changed from Hz to kHz — this is the severe one
Same table, same chip family, factor of 1000 apart:
| chip | voltage-states5-sram last entry |
interpretation |
|---|---|---|
| M3 Pro (verified locally) | 4056000000 |
Hz → 4.056 GHz ✅ |
| A18 Pro (macmon#57) | 4044000000 |
Hz → 4.044 GHz ✅ |
| M5 Max (macmon#47) | 4608000 |
kHz → 4.608 GHz; OSHI reports 4.6 MHz ❌ |
So on M5 getMaxFreq() is not merely reading the wrong cluster, it is off by three orders of magnitude. macmon's current cpu_freq_scale() treats M1/M2/M3 and A-series as Hz and everything from M4 onward as kHz, which — if right about M4 — means OSHI is already wrong on shipping M4 hardware. I have direct dumps only for M1–M3, A18 Pro (Hz) and M5 Max (kHz), so treat the M4 boundary as unverified.
This has been invisible until now because of the bug fixed in #3672: getMaxFreq() and getCurrentFreq() returned the 2.4 GHz DEFAULT_FREQUENCY placeholder unless a caller happened to ask for getProcessorIdentifier() first, which masked whatever the table actually said.
Suggested fix: a magnitude check, not a chip-name table. No CPU runs below 100 MHz, and the two encodings are ~70× apart with nothing in between (Hz values observed ≥ 3.38 × 10⁸, kHz values ≤ 4.7 × 10⁶). Scaling anything below ~10⁸ by 1000 covers every chip, needs no per-chip list, and cannot rot — consistent with the direction of #3537, which replaced hardcoded per-chip tables with runtime derivation.
2. The keys were renumbered
voltage-states1-sram does not exist on M5 Max, so getMaxFreqFromByteArray(null) returns the placeholder. The replacement indices are discoverable from a new acc-clusters property on the same pmgr node: 8-byte entries where byte 0 is the voltage-states index and byte 1 is the cluster tier.
M5 Max, decoded from acc-clusters = <160000000000000017010000000000000502000000000000>:
| tier | key | min–max | cluster |
|---|---|---|---|
| 0 | voltage-states22-sram |
1344–4380 MHz | Performance (6 cores) |
| 1 | voltage-states23-sram |
1344–4380 MHz | Performance (6 cores) |
| 2 | voltage-states5-sram |
1308–4608 MHz | Super (6 cores) |
acc-clusters does not exist on older chips — it is absent from the whole IORegistry on an M3 Pro, whose pmgr node has only clusters = <0600000006000000>. So try the legacy keys first and fall back to acc-clusters only when a key is missing; M1–M4 then keep their exact current code path.
3. acc-clusters entries are clusters, not core types — do not map tier to efficiency class
Note above that tiers 0 and 1 are two clusters of the same core type, with identical frequency ranges. sysctl agrees, and it is the authoritative view:
hw.nperflevels: 2
hw.perflevel0.physicalcpu: 6 hw.perflevel0.name: Super
hw.perflevel1.physicalcpu: 12 hw.perflevel1.name: Performance
Three acc-clusters entries, two perf levels. So deriving one efficiency class per acc-clusters tier would split the 12 Performance cores across two classes and report three tiers where macOS reports two. Cluster tier is the right key for which frequency table to read, and the wrong key for what efficiency class a core has.
hw.perflevelN.name and hw.perflevelN.physicalcpu are documented Apple API and give the tier names and counts directly — a much better source than inferring an efficiency class from a cluster-type letter. OSHI already reads hw.nperflevels and hw.perflevel0.physicalcpu in initProcessorCounts(), so the plumbing is half there.
Correspondingly, deriveEfficiencyClasses's clusterTypeClass recognizes only 'P' → 1 and 'E' → 0, and an unrecognized letter is not propagated by codename either, so it falls through to class 0. I have no dump of cluster-type from an M5, so whether it reports S is still a guess; reading the perf-level names would sidestep the question entirely.
What this means for the current two-value shape
queryNominalFrequencies() returns a Pair<Long, Long> and queryCurrentFreq() maps getEfficiency() > 0 to the performance frequency and everything else to the efficiency frequency. That is a two-tier shape. Whether any single shipping chip has three populated tiers is unclear — the M5 Max above has Super + Performance and no Efficiency cores (proc 18:6:0:12 = total:top:E:M), and macmon#47 reports the base M5 as Super + Efficiency — but the safe design is per-perf-level frequencies keyed by efficiency class rather than a hardcoded pair.
Also worth knowing: macOS 26 emits the 4-field number_processors on older chips too. An A18 Pro reports proc 6:2:4:0 — 2 top-tier, 4 efficiency, 0 mid-tier.
Fixture
Enough to unit-test all of the above in oshi-common with no Apple hardware. From macmon#47 (M5 Max, Mac17,6, macOS 26.4):
pmgr properties
"compatible" = <"pmgr1,t6050">
"acc-clusters" = <160000000000000017010000000000000502000000000000>
"clusters" = <060000000600060006000c00>
voltage-states5-sram (20 entries, Super):
60f5130 0f802000020b818001103000060361e003403000020f9220057030000205e27007503000000f22b0098030000e0853000b6030000405e3400d403000000aa3700f203000020693a00fc03000080ca3c0015040000409f3e002904000060e73f0033040000e0a2400033040000605e41003304000020bc410033040000e019420033040000e09043003304000000d94400600400000050460060040000
voltage-states22-sram (15 entries, Performance):
00821400fd020000e01519001b03000040651e003e030000002823005c030000607728007a030000203a2d009d03000040703100b103000080773500ca03000080653800e3030000a0243b00f7030000e0b43d000604000080b83f0015040000605e41002404000020bc41002404000060d5420024040000
voltage-states23-sram (15 entries, Performance):
00821400fd020000e01519001b03000040651e003e030000002823005c030000607728007a030000203a2d009d03000040703100b103000080773500ca03000080653800e3030000a0243b00f7030000e0b43d000604000080b83f0015040000605e41001f04000020bc41001f04000060d542001f040000
voltage-states1-sram does not exist on this chip. Entries are (uint32 frequency, uint32 millivolts); the millivolt column (760…1120) is a useful cross-check that the frequency column has been read at the right offset and stride.
For contrast, an M3 Pro (verified locally) has voltage-states1-sram maxing at 2.748 GHz, voltage-states5-sram at 4.056 GHz, both in Hz, no acc-clusters, and voltage-states9-sram maxing at 1.380 GHz — that one is the GPU, not a CPU cluster.
Data still wanted
- An M4
pmgrdump, to pin down where the Hz → kHz change actually happened. ioreg -c IOPlatformDevice -r -a | grep -A2 cluster-typefrom any M5, to settle thecluster-typeletters.sysctl hw.nperflevels hw.perflevel0.name hw.perflevel1.name hw.perflevel2.namefrom a base M5 or M5 Pro.
Split out of #3672, which fixed an unrelated initialization-order bug in the same method.
Activity
[-]Apple M5: pmgr voltage-state renumbering breaks efficiency-core frequency[/-][+]Apple Silicon: pmgr voltage-state keys renumbered and frequency units changed on M4/M5[/+]dbwiddis commentedon Aug 20, 2026
Recording two signals that #3674 deliberately does not use, so the next person here doesn't have to rediscover them.
PhysicalProcessor.getEfficiency()in #3674 is derived fromhw.nperflevels+hw.perflevel<n>.physicalcpu, falling back to thecluster-typeletters and then to codename grouping. Two other letter-free signals exist and would work:1.
cluster-idgives an exact core → cluster mapping. It is a property of the sameIOPlatformDevicecpuNnodes OSHI already walks forcompatibleandcluster-type, so it costs one moregetByteArrayPropertyin an existing loop. On an M3 Pro:cluster-idcluster-typevoltage-states1-sramvoltage-states5-sramIt is present on the earliest Apple Silicon — the M1 dump in #1483 has
cluster-idoncpu0— which matters, because that is exactly the hardware wherehw.nperflevelsis unavailable. As a grouping key it is strictly better than the codename currently used for propagation, which is a proxy that would fail on a chip whose two cluster types share a codename.2. Ranking clusters by their table's max frequency dedupes correctly. This is the only letter-free signal that gets the M5 Max right. Its
acc-clusterstiers are 0/1/2, so ranking by tier would report three efficiency classes where macOS reports two. Ranking by frequency collapses them: tables 22 and 23 both max at 4,380,000 → one class; table 5 at 4,608,000 → the next. That yields 12 Performance + 6 Super, matchinghw.perflevel0.name=Super(6) andhw.perflevel1.name=Performance(12).Why it was not built:
hw.nperflevelsalready decides on every macOS 12+ Mac, which is every Mac that can have an M4 or M5. This buys robustness, not a fixed bug, and on the M1-era hardware where the sysctls are missing theE/Pletters are verified correct.cluster-id↔acc-clustersentry-index link is unverified. No dump published anywhere carries both properties. It is far better founded than a letter guess (dense 0-based, count matches the entry count, tiers ascend in listed order, corroborated by theclusterscore offsets), but it is still an assumption.cluster count == table countis the natural guard.deriveEfficiencyClassesundeduped and in tier order, whilequeryClusterFrequencies()sorts and dedupes them andmapClusterFrequencies()depends on the class count thatderiveEfficiencyClassesproduces. That circularity is what caused Read Apple Silicon cluster frequencies lazily, not as a side effect #3672, so it wants its own change rather than riding along.