[PW_SID:1065182] [v2] riscv: memcpy: fast copy for unaligned buffers#1596
[PW_SID:1065182] [v2] riscv: memcpy: fast copy for unaligned buffers#1596linux-riscv-bot wants to merge 1 commit into
Conversation
The RISC-V memcpy() does an 8 byte wide copy when the two buffers have
the same alignment, and fallbacks to a single byte copy otherwise.
Implement a unaligned aware 8 byte copy when buffers are unaligned
which copies 8 bytes at time by doing proper shifting.
Synthetic benchmarks[1] show that the aligned code path is unaffected,
while the unaligned one gets a ~2.3x boost:
Before:
memcpy: aligned copy of 400 MBytes in 429 msecs (931 MB/s)
memcpy: unaligned copy of 400 MBytes in 1202 msecs (332 MB/s)
After:
memcpy: aligned copy of 400 MBytes in 428 msecs (933 MB/s)
memcpy: unaligned copy of 400 MBytes in 519 msecs (770 MB/s)
Network RX benchmarks on a Milk-V Megrez (ESWIN EIC7700X) with a
1 Gbps NIC (stmmac driver) confirm the improvement in a real-world
scenario. UDP RX flood with varying frame sizes:
Frame size stock memcpy optimized memcpy Improvement
---------- ------------ ---------------- -----------
64 bytes 242.6 Kpps 246.9 Kpps +1.8%
128 bytes 225.3 Kpps 243.0 Kpps +7.9%
256 bytes 200.8 Kpps 227.8 Kpps +13.4%
512 bytes 165.4 Kpps 203.6 Kpps +23.1%
Throughput at 512-byte frames improved from 672 Mbps to 827 Mbps.
The improvement scales with frame size as larger frames copy more
bytes per packet. Larger frame sizes were not tested as they would
saturate the 1 Gbps link.
[1] https://lore.kernel.org/lkml/20260301011209.4160-1-teknoraver@meta.com/
Signed-off-by: Matteo Croce <teknoraver@meta.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "[v2] riscv: memcpy: fast copy for unaligned buffers" |
|
Patch 1: "[v2] riscv: memcpy: fast copy for unaligned buffers" |
|
Patch 1: "[v2] riscv: memcpy: fast copy for unaligned buffers" |
|
Patch 1: "[v2] riscv: memcpy: fast copy for unaligned buffers" |
|
Patch 1: "[v2] riscv: memcpy: fast copy for unaligned buffers" |
|
Patch 1: "[v2] riscv: memcpy: fast copy for unaligned buffers" |
|
Patch 1: "[v2] riscv: memcpy: fast copy for unaligned buffers" |
|
Patch 1: "[v2] riscv: memcpy: fast copy for unaligned buffers" |
|
Patch 1: "[v2] riscv: memcpy: fast copy for unaligned buffers" |
|
Patch 1: "[v2] riscv: memcpy: fast copy for unaligned buffers" |
|
Patch 1: "[v2] riscv: memcpy: fast copy for unaligned buffers" |
|
Patch 1: "[v2] riscv: memcpy: fast copy for unaligned buffers" |
PR for series 1065182 applied to workflow__riscv__fixes
Name: [v2] riscv: memcpy: fast copy for unaligned buffers
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1065182
Version: 2