Date: Thu, 15 Nov 2012 17:41:16 -0500 From: Patrick Kelsey <kelsey@ieee.org> To: Warner Losh <imp@bsdimp.com> Cc: "Jayachandran C." <jchandra@freebsd.org>, "freebsd-mips@FreeBSD.org" <mips@freebsd.org>, Alan Cox <alc@rice.edu> Subject: Re: ZERO_REGION_SIZE Message-ID: <CAD44qMUGAGvGpY_jRWG71VChkOUDn-_dgcopt-uNx6FAmdfUHA@mail.gmail.com> In-Reply-To: <953A0D95-54E1-4023-A1F5-A4A7DE1C6175@bsdimp.com> References: <50A53391.4080909@rice.edu> <CAJ-Vmon-v3K7012ti_L6ao3wQHfQ99Jau1kJ%2BGhumbPjAuSDww@mail.gmail.com> <50A54CCD.8070409@rice.edu> <DF2CB7FC-C1ED-4F4C-A39A-60B5E7FC566D@bsdimp.com> <CACVs6=9ZiVeWcJUoeNU_Mybn5WgZ2edUkx4ERPEXD%2BPODp8gKw@mail.gmail.com> <CAD44qMVVq2nassx7fFai9s=zsiZVPBSFdef87UbMZ4j3PNGkMg@mail.gmail.com> <953A0D95-54E1-4023-A1F5-A4A7DE1C6175@bsdimp.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Nov 15, 2012 at 5:25 PM, Warner Losh <imp@bsdimp.com> wrote: > > On Nov 15, 2012, at 3:11 PM, Patrick Kelsey wrote: > >> On Thu, Nov 15, 2012 at 5:02 PM, Juli Mallett <jmallett@freebsd.org> wrote: >>> On Thu, Nov 15, 2012 at 1:07 PM, Warner Losh <imp@bsdimp.com> wrote: >>> >>>> >>>> On Nov 15, 2012, at 1:13 PM, Alan Cox wrote: >>>>> P.S. I would encourage someone with hardware to look into implementing a >>>>> non-iterative ffs*() using (d)clz. The MIPS pmap would benefit from >>>>> this. Basically, most pmap_enter() calls are doing an ffs*(). >>>> >>>> ffs finds the first bit set. clz counts the number of leading zeros and >>>> thus finds the last bit set. Would a non-iterative fls* be helpful? >>>> >>> >>> Right. And no widespread ctz/ffs MIPS instructions as far as I know. We >>> could use pop/dpop on processors that support them to do non-iterative >>> ffs*, with a few additional instructions, though. >> >> I was thinking something like this might work: >> >> value to ffs is in r1, MSB is the index of the MSB (so, 31 or 63): >> >> if (0 == r1) return(your_choice); >> r2 = r1 - 1; >> r2 = r1 ^ r2; >> return (MSB - clz(r2)); > > > Turns out NetBSD has one that does exactly this... > And now that I've gotten away from silly pencil and paper and back to the glare of the internet, I see gcc has had __builtin_ffs for some time...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAD44qMUGAGvGpY_jRWG71VChkOUDn-_dgcopt-uNx6FAmdfUHA>