]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
NFSD: Remove be32_to_cpu() from DRC hash function
authorChuck Lever <chuck.lever@oracle.com>
Thu, 30 Sep 2021 23:10:03 +0000 (19:10 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Apr 2024 14:18:58 +0000 (16:18 +0200)
[ Upstream commit 7578b2f628db27281d3165af0aa862311883a858 ]

Commit 7142b98d9fd7 ("nfsd: Clean up drc cache in preparation for
global spinlock elimination"), billed as a clean-up, added
be32_to_cpu() to the DRC hash function without explanation. That
commit removed two comments that state that byte-swapping in the
hash function is unnecessary without explaining whether there was
a need for that change.

On some Intel CPUs, the swab32 instruction is known to cause a CPU
pipeline stall. be32_to_cpu() does not add extra randomness, since
the hash multiplication is done /before/ shifting to the high-order
bits of the result.

As a micro-optimization, remove the unnecessary transform from the
DRC hash function.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfscache.c

index 6b9ef15c9c03b76757de5166203f8313d061829b..a8389095029076f762b8aacc0330c64c7b73f907 100644 (file)
@@ -87,7 +87,7 @@ nfsd_hashsize(unsigned int limit)
 static u32
 nfsd_cache_hash(__be32 xid, struct nfsd_net *nn)
 {
-       return hash_32(be32_to_cpu(xid), nn->maskbits);
+       return hash_32((__force u32)xid, nn->maskbits);
 }
 
 static struct svc_cacherep *