From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39887C47095 for ; Wed, 9 Jun 2021 08:28:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0DC9A6136D for ; Wed, 9 Jun 2021 08:28:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237165AbhFII34 (ORCPT ); Wed, 9 Jun 2021 04:29:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:36388 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232333AbhFII3z (ORCPT ); Wed, 9 Jun 2021 04:29:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 607E361042; Wed, 9 Jun 2021 08:27:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623227270; bh=mU+6m94m+AMm1pYeUgG2BY0KQAanw0ZzBPDVxTz7XZI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pZusCf0w/HrLmNN2pNl9z96u4oMNQMAWgpv8CDmoSg7bWj1qA6RjNrkjk/st4Hu+a RLXVhRf1KQfbuY3zwoMflCyQmESfEyaMVzx7/DIjjTfN21lGn9XefcGJuRNCzg5Tkq bnpXO/RqRbJZyZeWop4NCmHsFi73wn+vRvl+C+hA= Date: Wed, 9 Jun 2021 10:27:48 +0200 From: Greg Kroah-Hartman To: Maciej =?utf-8?Q?=C5=BBenczykowski?= Cc: Maciej =?utf-8?Q?=C5=BBenczykowski?= , Linux USB Mailing List , Brooke Basile , Bryan O'Donoghue , Felipe Balbi , Lorenzo Colitti Subject: Re: [PATCH] usb: f_ncm: only first packet of aggregate needs to start timer Message-ID: References: <20210608085438.813960-1-zenczykowski@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210608085438.813960-1-zenczykowski@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org On Tue, Jun 08, 2021 at 01:54:38AM -0700, Maciej Żenczykowski wrote: > From: Maciej Żenczykowski > > The reasoning for this change is that if we already had > a packet pending, then we also already had a pending timer, > and as such there is no need to reschedule it. > > This also prevents packets getting delayed 60 ms worst case > under a tiny packet every 290us transmit load, by keeping the > timeout always relative to the first queued up packet. > (300us delay * 16KB max aggregation / 80 byte packet =~ 60 ms) > > As such the first packet is now at most delayed by 300us. > > Under low transmit load, this will simply result in us sending > a shorter aggregate, as originally intended. > > This patch has the benefit of greatly reducing (by ~10 factor > with 1500 byte frames aggregated into 16 kiB) the number of > (potentially pretty costly) updates to the hrtimer. > > Cc: Brooke Basile > Cc: Bryan O'Donoghue > Cc: Felipe Balbi > Cc: Greg Kroah-Hartman > Cc: Lorenzo Colitti > Signed-off-by: Maciej Żenczykowski > --- > drivers/usb/gadget/function/f_ncm.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c > index 0d23c6c11a13..855127249f24 100644 > --- a/drivers/usb/gadget/function/f_ncm.c > +++ b/drivers/usb/gadget/function/f_ncm.c > @@ -1101,11 +1101,11 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port, > ncm->ndp_dgram_count = 1; > > /* Note: we skip opts->next_ndp_index */ > - } > > - /* Delay the timer. */ > - hrtimer_start(&ncm->task_timer, TX_TIMEOUT_NSECS, > - HRTIMER_MODE_REL_SOFT); > + /* Start the timer. */ > + hrtimer_start(&ncm->task_timer, TX_TIMEOUT_NSECS, > + HRTIMER_MODE_REL_SOFT); > + } > > /* Add the datagram position entries */ > ntb_ndp = skb_put_zero(ncm->skb_tx_ndp, dgram_idx_len); Nice, hopefully this helps out a lot on the systems where re-arming timers are slow. greg k-h