RFC genirq/cpuset: Evict unmanaged IRQs from runtime-isolated CPUs
Get series with b4
b4 am [email protected]Versions newest first
- v1 RFC Latest10 patches 1 replyIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/10 | genirq: Add IRQCHIP_AFFINITY_FILTERABLE flaginclude/ kernel/ | +25 | 0 replies | |
| 2/10 | sched/isolation: Add runtime isolation helpersinclude/ kernel/ | +63 | 0 replies | |
| 3/10 | genirq: Track automatic vs. explicit affinity provenanceinclude/ kernel/ kernel/ +2 more | +112 | 0 replies | |
| 4/10 | genirq: Filter unmanaged IRQ affinity against runtime isolationinclude/ kernel/ kernel/ +2 more | +360 | 0 replies | |
| 5/10 | genirq: Reapply unmanaged IRQ affinity on isolation changesinclude/ kernel/ kernel/ +1 more | +348 | 0 replies | |
| 6/10 | genirq: Align affinity notifiers and IRQ threads with isolationinclude/ kernel/ kernel/ +1 more | +146 | 0 replies | |
| 7/10 | genirq: Handle runtime isolation across hotplug and suspendkernel/ kernel/ kernel/ +4 more | +150 | 0 replies | |
| 8/10 | x86/apic: Support runtime IRQ isolationarch/ arch/ arch/ +7 more | +124 | 0 replies | |
| 9/10 | sched/isolation: Publish runtime isolation to genirqDocumentation/ kernel/ | +104 | 0 replies | |
| 10/10 | net: Keep core-managed IRQ affinity automaticlib/ net/ | +53 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [RFC PATCH 00/10] genirq/cpuset: Evict unmanaged IRQs from runtime-isolated CPUs
cpuset.cpus.partition=isolated removes CPUs from scheduler load balancing and HK_TYPE_DOMAIN housekeeping at runtime, but genirq does not consume that state. Drivers requesting IRQs after container start, reopening an interface, or resetting hardware can still route unmanaged interrupts onto isolated CPUs.
- Patch 1 defines the IRQCHIP_AFFINITY_FILTERABLE flag and its hierarchy contract.
- Patch 2 adds the sched/isolation runtime-isolated helper.
- Patch 3 records the placement provenance (automatic or explicit) and adds the core-only irq_set_affinity_auto() helper; a bare irq_set_affinity() is an explicit pin.
- Patch 4 adds the filter, the shared mask selection and the late-IRQF_NOBALANCING re-align.
- Patch 5 reapplies the requested affinity when the isolation set changes; the policy query lives in isolation.c.
- Patch 6 keeps the requested mask in the affinity notifier, reports a deferred move again when it completes, and aligns the IRQ threads with the filtered mask; consumers which build a reverse map follow the programmed mask.
- Patch 7 handles hotplug, suspend/resume replay and the CPU-online restore.
- Patch 8 opts x86 APIC in, filters its vector fallbacks and marks the forwarding irqchips PASSTHROUGH.
- Patch 9 publishes runtime isolation and documents the boundaries.
- Patch 10 keeps the netdev core-managed affinity automatic and steers its ARFS map by the programmed mask while runtime isolation is active; it is the consumer of patches 3 and 6.
Runtime-isolated CPUs are detected as DOMAIN_BOOT - DOMAIN. A mask which still has an online target after that subtraction keeps its boot-time isolcpus=domain CPUs, whether it was placed automatically or explicitly. Only when no online target remains may an automatically placed IRQ fall back to online HK_TYPE_DOMAIN CPUs, preferring the nodes the request covers and then irq_default_affinity and the device node, so a queue hinted onto another socket is not pulled back. The x86 vector fallback
subtracts only the runtime set, so boot isolcpus=domain fallback targets do not change; a CPU which is both boot-isolated and part of an isolated partition is not in the runtime set either, so its interrupt behaviour is unchanged. The -ENOSPC retry in the core honours irq_default_affinity first and then widens to the other online HK_TYPE_DOMAIN CPUs, so a boot-time isolcpus=domain CPU is never used as an emergency target and the request itself stays the last resort.
Automatic placement is tracked in a genirq-private IRQS_AFFINITY_AUTO state bit in desc->istate rather than in a public IRQD bit or instatus_use_accessors: it is core-internal, survives free_irq()/request_irq(), and irq_modify_status() cannot reach it. Default placement, unmanaged affinity descriptors, the hint API (irq_set_affinity_and_hint() and its deprecated alias) and the core-only irq_set_affinity_auto() record automatic placement. A bare irq_set_affinity() is an explicit pin, the safe default for per-CPU PMU, timer and architecture code; a driver which wants a queue to follow the housekeeping set uses the hint API, so no driver has to change. IRQF_NOBALANCING is applied after the interrupt is activated, so a default placement still starts on a housekeeping CPU; an explicit request which was narrowed before the flag was applied is then programmed again, because the filter is inert for a non-balancing interrupt. The replay runs through the regular affinity path, so a chip which cannot move in process context reprograms it from interrupt context. It only runs while runtime isolation is active, on a chip which opted in, for a request which was actually set and still has an online target. /proc writes and irq_force_affinity() are explicit and are never redirected: while the mask keeps an online non-isolated target the filter still subtracts the runtime-isolated CPUs, but the request itself remains the last resort and is never widened to CPUs outside it. A default placement has no target of its own and is still chosen among housekeeping CPUs when IRQF_NOBALANCING is passed to request_irq(); a driver which pre-marks the IRQ with irq_set_status_flags() skips both steps.
Per-CPU and managed interrupts are excluded. The affinity notifier
keeps reporting the requested mask for the pending and programmed
paths, as it does upstream: a consumer which stores the notified mask
as the request (net/core does) must not be handed the filtered policy,
or removing the partition later cannot restore the CPU. A consumer
which spreads work over several CPUs follows the mask the core asks
the chip to program, irq_copy_programmed_affinity(): the request minus
the runtime-isolated CPUs, or the automatic relocation. The effective affinity is deliberately not used there; on chips withIRQD_SINGLE_TARGET it is one CPU, and a reverse map built from it would collapse to a single entry. Patch 10 converts net/core andlib/cpu_rmap.c. A driver which registers its own irq_affinity_notify callback and steers hardware to a single CPU (bnxt TPH) is left
unchanged here; it keeps following the notified request, and
converting it needs a per-driver decision about which CPU actually
handles the interrupt. The other custom callbacks (i40e's polling
check, the mask caches of ionic, funeth, hfi1, qla2xxx and qedf) are
left on the request for the same reason; only the reverse-map
consumers are converted.
The notifier is scheduled from the reapply path as well, and a deferred
move is reported when it is queued and again when the pending mask has
been programmed, so a consumer which follows the programmed mask
converges on the new target. A CPU which enters isolation re-applies
the interrupts which have a notifier consumer even when the chip
already targets another member of the request, because the policy mask
lost that CPU and a reverse map has to drop it. Without a notifier
nothing observes the change, so the chip is left alone. An explicit mask which loses every online target is not relocated and keeps its request. When a CPU leaves a partition the preserved request is handed to the irqchip again even if the current effective mask still intersects it, so a chip which can place the interrupt elsewhere includes the returning CPU and the notifier and the
IRQ threads see the restored request. A single-target IRQ is no
exception: x86 marks its vector IRQs IRQD_SINGLE_TARGET, so the chip
keeps the current target, but the re-apply still restores the reverse
map and the thread mask. A broad mask whose IRQs were all evicted to
one housekeeping CPU therefore stays there physically until a balancer
or an explicit affinity write moves it. An automatic IRQ whose whole request became isolated is different: the fallback moved it outside the request, so its current CPU is not in the mask and the chip does move
it back when the request becomes placeable again. A CPU which returns
also completes an automatic fallback which had parked an interrupt
outside its requested mask after -ENOSPC. A threaded IRQ escapes to
the requested mask when its delayed hardware move still points at a runtime-isolated CPU; the move marks the IRQ threads when it is queued,
not only when it completes. Reapply runs under cpuset_top_mutex -> irq_isolation_mutex -> cpus_read_lock -> sparse_irq_lock -> desc->lock,
with the CPU hotplug read lock taken once around the static key update
and the reapply walk.
Points for maintainer feedback:
- Placement provenance: a bare irq_set_affinity() is explicit, the hint API keeps automatic placement, and core code which manages an affinity on a driver's behalf uses irq_set_affinity_auto(). The helper is not exported and its only consumer is net/core (patch 10), so no driver changes. A tree-wide audit of all 69 bare irq_set_affinity() call sites confirms that none binds a multiqueue NIC queue (they are per-CPU PMU/timer/portal, irqchip/MSI-mux, or explicit management pins), whereas multiqueue drivers already use the hint API (129 call sites tree-wide, 69 under drivers/net) or core-managed NAPI/PCI affinity. Is that the preferred shape?
- Hierarchy contract for IRQCHIP_AFFINITY_FILTERABLE. Every level of the parent chain which implements .irq_set_affinity has to declare itself either FILTERABLE (the level which programs delivery) or PASSTHROUGH (a forwarder which derives no state from the mask); an unmarked level keeps filtering off for the whole chain. This makes an unaudited domain default-off instead of inheriting the capability from its parent. On x86 the vector domain is FILTERABLE and the IO-APIC, PCI-MSI, DMAR, HPET, INTEL-IR, AMD-IR and HYPERV-IR levels, the Hyper-V PCI MSI parents and the UV core domain are PASSTHROUGH. ARM64/ GICv3-ITS would have to mark the ITS level explicitly before it can be enabled. Is this the
contract you want, or should a delivery level be able to opt in on behalf of its children?
- Trigger policy vs. genirq mechanism (LPC 2026 cgroup IRQ isolation discussions): this RFC wires the filter directly to runtime HK_TYPE_DOMAIN changes (DOMAIN_BOOT - DOMAIN) so existing cpuset.cpus.partition=isolated users get unmanaged IRQ eviction out of the box. We are aware of the discussions around exposing a dedicated cgroup knob or a separate housekeeping type for IRQ isolation, and of the subsystem-specific queue management for networking. The genirq filtering and x86 vector mechanics in patches 1 and 4-8 are intentionally decoupled from how the isolated mask is configured, and can be switched to a dedicated housekeeping mask or cgroup toggle with a contained change to housekeeping_runtime_isolated().
Testing:
- x86_64 and ARM64 build with W=1 and no warnings in the touched files.
- focused KVM test, 8 vCPUs, with isolcpus=domain,2 and also without boot-time isolcpus: automatic and explicit filtering, the boot-isolated mask preservation, the -ENOSPC fallback, the late-IRQF_NOBALANCING replay, the threaded IRQ escape, de-isolation restore, the explicit pin and the empty-effective-affinity case all pass.
- a QEMU boot with intel-iommu,intremap=on and an e1000e NIC: a PCIe MSI-X IRQ behind INTEL-IR is moved off the isolated CPU when its request is widened to include that CPU, which exercises the FILTERABLE/PASSTHROUGH walk on the real PCI-MSI -> INTEL-IR -> vector chain.
- scaling up to 4096 unmanaged filterable IRQs, all evicted from and restored to the isolated CPU, adds ~1 ms (~0.24 us/IRQ) over the ~8.5 ms no-IRQ baseline; the cpuset write path remains dominated by housekeeping_update(). Those are whole-request evictions: the fallback left them outside the request, so the chip moves them back on de-isolation. A broad mask which was only narrowed is the case which is not re-spread.
Boundaries:
- managed IRQs, queue reallocation and APIC vector compression are
out of scope;
- x86 APIC without interrupt remapping migrates on the next
interrupt; - irqbalance must be disabled from boot: stopping it later does not restore the automatic placement of the single-CPU /proc pins it already wrote. Writing a broad mask back keeps it explicit but still filters the runtime-isolated CPUs; only an IRQ whose entire online mask is isolated loses the fallback to other housekeeping CPUs. A balancer which reads cpuset.cpus.isolated is the alternative; it cannot close the window in which a driver calls request_irq() or pci_alloc_irq_vectors() while the container is already running, and there is no balancer on a no-daemon edge system. The kernel-side filter covers that window;
- de-isolation hands the preserved request to the irqchip again and restores the reverse map, but does not force a re-spread. A single-target IRQ (x86 marks its vector IRQs IRQD_SINGLE_TARGET) whose effective CPU is still in the request keeps that CPU, because the x86 vector code does not move an interrupt whose target is still valid; IRQs which were only narrowed (a broad mask evicted to one housekeeping CPU) stay there physically after the partition is gone, so a balancer which reads cpuset.cpus.isolated, or a new affinity write, is needed to spread them again. An IRQ whose whole request was isolated is moved back, because the fallback left it outside the request;
- on PREEMPT_RT the IRQ thread processes IRQTF_AFFINITY at the top of its wait loop and blocks in set_cpus_allowed_ptr() until it has been moved. The wake-up is queued against the old scheduling affinity, so the thread can still be scheduled once on the isolated CPU before it migrates; the handler itself runs on the housekeeping CPU. Keep latency-critical RT tasks at a higher real-time priority than the threaded IRQ default, or let the device settle before entering the critical loop;
- only the x86 APIC vector chip opts in today; ARM64 is compile-tested only, GICv3/ITS does not opt in yet.
Kris Pan (10):
genirq: Add IRQCHIP_AFFINITY_FILTERABLE flag sched/isolation: Add runtime isolation helpers
genirq: Track automatic vs. explicit affinity provenance
genirq: Filter unmanaged IRQ affinity against runtime isolation
genirq: Reapply unmanaged IRQ affinity on isolation changes
genirq: Align affinity notifiers and IRQ threads with isolation
genirq: Handle runtime isolation across hotplug and suspend x86/apic: Support runtime IRQ isolation sched/isolation: Publish runtime isolation to genirq
net: Keep core-managed IRQ affinity automatic
Documentation/admin-guide/cpu-isolation.rst | 102 ++++ arch/x86/hyperv/irqdomain.c | 4 +- arch/x86/kernel/apic/io_apic.c | 6 +- arch/x86/kernel/apic/msi.c | 8 +- arch/x86/kernel/apic/vector.c | 105 +++- arch/x86/kernel/hpet.c | 3 +- arch/x86/platform/uv/uv_irq.c | 1 + drivers/iommu/amd/iommu.c | 1 + drivers/iommu/hyperv/hv-irq-remap-x86.c | 2 + drivers/iommu/intel/irq_remapping.c | 2 + drivers/pci/controller/pci-hyperv.c | 2 + include/linux/interrupt.h | 8 + include/linux/irq.h | 54 ++ include/linux/sched/isolation.h | 42 ++ kernel/irq/Makefile | 1 + kernel/irq/cpuhotplug.c | 12 +- kernel/irq/debugfs.c | 4 + kernel/irq/internals.h | 62 ++ kernel/irq/irqdesc.c | 10 + kernel/irq/isolation.c | 623 ++++++++++++++++++++ kernel/irq/manage.c | 385 ++++++++++-- kernel/irq/migration.c | 10 + kernel/irq/pm.c | 15 + kernel/sched/isolation.c | 33 ++ lib/cpu_rmap.c | 32 +- net/core/dev.c | 24 +- 26 files changed, 1481 insertions(+), 70 deletions(-) create mode 100644 kernel/irq/isolation.c
Signature · 1 line
2.43.0