Received: from eggs.gnu.org ([208.118.235.92]:45781) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tqsin-0005Ed-6X for qemu-devel@nongnu.org; Thu, 03 Jan 2013 16:53:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tqsig-0000Zg-J5 for qemu-devel@nongnu.org; Thu, 03 Jan 2013 16:53:05 -0500 Date: Thu, 3 Jan 2013 15:52:37 -0600 From: Scott Wood In-Reply-To: <88EAD096-9509-483A-9C6F-C60EBD67FF11@suse.de> (from agraf@suse.de on Thu Jan 3 14:57:33 2013) Message-ID: <1357249957.22404.12@snotra> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; delsp=Yes; format=Flowed Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 12/15] openpic: IRQ_check: search the queue a word at a time List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: "" , "" On 01/03/2013 02:57:33 PM, Alexander Graf wrote: >=20 > On 03.01.2013, at 21:32, Scott Wood wrote: >=20 > > On 01/03/2013 02:31:30 PM, Alexander Graf wrote: > >> Am 03.01.2013 um 21:07 schrieb Scott Wood =20 > : > >> > On 01/03/2013 12:53:13 PM, Alexander Graf wrote: > >> >> On 22.12.2012, at 03:15, Scott Wood wrote: > >> >> > Search the queue more efficiently by first looking for a =20 > non-zero word, > >> >> > and then using the common bit-searching function to find the =20 > bit within > >> >> > the word. It would be even nicer if bitops_ffsl() could be =20 > hooked up > >> >> > to the compiler intrinsic so that bit-searching instructions =20 > could be > >> >> > used, but that's another matter. > >> >> > > >> >> > Signed-off-by: Scott Wood > >> >> What we really want is a bitmap wide ffs() bipops helper =20 > function that returns the first set bit in a bitmap and can optimize =20 > the hell out of that operation inside of itself. I don't think this =20 > belongs to the OpenPIC code. > >> > > >> > Well, we do have find_next_bit() in bitops.c, but it looks =20 > comparitively complicated in order to be generic and simply return a =20 > value rather than perform an action on each bit set. I suspect that =20 > the code in this patch would be faster, and avoids the need for me to =20 > follow all the twists and turns of find_next_bit() to figure out =20 > whether the undocumented interface is actually exactly what I guess =20 > it to be (e.g. what does it return when no bit is found?). > >> I would just call it bit_ffs and follow the same semantics. > > > > I'm not sure how that's an answer to what I wrote... >=20 > The answer is "man ffs" and it will tell you what semantics the =20 > function would have. Not completely, because ffs() doesn't operate on multiple words. > However given that find_next_bit() is defined in Linux, why not use =20 > its semantics? Can't we just copy Linux code here? As I said, the function *has* been copied. Its semantics differ from =20 ffs() (which is good, since ffs() has annoying semantics such as adding =20 one to the result). It took a fair bit of staring at the function to =20 be convinced that the not-found case returns "size" under all =20 circumstances and that there isn't a bug when size is not a multiple of =20 BITS_PER_LONG. > Whether it's faster or not is another question, but I'd like to keep =20 > bitops internals as internal to bitops as we can. I think you get diminishing (and eventually negative) returns if you =20 push it too far, but fine, I'll send a v2 using find_next_bit(). > We could even completely hide the bitops implementation details =20 > behind a private struct definition. But that would mean that we'd =20 > have to create an indirect memory access for the bitmap itself :(. >=20 > One advantage of keeping these bits internal would be that we could =20 > even add more accelerations. We could for example add another bitmap =20 > layer on top of the bitmap internally, similar to how the MSIs get =20 > another bitmap across all combined MSI registers in the MPIC. And =20 > find_next_bit could use that to speed up the lookup for really big =20 > bitmaps. Perhaps, if it's shown to be a performance problem still. -Scott=