From owner-svn-src-head@FreeBSD.ORG Thu Dec 4 07:20:40 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9C0856B5; Thu, 4 Dec 2014 07:20:40 +0000 (UTC) Received: from mail.turbocat.net (mail.turbocat.net [IPv6:2a01:4f8:d16:4514::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5ECDF3FD; Thu, 4 Dec 2014 07:20:40 +0000 (UTC) Received: from laptop015.home.selasky.org (cm-176.74.213.204.customer.telag.net [176.74.213.204]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 684881FE022; Thu, 4 Dec 2014 08:20:37 +0100 (CET) Message-ID: <54800B60.9020208@selasky.org> Date: Thu, 04 Dec 2014 08:21:04 +0100 From: Hans Petter Selasky User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: John-Mark Gurney Subject: Re: svn commit: r275468 - head/sys/dev/usb/controller References: <201412032155.sB3LtjJN043364@svn.freebsd.org> <20141204005451.GM99957@funkthat.com> In-Reply-To: <20141204005451.GM99957@funkthat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Dec 2014 07:20:40 -0000 On 12/04/14 01:54, John-Mark Gurney wrote: > Hans Petter Selasky wrote this message on Wed, Dec 03, 2014 at 21:55 +0000: >> Author: hselasky >> Date: Wed Dec 3 21:55:44 2014 >> New Revision: 275468 >> URL: https://svnweb.freebsd.org/changeset/base/275468 >> >> Log: >> Optimise the bit searching loops, by quickly skipping the 16 first set >> bits if all the 16 first bits are set. This way the worst case >> searching time is reduced from 32 to 16 cycles. > > You could use ffs instead: > x = ffs(~map); > if (x) { > x--; > /* normal code */ > } > > This has the benefit of using a single instruction on platforms that > support it (bsfl on i386), though apparently, we haven't optimized this > for all platforms... arm has a version for int, but their ffsl does > the same linear search instead of just calling ffs, or at least > detecting if sizeof(long) == sizeof(int) and calling ffs... > Yes, I'm aware about that, but like you say it is not optimised for all platforms yet. So I'm not sure if it will give any benefit for the platform the driver is running on .... I'll see if I can change the logic inside the C-version of ffs() and the do the swap like you suggest. --HPS