Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp2149800rdb; Sun, 24 Dec 2023 20:54:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IHgSH3iio9Z7hu/qZN+4DAPss9uLVSGuHmgQ49A4Vx7bgZ6VqobSmBu64OslNKCfAiNKw5i X-Received: by 2002:a05:6a20:4290:b0:18f:97c:9768 with SMTP id o16-20020a056a20429000b0018f097c9768mr6988059pzj.80.1703480098540; Sun, 24 Dec 2023 20:54:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703480098; cv=none; d=google.com; s=arc-20160816; b=eNRDBf+4BWWuEUuwe/b5kg3xWackm3wg3PBVjmKRCO5tUvf1PdedsdOKKjs2TAc13B CWAHeH3RD7CKV+Z+ZXZhe2vva6a2stwyigXmC8QyNi8TBFD9ssFqjqJPSFYNHRea0g1y WS9MT4DKuKDtNQ1BRtl1iI258Su4TOfqxCfUtWyenS/oLP2xkMWsmjY+/acDEzE7Bb2k M716n5NdmH50mN7z45V4DXlz8Mvju9j5cLEuJtAWhHzW0kuRRUOl9clAL6F3xPrIeYwp 6TvIX6V6Wlu5uLrg0wWi9SI3bgwCd9sZfhWqisKJJeaCfdbJ8ucVnUK/83Ne/NF1ECMK Q+FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=LA6daKzE9/cg6V/4J1YFnZFJh9BeMAT5H5FPrVgQbUg=; fh=ZTT3Py7m/X4mSvw6SK6+TRZhmqxsZi0TneX42+FLUx4=; b=cFs6EoYnIBbkjBRstKJVQv3uc7hyh1xAWkD8/kbigFl54j4M6hu4Skxk/QB1RNiPQ6 mDS6cNBqA03tdBBnPEn6Jbu/SVUbQo8L0n93oAi1figuFFSam/kzvw6SgX6AQjROq3HZ zZ4CpmMfjBQMo1tzLo6fsUVRrS6fGiedY87KeUJ2KEi53Y6to8zf6lePBa3YyuuRnlIn uGibUfZ5k+mhVSCj9qhvVNcFylISHWjQoYdE5DeUdScVN/FHRKC8lsCsDA/ywInsFN3r 7BGukPzPMtKbuZ6LKxevFZkKbQZiR4uNWhrxHgzoby6laYro764obIsCDoj43jC8LogH 5hmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Qrat2D9m; spf=pass (google.com: domain of linux-kernel+bounces-10891-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10891-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id ch11-20020a056a0208cb00b005ce05265f4asi3167227pgb.854.2023.12.24.20.54.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 20:54:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10891-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Qrat2D9m; spf=pass (google.com: domain of linux-kernel+bounces-10891-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10891-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E39782817A1 for ; Mon, 25 Dec 2023 04:54:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2498D10FE; Mon, 25 Dec 2023 04:54:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Qrat2D9m" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E039EA6 for ; Mon, 25 Dec 2023 04:54:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74E6BC433C7; Mon, 25 Dec 2023 04:54:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703480091; bh=UArUSyBZsPKxLkpUFilgpFD8aka1iX7bL7/0EeJ4W9s=; h=From:To:Cc:Subject:Date:From; b=Qrat2D9mqhj5ram8CGulN/a4AthJQBzq+uzfRUGEqVXSIEIdizPmerD1Gb9BqkX5j yOScpSvVveHperCPxKtZsxuFilvN/6urpCPsJfjdZTndKgpLv72pa3/9tTaDrfvutM Nzu5gTXzT+kiqck1CCNcUEqWq3AV+HIyWsp+2zID73GSrcNmCUeAH0iDwet5KQiJs+ +77xdqrGRHyrPTZZt8KuNkIjRBj/ahjruXT35opTqY58rphamGKD+utB3Bm/EJlNUr OfW4KpJjZWz8zfl4rLRmu+uanCkWxztq3OKLNvol0FDa+ASb4dvwpiMThiFiPWizz6 SPmxwG+W4/eNA== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Eric Biggers , Conor Dooley , Qingfang DENG Subject: [PATCH v4 0/2] riscv: enable EFFICIENT_UNALIGNED_ACCESS and DCACHE_WORD_ACCESS Date: Mon, 25 Dec 2023 12:42:05 +0800 Message-Id: <20231225044207.3821-1-jszhang@kernel.org> X-Mailer: git-send-email 2.40.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Some riscv implementations such as T-HEAD's C906, C908, C910 and C920 support efficient unaligned access, for performance reason we want to enable HAVE_EFFICIENT_UNALIGNED_ACCESS on these platforms. To avoid performance regressions on non efficient unaligned access platforms, HAVE_EFFICIENT_UNALIGNED_ACCESS can't be globally selected. To solve this problem, runtime code patching based on the detected speed is a good solution. But that's not easy, it involves lots of work to modify vairous subsystems such as net, mm, lib and so on. This can be done step by step. So let's take an easier solution: add support to efficient unaligned access and hide the support under NONPORTABLE. patch1 introduces RISCV_EFFICIENT_UNALIGNED_ACCESS which depends on NONPORTABLE, if users know during config time that the kernel will be only run on those efficient unaligned access hw platforms, they can enable it. Obviously, generic unified kernel Image shouldn't enable it. patch2 adds support DCACHE_WORD_ACCESS when MMU and RISCV_EFFICIENT_UNALIGNED_ACCESS. Below test program and step shows how much performance can be improved: $ cat tt.c #include #include #include #define ITERATIONS 1000000 #define PATH "123456781234567812345678123456781" int main(void) { unsigned long i; struct stat buf; for (i = 0; i < ITERATIONS; i++) stat(PATH, &buf); return 0; } $ gcc -O2 tt.c $ touch 123456781234567812345678123456781 $ time ./a.out Per my test on T-HEAD C910 platforms, the above test performance is improved by about 7.5%. Since v3: - adopt Eric's suggestions, such as better Kconfig help msg and so on. Since v2: - Don't set "-mstrict-align" CFLAGS if HAVE_EFFICIENT_UNALIGNED_ACCESS - collect Reviewed-by tag Since v1: - fix typo in commit msg - fix build error if NOMMU Jisheng Zhang (2): riscv: introduce RISCV_EFFICIENT_UNALIGNED_ACCESS riscv: select DCACHE_WORD_ACCESS for efficient unaligned access HW arch/riscv/Kconfig | 14 +++++++++++ arch/riscv/Makefile | 2 ++ arch/riscv/include/asm/asm-extable.h | 15 ++++++++++++ arch/riscv/include/asm/word-at-a-time.h | 27 +++++++++++++++++++++ arch/riscv/mm/extable.c | 31 +++++++++++++++++++++++++ 5 files changed, 89 insertions(+) -- 2.40.0