From: maohan4761@gmail.com
To: pjw@kernel.org, palmer@dabbelt.com
Cc: guoren@kernel.org, linux-riscv@lists.infradead.org,
linux-kernel@vger.kernel.org, Mao Han <han_mao@linux.alibaba.com>
Subject: [PATCH 0/1] riscv: Optimize user copy with efficient unaligned access support
Date: Tue, 2 Dec 2025 15:41:20 +0800 [thread overview]
Message-ID: <20251202074121.81364-1-maohan4761@gmail.com> (raw)
From: Mao Han <han_mao@linux.alibaba.com>
Many modern high-performance processors now handle unaligned memory
accesses with performance nearly on par with aligned accesses. However,
the current kernel implementation of
fallback_scalar_usercopy_sum_enabled still defaults to aligning accesses
to register size boundaries. This path incurs additional
shift-and-combine operations that fail to fully leverage hardware
capabilities and cannot utilize wide-load/store instructions for
trailing data chunks smaller than 9 × SZREG.
This patch introduces an optimized code path enabled by
RISCV_EFFICIENT_UNALIGNED_ACCESS, which relies on hardware support for
efficient unaligned memory accesses. By doing so, the software can fully
exploit the maximum available load/store instruction width and avoids
complex bit-manipulation logic for reassembly.
The optimization significantly improves performance of
__asm_copy_to/from_user for transfers smaller than
riscv_v_usercopy_threshold. In particular, for small data sizes (8–72
bytes) under unaligned scenarios, performance gains range from 40% to
600%.
lmbench’s sig hndl/catch test shows approximately a 20% improvement,
and iperf small-packet throughput sees noticeable gains as well.
Mao Han (1):
riscv: Optimize user copy with efficient unaligned access support
arch/riscv/lib/uaccess.S | 113 +++++++++++++++++++++++++++++++++++++++
1 file changed, 113 insertions(+)
--
2.25.1
next reply other threads:[~2025-12-02 7:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-02 7:41 maohan4761 [this message]
2025-12-02 7:41 ` [PATCH 1/1] " maohan4761
2026-02-09 17:53 ` Andrew Jones
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=20251202074121.81364-1-maohan4761@gmail.com \
--to=maohan4761@gmail.com \
--cc=guoren@kernel.org \
--cc=han_mao@linux.alibaba.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
/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
all inboxes | Powered by JetHome®