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

Guenter Roeck linux at roeck-us.net
Mon Jul 19 08:16:52 PDT 2021


On 7/19/21 7:49 AM, Akira Tsukamoto wrote:
> 
> On 7/19/2021 11:24 PM, Guenter Roeck wrote:
>> On 7/19/21 7:00 AM, Akira Tsukamoto wrote:
>>>
>>> On 7/19/2021 10:51 PM, Guenter Roeck wrote:
>>>> Hi,
>>>>
>>>> On 7/19/21 5:53 AM, Akira Tsukamoto 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.
>>>>>
>>>>
>>>> I had to revert the original patch from the mainline kernel prior to applying
>>>> this patch. Obviously that means that there may be other changes affecting the
>>>> outcome.
>>>>
>>>> riscv64 images work, but riscv32 images still fail with this patch applied.
>>>> The error is a bit different than before, though.
>>>>
>>>> ...
>>>> [   11.899979] Run /sbin/init as init process
>>>> [   12.152666] random: fast init done
>>>> moun: applet not found
>>>> "�����V�t: applet not found
>>>> /bi�����V�F-: applet not found
>>>> moun: applet not found
>>>> swaon: applet not found
>>>> hostname-F: applet not found
>>>>
>>>> After this, the image hangs.
>>>>
>>>> For comparison, the mainline kernel (v5.14-rc2) fails as follows.
>>>>
>>>> [   10.788105] Run /sbin/init as init process
>>>> Starting syslogd: OK
>>>> Starting klogd: OK
>>>> /etc/init.d/S02sysctl: line 68: syntax error: EOF in backquote substitution
>>>> /etc/init.d/S20urandom: line 1: syntax error: unterminated quoted string
>>>> Starting network: /bin/sh: syntax error: unterminated quoted string
>>>> sed: unmatched '/'
>>>> /bin/sh: syntax error: unterminated quoted string
>>>> FAIL
>>>> /etc/init.d/S55runtest: line 48: syntax error: EOF in backquote substitution
>>>>
>>>> I'll be happy to provide information on how to reproduce the problem
>>>> if needed. Please let me know.
>>>
>>> Yes, I do would like to know the procedure of build instruction of your rv32 image.
>>> Then I would reproduce the error and look into how to fix it.
>>>
>> Please have a look at http://server.roeck-us.net/qemu/riscv32/
>> and let me know if you need anything else.
> 
> Thanks for the link. I will work on it tomorrow in my time.
> Building the kernel with defconfig looks much quicker than the config.
> I will try it from defconfig and then config.
> 
> Also I would like to use the same rv32 toolchain. Are you using prebuilt
> riscv32-linux-gcc? Should not make differences but just in case.
> 

I use a toolchain built with either buildroot (when building the root file system)
or with the buildall scripts from https://github.com/jmesmon/buildall.git
(for the kernel). Either case, it is the default riscv32 toolchain from both.

> Is there a public reference for the way of building your qemu and opensbi?
> Not sure which version of qemu with which rv32 to build them, rv32i, rv32imad or else.

I don't know about rv32i or rv32imad, sorry. I build qemu from source using
	--disable-user --disable-gnutls --disable-docs \
         --disable-nettle --disable-gcrypt --disable-vnc-png \
         --disable-xen --disable-xen-pci-passthrough \
         --disable-libssh
configuration options. The firmware image (opensbi) is built as part of that.
You should be able to use a pre-built version of qemu v6.0 if that is available
somewhere.

Hope this helps,
Guenter



More information about the linux-riscv mailing list