Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80D4BC64EC4 for ; Wed, 22 Feb 2023 09:58:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231566AbjBVJ6v convert rfc822-to-8bit (ORCPT ); Wed, 22 Feb 2023 04:58:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231933AbjBVJ6p (ORCPT ); Wed, 22 Feb 2023 04:58:45 -0500 X-Greylist: delayed 1034 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 22 Feb 2023 01:58:18 PST Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6E9910E9; Wed, 22 Feb 2023 01:58:18 -0800 (PST) Received: from omf18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D58E5140ABD; Wed, 22 Feb 2023 09:40:03 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf18.hostedemail.com (Postfix) with ESMTPA id 320E134; Wed, 22 Feb 2023 09:39:57 +0000 (UTC) Message-ID: <2cf5852092ac5940b8bc6664f54bd6066fe03be2.camel@perches.com> Subject: Re: [PATCH v3 5/7] RISC-V: hwprobe: Support probing of misaligned access performance From: Joe Perches To: Evan Green , Palmer Dabbelt Cc: heiko@sntech.de, Conor Dooley , slewis@rivosinc.com, vineetg@rivosinc.com, Albert Ou , Andrew Bresticker , Andrew Jones , Anup Patel , Atish Patra , Celeste Liu , Conor Dooley , Guo Ren , Jisheng Zhang , Jonathan Corbet , Palmer Dabbelt , Paul Walmsley , Ruizhe Pan , Sunil V L , Tsukasa OI , Xianting Tian , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Date: Wed, 22 Feb 2023 01:39:55 -0800 In-Reply-To: <20230221190858.3159617-6-evan@rivosinc.com> References: <20230221190858.3159617-1-evan@rivosinc.com> <20230221190858.3159617-6-evan@rivosinc.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.44.4 (3.44.4-2.fc36) MIME-Version: 1.0 X-Rspamd-Queue-Id: 320E134 X-Stat-Signature: ybbcoyf11h49p9quu88t1dg4kuty1m1n X-Rspamd-Server: rspamout02 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX1+8kobCdGdcWhmHWOr9mPUUF3sOhp8Kwis= X-HE-Tag: 1677058797-751421 X-HE-Meta: U2FsdGVkX1+UdPFDfaN1hY5zcxQ+HQPvxVKNWYfjZMmIKNJ658qKEWuywkzdpnpyRHDVQTb4ua/dzl8jHTTtRA== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2023-02-21 at 11:08 -0800, Evan Green wrote: > This allows userspace to select various routines to use based on the > performance of misaligned access on the target hardware. [] > diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c [] > @@ -89,11 +94,11 @@ static bool riscv_isa_extension_check(int id) > void __init riscv_fill_hwcap(void) > { > struct device_node *node; > - const char *isa; > + const char *isa, *misaligned; > char print_str[NUM_ALPHA_EXTS + 1]; > int i, j, rc; > unsigned long isa2hwcap[26] = {0}; > - unsigned long hartid; > + unsigned long hartid, cpu; > > isa2hwcap['i' - 'a'] = COMPAT_HWCAP_ISA_I; > isa2hwcap['m' - 'a'] = COMPAT_HWCAP_ISA_M; > @@ -246,6 +251,28 @@ void __init riscv_fill_hwcap(void) > bitmap_copy(riscv_isa, this_isa, RISCV_ISA_EXT_MAX); > else > bitmap_and(riscv_isa, riscv_isa, this_isa, RISCV_ISA_EXT_MAX); > + > + /* > + * Check for the performance of misaligned accesses. > + */ > + cpu = hartid_to_cpuid_map(hartid); > + if (cpu < 0) > + continue; unsigned long can't be less than 0 Likely cpu should be long not unsigned long It seems cpu is rather randomly either int or long. Perhaps standardizing on int would be better.