Re: new dentry feature in 2.1.78

David S. Miller (davem@dm.cobaltmicro.com)
Sat, 10 Jan 1998 15:31:04 -0800


From: torvalds@transmeta.com (Linus Torvalds)
Date: 10 Jan 1998 23:16:34 GMT

Michael Elizabeth Chastain <mec@shout.net> wrote:
> #define i (((unsigned long) inode)/(sizeof(struct inode) & ~ (sizeof(struct inode) - 1)))

So, ten points to the person who can guess what the hell the above does ;)

(Hint: the calculation is not actually strictly necessary, it only tries
to aim for a better hash)

It was so easy, I had to answer. ;-)
It removes the non-significant bits from the inode address ;-)

And even when struct inode is not a strict power of 2 (which it
typically isn't) gcc still does a decent job since most of the
operations are constant and get optimized away. Gcc in this case,
has a very good idea what you are trying to do ;-)

Later,
David S. Miller
davem@dm.cobaltmicro.com