Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp849823pxk; Mon, 31 Aug 2020 02:55:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyW1gHkKIyWYeO5SFblqkZLXFyYbJ0By+fX4ILk+fjWKoW436t4w8E5UgFlzaGkHsGaqR8 X-Received: by 2002:aa7:cb45:: with SMTP id w5mr425149edt.77.1598867724687; Mon, 31 Aug 2020 02:55:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598867724; cv=none; d=google.com; s=arc-20160816; b=e4voZnp/I+zVDWeVKa1YBAUWvmbmUlqr8hluAZQbE6YM1ENEaNj5NbkCaxBQ1A/zZQ O22AjlN4NAmKoHmH6nSEsnePxa4ymXFxmoa/VOgbqdtUr+5Mgu0Px4bCnRUNfaR9pfZ5 k5O5c71gi2i7Yn3i2kcu9iSF0esuYtiLM5/8JqNYgAK44gQeX6vkk37ikE53YjEgkL7k yAJPQNsYrvgiR4G9MufKy4mTVdj5M+2jHuV//DmqdVAiLZL7JbjPTzYxvuX5M6qjezh/ GMh6YVWWjazw2QBpEpqtwh0PMjOtN9WhQ4uMuPVK6aJSazk46a686z5pu/nU6iAOR61D M+QQ== 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=NDI/wJhjYMeZ/La0tVEImq3Ar4g8wVsotQ/CDS5A/hA=; b=SRIehTh12GvTDOkYewUa5QaVTVKYyncE4kWdn1EU2zyO8r90UgUR3AJUO/Yc+xKFTN augq6I/uKVwT68rAmwH7lqYfQ4X6EL3r8OJbD4S7J3xeM+eZ0hiJHc0HrufO+/8cNZrF ZXFah+lz7Ju8HJKLi9M2ypvRcUo9WPyZuRu4yaLzfrfRay90tFr19PejqBP4CHrWmt9m xg60STR7PwB/U0ccGWQKTd7B4yFJD0l53arYMvQdi5/v/2iV5ve7P//gzv8BOKMAR5xi lf9RLEEqavVi9cmBPAXO+M8yedgO8OBvJlyTsCLvklQFPEjvnDstNcpIl/C2ZFrKAXDG h3YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vJO2ySKK; 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 q2si5028038edj.526.2020.08.31.02.55.01; Mon, 31 Aug 2020 02:55:24 -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=vJO2ySKK; 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 S1726312AbgHaJyY (ORCPT + 99 others); Mon, 31 Aug 2020 05:54:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:53948 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725964AbgHaJyT (ORCPT ); Mon, 31 Aug 2020 05:54:19 -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 6BF2A20EDD; Mon, 31 Aug 2020 09:54:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598867659; bh=05SB4QyhMRQEVhQuA76tAzTplfJxOwcQAfl8qdw+ScA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=vJO2ySKK2PRG4joUm75ogezdndbhgzjUDQ745LoRUyXOLGew7GRZ770bVHmzV4m5f 9WEBzxLHjfBpHSLBd2E3hXVsXcEu57+pv9z7rj2/Irudt8TkfV9TzoGt3JH6Oxxi6I trdvhQOhTGEnlh0iqxSOXRgs6gjhWLE4j01xCGeA= 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:10 +0300 Message-ID: <87zh6b9m4d.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----- iQJFBAEBCAAvFiEElLzh7wn96CXwjh2IzL64meEamQYFAl9MyMIRHGJhbGJpQGtl cm5lbC5vcmcACgkQzL64meEamQaifA//Si7r2rDSXtDMDrTep0yeVpCJA9vk3Ajp K1rz3FtJaOInbRADPFu4rEKMCiz2bYBB/kT+iiFDUzpw3AOiQvjxyXbS4IqETV5p +yxIaRE8Hr4dYGobRps9aykJfpMO4fZhSVfm99DLPXyFlmVBhE3AO9iz2bn1yC/X lq5ObwFqNnWya7yX7xOXLez4hM5waO621Fj45bWyXQFbO5Q+BaF5Tu+B0y0OptK0 7dhNBFDe8xXTLjlvgsATtByfcYYi5Ip83xNfOLev4gH49alc6QGmcIjeVR5fLaPb YPJjsKi+NB1PsRHc1eKjKlKWiIVunvZ8zxnTKGec+PWsAF0dgOC8ARb3IMJhYxbD bIRcK2qvmkrWa24KiMUIwguHyWRkVm2Wmd14rBTg2Q2REJThn/lTr/O+hxai7ZBL V55vc/6E2l/ZMxDwNi8tvlxE6gu3qxYJeY07bFTXqXf4RiNPyT1vIpdzcSQzN4ZR gjMSjNNXdTpvLLXfHYt1o29oBl1IhrvP4TzTPzPvxj3afMrgm8O9roOpeK9F7nCN 8Hp4PkQUE7PTwens37vC+sGCYXJUDAp5FU9Enzdansz0+QBCvRnJslNQq73P9vQB HR6/1JvhJzQRr9K6YHY5xzo9HZtp+QqKtzZZV27M1dZr+w6/g83knFJUuDdwm0zx jeRhoV3yH28= =5dAd -----END PGP SIGNATURE----- --=-=-=--