Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp52800ybb; Tue, 7 Apr 2020 16:40:24 -0700 (PDT) X-Google-Smtp-Source: APiQypKtaRPC1tdq2E+jJrN0yRlNf8Qk3DPF5mtNs3Qhnk+IvoTPO/gaaHyl+P1r6PusnFp+vsDw X-Received: by 2002:a05:6830:1c77:: with SMTP id s23mr3753281otg.191.1586302824321; Tue, 07 Apr 2020 16:40:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586302824; cv=none; d=google.com; s=arc-20160816; b=yuBiNDUEyrreV4p85WTA+pEK55s+5+8dU+5SB4WdgTGB/LPgZpUcmr8I2SkCYDQ3M2 1kIUlh3t7fYAsKKZRm2wKwvVW8Yn2HXTWjK68T1XiKxMuQRD6NufjGuMPSjuMWENls0w 6scFYIbY5CydDhv3dR+iz2m3rpjHYM/hlGqVf+UGuZMt/sQ7EdruSQcCPsjD2M0zgEVV 21EcGMkypRPZX4BrYEEbDs8bRT6l66RhbdPjO5gWq/Zcq8+7Sq1JhEZ5vYA1apOyeEsP vUF+FIGSI+hc6m/oh0ipLr1OcK5ZW9zNDMLgrBf0GyVdqOeheBnv/ygc8ui9IvVg1/OJ l23g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=U5iNSogE5A2g0sDAMoK19ni6oNXe+Euv9MUdu2QZ4K4=; b=eDYHrrR9dEn82ygZfdNHzqTqpWLdQuLYIVxg5Jo6uXSqeDnI0495+RMEktTxQYWs5r OXQvshalDWqQrlYHTPJrccrKNxAZp8VMA3F1eCF3bjn4jT6fC+lOMYrS1km2EdV9S5He QYFD/Z80tkERPHTuCueInK12xhCi0yPiZoOqOc86k2Vmz+ge3FjhyIL+mNao9vx0eGko nhze60Z0hOtSOk7DGIWn35gnjjrMNXyDKtJQqeNoFg4xoh0q8ooNu4wTf6lSroRuPv/L cWlykCEfKbB9l/+krYECXAZPHfJgjLKyPTniF6RFSka55pucqUEDhDexoRLx4Jt84/0+ lscw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w81si1620518oia.48.2020.04.07.16.39.56; Tue, 07 Apr 2020 16:40:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726446AbgDGXhE (ORCPT + 99 others); Tue, 7 Apr 2020 19:37:04 -0400 Received: from kernel.crashing.org ([76.164.61.194]:40816 "EHLO kernel.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726393AbgDGXhE (ORCPT ); Tue, 7 Apr 2020 19:37:04 -0400 Received: from localhost (gate.crashing.org [63.228.1.57]) (authenticated bits=0) by kernel.crashing.org (8.14.7/8.14.7) with ESMTP id 037NaIP6017886 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 7 Apr 2020 18:36:22 -0500 Message-ID: <93ae433317a82de86ff5e9c8485563b78656b615.camel@kernel.crashing.org> Subject: Re: [PATCH v3] usb: gadget: aspeed: improve vhub port irq handling From: Benjamin Herrenschmidt To: Tao Ren Cc: Felipe Balbi , linux-aspeed@lists.ozlabs.org, Andrew Jeffery , Greg Kroah-Hartman , openbmc@lists.ozlabs.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Stephen Boyd , Joel Stanley , taoren@fb.com, Chunfeng Yun , linux-arm-kernel@lists.infradead.org Date: Wed, 08 Apr 2020 09:36:16 +1000 In-Reply-To: <20200407060242.GA15050@taoren-ubuntu-R90MNF91> References: <20200315191430.12379-1-rentao.bupt@gmail.com> <20200401215826.GA8248@taoren-ubuntu-R90MNF91> <512d625e45ea953d722bb7ea73c3619730312284.camel@kernel.crashing.org> <20200403064826.GA10866@taoren-ubuntu-R90MNF91> <20200407060242.GA15050@taoren-ubuntu-R90MNF91> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2020-04-06 at 23:02 -0700, Tao Ren wrote: > I ran some testing on my ast2400 and ast2500 BMC and looks like the > for() loop runs faster than for_each_set_bit_from() loop in my > environment. I'm not sure if something needs to be revised in my test > code, but please kindly share your suggestions: > > I use get_cycles() to calculate execution time of 2 different loops, and > ast_vhub_dev_irq() is replaced with barrier() to avoid "noise"; below > are the results: > > - when downstream port number is 5 and only 1 irq bit is set, it takes > ~30 cycles to finish for_each_set_bit() loop, and 20-25 cycles to > finish the for() loop. > > - if downstream port number is 5 and all 5 bits are set, then > for_each_set_bit() loop takes ~50 cycles and for() loop takes ~25 > cycles. > > - when I increase downsteam port number to 16 and set 1 irq bit, the > for_each_set_bit() loop takes ~30 cycles and for() loop takes 25 > cycles. It's a little surprise to me because I thought for() loop > would cost 60+ cycles (3 times of the value when port number is 5). > > - if downstream port number is 16 and all irq status bits are set, > then for_each_set_bit() loop takes 60-70 cycles and for() loop takes > 30+ cycles. I suspect the CPU doesn't have an efficient find-zero-bit primitive, check the generated asm. In that case I would go back to the simple for loop. Cheers, Ben.