[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tencent_C797B88F7509E18C70E48CD99275BAFD1E0A@qq.com>
Date: Wed, 9 Apr 2025 17:51:41 +0800
From: Yaxiong Tian <iambestgod@...com>
To: rafael@...nel.org,
viresh.kumar@...aro.org,
Pierre.Gondois@....com
Cc: linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org,
Yaxiong Tian <tianyaxiong@...inos.cn>
Subject: [PATCH 1/2] cpufreq: cppc: Update and opt comment for cost calculation method
From: Yaxiong Tian <tianyaxiong@...inos.cn>
commit <1b600da510735a> ("PM: EM: Optimize em_cpu_energy() and remove division")
updated the energy calculation method, so the original comment needs to be updated
and opt.
Signed-off-by: Yaxiong Tian <tianyaxiong@...inos.cn>
---
drivers/cpufreq/cppc_cpufreq.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
index b3d74f9adcf0..756034b21682 100644
--- a/drivers/cpufreq/cppc_cpufreq.c
+++ b/drivers/cpufreq/cppc_cpufreq.c
@@ -379,9 +379,18 @@ static unsigned int get_perf_level_count(struct cpufreq_policy *policy)
return 1 + max_cap / CPPC_EM_CAP_STEP - min_cap / CPPC_EM_CAP_STEP;
}
-/*
- * The cost is defined as:
- * cost = power * max_frequency / frequency
+/**
+ * compute_cost - Calculate the cost for a given CPU and performance level step
+ * @cpu: Target CPU
+ * @step: Performance level step
+ *
+ * CPPC uses a linear cost model since it only provides relative efficiency ratios:
+ * Base cost (per CPU): CPPC_EM_COST_GAP * efficiency_class
+ * Step cost (per level): step * CPPC_EM_COST_STEP
+ *
+ * Lower cost implies higher efficiency. The model ensures:
+ * 1. Higher efficiency CPUs (low efficiency_class) always have lower cost.
+ * 2. Higher performance levels (larger step) linearly increase cost.
*/
static inline unsigned long compute_cost(int cpu, int step)
{
--
2.25.1
Powered by blists - more mailing lists