[PATCH v4 1/1] riscv: __asm_copy_to-from_user: Optimize unaligned memory access and pipeline stall

Akira Tsukamoto akira.tsukamoto at gmail.com
Mon Jul 19 08:22:37 PDT 2021


Hi Geert,

On 7/19/2021 11:49 PM, Geert Uytterhoeven wrote:
> Hi Tsukamoto-san,
> 
> On Mon, Jul 19, 2021 at 2:53 PM Akira Tsukamoto
> <akira.tsukamoto at gmail.com> wrote:
>> 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.
> 
> [...]
> 
>> Signed-off-by: Akira Tsukamoto <akira.tsukamoto at gmail.com>
> 
> Thanks for your patch!

Thanks for trying!

> 
> As v3 is part of v5.14-rc1, all fixes and improvements need to be
> send as incremental patches.

Yeah, I was not paying attention to v5.14-rc1. Will regenerate it 
when I spot the remaining bug on rv32.

> 
> After reverting ca6eaaa210deec0e ("riscv: __asm_copy_to-from_user:
> Optimize unaligned memory access and pipeline stall") and applying
> v4, booting linux-on-litex-vexriscv still fails, but now differently
> (real crash):

This time it looks like under copy instead of overrun copy last time.
The SZREG, LGREG, REG_L and REG_S should been taking care of the 
difference of rv32 and rv64, but probably still forgetting applying
some places.

Akira

> 
>     /bi�����V�F-: applet not found
>     2'�����t: applet not found
>     Kernel panic - not syncing: Attempted to kill init! exitcode=0x00007f00
>     CPU: 0 PID: 1 Comm: init Not tainted
> 5.14.0-rc2-orangecrab-01933-g5c9574869017 #357
>     Call Trace:
>     Unable to handle kernel NULL pointer dereference at virtual address 00000af0
>     Oops [#1]
>     CPU: 0 PID: 1 Comm: init Not tainted
> 5.14.0-rc2-orangecrab-01933-g5c9574869017 #357
>     epc : walk_stackframe+0x11c/0x13c
>      ra : dump_backtrace+0x2c/0x3c
>     epc : c0003970 ra : c00039bc sp : c1835e20
>      gp : c06a7690 tp : c1838000 t0 : 00000000
>      t1 : 00000000 t2 : 00000000 s0 : c1835e50
>      s1 : c05d8180 a0 : 00001000 a1 : 00000000
>      a2 : c04dfd68 a3 : c05d8180 a4 : ab1d4cdc
>      a5 : 00001000 a6 : c067d204 a7 : ffffefff
>      s2 : 00000000 s3 : c05cc9f4 s4 : 00000000
>      s5 : c05d8180 s6 : c04dfd68 s7 : 00000001
>      s8 : 00000000 s9 : 95b6f158 s10: 00000000
>      s11: 00000001 t3 : 00000000 t4 : 00000001
>      t5 : 00000000 t6 : 00000000
>     status: 00000100 badaddr: 00000af0 cause: 0000000d
>     [<c0003970>] walk_stackframe+0x11c/0x13c
>     [<c00039bc>] dump_backtrace+0x2c/0x3c
>     [<c04dfde8>] show_stack+0x44/0x5c
>     [<c04e4c98>] dump_stack_lvl+0x2c/0x40
>     [<c04e4cc8>] dump_stack+0x1c/0x2c
>     [<c04dff3c>] panic+0x13c/0x330
>     [<c000c774>] do_exit+0x830/0x8b8
>     [<c000c888>] do_group_exit+0x40/0xac
>     [<c000c918>] __wake_up_parent+0x0/0x34
>     [<c0002128>] ret_from_syscall+0x0/0x4
>     ---[ end trace d147f0f146982b08 ]---
>     note: init[1] exited with preempt_count 1
>     Fixing recursive fault but reboot is needed!
> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 



More information about the linux-riscv mailing list