Received: by 2002:a05:6830:16d2:b0:61c:ac69:ca1b with SMTP id l18csp2105446otr; Mon, 25 Jul 2022 07:26:14 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u/s8uVtg+OGnfM9VpPW0qjpmG24eiuuEVDb5twIYRBbSVrFm29Aa9WoFNO4SBxt7rm6deQ X-Received: by 2002:a17:907:9693:b0:72f:9cc:63d7 with SMTP id hd19-20020a170907969300b0072f09cc63d7mr10517114ejc.661.1658759174168; Mon, 25 Jul 2022 07:26:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658759174; cv=none; d=google.com; s=arc-20160816; b=Fm9ujVfc6ahKScL6m8fDb2W0bAIQcqIC7HGCUK0UNkth9Wwg7FVzAdwvRTbUCtCn0/ YVJVgK557sLbrEX4pbNBL9ypOmu8P/eobW+PGo7GOLQ6XF7/ey+/feeuo9BiXH0zUuGW f1lKa+FOF3hwFN9VRj6YQUh8QB44slO/CQP1ZG64bAyCQMzdykIQrvLOk6UfqKjOBm2A QRP88e7bOn1vZEaeEH/+1/fDhhVHGxNqsRyWe1EPDi8Rd0mbIecPvxoUDnrujg2MkDb+ oqH2vMu+Qsy8Yh0qlLrAmYlWUmSlixR+HzygADBxdpvoZG1o2OWLlOQVMMYDrGTM/VSN 4Ggg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=0LDnPH8s93+quncfeE5L9aNSFmrL7AIzEpGT7930jGU=; b=tGHbR/91Y+cYgegUgLVIdFvBeMZmXfjvoCs9KxDRwfe37ZNO3dKifuWfQfdbtCBc2Y u0IJoixdBwT2jhyHRVY9dy/8ieVBuMTlHnvNUTrxLITlV4tzDHL9I0MU4rmIBF7LEt1J JQ+NdGhgNrahljWQZOtOUo0BgJU6bjTYmwE2NeKNqkdAZ7pQdzg5Ssx4yMEh+scydbav fw8SJtWwrQGLWpWBXKs1wJv9zsPoUhxjy1ZTFtUnPRBQ1FkPUnEwFV5cx87wfw+expsT DJ4bOkuMZYfDrU3chX4qgRk6jdnmmXxINaeSCYox9mOQd/HoTD3Sb6EAvywv+psGVzCy qIZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id he30-20020a1709073d9e00b00711c6a5c5e6si7504052ejc.545.2022.07.25.07.25.48; Mon, 25 Jul 2022 07:26:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235175AbiGYN6L (ORCPT + 99 others); Mon, 25 Jul 2022 09:58:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234594AbiGYN6I (ORCPT ); Mon, 25 Jul 2022 09:58:08 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id EB83312D32 for ; Mon, 25 Jul 2022 06:58:02 -0700 (PDT) Received: (qmail 351518 invoked by uid 1000); 25 Jul 2022 09:58:01 -0400 Date: Mon, 25 Jul 2022 09:58:01 -0400 From: Alan Stern To: Weitao Wang Cc: gregkh@linuxfoundation.org, kishon@ti.com, dianders@chromium.org, s.shtylyov@omp.ru, mka@chromium.org, ming.lei@canonical.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, tonywwang@zhaoxin.com, weitaowang@zhaoxin.com Subject: Re: [PATCH v2] USB: HCD: Fix URB giveback issue in tasklet function Message-ID: References: <20220725065251.832087-1-WeitaoWang-oc@zhaoxin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220725065251.832087-1-WeitaoWang-oc@zhaoxin.com> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > Fixes: 94dfd7edfd5c ("USB: HCD: support giveback of URB in tasklet context") > Signed-off-by: Weitao Wang > --- > v1->v2: > - Fix compile warning by remove label "restart". > - Modify the patch description info. > - Change structure member from hi_priority to high_prio. > > drivers/usb/core/hcd.c | 25 ++++++++++++++----------- > include/linux/usb/hcd.h | 1 + > 2 files changed, 15 insertions(+), 11 deletions(-) > > diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c > index 06eea8848ccc..1feb9a604380 100644 > --- a/drivers/usb/core/hcd.c > +++ b/drivers/usb/core/hcd.c > @@ -1691,7 +1691,6 @@ static void usb_giveback_urb_bh(struct tasklet_struct *t) > > spin_lock_irq(&bh->lock); > bh->running = true; > - restart: > list_replace_init(&bh->head, &local_list); > spin_unlock_irq(&bh->lock); > > @@ -1705,10 +1704,16 @@ static void usb_giveback_urb_bh(struct tasklet_struct *t) > bh->completing_ep = NULL; > } > > - /* 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: /* * Blah blah blah * Blah blah blah */ Alan Stern