Re: [PATCH v2] USB: HCD: Fix URB giveback issue in tasklet function

From: WeitaoWang-oc@xxxxxxxxxxx
Date: Tue Jul 26 2022 - 02:47:33 EST


On 2022/7/25 21:58, Alan Stern wrote:
On Mon, Jul 25, 2022 at 02:52:51PM +0800, Weitao Wang wrote:

This is basically okay. Just a couple of small comments...

Usb core introduce the mechanism of giveback of URB in tasklet context to
reduce hardware interrupt handling time. On some test situation(such as
FIO with 4KB block size), when tasklet callback function called to
giveback URB, interrupt handler add URB node to the bh->head list also.
If check bh->head list again after finish all URB giveback of local_list,
then it may introduce a "dynamic balance" between giveback URB and add URB
to bh->head list. This tasklet callback function may not exit for a long
time, which will cause other tasklet function calls to be delayed. Some
real-time applications(such as KB and Mouse) will see noticeable lag.

Fix this issue by taking new URBs giveback in next tasklet function call.
Add a member high_prio for structure giveback_urb_bh and replace the local
high_prio_bh variable with this structure member in usb_hcd_giveback_urb.

The patch description should do more than say what the new code _is_ --
we can see that easily enough by reading the patch. The description
should explain _why_ the code was changed.

Okay, I will improve this patch description.

- /* check if there are new URBs to giveback */
+ /* giveback new URBs next time to prevent this function from
+ * not exiting for a long time.
+ */

Minor stylistic issue: The currently accepted format for multi-line
comments is like this:

This notes will be improved in next patch version also.
Thanks for your suggestion.

weitao
/*
* Blah blah blah
* Blah blah blah
*/

Alan Stern
.