Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp12733rdb; Mon, 4 Dec 2023 18:14:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IEw63JfYahGsdhUXkhdguFypekgmgpcBs22aSFT0VapSgnlw4AjtMSFJr1KkSj1AMgc5uVx X-Received: by 2002:a05:6a00:1145:b0:6c6:2885:82c7 with SMTP id b5-20020a056a00114500b006c6288582c7mr611153pfm.25.1701742461743; Mon, 04 Dec 2023 18:14:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701742461; cv=none; d=google.com; s=arc-20160816; b=HLxSqA0Ztn9uuy3YuYXCJIijlX3CFcpXlDWR1ByCW0iz2KfkDb1mJBXV7TJitNeSXx MK07EJKQ8I3YxPjUvOMH1zNSfsHIToUV9lddVQ9R2U17fn8ZVnOJeHbQAEvh4Sxa+79i OoapTO0J5l9liPp3OFPhpwzb5KunbG4sq1rcoaYC3D9U+ZMZPXLN6UvPjZzHVoSOrNUX RgOiaVgRCW8t0CcBNZkBQ0rYjPQ2IppMTgDdRxkUH5bRel1dICxpKCeGsdaw46l9u7Rf YBhxDDvqeuPClsvm4L574ASFrPtTq8Jwb8u4A+cmoax9YGHfXX3HlW9ms0TqGz9QvjuP jPYA== 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=AemOSc/t7SflFHsJkJfWExpQdfjeqc40HIwZpxh8WM4=; fh=X+V+pb4flfnVfATlxs7S+AwD26gmnxlpAjEtzo9h1/I=; b=p+vlJBPQmP97PlGO2Nma/4NDnSi/ZYHwc8lwus/ElaSH0W7X6mKhf1fYKWMMyJX/LG 8TBHIQVgm0mpUtCZTXAQs3nFCthe/JZxGbfkmF4zMEiThe+6SF+7dK79rMhRZKbvrpen XQ+EwfH0yntK9+UIrIma2mQfnnar6XmhXs8javiyzFULkKBXZ0poeOUjx4988evY2yQd FwqJWPiK7cWwy/8BeTJuWglNBCaEEbI/RE/G2PwUVvKt2oLqUB7FRJVWIDQj8uxOqfie ASthdbppW3c3VSbrdcvnM0HUg27+49TYv69/oaj7j1uoqc/ypvvNDxvRCZHBDhrkMdh3 IFrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gKx3XjHV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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. [23.128.96.35]) by mx.google.com with ESMTPS id s20-20020a056a0008d400b006be1d2ee8f9si9081388pfu.224.2023.12.04.18.14.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 18:14:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gKx3XjHV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 7D60580A0E18; Mon, 4 Dec 2023 18:14:18 -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 S231565AbjLECOC (ORCPT + 99 others); Mon, 4 Dec 2023 21:14:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229575AbjLECOB (ORCPT ); Mon, 4 Dec 2023 21:14:01 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D782109 for ; Mon, 4 Dec 2023 18:14:08 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC604C433C7; Tue, 5 Dec 2023 02:14:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701742448; bh=Ptz0fJBcWbfsG0oxaIzA0E/svH7JZtCOrjX9y9bQLyM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gKx3XjHV3fTHtX9IMh4wMxd+mVu98af3QIcNrtzqEa3jNUUtHdGghmc6Z2WnBvkgy EuauIQv3c4Q6CIXeFFVtbZqOuirDPCPCxrWOZONK6Hq0mQtvO7ahX7eCydaQOEVKDh 0XdHojXjflQkf+c0CZmhyLW2JAQmza7Php6CpJY+WXUINDPcWYxM+nBrGyTveFFx9s ZPa6/HvB08+sl/dp/NyYdr44vhuwkJo9LfpGKtuzwcXyfsZm+ak9uZyjk2PrPR+vVA 9UIyHsq0OpwPVZd5YweB1/SIvaEAl1eYFVpFpnDORY01+Ffl89IFTmn8K5tecOWH3O DyBqbwOU/D2AQ== Date: Mon, 4 Dec 2023 18:14:06 -0800 From: Eric Biggers To: Charlie Jenkins Cc: Jisheng Zhang , 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: <20231205021406.GD1168@sol.localdomain> References: <20231203135753.1575-1-jszhang@kernel.org> <20231203135753.1575-2-jszhang@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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]); Mon, 04 Dec 2023 18:14:18 -0800 (PST) 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. - Eric