Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp158712lqp; Fri, 12 Apr 2024 13:33:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUGGMct1KJ1qtrJcTF45jgHTbFQepiXLaBffSvUyEo0hp0RqIYVPvZzVMVSMNqPMgyvv1Zl9+GDi6o4zDZFJYGqIKqrSE3xc+YfirV0Gw== X-Google-Smtp-Source: AGHT+IGLKWxrLeVjUPsL1ueoRw4gjzw08N3p5b1YCBFkPZboSwjIuqg2/86eP0KzgnLkW9CVy4vh X-Received: by 2002:ac8:5a42:0:b0:434:8de0:52b2 with SMTP id o2-20020ac85a42000000b004348de052b2mr4638772qta.54.1712954017864; Fri, 12 Apr 2024 13:33:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712954017; cv=pass; d=google.com; s=arc-20160816; b=eMUPlubBLo1d82zM99zBZ3YRVGlaLgoROxHhfkEpT06LWs1EGr4r/gqYhoBxO4hWXT nI8ROY6kJ7CAt8/4TjMvI+U8m/cdHOBg+ZEUfYhMNC+5u1Jb5qg8vNGi4pIunDJdB3FQ rHH5LiNwc4+VI6yQiVI9hzfu0RFXvcZ8lJjg/Ri/gQ1TXhRtxs9jTi+iEezXO/t48nYW 1KxoxKaiHNHCSjtt71RyAN5keEK93ILaLdg/0awH7jy5LZtjCAHnuGNHBGytCz64Hb9Q 8ARFgsJBTnfXe12mEdA5JXDS+/PZViwmSsUuSk0n7tNBM/WVJktW14jrdBN7+dEPONQj +5rA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=o1AaNhHJ5tfwRY5filvCwj7/vP0Y99jQ74xcVxjRBJk=; fh=XSLaAynNYlMwxjwu8OlTnvNj3rXo3qeGVEH++VtEks4=; b=1HKiQh5kgXl1tAlpjdoruvV4JVhgH3+zSui+Q+9QfGm8HnAdvY7rs242zXv+bowTVE 29KuFky6UQzWKQM+R4jJhw5b1+eCEvey75tMEdV/P5wRNBe8hhBkxKlLej+E1JDm5dK8 z1lmeWx6lwkAnsB1PG9u7sRa3/p5mJhD27gDPtLuVKizFwnRH18SWRUQTZjjyE8Rbuh+ dSwTXpocIsZZbhFSVtzKO1daLcCP54/w7KmADST5pT+7KoFKrohsyqeu6gJATGfkHlMr cFbog/foRVHb4NmIX2UP0xLFyu7zDgH/2dHM8qzHpgA93dKo0VMiahjp+UMh3JT5wyZs r7qQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MttpEfVG; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-143314-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143314-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u22-20020ac858d6000000b00432c28a1d5asi4551163qta.150.2024.04.12.13.33.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 13:33:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-143314-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MttpEfVG; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-143314-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143314-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 987951C2147F for ; Fri, 12 Apr 2024 20:33:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 00D0529415; Fri, 12 Apr 2024 20:33:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MttpEfVG" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 104ED21A0A; Fri, 12 Apr 2024 20:33:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712954008; cv=none; b=mvN65wZuPSnWnyP+b/nCRVVm+QA7xN+s9G9vB9D+KzWmf2YEM8nbLWFLMTMhpOUHc4AENHVXYpe0Q4KmvLK+pkzkxtTF0PZZgrD6NhCMq+MmcUD+eGxSZvF/nAbkQR7Zf7iYph47wBe0Cihe1wUAe5IWrZNGXWnd8KQmMelHrNY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712954008; c=relaxed/simple; bh=YQ2UKw4sariCXmZ/qJSMve/BQZtVmS5ZWlzN1dqap/U=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qcR3/p9tSMhorQlM8Tia10LRTu3lZXX6ugEsTCev5kzrdiTudDuF03duIeTyE0p+gJExPwHC7JgVFNtUfrF9wjf4BwH/IFPiHa01eSyQuXcvccG3CKUooi+1UtU8iLKiw40bicArHt8CSpimoGv4sqneCpG7gvQN18+ejQrh+Kw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MttpEfVG; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1358BC113CC; Fri, 12 Apr 2024 20:33:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712954007; bh=YQ2UKw4sariCXmZ/qJSMve/BQZtVmS5ZWlzN1dqap/U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MttpEfVGcroBL6oEWqlTkdnkDxzRW5XoGbAKc5TKuHF+6y4aqdV5ucuP+AYZfTp8K 4ppufqNtlR5eecjFAluraMWcC+Qecd3oZyp0q1OMzyoicslfw+j42bn+Hb08wvM6D3 c1SxAEXs6qciuaK2Dap6U2O9no7Q8n3alWUbLY1kYhvvUkdJxIvfoYqilF9GH4H9dJ AlA2X0ovSlEqhekqJrMx79EqMHop6E7f38aM/aMO1gDCpY4/K2sowDll/jprg7roXl Fq/bZvY+TtrAy/phb4MYb4QstUD5UQeraxz5QuNsIj26skY0pPpO+lWBOaVEKjNrn5 EzJvEl8syoyZQ== Date: Fri, 12 Apr 2024 21:33:20 +0100 From: Conor Dooley To: Charlie Jenkins Cc: Conor Dooley , Rob Herring , Krzysztof Kozlowski , Paul Walmsley , Palmer Dabbelt , Albert Ou , Guo Ren , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Evan Green , =?iso-8859-1?Q?Cl=E9ment_L=E9ger?= , Jonathan Corbet , Shuah Khan , linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH 07/19] riscv: Optimize riscv_cpu_isa_extension_(un)likely() Message-ID: <20240412-eccentric-prune-a19dfc485748@spud> References: <20240411-dev-charlie-support_thead_vector_6_9-v1-0-4af9815ec746@rivosinc.com> <20240411-dev-charlie-support_thead_vector_6_9-v1-7-4af9815ec746@rivosinc.com> <20240412-aerosol-heritage-cec1eca172fb@wendy> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="WYt3sBPHBU50LMpH" Content-Disposition: inline In-Reply-To: --WYt3sBPHBU50LMpH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Apr 12, 2024 at 10:34:28AM -0700, Charlie Jenkins wrote: > On Fri, Apr 12, 2024 at 11:40:38AM +0100, Conor Dooley wrote: > > On Thu, Apr 11, 2024 at 09:11:13PM -0700, Charlie Jenkins wrote: > > > When alternatives are disabled, riscv_cpu_isa_extension_(un)likely() > > > checks if the current cpu supports the selected extension if not all > > > cpus support the extension. It is sufficient to only check if the > > > current cpu supports the extension. > > >=20 > > > The alternatives code to handle if all cpus support an extension is > > > factored out into a new function to support this. > > >=20 > > > Signed-off-by: Charlie Jenkins > > > --- > >=20 > > > static __always_inline bool riscv_cpu_has_extension_unlikely(int cpu= , const unsigned long ext) > > > { > > > - if (IS_ENABLED(CONFIG_RISCV_ALTERNATIVE) && riscv_has_extension_unl= ikely(ext)) > > > - return true; > > > + compiletime_assert(ext < RISCV_ISA_EXT_MAX, > > > + "ext must be < RISCV_ISA_EXT_MAX"); > > > =20 > > > - return __riscv_isa_extension_available(hart_isa[cpu].isa, ext); > > > + if (IS_ENABLED(CONFIG_RISCV_ALTERNATIVE) && __riscv_has_extension_u= nlikely_alternatives(ext)) > > > + return true; > > > + else > > > + return __riscv_isa_extension_available(hart_isa[cpu].isa, ext); > > > } > >=20 > > static __always_inline bool riscv_cpu_has_extension_likely(int cpu, con= st unsigned long ext) > > { > > if (IS_ENABLED(CONFIG_RISCV_ALTERNATIVE) && riscv_has_extension_likely= (ext)) > > return true; > >=20 > > return __riscv_isa_extension_available(hart_isa[cpu].isa, ext); > > } > >=20 > > This is the code as things stand. If alternatives are disabled, the if > > statement becomes if (0 && foo) which will lead to the function call > > getting constant folded away and all you end up with is the call to > > __riscv_isa_extension_available(). Unless I am missing something, I don= 't > > think this patch has any affect? >=20 > Yeah I fumbled this one it appears. I got thrown off by the nested > IS_ENABLED(CONFIG_RISCV_ALTERNATIVE). This patch eliminates the need for > this and maybe can avoid avoid confusion in the future. I think it just creates unneeded functions and can/should be dropped. --WYt3sBPHBU50LMpH Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZhmakAAKCRB4tDGHoIJi 0pbtAP9jkxR3+Jersf36JhdRHz+EJKoRwl2CgWp+9OK6jzrMcQEA+Nbu0mlIiEoV Dsowm8jCIeypptYWv/zWVcIHHTzErgc= =WYNo -----END PGP SIGNATURE----- --WYt3sBPHBU50LMpH--