Repository navigation
Description
SmcUtil.SMC_KEYS_CPU_TEMP_AS (and its FFM twin) hardcodes one list for all Apple Silicon:
{ "Tp09", "Tp0T", "Tp01", "Tp05", "Tp0D" }Those keys were derived from live SMC enumeration on one machine. Cross-checking against iSMC's key map — 1077 entries tagged by chip family — shows the same FourCC means different things on different chips, so a single list cannot be right everywhere.
How iSMC classifies each of our five keys
| key | M1 | M2 | M3 | M4 | A18 | M5 |
|---|---|---|---|---|---|---|
Tp09 |
Efficiency Core 1 | Perf Core 3 | – | Perf Core 3 | Perf Cluster Aggregate 1 | – |
Tp0T |
Efficiency Core 2 | – | Perf Cluster 1 | Perf Core 8 | – | – |
Tp01 |
Perf Core 1 | Perf Core 1 | – | Perf Core 1 | Perf Core 1 | – |
Tp05 |
Perf Core 2 | Perf Core 2 | Perf Core 1 | Perf Core 2 | Perf Core 2 | – |
Tp0D |
Perf Core 3 | Perf Core 4 | Perf Core 2 | Perf Core 4 | Perf Cluster Aggregate 2 | – |
Presence by family: M1 5/5, M2 4/5, M3 3/5, M4 5/5, A18 4/5, M5 0/5.
Two concrete consequences
1. No CPU temperature at all on M5. Its performance cores are an entirely different key set:
Tp0O Tp0R Tp0U Tp0X Tp0a Tp0d Tp0g Tp0j Tp0m Tp0p Tp0u Tp0y
None of our five appear. The report-m5-max.txt and report-m5-pro.txt sample dumps confirm it — none of our keys are present, so every read returns 0 and getCpuTemperature() reports unavailable.
2. An efficiency-core temperature reported as the CPU temperature on M1. Tp09 is tried first and is an Efficiency Core on M1, so smcGetFirstTemperature returns it whenever it is plausible. E-cores run cooler than P-cores, so M1 readings are biased low. Same shape on M3, where Tp0T is a cluster aggregate rather than a core.
Also worth noting: iSMC commit 7e229fa reworked the M4 performance-core mapping, adding the Tp1i/Tp1m/… family and cluster sensors. Their M4 list now runs to 60 perf-core entries.
Approaches, none obviously best
- Per-chip key tables, selected from
getProcessorIdentifier(). Most accurate, but needs a new table for every chip Apple ships, and iSMC's file shows how large that gets. - Union of all known keys, take the max plausible reading. No chip detection, degrades gracefully because an absent key returns 0 and is rejected by the plausibility guard from Reject implausible Apple Silicon SMC temperatures #3531. "Hottest core" is also a defensible definition of CPU temperature. Costs more SMC round-trips (~0.25 ms per key measured on an M2 Max), which matters little since the value is memoized.
- Dynamic enumeration via
SMC_CMD_READ_INDEX(already implemented inoshi-demo/SmcDump.java), filtering toTp*/Te*, cached once per JVM. Self-adapting to unreleased chips, but 2409 keys is a slow first call. - Config override, e.g.
oshi.os.mac.sensors.cputemperature.keys. Precedent exists —Sensors#getCpuTemperaturealready documentsoshi.os.linux.sensors.hwmon.namesand...cputemperature.typesfor Linux. Useful as an escape hatch alongside any of the above.
The union-plus-max option looks like the best effort/robustness trade to me, but I have only an M2 Max to verify on.
Discovered while investigating #3529; the plausibility guard in #3531 is a prerequisite for the union approach, since it is what makes reading a key that is absent or idle-gated safe.
Activity
dbwiddis commentedon Jul 27, 2026
Tested the
IOHIDEventSystemapproach on an M2 Max (via fermion-star/apple_sensors, packaged in Issac-Lopez/mac_temp_sensor). It solves both halves of this issue, and supersedes the union-of-known-keys approach I suggested above.1. Sensors are self-describing — no per-chip key table
IOHIDServiceClientCopyProperty(sc, CFSTR("Product"))returns readable names. On this M2 Max, 64 matching services:max(PMU tdie*)is a natural CPU die temperature and needs no FourCC mapping, so it should work on chips that don't exist yet. Names repeat across services (tdie1appears 4×, most 2×), so grouping or a max is needed rather than assuming uniqueness.2. It has no idle-gating problem
Same machine, same moment, genuinely idle:
The HID path reports real die temperatures exactly where the SMC reports parked sentinels. So it would also remove the "unavailable on an idle Mac" behaviour that #3531 necessarily introduced — #3531 is the correct fix for the SMC path, but this path does not need it.
Caveats
<IOKit/hidsystem/IOHIDEventSystemClient.h>is not in the public SDK;IOHIDEventSystemClientCreate,IOHIDEventSystemClientSetMatching,IOHIDEventSystemClientCopyServices,IOHIDServiceClientCopyProperty,IOHIDServiceClientCopyEventandIOHIDEventGetFloatValueall have to be hand-declared. Widely used (iSMC'shid/package, macmon, stats) but a policy call for OSHI, and a different risk profile from the SMC path.matching(0xff00, 5)worked here; the upstream comment says0xff05is the alternative and that0xff00is needed "for M1". Both should probably be tried, and confirmed on more hardware.noname(0.0) and probablyPMU tcal.Next
@dbwiddis is checking an M3 tomorrow. The useful things to capture there: whether
matching(0xff00, 5)returns services or whether it needs0xff05, and whether thePMU tdie*names appear with the same shape.dbwiddis commentedon Jul 27, 2026
M3 Pro results — HID sensor path confirmed
Ran the
IOHIDEventSystemprobe from the handoff on an M3 Pro. Short version: it behaves the same as M2 Max on Q1–Q3, and Q4 is even more damning for the SMC-key approach than expected.Environment
machdep.cpu.brand_string)Q1 — matching pair
matching(0xff00, 5)returned services immediately (same as M2 Max). 47 services total.0xff05was not needed.Q2 — HID sensor names (idle, with counts)
Differences from the M2 Max baseline:
PMU tdie0— the die sensors start attdie1and run totdie10(M2 Max hadtdie0..tdie10).PMU TP*names at all (M2 Max hadTP0s/TP1g/… ). So theTP*family isn't universal — a design must not depend on it.tdie/tdevappears 2×), so a name is not a unique key — aggregate (e.g.maxoverPMU tdie*) as on M2 Max.Q3 — idle plausibility (the key check)
PMU tdie*read 40.0–41.7 °C at idle — plausible, no sentinel collapse. Under all-core load (yes×12) they rose to 40.4–43.8 °C. HID path is clean on M3 Pro, matching M2 Max.Q4 — SMC behaviour on M3 Pro
This is the notable one. Via
ismc(dkorunic/tap, v0.17.0):All five of OSHI's hardcoded keys are ABSENT on M3 Pro — not just 3-of-5 as the handoff predicted, but 0-of-5:
The M3 Pro CPU keys are an entirely different set:
At idle these read plausibly (perf cores 45–48 °C,
TCMz73 °C) and rose under load (perf cores 54–68 °C) — i.e. on M3 Pro the SMC keys that exist don't show the idle sentinel the M2 Max die sensors did; the problem here is simply that OSHI queries five keys that don't exist on this chip, so OSHI reports temperature unavailable on an M3 Pro regardless of the PR #3531 sentinel filter.Conclusion
Q1–Q3 match M2 Max; the HID path is self-describing, idle-stable, and load-responsive on M3 Pro. Q4 reinforces that hardcoded FourCC keys are unmaintainable across chips (0/5 keys on M3 Pro, and per-chip meaning drift on the ones that do exist). The
IOHIDEventSystemProduct-name approach looks like the right direction.Remaining open question is the policy one flagged in the handoff: binding the private
IOHIDEventSystemClient*/IOHIDServiceClient*/IOHIDEventGetFloatValueAPIs (not in the public SDK, must be hand-declared) from both the FFM and JNA backends.dbwiddis commentedon Jul 27, 2026
Proposed direction: IOHID primary, SMC aggregate keys as fallback
After the M3 Pro results above, here's the design choice I'm leaning toward. Summarizing so it's captured before the detailed design.
The reframe
The scarce thing isn't keys, it's meaning — which key maps to which component on this particular silicon. The current bug (0/5 hardcoded keys exist on M3 Pro; per-chip meaning drift on the ones that do) is fundamentally a "we hardcoded meaning that varies per chip" problem. IOHID hands that meaning out for free at runtime via each sensor's
Productstring (PMU tdie*), generated by the OS for the exact chip you're on. That's the whole game.Plan
Primary — IOHID. One memoized discovery of the sensor service list on first read (fits our shared-memoized-supplier pattern), matched with
matching(0xff00, 5), filtered toPMU tdie*, aggregated withmax. Confirmed self-describing, idle-stable, and load-responsive on both M2 Max and M3 Pro with the identical matching call — no chip detection, no config file, no key list to maintain. Names repeat (~2× per service) so we aggregate over the group rather than treat a name as a unique key.Fallback — SMC by aggregate key, not per-core enumeration. If IOHID is unavailable, prefer a single SMC-computed aggregate the firmware already provides —
TCMz("CPU Die Max"), withTCMb(average) /TCAD(package) as further fallbacks — rather than enumerating and pruning per-core keys. On M3 ProTCMzexactly equalled the hottest performance cluster (Tp3X) at both idle and load, i.e. the SMC already computes the die-max for us. This sidesteps the entire "which core keys exist on this chip" mess that broke the current code. (Aggregate-key availability across chips still to be confirmed against iSMC's table.)Give up gracefully and report unavailable if both fail.
What I'm explicitly not doing, and why
Not maintaining a per-chip FourCC config table (the iSMC
sensors.goapproach — ~700 hand-maintained, auto-generated entries with per-platform meaning). It's the most work for the least robustness: it duplicates by hand, forever, data the OS already exposes at runtime through IOHID, and its only real value is as insurance for when IOHID is unavailable — but IOHID ships on every macOS. The failure mode it hedges (Apple changing the private API) is one where SMC FourCC meanings would likely drift too, so the table is a perpetual chase whether we maintain it or not.Not the "IOHID to discover, SMC to read" hybrid.
PMU tdie0(IOHID) andTp06(SMC) are different namespaces with no bridge, so discovering a sensor by name tells you nothing about which FourCC to read — it would need a name→key map anyway, collapsing back into the config table.Tradeoffs to weigh in the design
The reported number changes. HID
tdiereads ~40–44 °C where SMCTp0*cores read ~60–75 °C — die diode vs. core-junction hotspot; they genuinely measure different things. Moving to HID makes OSHI report a materially lower CPU temperature than the old keys did when they worked. Defensible (die-max is a clean single "how hot is the chip" number) but a visible behavior change worth documenting — and an argument in favor of theTCMzSMC fallback, since that one is a hotspot-style max.Private-API policy. IOHID (
IOHIDEventSystemClientCreate,...SetMatching,...CopyServices,IOHIDServiceClientCopyProperty,IOHIDServiceClientCopyEvent,IOHIDEventGetFloatValue) is undocumented and not in the public SDK — it must be hand-declared in both the FFM and JNA backends. Note the bar is already partly cleared: OSHI ships hand-declared SMC structs and callsIOConnectCallStructMethodtoday. IOHID is a step further out, not a new category — but it's a project-policy call, not just a technical one.Detailed design (binding surface for FFM + JNA, memoization/lifecycle, exact aggregation) to follow.