mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/1] riscv: Optimize user copy with efficient unaligned access support
@ 2025-12-02  7:41 maohan4761
  2025-12-02  7:41 ` [PATCH 1/1] " maohan4761
  0 siblings, 1 reply; 3+ messages in thread
From: maohan4761 @ 2025-12-02  7:41 UTC (permalink / raw)
  To: pjw, palmer; +Cc: guoren, linux-riscv, linux-kernel, Mao Han

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-02-09 17:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-02  7:41 [PATCH 0/1] riscv: Optimize user copy with efficient unaligned access support maohan4761
2025-12-02  7:41 ` [PATCH 1/1] " maohan4761
2026-02-09 17:53   ` Andrew Jones

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®