From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Jakub Kicinski" <kuba@kernel.org>,
"Ömer Mete Kaya" <omermetekaya0@gmail.com>,
oneukum@suse.com, netdev@vger.kernel.org, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, pabeni@redhat.com,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
david.laight.linux@gmail.com,
syzbot+04cd90bb99c6ef81a65d@syzkaller.appspotmail.com
Subject: Re: [PATCH net v6] usbnet: fix smp_processor_id() use in preemptible context
Date: Mon, 12 Oct 2026 23:25:27 +0200 [thread overview]
Message-ID: <20261012212527.5sFqlGYu@linutronix.de> (raw)
In-Reply-To: <8545800a-a37f-482a-9b06-cbdd70312b7a@rowland.harvard.edu>
On 2026-10-12 16:26:28 [-0400], Alan Stern wrote:
> On Mon, Oct 12, 2026 at 09:49:02PM +0200, Sebastian Andrzej Siewior wrote:
> > On 2026-10-09 13:31:17 [+0200], Greg Kroah-Hartman wrote:
> > > > As far as I am aware, there aren't really any guarantees on the
> > > > context of a USB URB-completion callback. The kerneldoc for struct urb
> > > > in include/linux/usb.h says "The completion callback is made
> > > > in_interrupt()", but that is most definitely out of date.
> > >
> > > I don't think so, I think some platforms still have those callbacks in
> > > irq context, unless we changed to threaded irq handlers everywhere? I
> > > could have missed that, but we should still write the callbacks to
> > > assume that and then we should be fine even if we aren't in irq context,
> > > right?
> >
> > The HCD invokes the completion callback usually in IRQ context. I think
> > the VHCI is an exception here.
> > For the forced-threaded mode we disable BH before the IRQ handler is
> > invoked. I think even dummy_hcd invokes them from the timer if my memory
> > is right.
> >
> > > > Drivers shouldn't rely on any particular context guarantees. Not even
> > > > whether local irqs are enabled/disabled.
> > >
> > > Agreed.
> >
> > I would suggest to make VHCI invoke the completion callback with BH
> > disabled. usbnet's tx_complete() does also defer_bh() which schedules a
> > BH worker via queue_work(). While this works without disabling BH it
> > leads to waking ksoftirqd and an additional context switch which we
> > could avoid by dealing with it directly.
>
> Today you fix VHCI, tomorrow some other virtual HCD will cause problems.
We don't have other virtual HCDs, do we?
The other driver is drivers/net/mctp/mctp-usb.c.
mctp_usb_out_complete() -> … -> mctp_usblib_tx_stats_update() does
get_cpu_ptr() for stats. But mctp_usb_in_complete() has
mctp_usblib_rx_complete() -> mctp_usblib_rx_stats_single_drop() and
mctp_usblib_rx() which do just this_cpu_ptr(). Plus the queue wakes &
netif_rx() which wake ksoftirqd.
That makes two drivers from a quick grep. But I guess it is just
networking for the per-CPU stats.
> Should we document any requirements that all HCDs will have to follow
> and that all completion handlers can rely on?
It used to complete in IRQ context. Then you added the possibility to
complete BH for those HCDs marked as such (except for the RH). I think
it was always reasonable to assume that it is either IRQ-context
(force-threaded or not for !HCD_BH) or BH (for HCD_BH). It makes hardly
a difference, BH is always off and networking uses to rely on it.
So yes, documenting would make sense.
Do you want to document it yourself and have me do the VHCI bits?
> Alan Stern
Sebastian
next prev parent reply other threads:[~2026-10-12 21:25 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-04 21:59 Ömer Mete Kaya
2026-10-08 3:00 ` Jakub Kicinski
2026-10-08 14:16 ` Alan Stern
2026-10-08 16:43 ` Jakub Kicinski
2026-10-08 18:03 ` Alan Stern
2026-10-09 11:31 ` Greg Kroah-Hartman
2026-10-12 19:49 ` Sebastian Andrzej Siewior
2026-10-12 20:26 ` Alan Stern
2026-10-12 21:25 ` Sebastian Andrzej Siewior [this message]
2026-10-13 2:09 ` Alan Stern
2026-10-13 9:11 ` Paolo Abeni
2026-10-13 9:22 ` Sebastian Andrzej Siewior
2026-10-13 8:54 ` Oliver Neukum
2026-10-13 9:20 ` Sebastian Andrzej Siewior
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=20261012212527.5sFqlGYu@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=david.laight.linux@gmail.com \
--cc=edumazet@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=omermetekaya0@gmail.com \
--cc=oneukum@suse.com \
--cc=pabeni@redhat.com \
--cc=stern@rowland.harvard.edu \
--cc=syzbot+04cd90bb99c6ef81a65d@syzkaller.appspotmail.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
all inboxes | Powered by JetHome®