From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MttpEfVG" 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: devicetree@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--