Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp850579pxk; Mon, 31 Aug 2020 02:57:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4koJavkHJkH61uUCL2DvmCKERFTNNYJSOvsPzeUo2sn0iii/OEuTNKLJh7g1n9ePJJJaL X-Received: by 2002:a17:906:c78f:: with SMTP id cw15mr384110ejb.330.1598867839558; Mon, 31 Aug 2020 02:57:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598867839; cv=none; d=google.com; s=arc-20160816; b=tAUL29FXqX+IiRG42ivKfjPBEiM6Ei++A3mcMk5nQIPvqokrEopTBTE70RO6t11WJg xyL4Bi2UOZCdKGjjtnzUGAALmXRztTS/4sjkAkE2gyoToq9NpLSp6yMAPhUPYbjF+fjQ BZNLL5WCoAAKsW9+5ivvjci7+XtSGAgbwKO5GPX12sjPeE9sJxmayegOWZ7yXG1Ggo8D Jsy3l+TgXUYoXYsgYTIr3n662ugku+zxJnrL/sjdopWWadkj3aThcjZekQ9Lvu7GoJ9l gA/ZlWXWW9nx1UFYgNGQSm3zKLZpIY6ye4YTOuPfNVl0lNIHQLGstV0li1lGH+07En0z gRiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=a3X7eIeP2lWsSyWpVP2przoD9fBpiscMjV4be2HyQUY=; b=Wc076FDPAa1LtaIkWu9CQfKaVnUtyOFVKoEoTnYmGl/h/LpAceTr6dO4A3uBI/LnvC +PWG7sK+yIFu7+1lRFRR/aRCR+wuHhDa4s326Xzk2IoIF3j7EcG+e1udFK24IE/K3r89 6S72wuiiyf6JaxcaE6Pcp77G4bmMIO9DxPHsWgwyWhT5CFcWH5C2AM3IwSJNYUJOMalL 28PSKCuoEyqWE6vnYorMXRlgsS7G5Ibjkx4JlCprWwrr68nCEtk3ueDL8aPuiYuDVeWE /5jz9/Z8fVU0A6PImJtItXZOzz/NKikvOamC/8cUZhbFoXaqWn3xJNkMDeZvSpNIOQCG CqUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cKvb8cb8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ox7si5226949ejb.423.2020.08.31.02.56.54; Mon, 31 Aug 2020 02:57:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cKvb8cb8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726572AbgHaJzH (ORCPT + 99 others); Mon, 31 Aug 2020 05:55:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:55054 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726253AbgHaJzF (ORCPT ); Mon, 31 Aug 2020 05:55:05 -0400 Received: from saruman (91-155-214-58.elisa-laajakaista.fi [91.155.214.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 356372098B; Mon, 31 Aug 2020 09:55:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598867704; bh=HT/dHnUDrMXwyD5q0jInxv9lB8IyvR2AIAngyUE4ihs=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=cKvb8cb8UjAzTAmanRgpW0ydgrUNNIScnsG4pOpTle6dEDHASTV2qlifBQDcLULSZ vvIVAUAQ3mRJ85ywB8acd9Q1/3WhCoxmaPIzl3rsEN9yJDSw9C4jd9hercXUv/wwNv I5r+gaMFlrQuWcuyVfRfkiDvKVGlUUm6LAsu19j0= From: Felipe Balbi To: Tao Ren Cc: Greg Kroah-Hartman , Joel Stanley , Andrew Jeffery , Benjamin Herrenschmidt , Chunfeng Yun , Stephen Boyd , linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, taoren@fb.com Subject: Re: [PATCH] usb: gadget: aspeed: fixup vhub port irq handling In-Reply-To: <20200817225603.GA21228@taoren-ubuntu-R90MNF91> References: <20200528011154.30355-1-rentao.bupt@gmail.com> <875z9hz8k3.fsf@kernel.org> <20200817225603.GA21228@taoren-ubuntu-R90MNF91> Date: Mon, 31 Aug 2020 12:54:57 +0300 Message-ID: <87y2lv9m32.fsf@kernel.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, Tao Ren writes: > On Mon, Aug 17, 2020 at 04:49:32PM +0300, Felipe Balbi wrote: >>=20 >> Hi, >>=20 >> rentao.bupt@gmail.com writes: >> > From: Tao Ren >> > >> > This is a follow-on patch for commit a23be4ed8f48 ("usb: gadget: aspee= d: >> > improve vhub port irq handling"): for_each_set_bit() is replaced with >> > simple for() loop because for() loop runs faster on ASPEED BMC. >> > >> > Signed-off-by: Tao Ren >> > --- >> > drivers/usb/gadget/udc/aspeed-vhub/core.c | 10 +++------- >> > drivers/usb/gadget/udc/aspeed-vhub/vhub.h | 3 +++ >> > 2 files changed, 6 insertions(+), 7 deletions(-) >> > >> > diff --git a/drivers/usb/gadget/udc/aspeed-vhub/core.c b/drivers/usb/g= adget/udc/aspeed-vhub/core.c >> > index cdf96911e4b1..be7bb64e3594 100644 >> > --- a/drivers/usb/gadget/udc/aspeed-vhub/core.c >> > +++ b/drivers/usb/gadget/udc/aspeed-vhub/core.c >> > @@ -135,13 +135,9 @@ static irqreturn_t ast_vhub_irq(int irq, void *da= ta) >> >=20=20 >> > /* Handle device interrupts */ >> > if (istat & vhub->port_irq_mask) { >> > - unsigned long bitmap =3D istat; >> > - int offset =3D VHUB_IRQ_DEV1_BIT; >> > - int size =3D VHUB_IRQ_DEV1_BIT + vhub->max_ports; >> > - >> > - for_each_set_bit_from(offset, &bitmap, size) { >> > - i =3D offset - VHUB_IRQ_DEV1_BIT; >> > - ast_vhub_dev_irq(&vhub->ports[i].dev); >> > + for (i =3D 0; i < vhub->max_ports; i++) { >> > + if (istat & VHUB_DEV_IRQ(i)) >> > + ast_vhub_dev_irq(&vhub->ports[i].dev); >>=20 >> how have you measured your statement above? for_each_set_bit() does >> exactly what you did. Unless your architecture has an instruction which >> helps finds the next set bit (like cls on ARM), which, then, makes it >> much faster. > > I did some testing and result shows for() loop runs faster than > for_each_set_bit() loop. Please refer to details below (discussion with > Benjamin in the original patch) and kindly let me know your suggestions. no strong feelings, just surprised that you're already worried about 20~40 cycles of cpu time ;-) Patch applied for next merge window =2D-=20 balbi --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJFBAEBCAAvFiEElLzh7wn96CXwjh2IzL64meEamQYFAl9MyPERHGJhbGJpQGtl cm5lbC5vcmcACgkQzL64meEamQbRNw//Ycg/zGDlByFwp5tnmnP1LkeCxblvsqjG n01I9rv8UAccFtJT/9QSYTtd6KOMvXM3dkMaX46ikxSPYPU3cZzQlMCqK4d40JJ4 YZxp/EnTM/Kt4V0R7tim2n1L7Nghyn1fY6crnN+R0PRYmFfrj3iEokFMIHhjnS8d PoDaT0aq3qH2uZRop0yN3mZmouAaTItfbXqxg42o13ZocuePy+M0bPeHPRXWZ9KQ aqL4vC9XZM7AXzeTVxn+53gnGzhFbCTmEiIdhfiBBffJT624hsfocIPUAxrj+kJj QyFUADnX5OHRElPzoiZyFKZlfAQUueQ6tC2I7/KFYuVu/tWT9/QE92aBOJ9Djomk 1+YCWr4MKz4RB313qyAw9zae77IpS2rQTbQwYts5iL3MTfpd1lwdTMX6TMJgReyG KBJ+amV5/Y74n5mxypnUXCQOTr3EqyHkr5ieYH6vkx9rzd3RylX6Qr1yGw839avx yIYcescxC9Wohlg8XAEs5ZCv+YsbapCzGlm7tq7m/eWHINbYIDOM+tpPkAfjzVmZ ZA5iNVntd+4punCL1Alpw+At/ZoJVMVHHdHDt73rfrZUIq8Xh20acsJCBh0xeQAE D6nte7wBz1h55Yz7NkWmNDaH9A0uUzYYnVeWRmZlt2RoNgkcx0w1OPXSJYtlInVi K+VeRcQfwJ0= =rGY9 -----END PGP SIGNATURE----- --=-=-=--