Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp66224lqp; Fri, 12 Apr 2024 10:34:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWsexcndF4YZ0iKAI1+RK5CjrJRGe6zheGOhkXRlu6+TXgZR6F1BPsevUIAjxo0YWJ7rcgYFx9WDKOjnfeyvBZQHpKzto3FI+6v4sCJAQ== X-Google-Smtp-Source: AGHT+IFgTyJGtQDiw41R6WsijvbNVkKsGYrx9Q2c2CdVP5LEQRwa9gZezepU2cD7VhPG/BHHUiwY X-Received: by 2002:a17:90a:1c97:b0:2a2:4135:5310 with SMTP id t23-20020a17090a1c9700b002a241355310mr3012294pjt.12.1712943282207; Fri, 12 Apr 2024 10:34:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712943282; cv=pass; d=google.com; s=arc-20160816; b=0D0UW6skPdCVytoydfnAa/lvYkEzhOy0LIRzUU6KI7he+vTLV7yCMzCN2hkx9k51SX zgy6aEQ3BbpHBV12FI+4AytSpFv+1NsR99SFlIL999SAaMNBGkefXS/XMFCW861riOIL sdxg9GoQeAepafYiZCqlqFiP0q5FmE7lSxPyJxv/+hkqPeSThOhS+EIYCSmhhg9DIJz9 BvuWi2xZyGoYRqMAPUKeBLJanvHOySjZ73/j4wiPCqmItywtSra4bym0SGGWT0DjDYu0 mozCi7oQwLW3X1PcPr5axXprkacp2gDFFcuUITXDtYd9xvvzP7Y9eyRcz16gFTDltAvW Uk5A== 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=PEydYnVIUiV6lB5t0xe0YqzJX4OVoeUrqtT1X9ALVoM=; fh=YSgJ6ngycLzH5D5o+07TlNnjeZvIaB7jzGvp7vckOWc=; b=sIW49tU/JQJvZ+DVWG7OSjQ6grTf5FHn2nJy6wHsi07JSnAG7+FRc6BIm35OMXT7xx sowDko6Wqba1TqFzjQCyxqj8JvXgjPjgAUwfPQRCkYqL34BCAsOEQwLB9eO7s+mvTktV H2WgCVA0ZGxOEu7w2tyzsK3iKJIVS0i4D5YpuZeKEmvjRcb2nGWnvjiqjTlwDofGZoY1 Sz/RuWwQcwMn6qlCrMD1qxeHbwiSdgdeJ55RDSeUFIVrFNjCzQfOItOsaeY6R30SBJlo evfA72IIThNdPFcAlkqfzFeIYMVQBSaa8FkoYOJb9vkIefg6FS+JQ4btKjNE+A7oXsFu ZCsA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=qvNcdshZ; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-143130-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143130-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id i11-20020a17090ad34b00b002a2414bfdd8si3773325pjx.164.2024.04.12.10.34.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 10:34:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-143130-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=qvNcdshZ; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-143130-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143130-linux.lists.archive=gmail.com@vger.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id BBD70284C37 for ; Fri, 12 Apr 2024 17:34:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4A07B14D6FC; Fri, 12 Apr 2024 17:34:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="qvNcdshZ" Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4ED1214D2BD for ; Fri, 12 Apr 2024 17:34:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712943273; cv=none; b=UksGdxzKlqBNkztojolybrmS7UmRgGU9olbgeWqqT9POPLKvCqTAUIeziqf9AGT91Wj9CQtsNFUAb0lFIbbv+8FxYEeYQ4YJi3WPkdy8sN83GsJ1eahH9+R3y68K/Wt6MsfcCnEgLc07LBwkqiotp2YbxvmF/e6WRC+UfCVEB3g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712943273; c=relaxed/simple; bh=trPSWbts0qeWRZx2qyrUZFaFTVVwg7Cc9kvkrHlL3Yc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=T8mhiujJGYMhDzISmLL16eUqwQA+gdfhVTAf+OsTsAHpLg4NVCLYJV0Qj1e3957qjQzqwe1TSgyZudvplWkT7LYts4VQfFb9yfB0y4mx+41Ss8jeTJV/cyAV9mrY4CN2BDSYz99hV+smrUYDboL7nN/EiebKbiydOI2Kwca6qvE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=qvNcdshZ; arc=none smtp.client-ip=209.85.215.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-5dbf7b74402so753580a12.0 for ; Fri, 12 Apr 2024 10:34:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1712943271; x=1713548071; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=PEydYnVIUiV6lB5t0xe0YqzJX4OVoeUrqtT1X9ALVoM=; b=qvNcdshZoOmLKcj6Hxhn8syXlCyDMdQAZ4X+m5c3xG9coLzT5HEFz7Du7HhJBELiUZ hhPsSnNxlEmbkrtle+3SGyxhiqahYZCu9IfHaqIffV1CBaoogmyG2NJKQVDx/avQN/Yq RcB+RORJSbaTyyAgNkaBGxP4VepCLYccBJZoQhB2i9Nn9ZTyIMBuaaUMImVXPYiGlDXR 8JzSJjyZk/QareLUU0t6AtNAZNBYFWTYS8j5y/LR68DJNPUhTpUy8ZUbWBZzNmCVnhzI bbWSfsfTr+ua76Bcx4wiWxQeHhr6cQmXb26YFW5n3dMFbKpaYbAkC/thhM149Bg9ffN/ LBJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712943271; x=1713548071; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=PEydYnVIUiV6lB5t0xe0YqzJX4OVoeUrqtT1X9ALVoM=; b=k8WIG+RrMklaemVoLszRC2ZeT0kw4Is+SSHH3QmgQeKrBBQgQ2o/0crS5a7WmT0/hY O8+Mx9WWSdIDl60MkcORI9sIxrBqL/t9pG9gDb1Y0nCWCEOaQKAp0sr0jw1ApH4aYqfU W7ijRVQxEQdLH7LhL0ri9N+AJXREFfH61HvxpWnGO9ajNEhXrTZ6r2Qe8R3RDMnzJmUt 24MredMKdr1n0LE84Rn4bgWZqClH53b9cBS7XO+BtD9Dpq+is0R8d8w/zhuTz4TA3IVP EJV9ISFxmd30h6fH61OORsb1CTBY4dsACTAY3R66yURRTeAA2xrwtIdexerPWYfM8YrJ h6Tg== X-Forwarded-Encrypted: i=1; AJvYcCVRhGFijdQWi3DoIeBkTVoObjhHACtCFHojymUUEYOvj1UKVeqHgTFOsNc9+Hm67IWrID1XJ8UciZhYglPH0nQ3dKR9ZA1P2oDuPyi4 X-Gm-Message-State: AOJu0YxHjlB2gLP453OM325MoLJwNCugNaJfRNTXZJJIehhx+vsRXLXP z3N0NdeF2ivFAM6I4qKX/VepfGb7RE3ocAIoUyyEFijhZ1kBIbf/EiSw3JW47vA= X-Received: by 2002:a17:90a:2cf:b0:2a5:733c:3105 with SMTP id d15-20020a17090a02cf00b002a5733c3105mr3650134pjd.26.1712943271582; Fri, 12 Apr 2024 10:34:31 -0700 (PDT) Received: from ghost ([2601:647:5700:6860:121b:da6b:94f1:304]) by smtp.gmail.com with ESMTPSA id fs6-20020a17090af28600b002a4e331cc69sm4732571pjb.20.2024.04.12.10.34.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 10:34:31 -0700 (PDT) Date: Fri, 12 Apr 2024 10:34:28 -0700 From: Charlie Jenkins To: Conor Dooley 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: 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: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240412-aerosol-heritage-cec1eca172fb@wendy> 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. > > > > The alternatives code to handle if all cpus support an extension is > > factored out into a new function to support this. > > > > Signed-off-by: Charlie Jenkins > > --- > > > static __always_inline bool riscv_cpu_has_extension_unlikely(int cpu, const unsigned long ext) > > { > > - if (IS_ENABLED(CONFIG_RISCV_ALTERNATIVE) && riscv_has_extension_unlikely(ext)) > > - return true; > > + compiletime_assert(ext < RISCV_ISA_EXT_MAX, > > + "ext must be < RISCV_ISA_EXT_MAX"); > > > > - return __riscv_isa_extension_available(hart_isa[cpu].isa, ext); > > + if (IS_ENABLED(CONFIG_RISCV_ALTERNATIVE) && __riscv_has_extension_unlikely_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 unsigned 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? 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. - Charlie > > Thanks, > Conor. >