From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) (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 492F114C587 for ; Fri, 12 Apr 2024 17:34:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712943273; cv=none; b=nR6VHrBphQ57pqTzWkxi6b4I5Bz0EroQtjZoOj7J/QOkeaPUzS9H2Du1zQqyEsoOxM+RnB+fpXq+GIEEEIdDL3JfcrOL6UbIp818CVsw5/0W2tv3wOp8iJsbBOEszPvP84zIkKaeRIEoKKY5TlT7ehvrLaaGyqmt+T9fgvEdtFU= 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.171 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 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: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-5ce2aada130so803012a12.1 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=Nn8Z2JsXow05xcTsNpi3kEpDIYiBdWfHbQq3rv7KALlO55wZBuO2ch+UiXzc83+u7d 4e3nuDXdibAaIwPfS1PLbzX1/Y94PJXlHYXWh7FriG5q+BtJEmxwwtpgwEz2jFSjwa3t lIyCYt/iUoxzcUhEd+FgJGBtYMm9y0WJus6hYrfUi6Aw6RDh52MEh1VGRrPgPTHorpME xCyr9ofLrr7ycDrdqfrJz6DwI0PiFTJvqR8j9qrss+H9+RZ++lnIDhl0pelZaghLIlww 8oVfEY+b608CZut+FZkUCVYlzWABHoNKuNZZucPhebD91P1zcC4H0tMSLIMUSYF+N4oI Gs3Q== X-Forwarded-Encrypted: i=1; AJvYcCX8YEkLk922eSru2xzUcwTJYbszqVUB8exQ1fCRuplRzKLF3xYbN0/CeNQoW2lDfsjBhHFHxQQHWixJYqV7RxPPvtP39EdjEQhP X-Gm-Message-State: AOJu0Yy3fudnRbLI1N5Ge1EReQ6ewTV21Ndza5xp0TMbb6TshSTXQ700 QadW87G8zo5yKGaf0+4C3pryzxcLXV3Tsx6mjOPG2UQOUEnLt1jvVVsou2OvW80= X-Google-Smtp-Source: AGHT+IGecMdCX/L7b/b4jRRmemcxcjENo5rWeeIe8AMz+k5W0w7mlpSYqVctJhJ2M4+aY/mVz0JUCQ== 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-doc@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. > From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E202BC00A94 for ; Fri, 12 Apr 2024 17:34:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XRAHVMT0QKgR0riSQmzEWyVsGV+qeFvcyJ1ml/IeKg0=; b=xHn8rq4qLQ2wJ+ KMr7vu7FZ2RbeQCvFNxdfx9RBDc4lqlk3fz4kiNL+Ojp8V98UJeHqOatdUlXuIIyJb0jdK+ZqQQQb v45yurQy4wdbnPr3buPlQNqIDTlITE1HXQavp9cfTQbEA9yI/g0amonUK21kSqYRI3XNWNhats8qU GQxJ2IiNwpTpcTzzsHjsJ0HZV+z6b+6mqwhFcUPnzAKhhOGk0n+oPCSVssUkA4b2XmyrQ+dvOnwUk rE/h6hcQx9fHnndr7PdIiSQl9uhrEA92pekUGkaBMX0ovITdSxGJJFDgXXsqHM/0+ZSa91uZo+/xL 6wJRDHyfTkkD3okSJPGg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvKnV-00000000gRq-0W9s; Fri, 12 Apr 2024 17:34:45 +0000 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvKnQ-00000000gNr-3uvv for linux-riscv@lists.infradead.org; Fri, 12 Apr 2024 17:34:42 +0000 Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-5dbcfa0eb5dso859879a12.3 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=lists.infradead.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=fv7eHrMDMkgAQv6CmhaTvjfTfqzvXG6owFgmv5IcQf2uquYdXvPnjznMenH3l6i2ia erqnp2yV7yIXo+822cAhyPnnDVHdcTB4gCzABVKQnQh9MBV8hsBrmiB28nIHo+ThXouN eIL0KrB/R8dcFjn3QpZVYU5n3M53dRz6HJw1B1CfkdsYSwtfLOS7cXayFHuPN4QBBFfm mHwUO0hNe5e98LXc9TDJ/mWR30Bs0d+P3KtrhDwXit5WOLZZaTa02wBum9R0u5h1nlHQ sc9WZyNsCRwX5rc4mMMa/dOSWYQRTsEUzMjPF1Jr/EssQY1mYMGQ8KFAELY6Nud7mWUS DZAA== 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=J/903PDnkVA8e3wdA62/YhextG+kCgOHWBEhLSxF5ipHfUIHNG2BR53IXbNWUt9snD lTL7SaS4FAr7cJU2/pJnwqC4Mjw/eTZX17gwSBd4aWHyN6aq7LmXjHHtG2rv255NGpyi 57vPVUlwht1ZpgrxjKvdZkd+gxQkXAyXNAE4r+h+++AyfgVx9OxPeX3ecCMYkyh3jBxP DqDDWLyx9oz1MitkD471zT6JUyT1pZbne4gwbD9esOleN7utekVM6fFLzbZMyjqN27QZ NkeHmAIIXNmR2uKowl04uJhJnBWgGlqc7/o0TyScwYcqndj9XRDRP2jRWQGkKEglY0Xk Lkww== X-Forwarded-Encrypted: i=1; AJvYcCV+Env0zjm7nNbU0yh4/+2YE6d/N+bt1gSj2rARQmhcDVRMA01KaZ/Ood3lkijUIkqMPpdpLKTrnhieMlCLm1akUsPgTKTtlDXSQwBUioJr X-Gm-Message-State: AOJu0YwMDkdton5V4P8WzsFGlRHNQI774cGE9bJoKoupmqN5yKIELhCo IVY/7c+8jAJftMknHWY2vWjrV+QqX+kXCGd7/2lE7UrRPA01yLQHjohYpSGI/8s= X-Google-Smtp-Source: AGHT+IGecMdCX/L7b/b4jRRmemcxcjENo5rWeeIe8AMz+k5W0w7mlpSYqVctJhJ2M4+aY/mVz0JUCQ== 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> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240412-aerosol-heritage-cec1eca172fb@wendy> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240412_103441_008947_6077061A X-CRM114-Status: GOOD ( 21.77 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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. > _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 67CC1C4345F for ; Fri, 12 Apr 2024 17:34:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=o1eNog2iwfUbrVQ0C0hLna3dXiexNPOU4OFmmG7pgKo=; b=BqXWsWBFBE9INK 3BRL+wTL2DnRHN0B663CeWcRdWUSO0Dvsl7mc8dpEuqN00F2syGOlzN5l1jd10s7SMCXP61gWUeqW RW9uzlZg0dLyNq7DVliLKJzS6gY5wzI93p2hyfeBDsRKA5VA9jhmqDJP4EuJcNvwwfPLgMkuyv91T 3cBrBLjOcmrxGSonKjVr+ZS5P9VV8Y2N5RHYoB2wDx4iR3PuH+ZWv2ETEUN0faIihuuM5biH6+66T zQQUlNNcvc/goO6Pirhipb+mp2WPRlN5B1WS53cZKRTfMzEf0QcxJX+iia1x5nY44+DlQ8KHhmPrp f8H9jTumLK4P2WwQ55DQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvKnU-00000000gRI-1mj5; Fri, 12 Apr 2024 17:34:44 +0000 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvKnQ-00000000gNs-3vn3 for linux-arm-kernel@lists.infradead.org; Fri, 12 Apr 2024 17:34:42 +0000 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-2a53eda3272so776231a91.2 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=lists.infradead.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=fv7eHrMDMkgAQv6CmhaTvjfTfqzvXG6owFgmv5IcQf2uquYdXvPnjznMenH3l6i2ia erqnp2yV7yIXo+822cAhyPnnDVHdcTB4gCzABVKQnQh9MBV8hsBrmiB28nIHo+ThXouN eIL0KrB/R8dcFjn3QpZVYU5n3M53dRz6HJw1B1CfkdsYSwtfLOS7cXayFHuPN4QBBFfm mHwUO0hNe5e98LXc9TDJ/mWR30Bs0d+P3KtrhDwXit5WOLZZaTa02wBum9R0u5h1nlHQ sc9WZyNsCRwX5rc4mMMa/dOSWYQRTsEUzMjPF1Jr/EssQY1mYMGQ8KFAELY6Nud7mWUS DZAA== 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=A6LtMAP8LsP7mju0G9FW6k65aHi8EL7oDYHkXRXTF3X78BFA0zvLGH1Xon4b9MbAzv +LMgYso0r5u0zkY6vsehvwCI+N7ZXZouonYz2GeD91g8P33TctEal/HzF0Z7M+Epl5tr ypN7ipb9SJGXhGoWx4MGf4hpZuAyqFERJLMhQPslhokrW3TCc+U/5lMpnwZOMqvtKWqY p04suQ52RmLRg4/eXx6TyJtm5CaG4+8XF7rZrex1qXZHcydijxpkmHaGjZ6CXUPKgXJ+ zcYgsU5XgeRuOHcjWHDIn2aIRrtbU1fK5/DHneYfiNpaRIwbZSRZ69hKUi9MeHMD/NjR H7eg== X-Forwarded-Encrypted: i=1; AJvYcCUZJSG4KBsQw7gZngeyE3X4mtplMAf5SWN8UTRH9GDvibDx9DjpHsu/uLDeOhaElT8AmXhk9Uu958PlIG+YRLNxdB19Svs0dAySFCepnVggy0w+3+s= X-Gm-Message-State: AOJu0YykSmUd7VcQY7+wa7HCOFcs5CYFuGD7mAP0F2pXNLJskhKDkWQC WFrHBzT5sMk+2+jDhVNog8O+uKORoU8GqdS9KbsHJ3g4fAXxTG5H9YY/c4VoWwE= X-Google-Smtp-Source: AGHT+IGecMdCX/L7b/b4jRRmemcxcjENo5rWeeIe8AMz+k5W0w7mlpSYqVctJhJ2M4+aY/mVz0JUCQ== 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> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240412-aerosol-heritage-cec1eca172fb@wendy> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240412_103441_030923_3FC13531 X-CRM114-Status: GOOD ( 23.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel