From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05BEFC07E95 for ; Tue, 20 Jul 2021 06:55:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E4B006113B for ; Tue, 20 Jul 2021 06:55:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239908AbhGTGOc (ORCPT ); Tue, 20 Jul 2021 02:14:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236496AbhGTGN6 (ORCPT ); Tue, 20 Jul 2021 02:13:58 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 365DBC061574 for ; Mon, 19 Jul 2021 23:54:32 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id p17so10971650plf.12 for ; Mon, 19 Jul 2021 23:54:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=TGUv40RVMYXOh6KiHqrq6840FSz1qV9wifGkcdU1UIE=; b=sdjrxl1Wj0oJ16dSDOf7qCbB4iokjDADNt7X5W/9J1EMuFGZJzg16irOTnAIC4b/FG i+5iGCtDUdNOGh0qYXOnwJ6+UiO1w7YtNysblfmGzVNIEQostlRp4bwmzqIXysySqyuB e3EIPoWZ6iAbq+/g2uMGj9jlwYeqyA+i0LP78oTm5t5T/OK8driv1/+Ue37uhYN67SNr /0LiJRjYFy/SjlCvsCRdmE9u8cLlZ9DEzjWajtY0yzqUnLZ+iSK51Q8jjYkMSKunYYAB REDtqeRNGIHbluJM/qJYFVtalRzjrhjP3PWOVR6EoBj9QO0tEa9wTWSRgBz/apw8XckU 2VkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=TGUv40RVMYXOh6KiHqrq6840FSz1qV9wifGkcdU1UIE=; b=bTxJpdgqQQXCpa709a7Hkt61qg4Rw1xIhU9xTV3gxjjS0ovXye1MgzQ8hyyw4inyD6 ty68c4B14hR+oTUOnLJ+9a37iQxWXcgJzkRHIIsNXF1wtk5cjnZPSIrCevtYIxYSpoO3 cWqL/ySfR7/snKrqGCxsC5cEkV/B925oXaizMV3cbt3NO4JwfOKSE8wSiyqw6dE6E3Hz 0evU/gSu56ZdRFekKJc+AJRrITjQO9VKgZ5RhoFapkptwf19PgUDHHE9DLHSJ/FHzqWY Q3wseet45SpQjf86u2y3YuLr2KYErei/71x1cPf5nysh68TiFDrkXuNLwNrEdJ13Re82 eBXw== X-Gm-Message-State: AOAM533B0Z6u9gTY52ZsAw179hWuz9m02DMauw0lN6x4nA+mv0qmg/1o jZ3X8VUUeDwSpq5FKpyTB/PY8BILfXg= X-Google-Smtp-Source: ABdhPJw/zdSDh0HwVmqBC8zH0slokjPAmbpjxwyQGgzcAobkwXE7LX3UdBaMqTX91UiGyNLGKJQcDg== X-Received: by 2002:a17:90b:128a:: with SMTP id fw10mr28594223pjb.116.1626764071284; Mon, 19 Jul 2021 23:54:31 -0700 (PDT) Received: from [192.168.1.153] (M106072041033.v4.enabler.ne.jp. [106.72.41.33]) by smtp.gmail.com with ESMTPSA id i18sm23006194pfa.149.2021.07.19.23.54.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 Jul 2021 23:54:30 -0700 (PDT) Subject: Re: [PATCH v4 1/1] riscv: __asm_copy_to-from_user: Optimize unaligned memory access and pipeline stall To: Guenter Roeck , Palmer Dabbelt , Geert Uytterhoeven , Qiu Wenbo , Paul Walmsley , Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org References: <5e1b5d90-5a1e-5e9f-7b92-6c53b8589c2a@gmail.com> <9a2bf544-2aaa-d175-bc0a-c8bcefd8141a@roeck-us.net> <718c5a83-de9f-3b5a-ef36-e52ad5bb4d67@gmail.com> From: Akira Tsukamoto Message-ID: <616a5e92-4225-6793-fa0c-02ff831e26df@gmail.com> Date: Tue, 20 Jul 2021 15:54:27 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/20/21 00:16, Guenter Roeck wrote: > 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, Super, I was perfectly able to reproduce the exactly the same error messages with the toolchain in buildroot and your rootfs. There were two bugs, one is overrun copy and second is wrong shifting in .Lshift_copy for rv32. Please wait for my fix. Akira