Repository navigation
irqchip/apple-aic: Report the effective affinity of AICv2+ IRQs - #447
Conversation
|
Review notes from a static read of 28ceabdc (build gates are queued and not yet run). Looks right for the native Apple path. AICv1 is unchanged, and SIQ_CFG is read only on T8140 at EL2. The effective-affinity mask capability is always selected on arm64, so the update isn't a no-op. One conditional issue is CPU hotplug. The affinity setter snapshots aic_irq_cpus & cpu_online_mask into each IRQ's effective mask, and aic_init_cpu() only updates the global acceptor mask. When a CPU goes offline, irq_migrate_all_off_this_cpu() drops it from the effective masks correctly. When it comes back, though, genirq's online callback only restores managed IRQs (kernel/irq/cpuhotplug.c), so ordinary IRQs keep the reduced mask and their threads stay excluded from that CPU. It can't happen today, since the Apple DTs use spin-table bring-up with no CPU-off. If hotplug ever lands, it would need an online-stage refresh through genirq (not the STARTING callback). Fine as a follow-up rather than a blocker. Next: the build gates, then a Neo GPU IRQ affinity check (the completion thread should be held to CPU0 on EL2 T8140) with timeout and lost-device counts compared against the same base, plus M1 Pro and M2 one-shots. |
28ceabd to
6f25fcf
Compare
AICv2 and later have no per-IRQ CPU target. The controller hands each hardware IRQ to one of the CPUs that accept IRQs, and each CPU says whether it does in its SIQ_CFG system register: a CPU whose routing field (bits 1:0) reads 3 never receives one. On T8140 the boot CPU reads 0 and every secondary reads 3, so every hardware IRQ is taken on CPU 0, even while CPU 0 holds IRQs masked for tens of milliseconds. Setting a secondary to 1 or 2 makes the controller deliver to it as well. The AICv2 irqchip has no irq_set_affinity, so the effective affinity of its IRQs stays empty and their threaded handlers may run on any CPU. The scheduler often places them away from the CPU taking the hard IRQ, which adds a cross-CPU wakeup to every interrupt. On SoCs where this routing has been verified on hardware, currently T8140, and only at EL2, since a hypervisor or secure monitor may trap SIQ_CFG, map AICv2+ IRQs to a second irqchip. It records at CPU bring-up which CPUs accept IRQs and reports them as each IRQ's effective affinity, so that genirq binds threaded handlers to the CPUs the hard IRQ arrives on. The requested mask cannot change delivery; it is accepted and kept only for reporting. On T8140 every AIC IRQ thread, PCIe MSI ones included, therefore runs on CPU 0, and smp_affinity writes do not move it. Every other SoC keeps the existing irqchip unchanged. The accepting set grows as CPUs start and existing IRQs keep theirs, which is enough while only one CPU accepts IRQs. A SoC with more than one accepting CPU would also need the masks refreshed when such a CPU comes online. On T8140 the G17 GPU completion thread used to run on CPU 5 most of the time and now stays on CPU 0. Over two boots of each kernel, compute submission at depth 2 goes from 47-49 us to 37 us per submit, and render submission at depth 1 from a CPU 0 submitter from 128 us to 108 us. Other submission rows are unchanged.
6f25fcf to
88aebfe
Compare
|
Thanks. On the hotplug point: fixed rather than deferred, and the scope narrowed (88aebfe):
Next: the Neo GPU IRQ affinity check on this head ( |
Summary
AICv2+ has no per-IRQ CPU target. Each CPU says in its SIQ_CFG system register whether it accepts IRQs; routing field (bits 1:0) = 3 means it never receives one. On T8140 (Neo) CPU 0 reads 0 and every secondary reads 3, so every hardware IRQ lands on CPU 0. Because the AICv2 irqchip has no
irq_set_affinity, the effective affinity stayed empty, and threaded handlers floated to any CPU. The G17 GPU completion thread (irq/65) often ran on the app's CPU, which saturated it and caused a bimodal "slow mode" in latency-sensitive GPU workloads.On SoCs whose routing has been verified on hardware (currently T8140), and only at EL2, AICv2+ IRQs map to a second irqchip,
aic2_routed_chip. It records at CPU bring-up which CPUs accept IRQs and reports them as each IRQ's effective affinity, so genirq binds threaded handlers to the CPU(s) the hard IRQ actually arrives on.Safety and scope:
apple,t8140-aic3).aic2_chipbyte for byte.smp_affinitywrites still fail there, and MSI affinity calls don't reach AIC.Behaviour change on T8140 (at EL2): every ordinary AIC IRQ thread, PCIe MSI ones included, now runs on CPU 0, and
smp_affinitywrites don't move it. They are accepted and kept only for reporting. The CPU 0 load numbers below cover this for gpubench.Hardware evidence (Neo, T8140)
Routing probe on a spare AIC line:
New core:
irq/65on CPU 0 in 100% of 50 ms samples, and/proc/irq/65/effective_affinity_list= 0. On the old core it was on CPU 5 64–99% of the time, with an empty effective affinity.Benchmarks (gpubench, µs/submit, 2 new-core boots vs 3 old-core boots; slow rounds in brackets):
Slow rows overall: 20/30 + 20/30 + 54/80 → 8/30 + 12/80. Other rows are unchanged.
CPU 0 load: not overloaded (69–70% busy under render d32 vs 54–57% before), and its 1 ms timer lateness improved (p99 81–83 µs vs 105–115).