Aug. 28, 2013
2:30 p.m.
hi all the codes about filesystem in the kernel is: static inline struct list_head * d_hash(struct dentry *parent, unsigned long hash){ hash += (unsigned long)parent / L1_CACHE_BYTES; hash = hash^(hash>>D_HASHBITS)^(hash>>D_HASHBITS*2); return dentry_hashtable + (hash & D_HASHMASK);} I know the function parameter of hash belongs to the qstr string is looking up, and the local variableshash should add the *address of the dentry of parent*. Why count the hash value use "L1_CACHE_BYTES" , "D_HASHBITS" and "D_HASHMASK"? And How to understand the codes following ? hash += (unsigned long)parent / L1_CACHE_BYTES; hash = hash^(hash>>D_HASHBITS)^(hash>>D_HASHBITS*2);