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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 5C4D3CDB465 for ; Thu, 19 Oct 2023 04:34:13 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ellerman.id.au header.i=@ellerman.id.au header.a=rsa-sha256 header.s=201909 header.b=Cujzwvfn; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4S9vxb4Vslz3cQ4 for ; Thu, 19 Oct 2023 15:34:11 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ellerman.id.au header.i=@ellerman.id.au header.a=rsa-sha256 header.s=201909 header.b=Cujzwvfn; dkim-atps=neutral Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4S9vwd3BxLz3c5j for ; Thu, 19 Oct 2023 15:33:21 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1697690000; bh=mQ5XTmp0WZ0EPEWae5zMXHWuVc77FJWFD50HtSF9EaI=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=CujzwvfnVGcmNcNeKFrYx6qEi5pDAqQHqLSjd6yLRttlhWQkGZPxi07OX41KdzdwM JLA1ZtEvBvaabEMYPv5rZIOjMpbngy7R3ZsW6TPHg9HB9DkwCnwug0XuXf5TkItSGQ GdVHU5R9HGkHZuZ7aTdMd7atInPfGaSWrSvFsvRCBFjO3QQjUEqPwVnzalQVFpE9c0 fIypi4XeC3yp6pHRx7hcOu0+2cIPcNqvK5MdSbCDEbU48pPnyQt1hvibwtnsoQGt7k GsOnILAHORGGJAZ6d+4FhTLTfkOUOaOUebYwN+KxUAxXPDm3RqcjUo75n9K24fSBCD qNEKuTArwq4Mw== Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4S9vwb6RlWz4xZS; Thu, 19 Oct 2023 15:33:19 +1100 (AEDT) From: Michael Ellerman To: Srikar Dronamraju Subject: Re: [PATCH v2 1/6] powerpc/smp: Cache CPU has Asymmetric SMP In-Reply-To: <20231018163751.2423181-2-srikar@linux.vnet.ibm.com> References: <20231018163751.2423181-1-srikar@linux.vnet.ibm.com> <20231018163751.2423181-2-srikar@linux.vnet.ibm.com> Date: Thu, 19 Oct 2023 15:33:16 +1100 Message-ID: <87y1fz5j03.fsf@mail.lhotse> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Valentin Schneider , Srikar Dronamraju , Peter Zijlstra , "ndesaulniers@google.com" , linux-kernel@vger.kernel.org, Rohan McLure , Nicholas Piggin , linuxppc-dev , Josh Poimboeuf Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Srikar Dronamraju writes: > Currently cpu feature flag is checked whenever powerpc_smt_flags gets > called. This is an unnecessary overhead. CPU_FTR_ASYM_SMT is set based > on the processor and all processors will either have this set or will > have it unset. The cpu_has_feature() test is implemented with a static key. So AFAICS this is just replacing one static key with another? I see that you use the new static key in subsequent patches. But couldn't those just use the existing cpu feature test? Anyway I'd be interested to see how the generated code differs before/after this. cheers > Hence only check for the feature flag once and cache it to be used > subsequently. This commit will help avoid a branch in powerpc_smt_flags > > Signed-off-by: Srikar Dronamraju > --- > Changelog: > v1->v2: Using static keys instead of a variable. > Using pr_info_once instead of printk > > arch/powerpc/kernel/smp.c | 15 +++++++++------ > 1 file changed, 9 insertions(+), 6 deletions(-) > > diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c > index 5826f5108a12..37c41297c9ce 100644 > --- a/arch/powerpc/kernel/smp.c > +++ b/arch/powerpc/kernel/smp.c > @@ -988,18 +988,16 @@ static int __init init_thread_group_cache_map(int cpu, int cache_property) > } > > static bool shared_caches; > +DEFINE_STATIC_KEY_FALSE(powerpc_asym_packing); > > #ifdef CONFIG_SCHED_SMT > /* cpumask of CPUs with asymmetric SMT dependency */ > static int powerpc_smt_flags(void) > { > - int flags = SD_SHARE_CPUCAPACITY | SD_SHARE_PKG_RESOURCES; > + if (static_branch_unlikely(&powerpc_asym_packing)) > + return SD_SHARE_CPUCAPACITY | SD_SHARE_PKG_RESOURCES | SD_ASYM_PACKING; > > - if (cpu_has_feature(CPU_FTR_ASYM_SMT)) { > - printk_once(KERN_INFO "Enabling Asymmetric SMT scheduling\n"); > - flags |= SD_ASYM_PACKING; > - } > - return flags; > + return SD_SHARE_CPUCAPACITY | SD_SHARE_PKG_RESOURCES; > } > #endif > > @@ -1686,6 +1684,11 @@ static void __init fixup_topology(void) > { > int i; > > + if (cpu_has_feature(CPU_FTR_ASYM_SMT)) { > + pr_info_once("Enabling Asymmetric SMT scheduling\n"); > + static_branch_enable(&powerpc_asym_packing); > + } > + > #ifdef CONFIG_SCHED_SMT > if (has_big_cores) { > pr_info("Big cores detected but using small core scheduling\n"); > -- > 2.31.1