From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt0-f196.google.com ([209.85.216.196]:32909 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756416AbcKVR7Y (ORCPT ); Tue, 22 Nov 2016 12:59:24 -0500 Received: by mail-qt0-f196.google.com with SMTP id n6so3578870qtd.0 for ; Tue, 22 Nov 2016 09:57:47 -0800 (PST) Date: Tue, 22 Nov 2016 22:57:42 +0300 From: Alexey Dobriyan To: viro@zeniv.linux.org.uk Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH 1/2] vfs: simpler d_hash() Message-ID: <20161122195742.GC29812@avx2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Precalculate "32 - d_cache_shift". Signed-off-by: Alexey Dobriyan --- fs/dcache.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- 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 */