Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp273876ybb; Tue, 7 Apr 2020 22:41:45 -0700 (PDT) X-Google-Smtp-Source: APiQypJGXgx0VXQG8BlJrrbdbsZzlI1HD+hiK+XUeXD1WA96tYc077+eHv2BUSbZN6lUx8JRf/jz X-Received: by 2002:a05:6808:8cb:: with SMTP id k11mr1197768oij.48.1586324505522; Tue, 07 Apr 2020 22:41:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586324505; cv=none; d=google.com; s=arc-20160816; b=VChwC+xs1IME3n4ViyMeIOGunaQIOY+mmvQG33/2Swcy911mV6Jv+mlcitSF4eN1uN aBi5LJUFWn0EHCrOvY5lZ53zzW5n35DY3fhQm2lEWrdpuf5Lx2QTDgxz961nzuyfgX4g /dRMBOG/xyWutQTK2uA2LrqGdlmvSUvDbxfnOxDVmRKnNqhuhhJR+PuV/cPq2Bsamrg+ 5hy7J9NWq6venc4NjR7jkKguxDuhWge5D6qwmtARZkGVfyo9lP8yomKYhgBy869nUHJu H7u/3JmC+JboCZ4iH7g0jU82T3wPC4GDUbPbLifJImZeUOqhCrvnWJzHFkg/eFUMWRQM pbyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=g1prhrjKxEZds2TfTdybytV1XN9ZFJTSPhvDxSwKWbE=; b=Zm2Wt+Qunhdfi3q+dQ0gIuPa+Foc+YgfA++fFuXJnZslVdDvlhrFPHsw6s3q2yF+3f MowV6SCAPNwVznXiqv0QYERcMpgNv0jBd8+oXZSpSniVxqBsHzph5K00jdFTkbs+inVS BW5FTUai/VhujEx70CLwxChV1sywGG8GqDcBRDCpjBCNzrn5YnkPsZmpQ/0RnwzqhZLo Mhog6gkfj9gHW3gJUoMhlBIpeKxxZsodoOFPehvmrAiVCtDtUmep+NHCuFoNXP7sJf8f 6P5hhqFXrA6zjLAPTkqVexvOkkqfa84keAQSUDGBwa1veKn/TxgMYXe0aPiqR5Ll413D noxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lLoEa84O; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b205si1511088oif.126.2020.04.07.22.41.31; Tue, 07 Apr 2020 22:41:45 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lLoEa84O; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726586AbgDHFkb (ORCPT + 99 others); Wed, 8 Apr 2020 01:40:31 -0400 Received: from mail-pj1-f67.google.com ([209.85.216.67]:52833 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725879AbgDHFkb (ORCPT ); Wed, 8 Apr 2020 01:40:31 -0400 Received: by mail-pj1-f67.google.com with SMTP id ng8so723686pjb.2; Tue, 07 Apr 2020 22:40:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=g1prhrjKxEZds2TfTdybytV1XN9ZFJTSPhvDxSwKWbE=; b=lLoEa84OH4TcHPRT1UimZUdQLc7+R6JFgPXWoCIIRTR2AyiT/OPSoK3ieDWDqzM8qx lyCsqh2n5Zq2XflpC4bOHZ8iVDQrslNa1+/DzvMLAIWXtGMWlgcDE9ziykfEik9ddmBi tyxXTYOkvFRPwBCL9z5pyp0iPfR1I3wurB47f21uuqJtHxLVwahEtgitfWWN7flMDjOZ Safx8k04FtvoZcMhRSmyzx7z3Cwfou//CwYoXYZ07Wi8fW04reFQgw8Y0kGd+M/oglj0 CPxccDmDXnLlKNcHfvjbisMg0rXq9cG1uOMWcwhtmdlAZqu3MIuoskOTHuqaUL6yiZXb 664Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=g1prhrjKxEZds2TfTdybytV1XN9ZFJTSPhvDxSwKWbE=; b=dsl/KrW+Cw8tzF+oUPBZAQeSP7UmOI9wKRMXIC85CSCnjliMNYlo4kRSm8PxSGrdGV BGSiwkmgPvEeFdjWFBcHQROPE4cxNz4D1p4b7WDzzo9klpUOwkWPK4BI2I7qPrFY4edW yrhsR3vyZwHaEoM3oo4kcGg0jEK/oqs5Hl7cRElY00T8wFb9VKwga/r4owlRxlGT6k7z 7bNFM3DonHzJIs1lRmV60h1juYAjN+5RGf0EsgffGZERGjPHV4QUodW5D9gojs1tm+sL yJ9MF9oGG5QvR9Gw0TiiYugF1+M40GMun1he05l1cZbNaoM4SHPffr4QqtczparVrIy8 El7g== X-Gm-Message-State: AGi0PuaCKwflXvVHlYqiPS9ONq2xa09XbnUU9J8c99nmneyy8y+1PcT8 go09WczEOFvOinBYnJUvufQ= X-Received: by 2002:a17:902:a5c6:: with SMTP id t6mr5265576plq.319.1586324430524; Tue, 07 Apr 2020 22:40:30 -0700 (PDT) Received: from taoren-ubuntu-R90MNF91 (c-73-252-146-110.hsd1.ca.comcast.net. [73.252.146.110]) by smtp.gmail.com with ESMTPSA id d3sm15544077pfq.126.2020.04.07.22.40.29 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Apr 2020 22:40:30 -0700 (PDT) Date: Tue, 7 Apr 2020 22:40:23 -0700 From: Tao Ren To: Benjamin Herrenschmidt 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 Subject: Re: [PATCH v3] usb: gadget: aspeed: improve vhub port irq handling Message-ID: <20200408054022.GA12469@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> <93ae433317a82de86ff5e9c8485563b78656b615.camel@kernel.crashing.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <93ae433317a82de86ff5e9c8485563b78656b615.camel@kernel.crashing.org> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 08, 2020 at 09:36:16AM +1000, Benjamin Herrenschmidt wrote: > 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. _find_next_bit_le() function is defined in arch/arm/lib/findbit.S. I'm looking at the code: will run more tests and send out patch v4 with simple for loop later. Cheers, Tao