Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1628398rdb; Sat, 2 Dec 2023 03:41:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IHVNvu3cjyDtnrod0uUDQOsHe6JVs9bvrsUQCjf0ZnYBc95GLfwYnrtTRHEmv+ykaHUAnza X-Received: by 2002:a05:6359:3117:b0:170:17eb:2051 with SMTP id rh23-20020a056359311700b0017017eb2051mr758689rwb.58.1701517298918; Sat, 02 Dec 2023 03:41:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701517298; cv=none; d=google.com; s=arc-20160816; b=VLTNRvImf+xseuy8/xd7Tlm11aPvxm+Wa/o5YSPoEiVi3NZg3OtpUn6NJdMkSPguN7 XhOzU+iiwYEfBzB2dHAVv+F8cZ8MHYhUK+Ky1Hv/LTxXEyzQQejENf8M0eiqbhp/br5H NEP2maXQaT+Zn5jXE4nPMNdPsb24rVoC3pPOzuS1EUaf6V/DSH+GZ2fVRiH/jJapwBtY Q4kxi5x6M7Fe2E2sOdt8QjNxMaGuQUIC4y5oZoIF9P3NkoPXiDq5ELCht67hlnMTfcwf KYQd81XtdPlABFXfG9NhLnHbGm2tYw04r9NoX52uPf2N6OCokBMbrEP1yx4iy4SIy0JC J22g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ZEPyiPZgv+Up1fs+8TsxAlQ9nRWFYVup4drEOONtrrQ=; fh=srb/EijQIrMEdOeqn3qQX6qrsAGyqHAqeSFkl/qDdLM=; b=uqIaaMyQCvZZ1zAIzN0YrzTJCqp+QR3e1GYJOhZhBPCsF/Naw8200neXqEgL15hcE7 ceMjQaF1NGLqH+zMEqjy99SRxaGOhC6gUflt3RdmtYhy4X90JSccgR/+OQhIfcHgpna1 Tl/1ovTnfWU5OkhhQ7EGvww5xqr9/CnG4i0gHLmBczPgWJy2rcDvaUk1r+TY1lOfQZtH 7RQMK9xcr21qHwe7Aai1p7R4pS/iDSYWToP2QCHjs2uaZbq7/pJQD4tiQJnSE+/U5FOR rZ6lN8jFgMqEOYzqiTzpuG+nOb6G4RqvSyi0oYkqawofYPDJvyA/ddIRamUrX7Umqhcg x0Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XxP7NmO7; 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 f3-20020a17090a700300b0028665a20c0asi1365487pjk.4.2023.12.02.03.41.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Dec 2023 03:41:38 -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=XxP7NmO7; 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 4C28E8077570; Sat, 2 Dec 2023 03:41:02 -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 S232576AbjLBLkk (ORCPT + 99 others); Sat, 2 Dec 2023 06:40:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbjLBLki (ORCPT ); Sat, 2 Dec 2023 06:40:38 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B82218C for ; Sat, 2 Dec 2023 03:40:42 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2E4CC433C9; Sat, 2 Dec 2023 11:40:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701517241; bh=DaUNBnJudQtx/0ecN0kp9sHu1Y4tp3r/amh8XiErTXw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XxP7NmO7pW5CZG2wIqTdiWAbz/p7Cb69Elg+6qaP8cxRpDnbg7ygo36gqVDhTE1K/ 9ky2d7U5rmERCih5gsM/OV7/Euy7yG9zru8jDb1Wo8AaCAmx16YQ8OWUrgYiZbRZU2 j3+lowrobiVTpvQ2b6+uTV66aCyeHH+QBwj9f/5P350NydZGYMw+Zqj8RrAblu9VK9 5QbS1cVL3ev75+j1EMolBAA/CKFvjCSTTpRLmXILv7TSu/sdW4GQJdCU2fgWr+hTQd frwOzSl7jv2TwAURI820vGSlC+0FQ9hxApvrrEHa/s+BsP9WMC1YSfh+TShW4XOF4M ZdQ7qFC8qFLAw== Date: Sat, 2 Dec 2023 19:28:10 +0800 From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/2] riscv: enable EFFICIENT_UNALIGNED_ACCESS and DCACHE_WORD_ACCESS Message-ID: References: <20231202111822.3569-1-jszhang@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20231202111822.3569-1-jszhang@kernel.org> X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,PDS_BTC_ID, PDS_BTC_MSGID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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]); Sat, 02 Dec 2023 03:41:02 -0800 (PST) On Sat, Dec 02, 2023 at 07:18:20PM +0800, Jisheng Zhang wrote: > 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. Adding something as below here can make the series more clear: 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 should enable it. typo: s/should/shouldn't > > 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 > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv