Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp10049976rwr; Fri, 12 May 2023 03:07:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ZnZtxutFsroVSQcpgJ7mDhpKAbAjR12RoD7JjL09lB0PWRZ0LC+7ljz0ctnthxJP2tBTS X-Received: by 2002:a17:902:8c87:b0:1a9:8d57:6d6c with SMTP id t7-20020a1709028c8700b001a98d576d6cmr19966276plo.24.1683886048932; Fri, 12 May 2023 03:07:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683886048; cv=none; d=google.com; s=arc-20160816; b=G1IYGu8vzYANjaxI282zmlzoI4PqA3OBFgSABVvlwpcyiVeAkbyiQwR/DBK1+DEp8l YGBWFN77bOXMditFR5jVFswFWozUXEiFKAWOXkp24bo/tHBwuaNVt+Ccuy8GlmAYMeJ2 ySBBYa8r+QNBjhHtRyCirnwLigqG8w5DuYn24QVEApihnpLTEi/6ubn3vy4x/MiH1/ao f7XO3Nx1XPyljwN/UNCKP5gXJdVZXajTyu9E0RiT96hWtwxKxdw5NSqqBwXmVA4jK61J kodvQwdTS65+awbPh5OhUVKXzP1Hj+IeSGsI+9k2NqnQsnLyt68eWZ9PrGh6jCqNJtLX ZHIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=jZnIWVM+K7vQ+gDNduF3BctJbe8oLsdi69v52yiaI2s=; b=Sc1WLnrDlVG2lqvVV/HZaJ0AfeXSz+bDpkXcCTwVFDVagsCGi9NWXtscPj2rhUTuNR pjtr0ghRsO6CiMFuznlagka3/bWw7DbeDaOD1pemJsSC+4SidUmrLF/LoIDEjIDpPs8M pinO7GnEBQ6ETuaMdAzVESN3h3j6evoor3b27bo3VuWyPMwxND3Dibtvsgi+nq3fWwFI cUK3CpRtwI9XyEb4zlINow6z4fNSVJUNA2yALcOJPsXm2RPNHSfYsy3CR7R0rm5Hx2NE HiaWgcTUjP8j//iovl2q4Q71oiCDYbeY9qv1WbNlR5dylPuopnsdf+S+2Yo0Qdnz3mLa 1eUg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bf9-20020a170902b90900b001ab03c66823si8326006plb.141.2023.05.12.03.07.14; Fri, 12 May 2023 03:07:28 -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 S240666AbjELJ7b (ORCPT + 99 others); Fri, 12 May 2023 05:59:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240634AbjELJ7A (ORCPT ); Fri, 12 May 2023 05:59:00 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BE36E11B4E; Fri, 12 May 2023 02:58:30 -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 1ECC2FEC; Fri, 12 May 2023 02:59:15 -0700 (PDT) Received: from e123648.arm.com (unknown [10.57.22.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D5C9E3F5A1; Fri, 12 May 2023 02:58:27 -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 v2 11/17] PM: EM: Use runtime modified EM for CPUs energy estimation in EAS Date: Fri, 12 May 2023 10:57:37 +0100 Message-Id: <20230512095743.3393563-12-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230512095743.3393563-1-lukasz.luba@arm.com> References: <20230512095743.3393563-1-lukasz.luba@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 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) -- 2.25.1