Re: [PATCH] dentry and inode cache hash algorithm performance changes.

From: Jose R. Santos
Date: Fri Apr 30 2004 - 16:07:24 EST


On 04/30/04 15:18:32, Andrew Morton wrote:
> "Jose R. Santos" <jrsantos@xxxxxxxxxxxxxx> wrote:
> >
> > diff -Nru a/fs/inode.c b/fs/inode.c
> > --- a/fs/inode.c Fri Apr 30 12:14:23 2004
> > +++ b/fs/inode.c Fri Apr 30 12:14:23 2004
> > @@ -671,8 +671,9 @@
> >
> > static inline unsigned long hash(struct super_block *sb, unsigned long hashval)
> > {
> > - unsigned long tmp = hashval + ((unsigned long) sb / L1_CACHE_BYTES);
> > - tmp = tmp + (tmp >> I_HASHBITS);
> > + unsigned long tmp = (hashval + ((unsigned long) sb) ^ (GOLDEN_RATIO_PRIME + hashval)
> > + / L1_CACHE_BYTES);
> > + tmp = tmp + ((tmp ^ GOLDEN_RATIO_PRIME) >> I_HASHBITS);
> > return tmp & I_HASHMASK;
> > }
> >
>
> Are you sure about this? It's doing:
>
> tmp = hashval + sb ^ ((GOLDEN_RATIO_PRIME + hashval) / L1_CACHE_BYTES)
>
> should it not be:
>
> tmp = hashval + (sb ^ (GOLDEN_RATIO_PRIME + hashval)) / L1_CACHE_BYTES
>
> ?

err... Wrote the patch to fast. It should read

tmp = (hashval * sb) ^ (GOLDEN_RATIO_PRIME + hashval) / L1_CACHE_BYTES

I screw up... I'll send a fixed patch in a while.

-JRS


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