Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp1456147rwp; Thu, 13 Jul 2023 11:05:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlHs57iLT6aufDMa2D8gp7+h/JMObPF7A82NrzS+lAJUEjND++QfO5H09uuxzoixC0g6/El8 X-Received: by 2002:a05:6a00:2e12:b0:67a:9208:87a with SMTP id fc18-20020a056a002e1200b0067a9208087amr2046597pfb.23.1689271546683; Thu, 13 Jul 2023 11:05:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689271546; cv=none; d=google.com; s=arc-20160816; b=WZ7j2dMX0HX86IqhS1lmsUYtW/3FeOMQ6Ha8BLSlhVw+zLVdMFxqTqOh0/s3uZP65N cjR4XJRXzLGV2vdJx3VrNryV2Apad0YpdDEycwmxLEgUVQCUyr8HpZC6K2G1EpStZQmc 7qIvp3RG+1ERl3OrMSEytnEItfrwma/ESRayQaBI3wXjm4kpkVm3Ig2WVqWi9MCt16SR Mr4ubZ9bRRiuL6QhAlMIpuADndNJsl1ccpGp0Lgh9iv0Ei0f9noSYzQorJUM2lXuJ2q/ WKC+zNDVSMB2cLfIMKossy31LJjojbhYAIvn0HMpIkN/BqEWBLAWrnksPFFqtrfcyjQU U8gQ== 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=jZ5gtfAYSfqHQsDa4Wqnb/So2D35lVkiQo1+rrEoAJ4=; fh=bxIwKt5pzhQQ8zjZYqI4rgD46fzCuJVfAA1OllGtcYQ=; b=r8DdhG3DAWoELsQU0v5j4fRhjLuQ/pB0YIxTn/++doEY02ETxY0cewJb9DR5ZTMIRn axfRNio6cdKZ58Sxnxy46IZ4ov+Mvd3NvEyqblOeLuldptQsu/HX2hVYXbKuXvUvNnex zVXOidymTD9WKO9rmf231kOKJlwhEpyfYauvzi2kRHJyJzdVrS87dIyxeLVM70WdAH3u VYBB+YbANSUK2e+N9ZiG43uPsdUD0KOD6/ZbEZZqX4N/42/nSd0H4Ufno1OD/I+0X+O1 wRwhdC5yI2Zfa9BmNhbVsMfYCl/eoEmorLRpjjmI7eX1AHQQ5xpv18atwd7iF2tkszn/ Qeqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hVQNPNoj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bq26-20020a056a000e1a00b00677a07fe4afsi5308796pfb.49.2023.07.13.11.05.33; Thu, 13 Jul 2023 11:05:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hVQNPNoj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232353AbjGMRVs (ORCPT + 99 others); Thu, 13 Jul 2023 13:21:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232670AbjGMRVp (ORCPT ); Thu, 13 Jul 2023 13:21:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BF652713; Thu, 13 Jul 2023 10:21:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 168FF61B06; Thu, 13 Jul 2023 17:21:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C50D3C433C7; Thu, 13 Jul 2023 17:21:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689268902; bh=N5E85XLHguq9VMc/lAhtUJwkW3CfjKC0ALqOBx9bMbY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hVQNPNojdWrmzo6Ws5YJFrydp9YnkwF629nYyfq57wdCnDCNI8dOl1RC3K38p0H4y WHKBjofujR4xjmcUU4ofhjcrHMGZUj0RVA8h6M/eQaxtutrt/xFVQ2gu26sBpiCTBc peb+7RTNskFXqx9r1PCfAY4q2N6dNrzxENjnUcUcg8BR6k8Be8bRH8qkAfuuCsf+a9 KkrD2zqfIOB6JWABjaDluHWSmhdgcJ0/ZpsxMhUB3ya2HfHnGPuCRlpYiIu6K8txqB MSb0g3SpeCEb8NCaDDug7+v/2iEmlNltKLC+FK23sKeu+2ugL4BQ9l83nML24G1eML /b3O7/cFKfuLw== Date: Thu, 13 Jul 2023 18:21:35 +0100 From: Conor Dooley To: Evan Green Cc: Palmer Dabbelt , linux-doc@vger.kernel.org, Yangyu Chen , Conor Dooley , Guo Ren , Jisheng Zhang , linux-riscv@lists.infradead.org, Jonathan Corbet , Xianting Tian , Marc Zyngier , Masahiro Yamada , Greentime Hu , Simon Hosie , Li Zhengyu , Albert Ou , Alexandre Ghiti , Paul Walmsley , Heiko Stuebner , Anup Patel , linux-kernel@vger.kernel.org, David Laight , Palmer Dabbelt , Andy Chiu , Andrew Jones Subject: Re: [PATCH v2 1/2] RISC-V: Probe for unaligned access speed Message-ID: <20230713-unaligned-engaging-af88fa5fd9c8@spud> References: <20230705164833.995516-1-evan@rivosinc.com> <20230705164833.995516-2-evan@rivosinc.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="fnLwWuReRbJ6hyE9" Content-Disposition: inline In-Reply-To: <20230705164833.995516-2-evan@rivosinc.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 --fnLwWuReRbJ6hyE9 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 05, 2023 at 09:48:32AM -0700, Evan Green wrote: I got kinda mad about the whole Zicclsm thing, so I decided to take a bit before reading the words "aligned access" again. > diff --git a/Documentation/riscv/hwprobe.rst b/Documentation/riscv/hwprob= e.rst > index 19165ebd82ba..88d7d64ec0bd 100644 > --- a/Documentation/riscv/hwprobe.rst > +++ b/Documentation/riscv/hwprobe.rst > @@ -87,13 +87,12 @@ The following keys are defined: > emulated via software, either in or below the kernel. These accesse= s are > always extremely slow. > =20 > - * :c:macro:`RISCV_HWPROBE_MISALIGNED_SLOW`: Misaligned accesses are su= pported > - in hardware, but are slower than the cooresponding aligned accesses > - sequences. > + * :c:macro:`RISCV_HWPROBE_MISALIGNED_SLOW`: Misaligned accesses are sl= ower > + than equivalent byte accesses. Misaligned accesses may be supported > + directly in hardware, or trapped and emulated by software. > =20 > - * :c:macro:`RISCV_HWPROBE_MISALIGNED_FAST`: Misaligned accesses are su= pported > - in hardware and are faster than the cooresponding aligned accesses > - sequences. > + * :c:macro:`RISCV_HWPROBE_MISALIGNED_FAST`: Misaligned accesses are fa= ster > + than equivalent byte accesses. The indent here for line #2 looks odd. Is that an artifact of the patch? > diff --git a/arch/riscv/kernel/copy-unaligned.h b/arch/riscv/kernel/copy-= unaligned.h > new file mode 100644 > index 000000000000..a4e8b6ad5b6a > --- /dev/null > +++ b/arch/riscv/kernel/copy-unaligned.h > @@ -0,0 +1,13 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* > + * Copyright (C) 2023 Rivos, Inc. > + */ > +#ifndef __RISCV_KERNEL_COPY_UNALIGNED_H > +#define __RISCV_KERNEL_COPY_UNALIGNED_H > + > +#include > + > +void __copy_words_unaligned(void *dst, const void *src, size_t size); > +void __copy_bytes_unaligned(void *dst, const void *src, size_t size); If we are putting this stuff in headers to call into asm, should we prefix it with "riscv", or is __ enough? > +void check_unaligned_access(int cpu) > +{ > + u64 c0, c1; I quite dislike variables like "c0"/"c1", they make things harder to read for no real benefit IMO. Would you mind renaming them? > + u64 word_cycles; > + u64 byte_cycles; > + int ratio; > + unsigned long j0, j1; > + struct page *page; > + void *dst; > + void *src; > + long speed =3D RISCV_HWPROBE_MISALIGNED_SLOW; > +static int check_unaligned_access0(void) > +{ > + check_unaligned_access(0); > + return 0; > +} > +arch_initcall(check_unaligned_access0); Could you please rename this function to match the actual use? So something like s/0/_boot_cpu/? Otherwise, I like the idea & we discussed the semantics last time around and I was happy with them. I don't feel qualified to review the actual speed test, so Acked-by: Conor Dooley --fnLwWuReRbJ6hyE9 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZLAynwAKCRB4tDGHoIJi 0vafAP9QtNqw2kcNrvo8jD3iX3SWjLnnq86q6AS5Xj38aRqJ+gEA41TCD6hkux31 urM+gYjkopnUOvXtpkDrq7fN1NIlcQk= =YmcG -----END PGP SIGNATURE----- --fnLwWuReRbJ6hyE9--