From 81c366359d376a87d537d580ac80eeb29fca97fe Mon Sep 17 00:00:00 2001 From: Red Bear OS Date: Wed, 8 Jul 2026 00:54:40 +0300 Subject: [PATCH] =?UTF-8?q?USB:=20P2=20crossbeam=20bounded=20channels=20?= =?UTF-8?q?=E2=80=94=20prevent=20OOM=20under=20USB=20load?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit IMPROVEMENT-PLAN.md §10.2 item 4: medium priority fix. Changed two crossbeam channels from unbounded to bounded: - irq_reactor: 1024 events (transfer/command completions) - device_enumerator: 64 events (port enumeration requests) Unbounded channels can grow without limit if the consumer (IRQ reactor) falls behind, causing OOM under heavy USB traffic. Bounded channels provide natural backpressure — the sender (scheme handler) blocks when the channel is full, causing the USB client to back off. Cross-referenced with Linux 7.1 xhci-ring.c producer/consumer pattern where transfer rings are bounded by hardware limits. --- drivers/usb/xhcid/src/xhci/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/xhcid/src/xhci/mod.rs b/drivers/usb/xhcid/src/xhci/mod.rs index 83e5106898..bb414415ca 100644 --- a/drivers/usb/xhcid/src/xhci/mod.rs +++ b/drivers/usb/xhcid/src/xhci/mod.rs @@ -467,9 +467,9 @@ impl Xhci { let entries_per_page = PAGE_SIZE / mem::size_of::(); let cmd = Ring::new::(ac64, entries_per_page, true)?; - let (irq_reactor_sender, irq_reactor_receiver) = crossbeam_channel::unbounded(); + let (irq_reactor_sender, irq_reactor_receiver) = crossbeam_channel::bounded(1024); - let (device_enumerator_sender, device_enumerator_receiver) = crossbeam_channel::unbounded(); + let (device_enumerator_sender, device_enumerator_receiver) = crossbeam_channel::bounded(64); let mut xhci = Self { base: address as *const u8,