[PATCH 1/2] cpufreq: cppc: Update and opt comment for cost calculation method

Yaxiong Tian posted 2 patches 10 months ago
[PATCH 1/2] cpufreq: cppc: Update and opt comment for cost calculation method
Posted by Yaxiong Tian 10 months ago
From: Yaxiong Tian <tianyaxiong@kylinos.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@kylinos.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