From: Joe Finzel <joe@sudmix.de>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Alan Stern <stern@rowland.harvard.edu>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] usb: core: sysfs: show product, manufacturer and serial without the device lock
Date: Sat, 5 Dec 2026 12:34:00 +0100 [thread overview]
Message-ID: <233bbbd1-a5ed-4737-89e1-6d69b210c0a0@sudmix.de> (raw)
In-Reply-To: <2026120355-dropkick-owl-c480@gregkh>
On Thu, Dec 03, 2026 at 07:06:11PM +0100, Greg Kroah-Hartman wrote:
> On Wed, Oct 14, 2026 at 11:01:51PM +0200, Joe Finzel via B4 Relay wrote:
> > is done -- seconds on a hub with several devices.
>
> "seconds"? USB isn't that slow.
Not per device, but it adds up because hub_event() keeps the hub locked
for the whole port loop. This is the root hub of the Z790 board from the
commit message, real hardware, 7.3.6:
[2.419] usb 1-2: new high-speed USB device number 2 using xhci_hcd
[4.295] hid-generic 0003:0B05:1A52.0001: ... [Generic USB Audio]
[4.408] usb 1-3: new full-speed USB device number 3 using xhci_hcd
[4.704] usb 1-4: new full-speed USB device number 4 using xhci_hcd
[4.950] usb 1-10: new high-speed USB device number 5 using xhci_hcd
[5.194] usb 1-11: new high-speed USB device number 6 using xhci_hcd
[5.600] usb 1-13: new high-speed USB device number 8 using xhci_hcd
[6.009] usb 1-14: new full-speed USB device number 10 using xhci_hcd
Most of it is the on-board audio device on port 2, which takes 1.9 s from
getting its address to its HID interface being bound (I haven't looked
into why yet); the other ports take 0.1-0.3 s each.
systemd stops udevd at 4.14 s and it exits at 6.15 s. In the last 40
boots of this machine the stop took 1.6-2.3 s, and every time it ended
141-152 ms after the "usb 1-14: new" line, so udevd waits for the root
hub's port loop to finish.
> qemu is "fake", so it can't provide real numbers, sorry. Use real
> hardware for testing this type of thing.
Fair enough. The numbers above are from the real machine; I only used
QEMU to show the effect of the patch reproducibly. I can run the same
board with the patch applied and send before/after numbers from it.
> They can still change.
The device can change them, but the kernel reads them only once:
usb_enumerate_device() sets udev->product, ->manufacturer and ->serial,
and nothing writes them again until usb_release_dev() frees them. If a
device comes back from a reset with different descriptors,
usb_reset_and_verify_device() re-enumerates it as a new device.
> What happens if the device goes away when this is called?
device_del() removes the attribute, and kernfs waits for any show() that
is already running (kernfs_drain()). The strings are only freed in
usb_release_dev(), after that.
> How is usb_lock_device() so slow? Is it because you are racing and
> trying to read the same device all at once and grabbing the lock and
> hitting the sleep in usb_lock_device() somehow? Why not turn that value
> down if that's the real issue?
There is no sleep in it, usb_lock_device() is device_lock(). It only
waits because hub_event() holds the same lock while it enumerates every
port, as above.
If you still prefer to keep the lock, I can drop the patch.
thanks,
Joe
prev parent reply other threads:[~2026-12-05 11:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 21:01 Joe Finzel via B4 Relay
2026-12-03 18:06 ` Greg Kroah-Hartman
2026-12-05 11:34 ` Joe Finzel [this message]
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=233bbbd1-a5ed-4737-89e1-6d69b210c0a0@sudmix.de \
--to=joe@sudmix.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/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®