Repository navigation
irqchip/apple-aic: Keep a concurrent smp_affinity write on a CPU set change - #2870
Conversation
|
Review at bfd106d. Thanks, the fix is right and small. Passing the descriptor's own mask lets
|
There was a problem hiding this comment.
Formal §1–§6 pre-PR checklist review at live head bfd106d447984be22d48354e9b5b29c1e72e2ad0 (CI green: host-tests).
Concurrency, Locking & Barriers Audit
- Locking & context:
aic_irq_cpus_update()runs only fromCPUHP_AP_ONLINE_DYNcallbacks (aic_irq_cpu_online/aic_irq_cpu_offline, registered only for AICv2/v3 at EL2 inaic_of_ic_init()). Those callbacks run in process context with IRQs enabled undercpu_hotplug_lock.irq_set_affinity()acquires onlydesc->lock(raw_spinlock_irqsave) and never takes hotplug locks, so there is no lock-order inversion. - Race fix: Replacing the unlocked
cpumask_copy(&aff, irq_get_affinity_mask(virq))withirq_set_affinity(virq, irq_get_affinity_mask(virq))defers reading the affinity mask untildesc->lockis held in__irq_set_affinity()->irq_do_set_affinity(). Under the Linux Kernel Memory Model,desc->lockrelease/acquire orders visibility ofassign_cpu(cpu, &aic_irq_cpus, accepts)against concurrent/proc/irq/N/smp_affinitywriters: any writer that winsdesc->lockfirst is preserved whenaic_irq_cpus_update()reads the live mask, and any writer that acquiresdesc->lockafteraic_irq_cpus_update()releases it is guaranteed to observe the updatedaic_irq_cpus. - Self-copy semantics:
irq_do_set_affinity()executescpumask_copy(desc->irq_common_data.affinity, mask)whenaic2_routed_irq_set_affinity()returnsIRQ_SET_MASK_OKwithmask == desc->irq_common_data.affinity. Core genirq already relies on the exact same pattern inkernel/irq/cpuhotplug.c:132and:226.
Checklist Summary
- §1 No model gating: Pass (no chip/board gates; applies cleanly to AICv2/v3 EL2 hotplug path).
- §2 Production-ready: Pass (removes the static cpumask and unlocked copy cleanly; no delays, retries, or parameters).
- §3 Safety: Pass.
- §4 Clean-room & attribution: Pass. Single human commit (
Jonathan Goyvaerts), validSigned-off-byandFixes:, zero AI trailers in commit. - §5 Evidence: Fail (see blocker below).
- §6 Naming: Pass.
Blocker
- §5 Evidence (missing hardware run): This PR has not been booted on any hardware (0 boot rows, 0 regression runs, and the modified
aic_irq_cpus_update()path has never executed). Before merge, run at least one verified hardware row at live head on an AICv2/v3 Mac with PSCI CPU hotplug (cpuN/onlinetoggling on an IRQ-accepting CPU concurrently with/proc/irq/*/smp_affinitywrites, confirmingsmp_affinityis preserved andeffective_affinity_listtracks the online accepting set), plus the §5 regression check (0 SELinux denials, 0 failed units, 0 new kernel errors).
Non-blocking nits
irq_get_affinity_mask(virq)can returnNULLifvirqis concurrently unmapped betweenirq_has_action(virq)and the lookup; guardingconst struct cpumask *aff = irq_get_affinity_mask(virq); if (!aff) continue;avoids passingNULLintoirq_set_affinity()if the virq number were reused before__irq_set_affinity()takesdesc->lock(pre-existing code had the same unlocked lookup).- Consider noting in the commit message that
aic_irq_cpus_update()runs only on AICv2/v3 at EL2 (aic2_routed_chip), affecting stored/effective affinity reporting without touching AICv1 or hardware IRQ delivery. - Pre-existing follow-up item: the return value of
irq_set_affinity()is ignored; if a user previously pinned an IRQ to a CPU that went offline,irq_do_set_affinity(..., force=false)returns-EINVALand skips refreshing effective affinity on subsequent online transitions.
…change aic_irq_cpus_update() copied each IRQ's affinity mask into a static cpumask and then passed the copy to irq_set_affinity(). The copy was taken without the descriptor lock, so a /proc/irq/N/smp_affinity write (irqbalance, say) that lands between the copy and irq_set_affinity() was overwritten with the stale mask, and the user's setting was lost. Pass irq_get_affinity_mask() to irq_set_affinity() directly. The mask is then read under the descriptor lock, so the set change applies whatever affinity is current. genirq does the same when it restores a managed IRQ's affinity on CPU online (irq_restore_affinity_of_irq()). The static cpumask goes with it. If the IRQ's descriptor is gone by the time its mask is looked up, irq_get_affinity_mask() returns NULL. Skip that IRQ instead of passing NULL on to irq_set_affinity(). aic_irq_cpus_update() runs only on AICv2 and AICv3 at EL2, where aic2_routed_chip is used. There it changes the stored and effective affinity that is reported. It doesn't touch AICv1, or how the hardware delivers IRQs (SIQ_CFG decides that). Fixes: d3d404c ("irqchip/apple-aic: Keep the routed IRQ affinity across CPU hotplug") Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
bfd106d to
ed5c57e
Compare
|
Thanks @DjDeveloperr. New head
On the hardware row: the CPU offline/online race can't run on the J616s (T6040). Its secondaries are What I can show is the boot of our combined kernel carrying the previous head
The new head itself has not been booted. If a fleet Mac with AICv2/v3 and offline-capable CPUs is available, that run would close §5. The test: toggle an accepting CPU's Assisted-by: LLM (Claude:Opus 5.5) |
There was a problem hiding this comment.
Formal Pre-PR Checklist Re-Review (§1–§6) — REQUEST_CHANGES
Re-reviewed at verified live head ed5c57ef2c58e34c0fab10d2123208efb9a212c0 (jgoyvaerts:m4pro/aic-affinity-locked-mask → aurora-silicon/linux:integration/aurora). Live CI: Host tests (45264648717) = success.
Code & Prior Nits Verification
- Both non-blocking nits from the prior review are cleanly addressed:
irq_get_affinity_mask(virq)is now NULL-checked beforeirq_set_affinity(virq, aff)(drivers/irqchip/irq-apple-aic.c:1121-1125), and the commit message clearly scopesaic_irq_cpus_update()to AICv2/v3 at EL2 (aic2_routed_chip, stored/reported affinity only). - The concurrency fix itself is sound and ready to merge once §5 hardware evidence lands.
Remaining Blocker
- §5 Evidence (exact head unbooted; modified path never exercised on hardware):
- Exact head
ed5c57ef2c58has not been booted on any hardware. - The earlier J616s (T6040) boot carried previous head
bfd106d44798in a combined kernel (7.3.0-m4.179), omitted SELinux/AppArmor denial counts, and ran withenable-method = "spin-table"(no PSCI / nocpuN/online). Becauseaic_of_ic_init()registersCPUHP_AP_ONLINE_DYNin early boot before peripheral IRQs have actions (irq_has_action(virq)), the modified loop body (irq-apple-aic.c:1121-1127) has never actually executed on hardware. - Action needed: Post a verified hardware run at live head
ed5c57ef2c58on an AICv2/v3 Mac with PSCI CPU hotplug (cpuN/onlinetoggling on an IRQ-accepting CPU concurrently with/proc/irq/*/smp_affinitywrites, confirming writtensmp_affinitymasks are preserved andeffective_affinity_listtracks the online accepting set) along with the full §5 regression tuple (0 SELinux denials,0 failed units,0 new kernel errors).
- Exact head
Pre-PR Checklist Summary (§1–§6)
- §1 No model gating: PASS.
- §2 Production-ready, no hacks: PASS.
- §3 Safety: PASS.
- §4 Clean-room & attribution: PASS — single commit
ed5c57ef2c58has human author/committer (Jonathan Goyvaerts), humanSigned-off-by:andFixes: d3d404c0e448, zero AI trailers in commit. - §5 Evidence: FAIL — live head unbooted, modified hotplug loop untested on hardware, missing full §5 regression tuple at
ed5c57ef2c58. - §6 Naming: PASS.
|
J616s (T6040) boot with head
This covers boot and health at the exact code only. As @DjDeveloperr notes, the changed loop body still hasn't executed on hardware. On this machine it can't: the CPUs are spin-table, and no peripheral IRQ has an action yet when CPU0's callback runs. The CPU offline/online row still needs an AICv2/v3 Mac with PSCI. Assisted-by: LLM (Claude:Opus 5.5) |
|
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. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at ed5c57ef2c58: the code is ready; it needs one more row.
Blockers: none in the code. Missing row: the AIC is shared by every generation, so before it merges it also needs one boot at this head on a non-M4 Mac with an smp_affinity write across a CPU offline and online, and no errors. We'll run it on our J714s or J700.
Checked: no Apple material, no gates. Your J616s boot carries this commit with the same patch-id, which counts as the M4 row: siq-cfg registered, 52 routed IRQs with effective affinity 0, no errors. CI green.
Superseded by the review at ed5c57e
|
J714s (M5 Pro, T6050) row at Kernel: one combined candidate The AIC runs its AIC2 routed chip here (Linux at EL2) and the CPUs hotplug through PSCI. At boot all 18 CPUs accept IRQs (effective affinity
Health on the candidate boot: 0 oops or WARN, 0 GPU recoveries over the whole boot, 0 DART faults. Its err-level lines at boot are the default's set minus one line (the lane-count message that 2068 removes), so 0 new. Failed units: only |
What:
aic_irq_cpus_update()copied each IRQ's affinity mask without the descriptor lock, so a/proc/irq/N/smp_affinitywrite (irqbalance, for example) that landed during a CPU set change was overwritten with the stale mask. It now passes the descriptor's own mask toirq_set_affinity(), which reads it underdesc->lock, and skips an IRQ whose descriptor is gone. Follow-up to #2222 (Ryan's merge-train nit 1).Tested: J616s M4 Pro (T6040, AIC at EL2) at
ed5c57ef2c58, booted on the default command line in our combined kernel 7.3.0-m4.183, which carries this commit patch-id equal (not a standalone kernel):irqchip/apple-aic:siq-cfgregistered, 52 routed IRQs report effective affinity0, 0 error-level kernel messages, no WARN/Oops/SError, 0 failed system or user units. No SELinux/AppArmor is loaded (LSMscapability,landlock,yama). The head also builds for arm64 (defconfig, LLVM=1, W=1) with no warnings; checkpatch clean.Risk: two-way door · M1 Pro/Max/Ultra, M2, M3, M4 and M5 booted at EL2 (AICv2/v3); the M1's AICv1 path is untouched. It changes only the stored and reported affinity, not where the hardware delivers IRQs (SIQ_CFG decides that). Checked unaffected: J616s only; no AICv1 Mac was booted.
Not yet: the changed loop body has not run on hardware. The J616s secondaries are spin-table (no PSCI, no
cpuN/online), and no peripheral IRQ has an action yet when CPU0's callback runs. Needs an AICv2/v3 Mac with PSCI CPU hotplug: toggle an accepting CPU'sonlinewhile writing/proc/irq/N/smp_affinity, then check that the written mask stays andeffective_affinity_listfollows the online accepting set. Also an AICv1 boot/no-regression check.Details
aic_irq_cpus_update()copied each IRQ's affinity mask into a static cpumask and passed the copy toirq_set_affinity(). It took the copy without the descriptor lock. A/proc/irq/N/smp_affinitywrite that lands between the copy andirq_set_affinity()was then overwritten with the stale mask, and the user's setting was lost.Now
irq_get_affinity_mask(virq)goes straight toirq_set_affinity(), so the mask is read under the descriptor lock and the CPU set change applies whatever affinity is current. genirq does the same when it restores a managed IRQ's affinity on CPU online (irq_restore_affinity_of_irq()passes the descriptor's own mask toirq_set_affinity_locked()). The static cpumask goes with it.If the IRQ's descriptor is gone by the time its mask is looked up,
irq_get_affinity_mask()returns NULL; that IRQ is now skipped instead of passing NULL on toirq_set_affinity()(DjDeveloperr's nit).Scope:
aic_irq_cpus_update()runs only on AICv2 and AICv3 at EL2, whereaic2_routed_chipis used. It changes the stored and effective affinity that is reported, not AICv1 or how the hardware delivers IRQs (SIQ_CFG decides that). One commit,drivers/irqchip/irq-apple-aic.conly.Not part of this PR: Ryan's nits 2-6 on #2222. They are cosmetic or predate it.
Evidence
ed5c57ef2c58:drivers/irqchip/irq-apple-aic.obuilds for arm64 (defconfig, LLVM=1, W=1) with no warnings; checkpatch 0 errors, 0 warnings.ed5c57ef2c58in our combined kernel 7.3.0-m4.183 (the commit there is patch-id equal to this head), AIC at EL2 (VHE), default command line, booted 2026-11-24 01:05 UTC:irqchip/apple-aic:siq-cfgis registered (hotplug state 191).0, the only CPU whose SIQ_CFG accepts IRQs. All havesmp_affinity_list0-13. 23 requested lines that have never been started (mailbox lines andane-h16) report an empty effective affinity, the same as on the previous boot.capability,landlock,yama: no SELinux or AppArmor is loaded, so there is no denial count to give (0avc:lines).bfd106d44798in our combined kernel 7.3.0-m4.179: the same siq-cfg registration and affinities, 0 error-level kernel messages, 0 failed system or user units. The current head differs from it only by the NULL check.enable-method = "spin-table", no PSCI node), so there is nocpuN/onlineand the set of accepting CPUs never changes after boot.