Re: [PATCH] Make div64_u64() precise on 32bit platforms

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Brian Behlendorf
Date: Tuesday, October 12, 2010 - 12:26 pm

I'm resending the patch as is and adding what I hope are the right CCs.  Also 
let me explain why I opted to add abs64() and use the gcc builtin.


I was reluctant to change abs() since it would have a much larger impact on 
the code base.  Using typeof() should be OK but if any of the callers 
mistakenly call abs() with an unsigned value then we could see compiler 
warnings about '__x < 0' being a useless conditional.


I opted for the gcc builtin because I felt it made the code more readable.  I 
also suspect it will perform slightly better than __fls() on some archs.  For 
example, on powerpc __fls() in implemented using the 'cntlzw' instruction.  
It returns (BITS_PER_LONG - 1 - cntlzw) which is wasted work since my 
function would immediately undo this to get back cntlzw.  If I was lucky the 
compiler would optimize this away for me but if I use the builtin I don't 
need to take the chance.

-- 
Thanks,
Brian Behlendorf
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH] Make div64_u64() precise on 32bit platforms, Brian Behlendorf, (Tue Oct 12, 12:26 pm)
Re: [PATCH] Make div64_u64() precise on 32bit platforms, Oleg Nesterov, (Wed Oct 13, 2:37 pm)
Re: [PATCH] Make div64_u64() precise on 32bit platforms, Oleg Nesterov, (Thu Oct 14, 5:11 am)
Re: [PATCH] Make div64_u64() precise on 32bit platforms, Brian Behlendorf, (Thu Oct 21, 10:46 am)
Re: [PATCH] Make div64_u64() precise on 32bit platforms, Oleg Nesterov, (Thu Oct 21, 11:12 am)
Re: [PATCH] Make div64_u64() precise on 32bit platforms, Andrew Morton, (Thu Oct 21, 12:22 pm)
Re: [PATCH] Make div64_u64() precise on 32bit platforms, Oleg Nesterov, (Thu Oct 21, 12:49 pm)