On Thu, 14 Apr 2016, Matthew Giassa wrote: > Replying in-line: > > > > You are correct: the software claims and releases certain interfaces > > > frequently. > > > > How frequently? The usbmon log you attached to the Bugzilla report > > shows it happening at intervals of approximately 20-40 ms (sometimes > > longer) -- and often with no messages sent in between. Does that seem > > at all reasonable? > That polling interval you describe is the extreme case, but its not that > uncommon. It just depends what "metrics" are enabled by the "gathering" > thread. The case of no messages being passed does not seem reasonable. > Data is expected to be transferred between each claim/release. You should track that down; it sounds like a bug in your program. > > Have you tried, just for the sake of testing, getting rid of all those > > claims and releases? Simply claim both interfaces once, at the start > > of the program, and release them at the end. > I do a long-term claim/release on the bulk interface already. I could > try for the sake of testing, but I would not be allowed to claim the > "control" interface for the duration of a streaming session, as that > would break an existing product feature. It would be worthwhile to test this, so you could verify that the constant claiming and releasing really is responsible for the poor performance. > Is the frequent claim/release of interfaces bad behavior in general? > It's to my understanding I should always claim an interface before use, > otherwise I get error log entries in `dmesg'. If you don't claim an interface before using it, either the attempt to use it will fail (if it is claimed by another process or driver) or else the system will claim it for you. So not claiming an interface before using it won't solve anything. > One other person who commented earlier, Oliver Neukum, noted this might > be a useful debug feature (disable LPM). It's a heavy hammer to throw at > the problem, but it does get the job done. Is the primary concern > against it mainly to prevent an excessive number of boot parameters > growing with time? That's one objection. Another is that the feature is too broad; it shouldn't be necessary to disable LPM for all devices in order to solve a problem with just one. A third objection is that it's a bad idea in general to take a debugging feature and make it a prerequisite for using your program -- debugging features should be used for debugging only. Besides, disabling LPM may not be the best solution for your problem. It's like treating a symptom instead treating the underlying cause. LPM in itself isn't bad; the problem is that it's getting turned on and off all the time and thereby causing delays. > This is a sincere question, and not an attempt at being snide, but from > a userspace perspective, should the frequency of claiming/releasing an > interface really matter? There's nothing in the libusb documentation > advising against it, and the docs also state it must be used before > performing I/O: > > *You must claim the interface you wish to use before you can perform > I/O on any of its endpoints. > *Claiming of interfaces is a purely logical operation; it does not > cause any requests to be sent over the bus. Interface claiming is used > to instruct the underlying operating system that your application wishes > to take ownership of the interface. > > I realize it's not ideal to have to claim/release so rapidly, but it's > not invoking undefined behavior. On the other hand, the documentation also doesn't say anything about how long it takes to claim or release an interface. If it takes 30 ms and you try to do it periodically at intervals of 40 ms, you won't have time for much else. The presumption in libusb is that claiming and releasing are infrequent activities. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html