Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp58435lql; Fri, 12 Apr 2024 03:49:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVibz/oeUkTIS/zl2E+sHmcjQFGKLfx7xRQXN7sASD66D2UX1u/72a0q+XJkr4ksS0f2A4dhhBfZk9YWMosIFaUEziD8GwYfTtP8i/VwQ== X-Google-Smtp-Source: AGHT+IEENVglX9Z/PN+Idj6qajQMrYZlhr+OPwrbhjuQNBipjDkmkZB+NrJnZmhCfSXufFqSqpLU X-Received: by 2002:a05:6870:2888:b0:22d:f83e:1971 with SMTP id gy8-20020a056870288800b0022df83e1971mr2159941oab.48.1712918972913; Fri, 12 Apr 2024 03:49:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712918972; cv=pass; d=google.com; s=arc-20160816; b=s1P/dK6JY1YVWTi3s+QwVOgf+vcSXIBov/eJ5fdQf6HQ/soOvYY5xMfeIQzdH0izh9 nioRdWRzLLpFeuEQYdWt4lM8V0BHew2fipVeD4gHv+zcvd9mL9qqwzl3rSMOqZ/Ro2iJ KY5amv48wrDwB7kjeojS6N73FO3cyyiEbz0TsjwocePKLXxDgdig5RQ9jaF1Z4n2ICUj gLrI7go4L9ZfIqA9S808s6GYqJHBwjOYORaTfjur9tkF/FgASR15H5EXUmqelnmMtygz 5QcLWMpLl+WVdNqxzFzW2U+aVLrh/s/mvfPR1CQh8ng0vHWjhmwHxQM5imQZploW85u3 nvDQ== 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=h+mBQM73uBaO83UO8Va0ZjUWBzHY+YU0XnmUu0n2wxs=; fh=4jyGPlIgBC+cOBl2betKVRRu896Cfe1VEzAQNc3FCOU=; b=qGu98p3dFMIf7uEFr36gmhV5siFAFuu5zOLVFpr4yTQ5l2QplyOamXSeRXEGMRFsU0 13IfKBWxaIj6YigCLH6Xa0W3c1OYZz5+etjBRpU1I8laX+KkHlJUZdbUH5wM9zOjeGog hB0ijATtthRd8j/sJkD3Ablxfp45CokmjeqDd+hv8mWfU/Urir4c6ZyqnWWryAyg4uW4 7ps6G4OpVky/w64E4e7kpEvspMz1g+c5tVGUIs8O4JmNpBcAlu9Isn6ZG5j3LfYYmmtm NY56gagT6ODQgcwRccMuJqF/DmgRqxpmSQGapRUDl/1A7CNA/K83F6hvgPurA/S/uiAA tuzg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=GJNxqNCO; arc=pass (i=1 spf=pass spfdomain=microchip.com dkim=pass dkdomain=microchip.com dmarc=pass fromdomain=microchip.com); spf=pass (google.com: domain of linux-kernel+bounces-142517-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142517-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microchip.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id fx1-20020a056a00820100b006ecbe857186si3072218pfb.242.2024.04.12.03.49.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 03:49:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142517-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=GJNxqNCO; arc=pass (i=1 spf=pass spfdomain=microchip.com dkim=pass dkdomain=microchip.com dmarc=pass fromdomain=microchip.com); spf=pass (google.com: domain of linux-kernel+bounces-142517-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142517-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microchip.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 3A024B21A02 for ; Fri, 12 Apr 2024 10:42:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 845B141744; Fri, 12 Apr 2024 10:42:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="GJNxqNCO" Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) (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 A704C20310; Fri, 12 Apr 2024 10:42:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.153.233 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712918526; cv=none; b=MJsbeDvxaVokNh5XDiiZyAX8Gdzbvbjuo0fZy9JU188lc+DDNT6rtmjA8vaFDw0FKlWpEcKDjdGBGyWelybFU/xVgBVsi+HSn16HnRmkrw67KcI6t+lhqUr1aeZiSewcQxq5E+ZhRAhSHSCpR9Yi41gwy7aYUz+Yhv0O3reEc2k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712918526; c=relaxed/simple; bh=X/p/ft+IL0tus7dW1yBsZJutmsAr0uojLmY1LWYjZes=; h=Date:From:To:CC:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CjSykpl8DynrJekHBiF5mbdmqpEl5mQuy3E3XppnrYIJcl4A2svqfZVBlpLc+RRLOJOylx5eh02d20Sc8461yfTrQSpHMLrxUboP8F35MmOZRE/ppXiVE0ivFtfyHW3fSEGKQLt8pmC4gLgVfdEGg4+081KwK6WWfHPF9CDcVBY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=GJNxqNCO; arc=none smtp.client-ip=68.232.153.233 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1712918524; x=1744454524; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=X/p/ft+IL0tus7dW1yBsZJutmsAr0uojLmY1LWYjZes=; b=GJNxqNCOgW14345HFh2W//scsLVA5YXzVszRvY5ns/CCFepjKdJ2fyK4 jRN00EWC47Y3OQcvTDu++GS0E8OQ+q9Z3uMa789dHSCLAGi7YQsZ06ndy kbljM56PtNzPcdVWhf9d4xxkXsJf4IiyCexleQhs59Ava6+UG8KhfDTnN gKR8+7m9oG09u/RZx1gfEbYy/d2VrYOzvg81llx8IOwLaz6pgesBLKxKW hupzj1RqqWVDusfd2C9vJFZ6eg1D+ZkHBO+D1mKFiAHZW0QDNfortM35R jbbkEhrwBcNanlSikW/7BvC+yrSjynU2t/eSvFy2NXHALA3nlec62dlhk g==; X-CSE-ConnectionGUID: tAWyHYMtQVGntX8nk/B7jA== X-CSE-MsgGUID: 13SAqUUaRYm44u3/FKnbdQ== X-IronPort-AV: E=Sophos;i="6.07,195,1708412400"; d="asc'?scan'208";a="20728192" X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 12 Apr 2024 03:42:02 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 12 Apr 2024 03:41:33 -0700 Received: from wendy (10.10.85.11) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Fri, 12 Apr 2024 03:41:29 -0700 Date: Fri, 12 Apr 2024 11:40:38 +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 , , , , Palmer Dabbelt , , , , Subject: Re: [PATCH 07/19] riscv: Optimize riscv_cpu_isa_extension_(un)likely() Message-ID: <20240412-aerosol-heritage-cec1eca172fb@wendy> 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> 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="YUt35LWoARaS+0kq" Content-Disposition: inline In-Reply-To: <20240411-dev-charlie-support_thead_vector_6_9-v1-7-4af9815ec746@rivosinc.com> --YUt35LWoARaS+0kq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 > --- > static __always_inline bool riscv_cpu_has_extension_unlikely(int cpu, co= nst unsigned long ext) > { > - if (IS_ENABLED(CONFIG_RISCV_ALTERNATIVE) && riscv_has_extension_unlikel= y(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_unlik= ely_alternatives(ext)) > + return true; > + else > + return __riscv_isa_extension_available(hart_isa[cpu].isa, ext); > } static __always_inline bool riscv_cpu_has_extension_likely(int cpu, const u= nsigned long ext) { if (IS_ENABLED(CONFIG_RISCV_ALTERNATIVE) && riscv_has_extension_likely(ext= )) return true; return __riscv_isa_extension_available(hart_isa[cpu].isa, ext); } 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? Thanks, Conor. --YUt35LWoARaS+0kq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZhkPpgAKCRB4tDGHoIJi 0gSNAQC+oMqT7zoEL9RxUhkl7uImpatcHajgjd6QJ8PnV2xTcgD/YMRe1XytJnd7 9pJBNiy2EcDN51fcQvf7s4vI9GM9Awc= =Tq3D -----END PGP SIGNATURE----- --YUt35LWoARaS+0kq--