[PATCH 2/3]fs/inode: iunique() Optimize Performance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
Change log:
Change the hash operation from division to shift. It will cost less time.
Also, I change the divisor from L1_CACHE_BYTES to L1_CACHE_SHIFT.
In the cache.h, the most L1_CACHE_BYTES defined as "(1 << L1_CACHE_SHIFT)".
---
Signed-off-by: Liuwenyi<qingshenlwy@xxxxxxxxx>
Cc: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: Jan Kara <jack@xxxxxxx>
Cc: Nick Piggin <npiggin@xxxxxxx>
Cc: linux-fsdevel@xxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx

---
diff --git a/fs/inode.c b/fs/inode.c
index 4d8e3be..397d65f 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -605,8 +605,8 @@ static unsigned long hash(struct super_block *sb, unsigned long hashval)
 {
 	unsigned long tmp;
 
-	tmp = (hashval * (unsigned long)sb) ^ (GOLDEN_RATIO_PRIME + hashval) /
-			L1_CACHE_BYTES;
+	tmp = (hashval * (unsigned long)sb) ^ (GOLDEN_RATIO_PRIME + hashval) >>
+			L1_CACHE_SHIFT;
 	tmp = tmp ^ ((tmp ^ GOLDEN_RATIO_PRIME) >> I_HASHBITS);
 	return tmp & I_HASHMASK;
 }

 				
--------------
Best Regards,
Liuweni
2009-11-25

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

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux