Repository navigation
irqchip/apple-aic: Keep a concurrent smp_affinity write on a CPU set change - #2870
jgoyvaerts wants to merge 1 commit into
Conversation
|
Review at bfd106d. Thanks, the fix is right and small. Passing the descriptor's own mask lets
|
DjDeveloperr
left a comment
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.
Assisted-by: LLM (Gemini 4 Neon)
…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) |
DjDeveloperr
left a comment
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.
Assisted-by: LLM (Gemini 4 Neon)
|
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) |
Follow-up to #2222, from RyanTheTide's merge-train review (nit 1).
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 (irqbalance, for example) 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.Tested
ed5c57ef2c58:drivers/irqchip/irq-apple-aic.obuilds for arm64 (defconfig, LLVM=1, W=1) with no warnings; checkpatch 0 errors, 0 warnings.bfd106d44798in our combined kernel (7.3.0-m4.179, AIC at EL2 with VHE):irqchip/apple-aic:siq-cfgis registered (hotplug state 191). 52 routed (AIC2) IRQs report effective affinity0, the one CPU whose SIQ_CFG accepts IRQs. 23 other requested AIC2 IRQs, which have never fired (mailbox lines andane-h16), report an empty effective affinity. 0 error-level kernel messages, 0 failed system or user units. The new head differs only by the NULL check and has not been booted.enable-method = "spin-table", no PSCI node), so there is nocpuN/onlineand the set of accepting CPUs never changes after boot. This needs an AICv2/v3 Mac whose CPUs can go offline.Not done
Ryan's nits 2-6 on #2222 are not part of this PR. They are cosmetic or predate it.
Assisted-by: LLM (Claude:Opus 5.5)