lkml.org 
[lkml]   [2010]   [May]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] idr: fix backtrack logic in idr_remove_all
On Tue, May 18, 2010 at 05:23:20PM +0200, ext Tejun Heo wrote:
> On 05/18/2010 01:18 PM, Imre Deak wrote:
> >> Shouldn't this be id ^ bt_mask? The above only detects 1 -> 0
> >> transitions not the other way around.
> >
> > It works according to the following with n=1:
> >
> > id id+2 fls((id+2) & ~id)
> > 0 2 2
> > 2 4 3
> > 4 6 2
> > 6 8 4
> > 8 10 2
> > 10 12 3
> > 12 14 2
> >
> > I think this should work.
>
> Ah, I thought you were doing fls(id & ~(id + 2)) and thus looking at 1
> -> 0 transitions. It's the other way and you're looking for the
> highest 0 -> 1 transition which should be the same to the highest bit
> changing if you aren't overflowing.

Yes, both ways you get the same result and in case of overflow neither
will work.

> The patch looks good then. I still think ^ test would be clearer tho.
> Hmmm...

Well xor results in one instruction less on machines without a nand
instruction, so I'll change that.

> Can you please add little comment there stating that you're
> looking for the highest bit flipping?

Yes, I'll re-test and follow up with an updated patch.

Thanks for the review,
Imre

>
> Reviewed-by: Tejun Heo <tj@kernel.org>
>
> Thanks.
>


\
 
 \ /
  Last update: 2010-05-18 23:21    [W:0.035 / U:32.248 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site