Re: [PATCH net] can: mcp251xfd: flush RX offload queue during long IRQs

From: Chris Strong

Date: Tue Sep 29 2026 - 12:03:50 EST


Hi Marc,

Great! Thanks for the review and feedback. I made the changes and sent
the v2 patch series as suggested.

Best regards,

Chris


On Tue, Sep 29, 2026 at 10:49 AM Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx> wrote:
>
> On 22.09.2026 00:01:06, Chris Strong via B4 Relay wrote:
> > From: Chris Strong <chris.strong@xxxxxxxxxxxxxxx>
> >
> > Under sustained receive traffic, the threaded interrupt handler can
> > continue draining the controller indefinitely. Received SKBs accumulate
> > in skb_irq_queue, but can_rx_offload_threaded_irq_finish() only splices
> > them into the NAPI-visible skb_queue when the handler finishes.
> >
> > The RX-offload overflow checks inspect skb_queue rather than
> > skb_irq_queue. If the handler does not return, the IRQ-local queue can
> > therefore grow without bound while NAPI remains unscheduled. This can
> > exhaust memory and prevent received frames from reaching the networking
> > stack.
> >
> > Add a small RX-offload predicate that reports when the IRQ-local queue
> > has reached the NAPI weight. Use it to stop the dedicated RX interrupt
> > loop, process TEF and the other pending interrupt sources, and then
> > publish the batch. Publish additional batches from the main interrupt
> > loop while the controller remains busy. Since one RX pass can enqueue a
> > complete hardware ring, this keeps each splice near the NAPI weight
> > rather than enforcing a strict limit.
> >
> > Keep this policy in mcp251xfd because its controller-draining loops are
> > the source of the unbounded handler. Accounting for skb_irq_queue in the
> > generic overflow check would cap memory use by dropping frames, but
> > would still leave NAPI unscheduled.
> >
> > Publishing smaller batches narrows the timestamp sorting window.
> > Ordering across batches is already best-effort; RX and TEF events from
> > each controller-status pass are processed before the batch is published.
> >
> > Fixes: c757096ea103 ("can: rx-offload: add skb queue for use during ISR")
> > Assisted-by: LLM
> > Signed-off-by: Chris Strong <chris.strong@xxxxxxxxxxxxxxx>
> > ---
> > Hi all,
> >
> > This is my first upstream Linux kernel patch submission, so feedback on both
> > the implementation and the submission format would be appreciated.
>
> You're using b4, this is a good choice and the best tool for this job.
>
> Please split the changes into 2 patches, first add the rx-offload
> helper, then the mcp251xfd changes.
>
> The changes look pretty good to me! Good Work!
>
> If you want to improve you can shorten the patch description. The
> subject already states what you do, the patch description should explain
> in more detail (if needed) and why. Finish with describing your changes
> in imperative mood. See [1] for details.
>
> [1] https://github.com/torvalds/linux/blob/master/Documentation/process/submitting-patches.rst#describe-your-changes
>
> regards,
> Marc
>
> --
> Pengutronix e.K. | Marc Kleine-Budde |
> Embedded Linux | https://www.pengutronix.de |
> Vertretung Nürnberg | Phone: +49-5121-206917-129 |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |



--
Chris Strong
Software Engineer III
flocksafety.com
chris.strong@xxxxxxxxxxxxxxx