Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2183674rdb; Sun, 3 Dec 2023 06:11:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IFofzISY3Maag0nJZcMr8/hJMSY4SzUKO5l2GdJAkeWTQVUFEjyBDRR99qm42flB2UUGdiO X-Received: by 2002:a17:902:d5cb:b0:1d0:5806:f45d with SMTP id g11-20020a170902d5cb00b001d05806f45dmr2316970plh.42.1701612697467; Sun, 03 Dec 2023 06:11:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701612697; cv=none; d=google.com; s=arc-20160816; b=rq5jLJreJ8xSldYcAto814Bi0bHgt/toNapJ8ONKVGqufGIp/UnW1zfWtUoiPFmLTr HhseB6EAxRWenENCtPMU52hWEjd2WXiFSXTndj2SISMDQVzs7SRkBRh15ZwzGLRUCxJN R6ZkGZL4Yfdndg3bGtoh3qiaHov+53rt1kefJVeo8x7C1yjw9UtnJ0Xaans+WVLvSE1H He2KH81WWOcvhlyQmi/OUflPHL+Ntxpsmojwz6yth9eBXWwq2UHoH6yNN2b7uQaN0Fb/ +Ggfpdwo2j5d0PbRxdS4QBnMVd+WptbbkNvkHct51UtGKG1v7abVDwFKBSCIYEAyQlKV wHzA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pM3mloQEKJXb/dbTzSC+E9l8uluaB/D7G6g9O4S1U8E=; fh=T0ryW5OP96DN4wdflsGGxk+zhVda+4hODT08VkNo2Z0=; b=BUFgtaBb9EAf7TvU17CxFIv72xa4z0F1yIUapYRtxjHVMGBOeLHfYDAbmOlGDT7j4x szq+Kiwt6TEhUS32bHtD7hywg9WlVqzJI2AeJ7Pz2+7QOdV0SA9spqawXm9V1SuNmO4A 94fc8Zmo8bFJo8dmBisj+gy6s+J/LeOHjOpoZcwS+Dux2H3iQoVIMX1quYv7uT3PdeZk SKeflDiB+LKqAqLlNCviEgJ+9szd5Vrrojl4+rD4+knsZnWQSxvrwTZ9LJL0O8AKY0gQ HKIHfWHecAN97wIWLYJrLeCPPH9IJchBDABVjzmYNWNrDK2ji1EBr/v2a0iwKVebLtWs +4vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="NbWzBVf/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id u3-20020a170902e5c300b001cfd4eb4deasi1208671plf.357.2023.12.03.06.11.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 06:11:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="NbWzBVf/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 3A733807BA3F; Sun, 3 Dec 2023 06:10:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233554AbjLCOKY (ORCPT + 99 others); Sun, 3 Dec 2023 09:10:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233549AbjLCOKX (ORCPT ); Sun, 3 Dec 2023 09:10:23 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 091DF90 for ; Sun, 3 Dec 2023 06:10:30 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51C66C433CA; Sun, 3 Dec 2023 14:10:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701612629; bh=c3VWF+YhQlWgynBzGD9ffKWLf/aMfGwEbNyjhdaRP3E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NbWzBVf/UR4yv5Cp0G8WhSSQ384ppzLv/5r701R/0c1MD0woHqROVMOeNzp4L99/Q CXlzhCeO6GssHUvSmheVJtYG0DxrkMlPSppERq60obNeK01/kpaAOY3lZlF/2yR2+d RSPiLMVRa/WoaC5jwyiwY+G7boSPOrhzNyYzaavFVC1U8A3nSyHy61q429QY63KQSf aSl3DCLDORHSFU+P3LdEOYOKV20PTRv26H1bPIx57US5oeDPcbc3Wwn3iYkP57YSeE DWKJaIvCsnMvPkeoveRRzz8hMAUba1Z8HvQO7W8vf7HjepMKfUACJn/IkgXH0Q9Ihn hi4xaCGUZvjGg== 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 1/2] riscv: introduce RISCV_EFFICIENT_UNALIGNED_ACCESS Date: Sun, 3 Dec 2023 21:57:52 +0800 Message-Id: <20231203135753.1575-2-jszhang@kernel.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20231203135753.1575-1-jszhang@kernel.org> References: <20231203135753.1575-1-jszhang@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, 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 groat.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 (groat.vger.email [0.0.0.0]); Sun, 03 Dec 2023 06:10:48 -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 other 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. Now let's introduce 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. Signed-off-by: Jisheng Zhang --- arch/riscv/Kconfig | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 7f8aa25457ba..0a76209e9b02 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -654,6 +654,18 @@ config RISCV_MISALIGNED load/store for both kernel and userspace. When disable, misaligned accesses will generate SIGBUS in userspace and panic in kernel. +config RISCV_EFFICIENT_UNALIGNED_ACCESS + bool "Use unaligned access for some functions" + depends on NONPORTABLE + select HAVE_EFFICIENT_UNALIGNED_ACCESS + default n + help + Say Y here if you want the kernel only run on hardware platforms which + support efficient unaligned access, then unaligned access will be used + in some functions for optimized performance. + + If unsure what to do here, say N. + endmenu # "Platform type" menu "Kernel features" -- 2.42.0