[1/2] vfs: simpler d_hash()
diff mbox

Message ID 20161122195742.GC29812@avx2
State New
Headers show

Commit Message

Alexey Dobriyan Nov. 22, 2016, 7:57 p.m. UTC
Precalculate "32 - d_cache_shift".

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 fs/dcache.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -106,7 +106,7 @@  static struct hlist_bl_head *dentry_hashtable __read_mostly;
 
 static inline struct hlist_bl_head *d_hash(unsigned int hash)
 {
-	return dentry_hashtable + (hash >> (32 - d_hash_shift));
+	return dentry_hashtable + (hash >> d_hash_shift);
 }
 
 #define IN_LOOKUP_SHIFT 10
@@ -3560,6 +3560,8 @@  static void __init dcache_init_early(void)
 
 	for (loop = 0; loop < (1U << d_hash_shift); loop++)
 		INIT_HLIST_BL_HEAD(dentry_hashtable + loop);
+
+	d_hash_shift = 32 - d_hash_shift;
 }
 
 static void __init dcache_init(void)
@@ -3591,6 +3593,8 @@  static void __init dcache_init(void)
 
 	for (loop = 0; loop < (1U << d_hash_shift); loop++)
 		INIT_HLIST_BL_HEAD(dentry_hashtable + loop);
+
+	d_hash_shift = 32 - d_hash_shift;
 }
 
 /* SLAB cache for __getname() consumers */