Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7844219rdb; Thu, 4 Jan 2024 09:18:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IFUdkoT6E2Lmm0P+qZ2X1/8R17zpNyT9BLc5CycsUUAspH3XRAWAXMTPOz1Z9GuQl/MZ6QV X-Received: by 2002:a05:6a20:f393:b0:194:f5e7:9a12 with SMTP id qr19-20020a056a20f39300b00194f5e79a12mr800251pzb.67.1704388723163; Thu, 04 Jan 2024 09:18:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704388723; cv=none; d=google.com; s=arc-20160816; b=u9jpFl9bJvhIlXC038W5gnm2rTwADVmpFyXmxVpCwOWw4eQ0g1YqKHx1IcTkeuB/lD HpFZK2wVwvwe3zhyzrJ3kmCZVwg+3MVZ2Hxxu3ReRGuABYujNPRShd38tfiVgrM06UqK N9sSIV84Nvj+mzg+TYrS5hsRgtSi5zA97ntxlJA7I3ErMXgYRNhe5fleN9UblC6KwYuv 8Zyajo7H2YKQGwXFggsX/Dga2890TemE/YEv7j1Quyv4naa1gcP74TH7k/z+UuBtNDYy teAoICS4aKgsnXUD/WnLqFziBrJJR001NbI6fO5UpIsz3cRpHlHdTWHguI+QravmehSo w0Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=z9JKC41T07MJsYasfrWLWMGJ7gBKZ1zK3m32VMt9k9c=; fh=jF+j1UEDAwnYbShW3HmO1TshMsWh36Jt7pSLTP62NeE=; b=i+kOQpzIFsdJdHywBtlrjyz3TIDVRjtIS3zM8mWGKBx3Wl0wwljWQF45b01vSrAZ++ FTy595tlk3j2ISq82n2imirPGJdlTzSKsoWbMuzd1llJWrUiGoG4Vf9KRo3XwpfCQkqQ idzMsF4N5uQoueKYCUJGAhkQF0SkK29zyDWO6s7+HkK8JOaQEL7h0URRv7zj/uL/Yo3m TAHCxAZBsrmo0yecyqGbicGx4AsKUFApYN1eC/zwr0yNWee4YXZOReQq11nzWDKaJrmn 9gGzxRqlaWRKcxYyE4wI5V30r3BzQqySmTkwPp7tCcE1ef+2Tu0sRtUiEQ7U76E2uvnS lcmA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-17012-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17012-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id fb34-20020a056a002da200b006cb852928ffsi20486417pfb.66.2024.01.04.09.18.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 09:18:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17012-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-17012-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17012-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D6E8528837E for ; Thu, 4 Jan 2024 17:18:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D7AE02DF87; Thu, 4 Jan 2024 17:15:16 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D5FE2CCC4; Thu, 4 Jan 2024 17:15:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 C414E1570; Thu, 4 Jan 2024 09:16:00 -0800 (PST) Received: from e129166.arm.com (unknown [10.57.88.128]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 5BF843F64C; Thu, 4 Jan 2024 09:15:12 -0800 (PST) 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, mhiramat@kernel.org, qyousef@layalina.io, wvw@google.com Subject: [PATCH v6 09/23] PM: EM: Use runtime modified EM for CPUs energy estimation in EAS Date: Thu, 4 Jan 2024 17:15:39 +0000 Message-Id: <20240104171553.2080674-10-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240104171553.2080674-1-lukasz.luba@arm.com> References: <20240104171553.2080674-1-lukasz.luba@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h index 8ddf1d8a9581..5f842da3bb0c 100644 --- a/include/linux/energy_model.h +++ b/include/linux/energy_model.h @@ -239,9 +239,14 @@ static inline unsigned long em_cpu_energy(struct em_perf_domain *pd, unsigned long allowed_cpu_cap) { unsigned long freq, ref_freq, scale_cpu; + struct em_perf_table *em_table; struct em_perf_state *ps; int cpu, i; +#ifdef CONFIG_SCHED_DEBUG + WARN_ONCE(!rcu_read_lock_held(), "EM: rcu read lock needed\n"); +#endif + if (!sum_util) return 0; @@ -264,9 +269,10 @@ 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]; + em_table = rcu_dereference(pd->em_table); + i = em_pd_get_efficient_state(em_table->state, pd->nr_perf_states, + freq, pd->flags); + ps = &em_table->state[i]; /* * The capacity of a CPU in the domain at the performance state (ps) -- 2.25.1