Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1624958rdb; Sat, 2 Dec 2023 03:32:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IF6QyXQqxGgMgwLph+XOZyxr1u9dEd39rKLfww/nPoOQ8l4LwFr7hw0qiMSd7SktXKwkc8A X-Received: by 2002:a05:6a20:be02:b0:18f:97c:977d with SMTP id ge2-20020a056a20be0200b0018f097c977dmr1249581pzb.101.1701516734297; Sat, 02 Dec 2023 03:32:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701516734; cv=none; d=google.com; s=arc-20160816; b=08HdeTiJRBSw58ziXpYvamRBHOwqsd+ez9ciSVxg352Qtemlpg04AKwpwH9gHNEgct uxFodDsCHvxl7pEmRArekfV0h26KUutZy/zYRCy6ITQznlA9xx7R4wiRt6dtSlP+876S O/PJK23RMQJIIe4B3ltPa3kHO1qBUn9DYrHGKBXTWCM5MhY0UqMoxldU0fsbRHpL0pBZ g6v9uH6dfNQUbvqZbsGIwekPa1gjOwUO5nYpiW4k3TBCPXhA9jiUW7sMUjHrgiYbDerD EoezgaXjtWvDaknqwrmVcVSKN3XeqQBUGOf/S+w2XDotJshMKF9QuGKYKv+gP4RhOpKM Pg2g== 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=7OnPZrLa76Nvz2z9QUWw960dZ7G/jCH4ps8byLVOLl8=; fh=srb/EijQIrMEdOeqn3qQX6qrsAGyqHAqeSFkl/qDdLM=; b=MAUmTlCSkDyy/nmzi5Pru9lwH9zIQ3GBKGNGpYfMRXIIX8JhAtxrrC0ILB9ZcweTTX x0HJC63uDR8EhhLnuXS0kRrEMWMBMABmjqRX6P55XQaHXA3TGItqhJfJ9PKEXGxLMHlq Lo0tyVm+MgQuoOcAhfngvbCkjtY86LTF4bA+Oeaam5D/mjtz+vPEfdsuloKylNrEE3ox v7yQ8KKXpifkl6AFQFXS3nq2MVnz7uff5aPTR0JdtfZvPta2HEFeVW7LQ2SzAqdg2Z6v VvHpKu7cxThZfFpkGV0aeZZgvEJUg1A+znJIhp+y5nGdz4yvVjW50qEnrb+N/w8ZFetq 0jUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PDZS5xOu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id r9-20020a63d909000000b005b95ee3edc6si4856542pgg.628.2023.12.02.03.32.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Dec 2023 03:32:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PDZS5xOu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 1852F803B37A; Sat, 2 Dec 2023 03:32:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232186AbjLBLan (ORCPT + 99 others); Sat, 2 Dec 2023 06:30:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbjLBLam (ORCPT ); Sat, 2 Dec 2023 06:30:42 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EADDF0 for ; Sat, 2 Dec 2023 03:30:48 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E982DC433C7; Sat, 2 Dec 2023 11:30:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701516648; bh=kc94KxJklyWoPHmt6+H5e2NnVhPjnhF/egXD3sMeH9s=; h=From:To:Cc:Subject:Date:From; b=PDZS5xOu5TYmg25XuIj8ahMbd8+EX/4hhB19ehvPVfSP5RtWf5YHBTaNtbbbkkbOB C5AAhIvLt98znugz2CXFtv203fZXZUV4vl7x1TRLuJtMhP7Z292d/Ge5h/Aa5WDkBr 9mLVUhgakh6j5Bb3vHHKzaCiRRo8OUz6+Aezen51F1owVbshgfVTEkMkvHhTCie+aR eei+3mUsX7IvSzOKj982p8RUmPXPT2TYhfF4R4dEu0mVox/0v/DtAK0cVk76ACiOVp DZvFLBkuCYU4pHRglerDUHyvDpLCQO5CfWhe+HxgZ4S9vnddkkWHHAzZDFFn93VzDY t6egOxopVAgug== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 0/2] riscv: enable EFFICIENT_UNALIGNED_ACCESS and DCACHE_WORD_ACCESS Date: Sat, 2 Dec 2023 19:18:20 +0800 Message-Id: <20231202111822.3569-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=-0.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,PDS_BTC_ID, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email 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 (morse.vger.email [0.0.0.0]); Sat, 02 Dec 2023 03:32:12 -0800 (PST) Some riscv implementations such as T-HEAD's C906, C908, C910 and C920 supports efficient unaligned access, for performance reason we want to enable HAVE_EFFICIENT_UNALIGNED_ACCESS on these platforms. To avoid performance regressions on other non efficient unaligned access platforms, HAVE_EFFICIENT_UNALIGNED_ACCESS can't be globaly 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. 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 should 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%. 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 | 23 ++++++++++++++++++ arch/riscv/mm/extable.c | 31 +++++++++++++++++++++++++ 4 files changed, 82 insertions(+) -- 2.42.0