Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2183143rdb; Sun, 3 Dec 2023 06:10:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IHG7SmEnepIIRlwMcEPKA+8tDy+DJ+2nKNi084AtqKRBTHt/qxIE6OoNneBMCF/8+XLhnrK X-Received: by 2002:a05:6a00:338d:b0:6ce:4a11:597d with SMTP id cm13-20020a056a00338d00b006ce4a11597dmr113887pfb.65.1701612637449; Sun, 03 Dec 2023 06:10:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701612637; cv=none; d=google.com; s=arc-20160816; b=hLAXDHCnA1g3F9qlzg1oi/c5x04EKUts2NQt6tGgRPTFUUJIrubjMuQDNVk8f9mMo1 Am0r4ZFeJJhYrPKAv7ZPsUA6c2M+aJZEIVuLwbfLSYZ2TaGi6EHhGEm9A3smMDBbeSAn NF4vrWg3DtvhO31U3kw3hR1zMBgwGaJgDiV6MSsmsRyl63o1IIbk4anMVsAZbkPXeu6+ Rs45mptQ1D6FWnhsVAK5AuWuiRct8k03n2XaTAXtRDy0wgtB7bErJosAJedsE7b5bjoe e9CbVGKxbiBijgvev85NTNIAXUpvafp/pg5tW5+P+IwEEq1aQvm/nZYisZ9JgAMKRYnc yDRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=AliS+LaGiG3oagDmwXXWunJQ3nV/Hzar5oUleO73tb0=; fh=T0ryW5OP96DN4wdflsGGxk+zhVda+4hODT08VkNo2Z0=; b=0y918Y1Qu7DyRBX4vL1FnM3zYGmdPvU2bvxqn60xoc2bRiRhmGpNQXe84wwW+b3fQT 20f/xUN/ZyT5DbNEMMj4teezopaBTqIApmnYR0AjEy2fdw6gwt2bTmxzMjMkFq3yXRkI 2kX4hP9p49MGkMRMDGOuLqN7wx6w1+yWmA366k2qlPAIFSszEfPFMLMgu7BEwcG80PV2 jws5E6iD02l7+u4AbU3A5SCq0Tpc7OoJulAYy0h3Syze1FZrG+rcNNbw7s3Wlvly2edF /Ts/AHjANLmRQNbfDGVAaAQ/pZvnLidjlidNUtK2+aMwGRuHIraVUxXXZwmTgoWytwBa 8SHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sglyprX5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id j24-20020a63cf18000000b005c1ce3c9628si6182863pgg.752.2023.12.03.06.10.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 06:10:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sglyprX5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 6F165806A100; Sun, 3 Dec 2023 06:10:36 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233536AbjLCOKX (ORCPT + 99 others); Sun, 3 Dec 2023 09:10:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjLCOKV (ORCPT ); Sun, 3 Dec 2023 09:10:21 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C3DA90 for ; Sun, 3 Dec 2023 06:10:28 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F48BC433C9; Sun, 3 Dec 2023 14:10:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701612627; bh=QZ+9c3MhqDU0C1Ei9+Fc5gRRLMVSExYSRe6oAlwtRlM=; h=From:To:Cc:Subject:Date:From; b=sglyprX5e81KPNAgEajlkRuYjgMk4GCbCkUVSK6gfxEzfdj9KE/RvF/zYZqgLpRe/ GB3E565v+J9TjzAIgE66mkD9YNMIi7wvJylmWf8SzsYqMpPetVyxDErovpepry7G9f jZvuDMzTz1oIZdrLGIkJa6L3n5a+O47WqNTg5dRbeN5WJSLq8TjFn9Y8uWSCDyfgvh geZSbBmGWVPpYZpjxQ11SXyRwQLIvK7zTDAXfi876Mk+EA6LIOVT8ZKkSXGJspJvU7 MDg02EBgqozaU0OZd8mOe24EDDUxykxUrsrYUU0v8A6L/+VIzEjvolKaTRIBo46YKq 7P4MW0OkXmXZg== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: Conor Dooley , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 0/2] riscv: enable EFFICIENT_UNALIGNED_ACCESS and DCACHE_WORD_ACCESS Date: Sun, 3 Dec 2023 21:57:51 +0800 Message-Id: <20231203135753.1575-1-jszhang@kernel.org> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,PDS_BTC_ID, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 03 Dec 2023 06:10:36 -0800 (PST) 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 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 | 13 +++++++++++ arch/riscv/include/asm/asm-extable.h | 15 ++++++++++++ arch/riscv/include/asm/word-at-a-time.h | 27 +++++++++++++++++++++ arch/riscv/mm/extable.c | 31 +++++++++++++++++++++++++ 4 files changed, 86 insertions(+) -- 2.42.0