summaryrefslogtreecommitdiff
path: root/include/linux/stringhash.h
diff options
context:
space:
mode:
authorGeorge Spelvin <linux@sciencehorizons.net>2016-06-10 07:22:12 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2016-06-12 00:57:56 +0300
commit703b5faf22fbddf984a361e6555f3a03fdba63d9 (patch)
tree6bcfde71273dc055ba28abedd8305d6a829639f5 /include/linux/stringhash.h
parent8387ff2577eb9ed245df9a39947f66976c6bcd02 (diff)
downloadlinux-703b5faf22fbddf984a361e6555f3a03fdba63d9.tar.xz
fs/dcache.c: Save one 32-bit multiply in dcache lookup
Noe that we're mixing in the parent pointer earlier, we don't need to use hash_32() to mix its bits. Instead, we can just take the msbits of the hash value directly. For those applications which use the partial_name_hash(), move the multiply to end_name_hash. Signed-off-by: George Spelvin <linux@sciencehorizons.net> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/stringhash.h')
-rw-r--r--include/linux/stringhash.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/include/linux/stringhash.h b/include/linux/stringhash.h
index eb7debb280c0..7c2d95170d01 100644
--- a/include/linux/stringhash.h
+++ b/include/linux/stringhash.h
@@ -3,6 +3,7 @@
#include <linux/compiler.h> /* For __pure */
#include <linux/types.h> /* For u32, u64 */
+#include <linux/hash.h>
/*
* Routines for hashing strings of bytes to a 32-bit hash value.
@@ -45,11 +46,12 @@ partial_name_hash(unsigned long c, unsigned long prevhash)
/*
* Finally: cut down the number of bits to a int value (and try to avoid
- * losing bits)
+ * losing bits). This also has the property (wanted by the dcache)
+ * that the msbits make a good hash table index.
*/
static inline unsigned long end_name_hash(unsigned long hash)
{
- return (unsigned int)hash;
+ return __hash_32((unsigned int)hash);
}
/*