From: Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: Vincent Mailhol <mailhol@kernel.org>,
Nicolas Ferre <nicolas.ferre@microchip.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Claudiu Beznea <claudiu.beznea@tuxon.dev>,
Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>,
linux-can@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, imx@lists.linux.dev,
NXP S32 Linux Team <s32@nxp.com>
Subject: Re: [PATCH v5 0/3] can_rx_offload keeps a lockless irq_queue that the IRQ handlers fill and that is later spliced under skb_queue.lock into the NAPI-facing skb_queue. This works as long as a single context fills the irq_queue. flexcan with FLEXCAN_QUIRK_SECONDARY_MB_IRQ and mcf5441x use two mailbox IRQ lines. When those are affined to different CPUs the two handlers can enqueue into the same list at the same time and corrupt it.
Date: Mon, 7 Sep 2026 18:07:42 +0300 [thread overview]
Message-ID: <6bdc8044-34de-4d7a-89a5-908de7f8b044@oss.nxp.com> (raw)
In-Reply-To: <20260907-lively-easygoing-groundhog-51cdd3-mkl@pengutronix.de>
On 9/7/2026 4:49 PM, Marc Kleine-Budde wrote:
> On 07.09.2026 12:49:39, Ciprian Costea wrote:
>> From: Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com>
>>
>> This series:
>> 1. Makes the irq_queue per-CPU so the handlers no longer share a list.
>
> As sashiko pointed out, using per-CPU variables in a preemptible context
> doesn't work. When proposing to use per-CPU variables I haven't thought
> that far. So in hindsight this approach is not good.
>
> What about following what NAPI does. Have a dedicated data structure per
> IRQ. I think these ones are needed:
>
> | struct sk_buff_head skb_irq_queue;
> | u32 skb_queue_len_max;
> |
> | unsigned int mb_first;
> | unsigned int mb_last;
>
> And pass them to can_rx_offload_queue_timestamp() and
> can_rx_offload_irq_finish().
>
> regards,
> Marc
>
Hello Marc,
Thanks for replying.
Indeed the per-CPU approach should be dropped. I've also missed the
PREEMPT_RT case.
Your proposal seems better than even having a dedicated spinlock for
skb_irq_queue operations as I've originally thought.
One thing to confirm before I go ahead and implement this approach for
V6: Having the following connected patchset in mind [1] which separates
the IRQ handlers, both flexcan MB IRQs currently run flexcan_do_mb()
over the full iflag. Therefore, to actually separate the producers I'll
have each IRQ drain only its own mb_first..mb_last range into its own
queue - is this the right approach ?
[1]
https://lore.kernel.org/all/20260831143449.12828-1-ciprianmarian.costea@oss.nxp.com/T/#t
Regards,
Ciprian
next prev parent reply other threads:[~2026-09-07 15:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 10:49 [PATCH v5 0/3] can_rx_offload keeps a lockless irq_queue that the IRQ handlers fill and that is later spliced under skb_queue.lock into the NAPI-facing skb_queue. This works as long as a single context fills the irq_queue. flexcan with FLEXCAN_QUIRK_SECONDARY_MB_IRQ and mcf5441x use two mailbox IRQ lines. When those are affined to different CPUs the two handlers can enqueue into the same list at the same time and corrupt it Ciprian Costea
2026-09-07 10:49 ` [PATCH v5 1/3] can: rx-offload: make skb_irq_queue per-CPU Ciprian Costea
2026-09-07 10:49 ` [PATCH v5 2/3] can: at91_can: fix rx-offload cleanup on unbind and probe errors Ciprian Costea
2026-09-07 10:49 ` [PATCH v5 3/3] can: gs_usb: check can_rx_offload_add_manual() return value Ciprian Costea
2026-09-07 13:49 ` [PATCH v5 0/3] can_rx_offload keeps a lockless irq_queue that the IRQ handlers fill and that is later spliced under skb_queue.lock into the NAPI-facing skb_queue. This works as long as a single context fills the irq_queue. flexcan with FLEXCAN_QUIRK_SECONDARY_MB_IRQ and mcf5441x use two mailbox IRQ lines. When those are affined to different CPUs the two handlers can enqueue into the same list at the same time and corrupt it Marc Kleine-Budde
2026-09-07 15:07 ` Ciprian Marian Costea [this message]
2026-09-08 8:58 ` Marc Kleine-Budde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6bdc8044-34de-4d7a-89a5-908de7f8b044@oss.nxp.com \
--to=ciprianmarian.costea@oss.nxp.com \
--cc=alexandre.belloni@bootlin.com \
--cc=claudiu.beznea@tuxon.dev \
--cc=dev.kurt@vandijck-laurijssen.be \
--cc=imx@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
--cc=nicolas.ferre@microchip.com \
--cc=s32@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox