From: Charlie Jenkins <charlie@rivosinc.com>
To: Charlie Jenkins <charlie@rivosinc.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Conor Dooley <conor@kernel.org>,
Samuel Holland <samuel.holland@sifive.com>,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Cc: Paul Walmsley <paul.walmsley@sifive.com>,
Albert Ou <aou@eecs.berkeley.edu>
Subject: [PATCH v2 0/5] riscv: Add fine-tuned checksum functions
Date: Tue, 05 Sep 2023 21:46:49 -0700 [thread overview]
Message-ID: <20230905-optimize_checksum-v2-0-ccd658db743b@rivosinc.com> (raw)
Each architecture generally implements fine-tuned checksum functions to
leverage the instruction set. This patch adds the main checksum
functions that are used in networking.
Vector support is included in this patch to start a discussion on that,
it can probably be optimized more. The vector patches still need some
work as they rely on GCC vector intrinsics types which cannot work in
the kernel since it requires C vector support rather than just assembler
support. I have tested the vector patches as standalone algorithms in QEMU.
This patch takes heavy use of the Zbb extension using alternatives
patching.
To test this patch, enable the configs for KUNIT, then CHECKSUM_KUNIT
and RISCV_CHECKSUM_KUNIT.
I have attempted to make these functions as optimal as possible, but I
have not ran anything on actual riscv hardware. My performance testing
has been limited to inspecting the assembly, running the algorithms on
x86 hardware, and running in QEMU.
ip_fast_csum is a relatively small function so even though it is
possible to read 64 bits at a time on compatible hardware, the
bottleneck becomes the clean up and setup code so loading 32 bits at a
time is actually faster.
Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
---
Changes in v2:
- After more benchmarking, rework functions to improve performance.
- Remove tests that overlapped with the already existing checksum
tests and make tests more extensive.
- Use alternatives to activate code with Zbb and vector extensions
- Link to v1: https://lore.kernel.org/r/20230826-optimize_checksum-v1-0-937501b4522a@rivosinc.com
---
Charlie Jenkins (5):
riscv: Checksum header
riscv: Add checksum library
riscv: Vector checksum header
riscv: Vector checksum library
riscv: Test checksum functions
arch/riscv/Kconfig.debug | 1 +
arch/riscv/include/asm/checksum.h | 194 ++++++++++++++++++++
arch/riscv/lib/Kconfig.debug | 31 ++++
arch/riscv/lib/Makefile | 3 +
arch/riscv/lib/csum.c | 333 ++++++++++++++++++++++++++++++++++
arch/riscv/lib/riscv_checksum_kunit.c | 330 +++++++++++++++++++++++++++++++++
6 files changed, 892 insertions(+)
---
base-commit: 65d6e954e37872fd9afb5ef3fc0481bb3c2f20f4
change-id: 20230804-optimize_checksum-db145288ac21
--
- Charlie
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next reply other threads:[~2023-09-06 4:47 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-06 4:46 Charlie Jenkins [this message]
2023-09-06 4:46 ` [PATCH v2 1/5] riscv: Checksum header Charlie Jenkins
2023-09-07 9:40 ` Conor Dooley
2023-09-07 17:44 ` Charlie Jenkins
2023-09-10 21:20 ` David Laight
2023-09-11 18:16 ` Charlie Jenkins
2023-09-06 4:46 ` [PATCH v2 2/5] riscv: Add checksum library Charlie Jenkins
2023-09-07 9:52 ` Conor Dooley
2023-09-07 17:47 ` Charlie Jenkins
2023-09-06 4:46 ` [PATCH v2 3/5] riscv: Vector checksum header Charlie Jenkins
2023-09-07 9:47 ` Conor Dooley
2023-09-07 17:43 ` Charlie Jenkins
2023-09-07 9:58 ` Conor Dooley
2023-09-07 17:41 ` Charlie Jenkins
2023-09-06 4:46 ` [PATCH v2 4/5] riscv: Vector checksum library Charlie Jenkins
2023-09-06 4:46 ` [PATCH v2 5/5] riscv: Test checksum functions Charlie Jenkins
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230905-optimize_checksum-v2-0-ccd658db743b@rivosinc.com \
--to=charlie@rivosinc.com \
--cc=aou@eecs.berkeley.edu \
--cc=conor@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=samuel.holland@sifive.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).