x86/csum: clean up `csum_partial' further
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 27 Jun 2023 20:55:32 +0000 (13:55 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 20 Jan 2024 10:51:47 +0000 (11:51 +0100)
commit2f09679b8ac17288b1b126c6c865ddeb79c6b0f6
treebb6b43d60915d26e4d36b8508bcd0d0e6afb854b
parent1078f257eb3ac68b149031747dd8f896b418d881
x86/csum: clean up `csum_partial' further

[ Upstream commit a476aae3f1dc78a162a0d2e7945feea7d2b29401 ]

Commit 688eb8191b47 ("x86/csum: Improve performance of `csum_partial`")
ended up improving the code generation for the IP csum calculations, and
in particular special-casing the 40-byte case that is a hot case for
IPv6 headers.

It then had _another_ special case for the 64-byte unrolled loop, which
did two chains of 32-byte blocks, which allows modern CPU's to improve
performance by doing the chains in parallel thanks to renaming the carry
flag.

This just unifies the special cases and combines them into just one
single helper the 40-byte csum case, and replaces the 64-byte case by a
80-byte case that just does that single helper twice.  It avoids having
all these different versions of inline assembly, and actually improved
performance further in my tests.

There was never anything magical about the 64-byte unrolled case, even
though it happens to be a common size (and typically is the cacheline
size).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/lib/csum-partial_64.c