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 X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5E6FC4361B for ; Thu, 10 Dec 2020 11:10:21 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5DA0F23B85 for ; Thu, 10 Dec 2020 11:10:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5DA0F23B85 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject: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=Tqx1hQriq2IwlwzHgx18UTKQnk886mVc7z2cDbrO6EA=; b=ssn7RqXlu/lUy9HrzD6XbO68s TXQQOnfIMfOMUtDI4qCEfaa2vvjFt/3hYjuqjKwaqu6IdUZh3bbu3YH0DnE2xYCZC7ishMaKc5ndb ycM+C0iAMw9W4bvI0kyWYb52wmt0OmQV6ejdOMzkQ2X0KfdTLKYtsaMtFGkoiWzythCj0NnE9Ju12 w+OWMYGtR7DYbJRNeQ3EBKtOxU+ReYKGNJ6tZIyC/PMYA463xeq0bFaZUGukzJmmapJnB8bPTPrOb ejiFIOZ/5NQbC3xbFQJffXGqyK7ySIHE60mDsmzXrYnZNTFycl6yDa0eP+P+6/Aq9P/rHP62mE0vJ JErzR8Alw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1knJov-0008CR-NJ; Thu, 10 Dec 2020 11:09:13 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1knJos-0008Bc-2L for linux-arm-kernel@lists.infradead.org; Thu, 10 Dec 2020 11:09:11 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7C5C630E; Thu, 10 Dec 2020 03:09:08 -0800 (PST) Received: from localhost (unknown [10.1.198.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1ABE13F718; Thu, 10 Dec 2020 03:09:08 -0800 (PST) Date: Thu, 10 Dec 2020 11:09:06 +0000 From: Ionela Voinescu To: Viresh Kumar Subject: Re: [PATCH] arm64: topology: Avoid the static_branch_{enable|disable} dance Message-ID: <20201210110906.GA5300@arm.com> References: <5594c7d6756a47b473ceb6f48cc217458db32ab0.1607584435.git.viresh.kumar@linaro.org> <10396de8046ada347d681eb84ea4dc6ec27e1742.1607593250.git.viresh.kumar@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <10396de8046ada347d681eb84ea4dc6ec27e1742.1607593250.git.viresh.kumar@linaro.org> User-Agent: Mutt/1.9.4 (2018-02-28) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201210_060910_248850_F8B7A384 X-CRM114-Status: GOOD ( 26.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Vincent Guittot 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 Thursday 10 Dec 2020 at 15:12:25 (+0530), Viresh Kumar wrote: > Avoid the static_branch_enable() and static_branch_disable() dance by > redoing the code in a different way. We will be fully invariant here > only if amu_fie_cpus is set with all present CPUs, use that instead of > yet another call to topology_scale_freq_invariant(). > > This also avoids running rest of the routine if we enabled the static > branch, followed by a disable. > > Also make the first call to topology_scale_freq_invariant() just when we > need it, instead of at the top of the routine. This makes it further > clear on why we need it, i.e. just around enabling AMUs use here. > > Signed-off-by: Viresh Kumar > --- > arch/arm64/kernel/topology.c | 21 +++++++++------------ > 1 file changed, 9 insertions(+), 12 deletions(-) > > diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c > index 7f7d8de325b6..6dedc6ee91cf 100644 > --- a/arch/arm64/kernel/topology.c > +++ b/arch/arm64/kernel/topology.c > @@ -221,7 +221,7 @@ static DEFINE_STATIC_KEY_FALSE(amu_fie_key); > > static int __init init_amu_fie(void) > { > - bool invariance_status = topology_scale_freq_invariant(); > + bool invariance_status; > cpumask_var_t valid_cpus; > int ret = 0; > int cpu; > @@ -255,18 +255,15 @@ static int __init init_amu_fie(void) > cpumask_equal(valid_cpus, cpu_present_mask)) > cpumask_copy(amu_fie_cpus, cpu_present_mask); > > - if (!cpumask_empty(amu_fie_cpus)) { > - pr_info("CPUs[%*pbl]: counters will be used for FIE.", > - cpumask_pr_args(amu_fie_cpus)); > - static_branch_enable(&amu_fie_key); > - } This check verifies if there are *any* CPUs for which AMUs can be used for FIE (!empty mask) -> enable static key. > + /* Disallow partial use of counters for frequency invariance */ > + if (!cpumask_equal(amu_fie_cpus, cpu_present_mask)) > + goto free_valid_mask; > The replacement verifies if *all* present CPUs support AMUs for FIE and only then it enables the static key. Ionela. > - /* > - * If the system is not fully invariant after AMU init, disable > - * partial use of counters for frequency invariance. > - */ > - if (!topology_scale_freq_invariant()) > - static_branch_disable(&amu_fie_key); > + pr_info("CPUs[%*pbl]: counters will be used for FIE.", > + cpumask_pr_args(amu_fie_cpus)); > + > + invariance_status = topology_scale_freq_invariant(); > + static_branch_enable(&amu_fie_key); > > /* > * Task scheduler behavior depends on frequency invariance support, > -- > 2.25.0.rc1.19.g042ed3e048af > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel