Repository navigation
perf: apple_m1: map the generic L1D read-miss event on M1, M2, M4 and T6050 - #2517
Conversation
|
Claude Opus 5.5 on @satchlj's behalf: J775c (T6050) row for this head: it builds, and the generic event counts the same counter. Kernel: lobata's cand-3,
Not tested on M4. 🤖 Generated with Claude Code |
|
Claude Opus 5.5 on @satchlj's behalf: a second commit, It is not built yet and untested on M1/M2. A check there: 🤖 Generated with Claude Code |
|
Blockers: 1. The mapping itself is sound: each core's
HW row: an M1 or M2 (Firestorm/Avalanche core) and an M4 running this head, Assisted-by: LLM (Claude:Opus 5.5) |
The Apple CPU PMU drivers pass no cache map to armpmu_map_event(), so the generic PERF_TYPE_HW_CACHE event L1D | OP_READ | RESULT_MISS is refused on every Apple core. In-kernel users that ask for it portably, such as a scheduler feature telling memory-bound tasks from compute-bound ones, then get nothing. The M4 and T6050 drivers already name that counter, as the l1d-load-misses event. Map the generic event to it in each core's own table, and leave everything else unsupported. Signed-off-by: Satya Benson <satya@benson.earth>
Do for the M1 and M2 cores what the previous commit did for M4 and T6050: map L1D | OP_READ | RESULT_MISS to their L1D load-miss event, M1_PMU_PERFCTR_L1D_CACHE_MISS_LD (0xa3), the same kind of event as the M4 and T6050 entries. It takes the default counter placement (any counter but 0 and 1). Everything else stays unsupported. Without it, in-kernel users of the generic event, such as MEM_SPREAD, classify nothing on M1 and M2, so rows from those machines could not show what such a feature does there. Signed-off-by: Satya Benson <satya@benson.earth>
9b204b9 to
6fcc45d
Compare
|
Codex GPT-6.2 Sol on @satchlj's behalf Folded the event provenance comment into the M1/M2 mapping commit and removed the stale sentence from the M4/T6050 commit. Both commits carry only the human sign-off, and the PR footer is updated. The ARM64 apple_m1_cpu_pmu.o build passed in neo-build. The revised head is untested on hardware. The M1/M2 and M4 counter comparisons, unsupported-event checks and kernel-log rows remain pending. |
|
Re-review of 6fcc45d: Blockers: 1. From our last comment:
The code is the same as the version reviewed: cache maps at apple_m1_cpu_pmu.c:280-313, passed at :822, :833, :840 and :847.
HW row (still open): an M1 or M2 (one P core) and an M4 running this head. Run Assisted-by: LLM (Claude:Opus 5.5) |
|
Merge-train adversarial review (MERGETRAIN-LINUX2) at 6fcc45d: NO BLOCKERS. Code read only, nothing built here. Before the merge it still needs Dj's verdict at this head; the missing rows are listed below. Full review#2517 perf: apple_m1: map the generic L1D read-miss event on M1, M2, M4 and T6050 @6fcc45d8VERDICT: NO BLOCKERS Checked: the three cache maps at drivers/perf/apple_m1_cpu_pmu.c:280-313 mark everything Commit hygiene: both c75d384 and 6fcc45d end with only Nits:
Missing rows:
|
There was a problem hiding this comment.
Adversarial Pre-PR Checklist Review (head 6fcc45d80590)
Verdict: 0 code/policy/attribution/CI blockers. Holding APPROVE pending the missing §5 hardware rows below.
Checklist Summary (§1–§6)
- §1 No model gating: Pass. Each PMU compatible in
m1_pmu_of_device_ids[]already dispatches to its own*_pmu_map_event()callback (m1_pmu_map_event,m2_pmu_map_event,m4_pmu_map_event,t6050_pmu_map_event), which now passes its corresponding*_pmu_cache_maptable toarmpmu_map_event(). No SoC/board/firmware gates are introduced. - §2 Production-ready: Pass. Works on the default kernel command line with no module parameters, magic delays, or lab-only paths.
- §3 Safety: Pass. All three cache maps initialize every slot via
PERF_CACHE_MAP_ALL_UNSUPPORTED(CACHE_OP_UNSUPPORTED->-ENOENTinarmpmu_map_cache_event()) and map only[C(L1D)][C(OP_READ)][C(RESULT_MISS)]to existing in-tree event IDs (M1_PMU_PERFCTR_L1D_CACHE_MISS_LD = 0xa3fitting 8-bitM1_PMU_CFG_EVENT,M4_PMU_PERFCTR_L1D_CACHE_MISS_LD = 0x03,T6050_PMU_PERFCTR_L1D_CACHE_MISS_LD = 0x5a3fitting 16-bitM4_PMU_CFG_EVENT). Counter affinities place all three on programmable counters only (ANY_BUT_0_1,M4_PMU_CNTR_EVT,T6050_PMU_CNTR_EVT), never stealing fixed counters 0 or 1. - §4 Clean-room & attribution: Pass. Both commits (
c75d3841c769,6fcc45d80590) carry human author/committer (Satya Benson <satya@benson.earth>) and a humanSigned-off-by:only (zeroCo-Authored-By:or AI trailers). All three event numbers were already present indrivers/perf/apple_m1_cpu_pmu.c. The PR body includesAssisted-by:. - §6 Naming: Pass. The provenance comment at
drivers/perf/apple_m1_cpu_pmu.c:302-307cites historical upstream origin matching the file header (line 10); no disallowed Aurora naming is introduced. - CI: Green (
host-testsSUCCESS;mergeable=true).
Remaining §5 Hardware Rows Before Approve
The revised head (6fcc45d80590) has not yet been run on hardware (only an earlier T6050 J775c run on fc44f454 exists, prior to commit 2 and without unsupported-event / regression checks):
- M1 or M2 (
m1_pmu_cache_map,0xa3) at6fcc45d8on a P-core (and ideally an E-core too, sinceicestorm/blizzardsharem1_pmu_cache_map):perf stat -e L1-dcache-load-misses,r0a3counts agree within ~1% (note0xa3had no named sysfs event before and relies on defaultANY_BUT_0_1affinity),L1-dcache-store-missesandLLC-load-missesreportnot supported, plus regression run (0 SELinux denials, 0 failed units, 0 new kernel errors). - M4 (
apple,t6040-pmu,0x03) at6fcc45d8:perf stat -e L1-dcache-load-misses,l1d-load-missescounts agree within ~1%,L1-dcache-store-missesandLLC-load-missesreportnot supported, plus regression run (0 SELinux denials, 0 failed units, 0 new kernel errors). - T6050 / regression note: Confirm unsupported-event rejection and regression check (0 SELinux denials, 0 failed units, 0 new kernel errors) at
6fcc45d8(and optionally note/runapple,t8140-pmuNeo andapple,t8142-pmuM5, which inheritm4_pmu_cache_mapandt6050_pmu_cache_mapviam4_pmu_init()/t6050_pmu_init()).
Non-blocking Nit
- The PR title and commit subjects name "M1, M2, M4 and T6050", while
m4_pmu_init()also bindsapple,t8140-pmu(A18 Pro / Neo) andt8142_pmu_init()inheritst6050_pmu_map_event(M5). Mentioning those two compatibles in the PR description/testing scope would make the affected surface explicit.
|
Claude Opus 5.5 on @satchlj's behalf. J775c (Mac Studio M5 Max, T6050) row for What was booted: not an exact-head tree.
Same-run counts:
Assisted-by: LLM (Anthropic:Claude Opus 5.5) |
RyanTheTide
left a comment
There was a problem hiding this comment.
Independent source review at 6fcc45d80590. I checked the cache map entries against the existing event symbols and the PMU-specific callbacks. The change exposes one generic cache event and leaves the other entries unsupported. Please run the generic and corresponding named or raw L1D read-miss events together on M2 P and E cores, with a pinned load and repeated counts. The T6050 row covers a different event map.
There was a problem hiding this comment.
Formal adversarial §1–§6 pre-PR re-review at live head 6fcc45d80590e6c2a5917df7e34831b53aa4f63a (checked against live integration/aurora 70a00e583b03: not superseded; verified compatible with 2bd81001a9 apple_m1_cpu_pmu-test.c, whose m1pmu_test_cache_map() intentionally leaves L1D|READ|MISS out).
Code, Policy & CI Audit (§1–§4, §6)
- Correctness / locking / lifetime / ABI: Clean.
t6050_pmu_cache_map(0x5a3),m4_pmu_cache_map(0x03), andm1_pmu_cache_map(0xa3) initialize all slots viaPERF_CACHE_MAP_ALL_UNSUPPORTED, map only[C(L1D)][C(OP_READ)][C(RESULT_MISS)]to existing in-tree event IDs fittingM1_PMU_CFG_EVENT/M4_PMU_CFG_EVENT, and place all three on programmable counters only (ANY_BUT_0_1,M4_PMU_CNTR_EVT,T6050_PMU_CNTR_EVT). - §1 No model gating: Pass — dispatched per OF compatible's existing
*_pmu_map_event()callback. - §2 Production-ready: Pass — works on default kernel command line.
- §3 Safety: Pass.
- §4 Clean-room & attribution: Pass — both commits (
c75d3841c769,6fcc45d80590) carry human author/committer and humanSigned-off-by:only (zero AI trailers); PR body carriesAssisted-by:. - §6 Naming & live CI: Pass (
host-tests:success;MERGEABLE/CLEAN).
§5 Blockers (Required Before Approve)
While the updated J775c (T6050) row (cand-15, matching apple_m1_cpu_pmu.c blob f2592ca86713) verifies t6050_pmu_cache_map across all three clusters with unsupported-event rejection and 0/0/0 regression counts, the other two new cache maps remain untested on hardware:
- M1 or M2 (
m1_pmu_cache_map, commit 2,0xa3) — 0 hardware runs:0xa3had no named sysfs event before and relies on defaultANY_BUT_0_1counter affinity. Needs an M1/M2 run on both P and E cores comparingperf stat -e L1-dcache-load-misses,r0a3(within ~1% on pinned workloads), confirming unsupported cache events (L1-dcache-store-misses,LLC-load-misses) return not supported, and recording the 0/0/0 regression gate (0 SELinux AVC denials, 0 failed units, 0 new kernel errors). - M4 / T6040 (and/or T8140 Neo,
m4_pmu_cache_map,0x03) — 0 hardware runs: needs an M4 (or T8140) run comparingperf stat -e L1-dcache-load-misses,l1d-load-misses(within ~1%), confirming unsupported cache events return not supported, and recording the 0/0/0 regression gate.
(Non-blocking note: m4_pmu_init() also covers apple,t8140-pmu and t8142_pmu_init() inherits t6050_pmu_map_event; noting those compatibles in the PR scope would make coverage explicit.)
|
Gemini 4 Neon on @satchlj's behalf. Hardware verification at
Results
Note: M1/M2/M4 paths were not exercised on this T6050 host. |
There was a problem hiding this comment.
Formal §1–§6 pre-PR re-review at verified live head 6fcc45d80590e6c2a5917df7e34831b53aa4f63a (MERGEABLE/CLEAN on integration/aurora, non-draft, host-tests green): REQUEST_CHANGES — 0 code/policy/attribution/CI blockers, holding solely on the two remaining untested hardware cache maps (§5).
What Cleared
- §1–§4, §6 & CI — PASS: 0 code/safety/architecture/naming blockers; both commits (
c75d3841c769,6fcc45d80590) carry human author/committer (Satya Benson <satya@benson.earth>) and humanSigned-off-by:only (zero AI commit trailers); PR body carriesAssisted-by:;host-testsgreen. - §5 T6050 (
t6050_pmu_cache_map,0x5a3) — PASS: New exact-head J775c (lobata,7.3.0-posth4-b2+,boot_idf2f9d218-8991-4c40-86dd-95316c20dd88, default cmdline) verifiesL1-dcache-load-misses:H(2,302,237,831) vsr5a3:H(2,302,248,949,0.0005%diff), confirmsL1-dcache-store-missesandLLC-load-missesreport<not supported>, and records a clean §5 health tuple (SELinux N/A on Arch-SELINUX,0new failed units,0new kernel errors,0warnings/BUGs).
Remaining §5 Blockers Before APPROVE
As noted in the Batch 2 row (and in both @RyanTheTide's and our prior reviews), the other two cache maps added by this PR still have 0 hardware runs:
- M1 or M2 (
m1_pmu_cache_map, commit 2,0xa3) — 0 runs:0xa3had no named sysfs event before and relies on defaultANY_BUT_0_1affinity. Needs a pinned run on both P and E cores comparingperf stat -e L1-dcache-load-misses,r0a3(within ~1%), confirming unsupported cache events (L1-dcache-store-misses,LLC-load-misses) return<not supported>, plus the §5 regression check (0 SELinux denials, 0 failed units, 0 new kernel errors). - M4 / T6040 (or T8140 Neo,
m4_pmu_cache_map,0x03) — 0 runs: Needs a run comparingperf stat -e L1-dcache-load-misses,l1d-load-misses(within ~1%), confirming unsupported cache events return<not supported>, plus the §5 regression check.
Because @satchlj only has J775c (lobata), these two rows need to be collected on lab M1/M2 and M4 hardware; once posted at 6fcc45d80590, this is ready to flip straight to APPROVE.
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at 6fcc45d80590: the code is ready; it needs only rows on the M1/M2 and M4 maps, which we're getting for you.
Blockers: none in the code. Missing rows: the M1/M2 map (0xa3) and the M4 map (0x03) haven't run on those Macs yet. On each, perf stat -e L1-dcache-load-misses should match the raw event within about 1 % on a pinned read loop, and other cache events should still report <not supported>. You only have the J775c, so the lab will run these.
Checked: no Apple material, no gates. Each core's own map_event passes its own map, every other cache entry stays unsupported, and the event numbers are the ones the driver already uses. The J775c row (the same driver file as this head) matches r5a3 to 0.0005 % and rejects store and LLC misses. CI green. This replaces my earlier reviews.
Evidence
Read both commits (drivers/perf/apple_m1_cpu_pmu.c, +37/-4) and the J775c rows from 11-22 and 11-24. T8140 and T8142 share these map functions, so their rows are checks after the merge.
Superseded by the review at 6fcc45d
|
Merge readiness at
Areas: none matched in CODEOWNERS Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
|
|
J773g (Mac mini, M4 / T8132) at Kernel:
|
perf: apple_m1: give the M1, M2, M4 and T6050 CPU PMUs a generic cache map with one entry.L1D | OP_READ | RESULT_MISSmaps to each PMU's L1D read-miss counter. Commit 1 maps the existing namedl1d-load-missesevent on M4 and T6050. Commit 2 mapsM1_PMU_PERFCTR_L1D_CACHE_MISS_LD(0xa3) on M1 and M2. Every other cache event stays unsupported.Why: without a cache map,
armpmu_map_event()refuses everyPERF_TYPE_HW_CACHEevent on Apple cores. #2482 (MEM_SPREAD) asks for exactly this event, so in this tree it classifies nothing on any Apple SoC, as Ryan pointed out there. #2482 depends on this PR.Selection: by each core's own PMU match data (
m1_pmu_map_event,m2_pmu_map_event,m4_pmu_map_event,t6050_pmu_map_event), using event numbers already in the tree.Testing
drivers/perf.L1-dcache-load-missescounted 900,381,519 andl1d-load-misses900,456,498 on the same run (see the comment below).26294e82don't touchdrivers/perf.drivers/perf/apple_m1_cpu_pmu.ofor ARM64 inneo-build. Hardware rows for the revised head are pending on M1/M2 and M4. MEM_SPREAD rows on M1 Pro and M2 are requested on sched/fair: spread memory-bound tasks across LLCs (MEM_SPREAD, stacked on #2481) #2482.