Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4494235rdh; Wed, 29 Nov 2023 03:09:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IGfq/61e7g7iN+ZP4CQ7Gwc0xeqPHkrVGszBm0fmc65jNv5xlCAbzRSEIo4Oe4kzIq6BF+W X-Received: by 2002:a05:6830:44a0:b0:6d8:175a:2890 with SMTP id r32-20020a05683044a000b006d8175a2890mr17311805otv.22.1701256158628; Wed, 29 Nov 2023 03:09:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701256158; cv=none; d=google.com; s=arc-20160816; b=jTInmWQKe1y5PjBH13WGAO49gHM9ynNcIX6Ra2PJzCzY7BqvC6fK6hNRz5tYL4gfQd XqPVljYgbwTMpRME9ancXnQhQ6uDnfcftjzRE6RoVWy8wxKyPdiw9NZeanoutaF2fYn3 rZa57ky8Nii/GPx/MvGWTXmN+rd5cmcphWQjGwoYqmCRZU2T6EfA4nkbpABfOUFtT/Xh G8Wpwf7BdxVIDq9PKrNwE6Xqzp7aGpCUIHvLHqVxojyS4VrbFsnoMl24/f0S8jb8uMcl Xh4Bhpi6sA4hG61UL18Tb033coSzBnIFOGuaB/vQh7y5i+Z2CTedEQ2SaPZZ+9jpd36l V/eg== 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=rU5YCboC/GcIpHk/fDUIpYrNvsd4my19E2aif2cffxc=; fh=jF+j1UEDAwnYbShW3HmO1TshMsWh36Jt7pSLTP62NeE=; b=jU7XAQ1C1gNbPZGdWQtXbEDsOSLleAnXWCI0iP8bc9hJSOPvLAC565MrPJskpvYvui ZuHHN4aiJWcwUhywSVkx2s+kRM05Ym37FHxHYyh8xZ2YN+zOUohJehVD0FeHcDBwGCJJ IAhn2+hG8Pj/Yz/+CzYfrjaEz9o1PJW7F4x/Abs6X06mrxhXoaEDPTXJ8nB7/Yp6Xp0f DTjPX/MEojB+N6G6x3bAetr39SxSiKTZWdZ9d6BQgNOTZJ1c9MMYb48pbC719Nwp/3/q hYUdBddJjipxvbWVKeEnc6zXUsnP63by/J1sZpAHzT6BV5b3e6rZgVxztWCqydBSJVX2 w3OQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id s23-20020a63f057000000b005be3683ec6asi14095534pgj.184.2023.11.29.03.09.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 03:09:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id D707F80423B0; Wed, 29 Nov 2023 03:09:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232454AbjK2LI7 (ORCPT + 99 others); Wed, 29 Nov 2023 06:08:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232450AbjK2LIe (ORCPT ); Wed, 29 Nov 2023 06:08:34 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6AAA61FEB; Wed, 29 Nov 2023 03:08:26 -0800 (PST) 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 422322F4; Wed, 29 Nov 2023 03:09:13 -0800 (PST) Received: from e129166.arm.com (unknown [10.57.4.241]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A925C3F5A1; Wed, 29 Nov 2023 03:08:23 -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 v5 09/23] PM: EM: Use runtime modified EM for CPUs energy estimation in EAS Date: Wed, 29 Nov 2023 11:08:39 +0000 Message-Id: <20231129110853.94344-10-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231129110853.94344-1-lukasz.luba@arm.com> References: <20231129110853.94344-1-lukasz.luba@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 29 Nov 2023 03:09:16 -0800 (PST) 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 1e618e431cac..94a77a813724 100644 --- a/include/linux/energy_model.h +++ b/include/linux/energy_model.h @@ -238,6 +238,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; @@ -255,7 +256,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); @@ -265,9 +273,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