Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4306125pxv; Mon, 19 Jul 2021 23:56:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVBE/YEdIp1lmM6CYgsanmIRK8sgi6P8+5t9GrUGEpEcFwkhOfCK1nY3tLNzEVa2ebM3Jh X-Received: by 2002:aa7:cd73:: with SMTP id ca19mr38792866edb.117.1626764207759; Mon, 19 Jul 2021 23:56:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626764207; cv=none; d=google.com; s=arc-20160816; b=nqW3jR0Bb5xcKSnPQlt96ApBGK4OP6C0fpoaOXDgCAyk1WTBpe9ovyiRCqBbgUwu2e zy/ldNNAGZ6ozM6KwqwMKbT+tIUIvuYEyE2pDDDVcRzgCSOwuiWgsvzmk0bhaxjuEnyN XppkQGh/qbiEHDvJESrxRa8/c9jdnQ6by2KbQhULRz+dcIYa/HDBKa5+7MuugzVciZUT PzGklcNC+m5buZQYtpcuqyzhOLsn3lQcrUfCn5RFN4PbFY0PJjtVoaqcjKiM78UQOh6M Ub2TQGX4t3xkLPxTqce0JWivRwdN9KS5QjklEx5KfXC34jYsTZiux/Itm+neu45CZocy SxoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject:dkim-signature; bh=TGUv40RVMYXOh6KiHqrq6840FSz1qV9wifGkcdU1UIE=; b=WRTAxDkgUgzu1zMKUz3EEZPywxBbZoHHgCFo988cJGTmKebyV1hsBQqfBwNhSSsayC nsXt77Lr/zAuoDxnVn0vfWyOlCZus1F6M4/qkmMTnt3N5UwhGgh4o+DdFgxUMpkIzj1s qPj846WC/fUSNiIcKLNdqO09aFY+0AKJpIAy6CVyvSb7GYgVcHPzV+vJ7GJ4C37FnjGw ydftORxajarOo4pClapgQMg93JbdfoUor/GnUWeLK1Gv2tN6JLfpWCBsmKlkTdz8LRdq ylCIP0kHNedG0O4WXwlt1AMeIqvSCn9Q3mO0aEA0YHSSVm33szvGGlXVq0RpntOIyo1k ZAtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sdjrxl1W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gg2si10517338ejb.176.2021.07.19.23.56.23; Mon, 19 Jul 2021 23:56:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sdjrxl1W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237125AbhGTGO3 (ORCPT + 99 others); Tue, 20 Jul 2021 02:14:29 -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-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