From patchwork Tue Mar 14 10:33:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Luba X-Patchwork-Id: 69488 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1679063wrd; Tue, 14 Mar 2023 03:40:06 -0700 (PDT) X-Google-Smtp-Source: AK7set89I0dGKWGCLJW7r7o5BLsAit3Ou2I88FytMCvbtI32vX13sjFrPNH0e6AiY33sGu8p11bY X-Received: by 2002:a05:6a20:3d02:b0:bc:42f9:6b21 with SMTP id y2-20020a056a203d0200b000bc42f96b21mr46067949pzi.15.1678790405818; Tue, 14 Mar 2023 03:40:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678790405; cv=none; d=google.com; s=arc-20160816; b=D11atGxHvcvvSgU4EdHeflGtn+5SsCS8T+tFdNu6L4bdf/wYA28xGeUKhOFa+SN2TW NhskwNjVS51ohrC3zApN/7moG0YHDNqlf3DUZK2COXtKwplE0PBOyvk2q1aUtA37IAj0 HbN/HIc6nKyrWDJYOCp+scSOKQasQdEhOlZ8MYDyn22BVZedlgz5Lgp3eljIf4Zf9DZW lBJncfIxIsvuvOu7aLW6e9LCNXBdICeSIhgasgYTCDnF1VOXVMRHdBqVbAxVAyfmhZLN FLGeQaXhW64XFPIMN1cky/E65mkUybQp4xJBgLQJSJ2IAPAXn73jJx9h22RX+iGyauhF dxug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=Q5/hMggK5nUzVk4QLCay3SnYKebNETeA9wwkxbhdego=; b=LFBbrnXKUb5/zW2SdBYlYy9+gtB1TeH8EGkfntMaR9CzcH3JlJOGJINAhUVq3Pudp0 fGUROclZPCYuAHU8Zn2G3qfK4u6gbzORs0i3YdVNxZN8qHult51eytI07tH+AMDZbo96 oZrbnIiImzR17S8WcwuV5cqiFszrGI2EArhxE1ZgAXmDDob/KmFPODqfTnpAv45PB6il Q5TyO5CyNE84AxAHCnMg22merX2uaI2ZoJNLNOusj6dMPy5XCLCF+fwMRvZwyIfLAvtd 5kaZnpldm2PHDoEQiX6ICW7aQRadPmMSiPWGMRSKmhNc5OoMDSKjtN+o3O9F3awUPqZB 2lxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q14-20020aa7982e000000b006222f47503dsi1985421pfl.39.2023.03.14.03.39.53; Tue, 14 Mar 2023 03:40:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231145AbjCNKgf (ORCPT + 99 others); Tue, 14 Mar 2023 06:36:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231267AbjCNKgH (ORCPT ); Tue, 14 Mar 2023 06:36:07 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EE69494A6B; Tue, 14 Mar 2023 03:35:19 -0700 (PDT) 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 D928C16F8; Tue, 14 Mar 2023 03:35:31 -0700 (PDT) Received: from e123648.arm.com (unknown [10.57.19.101]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 61CC23F71A; Tue, 14 Mar 2023 03:34:45 -0700 (PDT) From: Lukasz Luba To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rafael@kernel.org Cc: lukasz.luba@arm.com, dietmar.eggemann@arm.com, rui.zhang@intel.com, amit.kucheria@verdurent.com, amit.kachhap@gmail.com, daniel.lezcano@linaro.org, viresh.kumar@linaro.org, len.brown@intel.com, pavel@ucw.cz, Pierre.Gondois@arm.com, ionela.voinescu@arm.com, rostedt@goodmis.org, mhiramat@kernel.org Subject: [PATCH 11/17] PM: EM: Use runtime modified EM for CPUs energy estimation in EAS Date: Tue, 14 Mar 2023 10:33:51 +0000 Message-Id: <20230314103357.26010-12-lukasz.luba@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230314103357.26010-1-lukasz.luba@arm.com> References: <20230314103357.26010-1-lukasz.luba@arm.com> X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760339328720433099?= X-GMAIL-MSGID: =?utf-8?q?1760339328720433099?= The new Energy Model (EM) supports runtime modification of the performance state table to better model the power used by the SoC. Use this new feature to improve energy estimation and therefore task placement in Energy Aware Scheduler (EAS). Signed-off-by: Lukasz Luba --- include/linux/energy_model.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h index e1772aa6c843..8e3fa2b6bf28 100644 --- a/include/linux/energy_model.h +++ b/include/linux/energy_model.h @@ -262,6 +262,7 @@ static inline unsigned long em_cpu_energy(struct em_perf_domain *pd, unsigned long max_util, unsigned long sum_util, unsigned long allowed_cpu_cap) { + struct em_perf_table *runtime_table; unsigned long freq, scale_cpu; struct em_perf_state *ps; int cpu, i; @@ -279,7 +280,14 @@ static inline unsigned long em_cpu_energy(struct em_perf_domain *pd, */ cpu = cpumask_first(to_cpumask(pd->cpus)); scale_cpu = arch_scale_cpu_capacity(cpu); - ps = &pd->table[pd->nr_perf_states - 1]; + + /* + * No rcu_read_lock() since it's already called by task scheduler. + * The runtime_table is always there for CPUs, so we don't check. + */ + runtime_table = rcu_dereference(pd->runtime_table); + + ps = &runtime_table->state[pd->nr_perf_states - 1]; max_util = map_util_perf(max_util); max_util = min(max_util, allowed_cpu_cap); @@ -289,9 +297,9 @@ static inline unsigned long em_cpu_energy(struct em_perf_domain *pd, * Find the lowest performance state of the Energy Model above the * requested frequency. */ - i = em_pd_get_efficient_state(pd->table, pd->nr_perf_states, freq, - pd->flags); - ps = &pd->table[i]; + i = em_pd_get_efficient_state(runtime_table->state, pd->nr_perf_states, + freq, pd->flags); + ps = &runtime_table->state[i]; /* * The capacity of a CPU in the domain at the performance state (ps)