Skip to content

[PW_SID:1065182] [v2] riscv: memcpy: fast copy for unaligned buffers#1596

Closed
linux-riscv-bot wants to merge 1 commit into
workflow__riscv__fixesfrom
pw1065182
Closed

[PW_SID:1065182] [v2] riscv: memcpy: fast copy for unaligned buffers#1596
linux-riscv-bot wants to merge 1 commit into
workflow__riscv__fixesfrom
pw1065182

Conversation

@linux-riscv-bot
Copy link
Copy Markdown

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

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>
@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2] riscv: memcpy: fast copy for unaligned buffers"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 136.82 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2] riscv: memcpy: fast copy for unaligned buffers"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1102.60 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2] riscv: memcpy: fast copy for unaligned buffers"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1609.77 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2] riscv: memcpy: fast copy for unaligned buffers"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 26.59 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2] riscv: memcpy: fast copy for unaligned buffers"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 27.90 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2] riscv: memcpy: fast copy for unaligned buffers"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.61 seconds
Result: WARNING
Output:

WARNING: From:/Signed-off-by: email address mismatch: 'From: Matteo Croce <technoboy85@gmail.com>' != 'Signed-off-by: Matteo Croce <teknoraver@meta.com>'

total: 0 errors, 1 warnings, 0 checks, 98 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Commit 43357576542c ("riscv: memcpy: fast copy for unaligned buffers") has style problems, please review.

NOTE: Ignored message types: ALLOC_SIZEOF_STRUCT CAMELCASE COMMIT_LOG_LONG_LINE GIT_COMMIT_ID MACRO_ARG_REUSE NO_AUTHOR_SIGN_OFF

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.
total: 0 errors, 1 warnings, 0 checks, 98 lines checked
WARNING: From:/Signed-off-by: email address mismatch: 'From: Matteo Croce <technoboy85@gmail.com>' != 'Signed-off-by: Matteo Croce <teknoraver@meta.com>'


@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2] riscv: memcpy: fast copy for unaligned buffers"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 82.19 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2] riscv: memcpy: fast copy for unaligned buffers"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2] riscv: memcpy: fast copy for unaligned buffers"
kdoc
Desc: Detects for kdoc errors
Duration: 0.88 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2] riscv: memcpy: fast copy for unaligned buffers"
module-param
Desc: Detect module_param changes
Duration: 0.28 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2] riscv: memcpy: fast copy for unaligned buffers"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.34 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2] riscv: memcpy: fast copy for unaligned buffers"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.32 seconds
Result: PASS

@linux-riscv-bot linux-riscv-bot deleted the pw1065182 branch March 19, 2026 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants