From patchwork Thu Dec 10 09:42:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 11964025 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=-16.8 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_GIT 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 92C6AC4361B for ; Thu, 10 Dec 2020 09:43:56 +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 474FD2313E for ; Thu, 10 Dec 2020 09:43:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 474FD2313E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org 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:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=GbDdUfXKyGtROsOFSZkRG2dEMHBcpBuRXFnavJzItV8=; b=Udpa8ztu3FCkwdPWkE3qT6u2Q cIU2W2elTFTZvPEMSx9APIG4pEQpcWiSX/A5Dg/vWrE9T06FAAyr85z06dZiU81Sc8fSrFlwrW4lH HdKNfFRXboKhLQ3yJ8lnU5x8KM0PmxMuSWuqrj5GDz0TI3do+757rqNIrx+sATiSS9hnrGqC+TXnq Lm/7NlYH/5tChIWwdmqYLj4CuWwCk8Emq/xZp8zll+2fpkxKyXoM/XQO6Yue4BzJ+NQ2EyFERuDWe EcX4QkCxkBt5VEehSXE5kswjI7RqYfe6oHjKhez6xE3JsembwmaVVp6NcZt3YigmfTCMqv3u2HWJJ GuBW4Kkkg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1knITA-0000HV-Td; Thu, 10 Dec 2020 09:42:41 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1knIT5-0000Fa-0G for linux-arm-kernel@lists.infradead.org; Thu, 10 Dec 2020 09:42:36 +0000 Received: by mail-pg1-x541.google.com with SMTP id g18so3733612pgk.1 for ; Thu, 10 Dec 2020 01:42:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XtvCgTzFUBGsUNcdgDa+auavrqoDFdovqrXwRiSLhnU=; b=vaHlq5UdrrasmXTd3NvOcRuwNbBv0DnOdxbmGIdC+wLZi8tO0J5I9/N/Lv2O3KlLbr fZLm2Fhgk+zlNgVGODtqPpkXMCafl3lH+7OSCksw1AES1b+eSHz/QUmNzMw7VuC2vWzt /NCNQAinWk6zDcCEq43ivF4+zi3X+Pw4HQifZLHDalH9OMIVrNpJ2154/92FH3Kf2L6S Jp8k3kz7UwQThJuKqkUhYWcPV3Te5g+kRULU+8BZ7py4RKvu8OvxPu3kMLZoblmcAsVv EygWLTHQJX3OGOpJLgzUGvsOMt0Shozf5wG4jGPVnhdfmbwPQ+DSDmDsuEkDJKuIwdNN hRKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XtvCgTzFUBGsUNcdgDa+auavrqoDFdovqrXwRiSLhnU=; b=bO1VQQVm+ZftVWAaoadjCZgcbTZSa9jAMtNEMGqj0Ta2q6viR/pEJWBBiNeDrzmuzA f/nKD3WDZBTgybUy1+DfWBHeA3mVZ6JrMU5cqrSqONGl7VtFKCRoorDg052IVtL+SI95 hLECzrGhY2XIcazb07JGj8Y2gDyLbbdVZX+Jei3ivyDS45jZyZEp3v+7sWXgJ81tFceY pCnGobLKFh1j8SsjdVvHceNYv3v4fsPVMbJSUO6182DvKXwsr3UVX1sqapPBOvb5ANtf ppuwT6I+2mEqu9ZCjxwtW4cV5kCvD32nlw7GmhiG01tvBe4UAzQBGIwRWx5iaeRyN3AQ ivnw== X-Gm-Message-State: AOAM530upQN+bul/RjWSJ7sGJgk6P0IfFAhqPq1rhPea9+As3g6vLdLw lZngLLtaa2wnKZaIrCTlKd1mNw== X-Google-Smtp-Source: ABdhPJxySeJx+xlUvznUbnXJtKJhcnebaCZyKDqohqeG56RLoCVg2RV3j/zrZt4B9kNETyckzxht8A== X-Received: by 2002:a63:943:: with SMTP id 64mr5999750pgj.80.1607593352804; Thu, 10 Dec 2020 01:42:32 -0800 (PST) Received: from localhost ([122.172.20.109]) by smtp.gmail.com with ESMTPSA id a23sm5521642pju.31.2020.12.10.01.42.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Dec 2020 01:42:32 -0800 (PST) From: Viresh Kumar To: Ionela Voinescu , Catalin Marinas , Will Deacon Subject: [PATCH] arm64: topology: Avoid the static_branch_{enable|disable} dance Date: Thu, 10 Dec 2020 15:12:25 +0530 Message-Id: <10396de8046ada347d681eb84ea4dc6ec27e1742.1607593250.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: <5594c7d6756a47b473ceb6f48cc217458db32ab0.1607584435.git.viresh.kumar@linaro.org> References: <5594c7d6756a47b473ceb6f48cc217458db32ab0.1607584435.git.viresh.kumar@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201210_044235_129269_716E2D4A X-CRM114-Status: GOOD ( 18.01 ) 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: Viresh Kumar , Vincent Guittot , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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); - } + /* Disallow partial use of counters for frequency invariance */ + if (!cpumask_equal(amu_fie_cpus, cpu_present_mask)) + goto free_valid_mask; - /* - * 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,