Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp304938rdb; Tue, 5 Dec 2023 06:06:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IEOsQe/urRxKsTtUFnD2FjSnJbJ8u56HGnDh15U5726wFpnXEDr/EcZT7bmTZzEG4fZVDgf X-Received: by 2002:a05:6a20:7484:b0:18f:97c:b9f9 with SMTP id p4-20020a056a20748400b0018f097cb9f9mr4256033pzd.83.1701785204871; Tue, 05 Dec 2023 06:06:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701785204; cv=none; d=google.com; s=arc-20160816; b=RGlo3q2fFCovLw0mZpDiyGIYPV7cYPdI/bYCPUrCnqRwyUOE9y2PRdra9QnTDiWh9r 6jdhAqHbu+yD9oV/N9WyNNwHLTLVaX8lpVfTTNxQ1kCCD8AP0WL4dHuUZHVOd7J7x3oI h1/MNWUKsTR342RXzVqPiIJ39u0YSK2S1UO6pQvXXUfRBlJZgCsi+H7R8GtNeIx/60S3 vtBgdZSVYBMmsu6u27y19TwgATn7dvgio8fZqJ/rw2PU8IKZB1u5X6x1X/vrAPQIlIcx L1jRLKVAYWBG2AJlG5U3ak6qQSrDi08VlbZMDFmH75C+wUzVIS2ypmnn+0YKTqpkQ6kZ y/FA== 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=sUYC8kN/UsVYXUIyc8M8ACU+LV+YjrsN4pT0yXox+0k=; fh=FLk+SM9TZK0q9GqdkObIWlsxzRA+/XHKqAcI9zIxHQQ=; b=wGfuAJQnMv9P4QAPDecsFlPH3bJukhLhdSVYfvBUbD/iprbjcaKsgdZJL3ymj+cj9i HLunDcDHaU0RaLyKTnxl+anWY7w3ZDYGVS9C+2WuNAB3ozExlpaRYV4V6hkquz0TzFXW 1DdYRUCRVtkgwSgcRzYskpCD0hkm4iWqcmmw+hPk+AgBBGyYsYSOUQpzDHCGcp0Ejo36 eCe5DQBUO+X834U9H6e6alIn7wnsdJBhPvzekTSsxP0DIef1lZ2CQWZD8KF518E+iISx pm3yAv9pWiwT64rnBGtEiACiVQjSWKzRyD+r22YmAtvzzXGuyCLTeVscxoVlOMfH6CGI LqNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SmHmUefI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id t25-20020a056a00139900b006ce5ff97f61si2407674pfg.65.2023.12.05.06.06.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 06:06:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SmHmUefI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id B568A80A68B9; Tue, 5 Dec 2023 06:06:32 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345612AbjLEOGQ (ORCPT + 99 others); Tue, 5 Dec 2023 09:06:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345587AbjLEOGP (ORCPT ); Tue, 5 Dec 2023 09:06:15 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E9D318D for ; Tue, 5 Dec 2023 06:06:21 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E145DC433C8; Tue, 5 Dec 2023 14:06:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701785181; bh=ztrbzYTZQKsvH33tkgl+qwxlT0HfVPRGVJ2xrk1JJVw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SmHmUefIXAFabqnUAvfcofVrTfm2RcsTluAm+Xmw61SuLNhe5yjfdiqa+lU2oaxIc icituGymcVYow/PXPTqTAU2Sqo89b3S0A+JRMA1Jx7l4b/n2Aeww8e2Usc35lDCyac OWDjd7AeeoAgpmfCtRU0yqekStpY1do1ZGxNlPaU+a9+NwwXcVwL61m9/VRLRVGiJs 5XwNg2VDcZMo/+TY+qF2EjH5JAr46unQvCEebQkUgR9i1bq1ISFCza+QbUzPRk6XU1 I82U8TSJlERrTvk7LvGS2LvCt5AeEgbrPjWuEJRXMaAMlcKvJe80r7OUtmJ9Tg7RZr M86gdse7FdLhA== Date: Tue, 5 Dec 2023 21:53:50 +0800 From: Jisheng Zhang To: Eric Biggers Cc: Charlie Jenkins , Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/2] riscv: introduce RISCV_EFFICIENT_UNALIGNED_ACCESS Message-ID: References: <20231203135753.1575-1-jszhang@kernel.org> <20231203135753.1575-2-jszhang@kernel.org> <20231205021406.GD1168@sol.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20231205021406.GD1168@sol.localdomain> 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 pete.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 (pete.vger.email [0.0.0.0]); Tue, 05 Dec 2023 06:06:32 -0800 (PST) On Mon, Dec 04, 2023 at 06:14:06PM -0800, Eric Biggers wrote: > On Mon, Dec 04, 2023 at 11:15:28AM -0800, Charlie Jenkins wrote: > > > 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 > > > > There already exists hwprobe for this purpose. If kernel code wants to > > leverage the efficient unaligned accesses of hardware, it can use static > > keys. I have a patch that will set this static key if the hardware was > > detected to have fast unaligned accesses: > > > > https://lore.kernel.org/linux-riscv/20231117-optimize_checksum-v11-2-7d9d954fe361@rivosinc.com/ > > Is the plan to make the get_unaligned* and put_unaligned* macros expand to code > for both cases, and select between them using a static key? Note that there are > a very large number of callers of these macros in the kernel. And what about > kernel code that checks CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS directly? > > AFAIK, no other Linux architecture supports kernel images where the unaligned > access support is unknown at compile time. It's not clear to me that such an > approach is feasible. A static key can easily be provided, but it's unclear > what code would use it, given that currently lots of kernel code assumes that > unaligned access support is known at compile time. > > Meanwhile, there are people building kernels they know will only be deployed on > systems where unaligned accesses are supported. To me, it seems useful to > provide a kconfig option for them to build a more efficient kernel. Generally, I agree with Eric's above points. Various subsystem such as net, mm, lib and so on have different code path for CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS, while Charlie's patch only touch partial code of arch/riscv, and even if those subsystem maintainers agree with dynamic code patching(I still believe persuading those subsystem maintainers is not easy), that's still a huge task which needs to be done step by step. So before that, we'd better let this series merged and benefit all efficient unaligned access riscv systems. When the huge task is completed, we can remove the config option. Thanks