Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4164201pxv; Mon, 19 Jul 2021 18:59:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFoZV7AwcpxOLMo1x9xSnb3u2TUE/i39VGPMLXvk5SQ/m7pqFk6XGSu3I4pARQBqx8jDr/ X-Received: by 2002:a05:6402:c9:: with SMTP id i9mr38190721edu.48.1626746366211; Mon, 19 Jul 2021 18:59:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626746366; cv=none; d=google.com; s=arc-20160816; b=rIrvyC4fNBDKZhoIOiAgtdDbF4/tE0NCkWpA/hXjHJ/z+WG0sr+1jP6fMSQRyNZ3oV MD075sUrfwaNNRldvks6N9R0p8WMKJTBxy1R9UOKIpg40vsFJnSY8Dx3k+lGcld0llKe hL0c2ep/+9YKtAeB0DVck34P2vzJY3UUrXyjRe4eBrmy7FCyLrm5oB7N5X5XldP78Mxb GRLfDq0OeszrT+v4BmK+MbWvkp9LwiBf62mSHnzyP+/3vGIyIWPkRqf6YztKtJQ3ksxr u21ZhIbCzSbWVWoxb5ITrhgVqc2Q9BMOcMajFXK4TLxJ8ukONMwdJshLuQjdPopzaA/C pT+g== 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 :cc:to:subject:dkim-signature; bh=nvVob/r6aogoYIZPXj3xzusDgNE755/gn+vTBsW74ko=; b=QqV3sb1mWHrQEuQNjZJiyKLoBbavd61lP1GalQjPkAEtw8MUNscx1xHanWpPmej2mk zTTTXT31EhETUvHSSbt2q4RbR8/wIDD3wXt9+5h1G6/mxTSuNDnSLuyO72/KEQkGpq0h nkraeP/+ngfKU/e8EGCqGPXFt3RoLqC9/fIDrDE+2vZL2pvxw5TMxmgECYPhpIEiw6f0 712pjlewybn/DBIlu+MiVlOzntF62mjRFFriz6odwmzxDZS7O566sw3jXrp659e34ZLn w0KN/NWJV5SGJOxRnWoRhRhYAhMY/XvCehb5qzPDhV9mEc8Phd/WytnG1XOssDmBI4DR Rt+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RPkxmalK; 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 i17si24675969edv.516.2021.07.19.18.59.03; Mon, 19 Jul 2021 18:59:26 -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=RPkxmalK; 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 S235563AbhGSPnB (ORCPT + 99 others); Mon, 19 Jul 2021 11:43:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345171AbhGSPAO (ORCPT ); Mon, 19 Jul 2021 11:00:14 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D36C0C076B96 for ; Mon, 19 Jul 2021 07:53:31 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id jx7-20020a17090b46c7b02901757deaf2c8so233356pjb.0 for ; Mon, 19 Jul 2021 08:22:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=nvVob/r6aogoYIZPXj3xzusDgNE755/gn+vTBsW74ko=; b=RPkxmalK9O2x0tnnD63jkQ1EtIKZ7h7qqYU1CHCCSAGuud+0tDc03Qr561ZcB5P9ta 2i8hidiCj9YuDDEdqXR0gC7n6pTh3IUhO3eVZDyvfto9Eid4HrFpJXOq8aFNPJgG+mwz azvJJGUa2Pfrv5LcWY1YOomimuhASWz7l7EpGEAqAWPABmrfMp6faOb/srC4ebwnVsAr twPOayf0xMmviobC7ygj+yLp6qTlIjxnnGKioeszevYnlzo426CbaAt8XiMadYSYofdf SoMCq8OVfL9vUPLxBisBbGzNysqPInMIx8DJXVOASFjBIeasi1SA68zz03NxNHneuSG4 sqiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=nvVob/r6aogoYIZPXj3xzusDgNE755/gn+vTBsW74ko=; b=ZNqNhXbavuN3x4NnHbZjFBFz3KEEYcOUpyr12IWgcnDiEU10zhkGw3EJZqiCWXzMQB cBbrGOOBN4RRNSwxM7BUVAnHfiHCO6uNq7lz9o2eCYwZg+QTo+NMQ76rS7AawNjJnFjq OPKGbqckAy2KYn6Rfj1C4vrgKixClUBbgNFiUHoO9mue9SWnuvoYHhr212EGWaWX73K1 Px6iNsrme6YMbnmjXQEFgbOS/75Q1DzDKmAXWSvKGftoYU8WtJW66giU0LKaBMbjQzv8 a8mtzRnKOOA1G5ktkhvSK7PlBx99GDaMDa9fmnuZn5by1N0DOyvwMdD/iUe0uBZmduAr CuFw== X-Gm-Message-State: AOAM532cbxGNrMkEl82JQHewQYnuMy5NhkckWNt0Qcll0XyslYOCS7P4 UenaElgjcOaQ0B9qZ5uO6saXzyXMdPM= X-Received: by 2002:a17:90b:2112:: with SMTP id kz18mr30847210pjb.137.1626708161753; Mon, 19 Jul 2021 08:22:41 -0700 (PDT) Received: from [192.168.1.153] (M106072041033.v4.enabler.ne.jp. [106.72.41.33]) by smtp.gmail.com with ESMTPSA id w145sm9410903pfc.39.2021.07.19.08.22.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 Jul 2021 08:22:41 -0700 (PDT) Subject: Re: [PATCH v4 1/1] riscv: __asm_copy_to-from_user: Optimize unaligned memory access and pipeline stall To: Geert Uytterhoeven Cc: Palmer Dabbelt , Guenter Roeck , Qiu Wenbo , Paul Walmsley , Albert Ou , linux-riscv , Linux Kernel Mailing List References: <5e1b5d90-5a1e-5e9f-7b92-6c53b8589c2a@gmail.com> From: Akira Tsukamoto Message-ID: <97ee158e-0fe8-cd7a-6ee2-35f9018838de@gmail.com> Date: Tue, 20 Jul 2021 00:22:37 +0900 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.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 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 > 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 > > 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 > [] walk_stackframe+0x11c/0x13c > [] dump_backtrace+0x2c/0x3c > [] show_stack+0x44/0x5c > [] dump_stack_lvl+0x2c/0x40 > [] dump_stack+0x1c/0x2c > [] panic+0x13c/0x330 > [] do_exit+0x830/0x8b8 > [] do_group_exit+0x40/0xac > [] __wake_up_parent+0x0/0x34 > [] 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 >