lkml.org 
[lkml]   [1999]   [Apr]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: more on hash functions
From
Date
cel@monkey.org (Chuck Lever) writes:
>
> the buffer hash function i used is this:
>
> #define _hashfn(dev,block) \
> ((((unsigned long)(block) * (40499UL * 65543UL)) >> 17) & bh_hash_mask)
>
> this is the same number of instructions as the old function, except that
> one of the instructions is IMUL. i haven't looked up how expensive this
> might be. however, i believe a fixed expense is better than a higher
> loops/lookup average, since IMUL with a constant multiplier doesn't incur
> any memory overhead once it's in the instruction cache, whereas an extra
> iteration of find_buffer might be another 2 memory references, either or
> both of which might be cache misses.

This is correct for the x86 picture, but breaks e.g. on earlier sparcs
or some m68ks where multiplication is very slow. Remember Linux is not x86
only.


-Andi

--
This is like TV. I don't like TV.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:51    [W:0.046 / U:0.216 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site