linux-stable/arch/riscv/lib
Akira Tsukamoto ca6eaaa210
riscv: __asm_copy_to-from_user: Optimize unaligned memory access and pipeline stall
This patch will reduce cpu usage dramatically in kernel space especially
for application which use sys-call with large buffer size, such as
network applications. The main reason behind this is that every
unaligned memory access will raise exceptions and switch between s-mode
and m-mode causing large overhead.

First copy in bytes until reaches the first word aligned boundary in
destination memory address. This is the preparation before the bulk
aligned word copy.

The destination address is aligned now, but oftentimes the source
address is not in an aligned boundary. To reduce the unaligned memory
access, it reads the data from source in aligned boundaries, which will
cause the data to have an offset, and then combines the data in the next
iteration by fixing offset with shifting before writing to destination.
The majority of the improving copy speed comes from this shift copy.

In the lucky situation that the both source and destination address are
on the aligned boundary, perform load and store with register size to
copy the data. Without the unrolling, it will reduce the speed since the
next store instruction for the same register using from the load will
stall the pipeline.

At last, copying the remainder in one byte at a time.

Signed-off-by: Akira Tsukamoto <akira.tsukamoto@gmail.com>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
2021-07-06 15:09:48 -07:00
..
delay.c riscv: delay: use do_div() instead of __udivdi3() 2019-08-08 16:05:38 -07:00
error-inject.c riscv: Add support for function error injection 2021-01-14 15:09:09 -08:00
Makefile riscv: Add support for function error injection 2021-01-14 15:09:09 -08:00
memcpy.S riscv: Add KASAN support 2020-01-22 13:09:58 -08:00
memmove.S riscv: provide memmove implementation 2020-12-10 17:27:54 -08:00
memset.S riscv: Add KASAN support 2020-01-22 13:09:58 -08:00
tishift.S riscv: Less inefficient gcc tishift helpers (and export their symbols) 2020-01-18 19:13:41 -08:00
uaccess.S riscv: __asm_copy_to-from_user: Optimize unaligned memory access and pipeline stall 2021-07-06 15:09:48 -07:00