From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Vincent Guittot <vincent.guittot@linaro.org>,
Ingo Molnar <mingo@kernel.org>, Lukasz Luba <lukasz.luba@arm.com>,
Sasha Levin <sashal@kernel.org>,
rafael@kernel.org
Subject: [PATCH AUTOSEL 6.7 7/8] energy_model: Use a fixed reference frequency
Date: Mon, 15 Jan 2024 19:08:19 -0500 [thread overview]
Message-ID: <20240116000838.212299-7-sashal@kernel.org> (raw)
In-Reply-To: <20240116000838.212299-1-sashal@kernel.org>
From: Vincent Guittot <vincent.guittot@linaro.org>
[ Upstream commit 15cbbd1d317e07b4e5c6aca5d4c5579539a82784 ]
The last item of a performance domain is not always the performance point
that has been used to compute CPU's capacity. This can lead to different
target frequency compared with other part of the system like schedutil and
would result in wrong energy estimation.
A new arch_scale_freq_ref() is available to return a fixed and coherent
frequency reference that can be used when computing the CPU's frequency
for an level of utilization. Use this function to get this reference
frequency.
Energy model is never used without defining arch_scale_freq_ref() but
can be compiled. Define a default arch_scale_freq_ref() returning 0
in such case.
Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Tested-by: Lukasz Luba <lukasz.luba@arm.com>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Link: https://lore.kernel.org/r/20231211104855.558096-5-vincent.guittot@linaro.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
include/linux/energy_model.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h
index b9caa01dfac4..c19e7effe764 100644
--- a/include/linux/energy_model.h
+++ b/include/linux/energy_model.h
@@ -224,7 +224,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)
{
- unsigned long freq, scale_cpu;
+ unsigned long freq, ref_freq, scale_cpu;
struct em_perf_state *ps;
int cpu;
@@ -241,11 +241,11 @@ 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];
+ ref_freq = arch_scale_freq_ref(cpu);
max_util = map_util_perf(max_util);
max_util = min(max_util, allowed_cpu_cap);
- freq = map_util_freq(max_util, ps->frequency, scale_cpu);
+ freq = map_util_freq(max_util, ref_freq, scale_cpu);
/*
* Find the lowest performance state of the Energy Model above the
--
2.43.0
next prev parent reply other threads:[~2024-01-16 0:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-16 0:08 [PATCH AUTOSEL 6.7 1/8] sched/numa: Fix mm numa_scan_seq based unconditional scan Sasha Levin
2024-01-16 0:08 ` [PATCH AUTOSEL 6.7 2/8] perf/core: Fix narrow startup race when creating the perf nr_addr_filters sysfs file Sasha Levin
2024-01-16 0:08 ` [PATCH AUTOSEL 6.7 3/8] debugobjects: Stop accessing objects after releasing hash bucket lock Sasha Levin
2024-01-16 0:08 ` [PATCH AUTOSEL 6.7 4/8] sched/topology: Add a new arch_scale_freq_ref() method Sasha Levin
2024-01-16 0:08 ` [PATCH AUTOSEL 6.7 5/8] cpufreq: Use the fixed and coherent frequency for scaling capacity Sasha Levin
2024-01-16 0:08 ` [PATCH AUTOSEL 6.7 6/8] cpufreq/schedutil: Use a fixed reference frequency Sasha Levin
2024-01-16 0:08 ` Sasha Levin [this message]
2024-01-16 0:08 ` [PATCH AUTOSEL 6.7 8/8] sched/fair: Fix tg->load when offlining a CPU Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240116000838.212299-7-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=mingo@kernel.org \
--cc=rafael@kernel.org \
--cc=stable@vger.kernel.org \
--cc=vincent.guittot@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox