Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp850743pxk; Mon, 31 Aug 2020 02:57:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdFIy0gqrAyM/ykOW4vmx6oXPrteyJCdzkuWyglNcKqzjuWA4koJeY5Fp1Gtg4oDaWFaZ8 X-Received: by 2002:a05:6402:6c1:: with SMTP id n1mr439233edy.215.1598867860726; Mon, 31 Aug 2020 02:57:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598867860; cv=none; d=google.com; s=arc-20160816; b=BmwAtbMr5E4SUZHb4BP2HPngepddvzUCPFaovSUo8DRSTdh5LgW8u7TDmDeHxjLukt dFB/JL9xTBZ4QfireTL/F+iEGj1Bx8Ds8KuUomE/qA+I24ZRQZOpPthbpLBECVRhf+8w qb+iXGkcVlOd9akv7ncv88kyw4MWKioCO6KnRJ4xz0uhpkriFBK7JvZ2wgIyjAtY8pP4 z0hhVMx28L53nAMtlkBEJbnqMAYkITBjjOdhp3dIjYULgdQcuBG2NmoTrjdhs4pjKaZZ a33+lo9+ahPEj/OQkHYPiAWIDIf3e1+8s0dovEpQrKHsUqZGNyT03MVRFAkh1bnhh9kH yW3A== 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=qr8Wi/8NgU/36Jz2nraZJmzftgjMFOuircbFbS8vuRY=; b=brQOh7VXeUSpNI9lh1G4YgmiSEf+C/h3GIvhLtfrr+qbV7P2Pumz1j+ek5lwKEZvo9 QtCHgMwGF+WB3ILiPXu4epw5FFzAMsCdDvJm9C4KB4eLpZs/n2U2ZNxQWqucfndtHNSN ZZc4jTEhs64BNY3UDCPs+ebP2An81EgNQgAaurfImbXtz54HeMQJP5JzLu4WYipQ7ICI 4nJm6vS5Q7SL13rtgrOXj4zEULTv49dS2l6zqTxu+AL71E29VLNGxEtiNRzYcDbMZZ2i mPjfWfFnj+qjOtinn+d2ySjxkWg0pSRFoPse3hbG5Q5D+QKiqOQO8SDyJQb6DdXhvkmS emKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CTTm1Xp+; 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 ec14si5321195ejb.320.2020.08.31.02.57.17; Mon, 31 Aug 2020 02:57:40 -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=CTTm1Xp+; 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 S1726479AbgHaJ43 (ORCPT + 99 others); Mon, 31 Aug 2020 05:56:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:57356 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726048AbgHaJ41 (ORCPT ); Mon, 31 Aug 2020 05:56:27 -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 E5364206EB; Mon, 31 Aug 2020 09:56:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598867786; bh=8yMQdTXBY8cQmkVCJWjYQCGKmduWY33EwADjjgbXbOQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=CTTm1Xp+6eu4sCExbS33lyjWCv+M/eiOMviMXp+imXmEFzv2VNI/Zdl4DNv3bbYGF uCUHOli/ug/kc9Q2Bfm+GfqvZkR1qPFrNqzaJsMx3jHHGhtKNUYilEGQjYWwkcSCKq hbh3JgtkfSvzEbjaABhH9M2sXnEw1F66PuQnxz3U= 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:56:22 +0300 Message-ID: <87v9gz9m0p.fsf@kernel.org> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Tao Ren writes: >> > diff --git a/drivers/usb/gadget/udc/aspeed-vhub/core.c b/drivers/usb/gadget/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 *data) >> > >> > /* Handle device interrupts */ >> > if (istat & vhub->port_irq_mask) { >> > - unsigned long bitmap = istat; >> > - int offset = VHUB_IRQ_DEV1_BIT; >> > - int size = VHUB_IRQ_DEV1_BIT + vhub->max_ports; >> > - >> > - for_each_set_bit_from(offset, &bitmap, size) { >> > - i = offset - VHUB_IRQ_DEV1_BIT; >> > - ast_vhub_dev_irq(&vhub->ports[i].dev); >> > + for (i = 0; i < vhub->max_ports; i++) { >> > + if (istat & VHUB_DEV_IRQ(i)) >> > + ast_vhub_dev_irq(&vhub->ports[i].dev); >> >> 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 you're already worried about 20~40 cycles of cpu time ;-) patch queued for next merge window -- balbi