USB performance bug since kernel 2.6.13 (CRITICAL???)
Hi Wolfgang (and all),
Thanks for the input. However, I am not understanding exactly why kernel mode is treated any differently than user mode for this sort of thing. I am looking at the code in ehci-q.c and ehci-hcd.c.
It seems like the unlinking of completed URBs happens asynchronously on a timer. This is a surprise to me since I thought this was happening on an IRQ from the host controller. But if what I'm surmising is correct it would explain everything I am seeing. I'm not able to ascertain how user mode drivers are treated differently than kernel mode drivers in this regard. From what I can tell, all drivers would be broken equally! Can anyone who has more experience
with this code confirm this for me?
Besides, we count on sub-10 ms response times all the time in user mode. Take for example, the access of a file. If opening a file had a fixed latency of 4 ms, people would be up in arms. So that's not entirely a valid excuse. A USB operation that used to take 1 ms now takes 4 ms. That's a pretty big change.
The ability to write user-mode drivers for USB devices is very powerful for deployment. If one writes a kernel driver, there are severe deployment hassles. As such, my company has chosen to write user-mode drivers on both Windows to avoid driver deployment nightmares. This has been extremely successful so far.. Ironically, Windows (using libusb-win32) has had no such performance glitches. As a matter of principle, Linux should at least be as good as Windows, right?
Hopefully we can get this sorted out.
Cheers.
----- Original Message ----
From: WolfgangMües <[email protected]>
To: [email protected]
Sent: Friday, October 13, 2006 12:11:08 PM
Subject: Re: [linux-usb-devel] USB performance bug since kernel 2.6.13 (CRITICAL???)
Quoted 9 lines · Open Source
Alan -- yes, I understand the ability to increase throughput by transfering more bytes and I am definitely able to see better overall throughput when increasing the number of bytes per transaction. However, I needs to still have good transaction-level timing because I cannot always queue the transactions up. Recall that each transaction is a WRITE followed by a READ. The results of the READ determine the outgoing bytes for the following transaction's WRITE.
Relying on sub-10ms response times in userspace is broken by design.
I have written a driver with similar timing requirements, and I have done it in the kernel. This is the right way to go. Nothing else.
regards
Wolfgang
Signature · 12 lines
Das Leben kann nur rückwärts verstanden, muß aber vorwärts gelebt werden. ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ [email protected] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Quoted 7 lines · Open Source
Hi Wolfgang (and all),
Thanks for the input. However, I am not understanding exactly why kernel mode is treated any differently than user mode for this sort of thing. I am looking at the code in
ehci-q.candehci-hcd.c.
Quoted 11 lines
It seems like the unlinking of completed URBs happens asynchronously on a timer. This is a surprise to me since I thought this was happening on an IRQ from the host controller. But if what I'm surmising is correct it would explain everything I am seeing. I'm not able to ascertain how user mode drivers are treated differently than kernel mode drivers in this regard. From what I can tell, all drivers would be broken equally! Can anyone who has more experience
with this code confirm this for me?
I don't think so. You must be mis-reading the code. The only timers used in ehci-hcd are a couple of watchdogs; they shouldn't affect the normal URB completions which occur within ehci_work(), called by ehci_irq().
What Wolfgang meant was that user processes are subject to unpredictable delays from all kinds of sources.
Alan Stern
Quoted 7 lines · Open Source
It seems like the unlinking of completed URBs happens asynchronously on a timer. This is a surprise to me since I thought this was happening on an IRQ from the host controller. But if what I'm surmising is correct it would explain everything I am seeing.
You didn't say what EHCI controller you're using.
The original reason for that timer was specifically to handle bugs in VIA silicon: that won't always issue all of the IRQs it's supposed to. Specifically the IAA IRQ would never arrive, leading to unlink operations wedging.
Later on that timer got overloaded (and hence it got to be a bit of a mess) with two other tasks:
(a) deducing that an endpoint had been idle long enough to take off the ring of active control/bulk queues, which is what ensures that an idle controller isn't wasting memory bandwidth by doing DMA all the time.
(It turns out to be a Bad Idea to take idle endpoints off that ring the instant they become idle, since they will as a rule be reused very quickly ... so immediate removal slows things down a lot. Plus it chases an annoying number of races between driver and controller.)
(b) being a general I/O watchdog, since there were some other (rare) cases where IRQs would appear to get lost
In short, except for (a) the only reason I know of that changing HZ should affect system performance is IRQ lossage ... of which the primary reason has always been strange behavior from VIA controllers.
- Dave