From: Yaxiong Tian <iambestgod@qq.com>
To: rafael@kernel.org, viresh.kumar@linaro.org, Pierre.Gondois@arm.com
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Yaxiong Tian <tianyaxiong@kylinos.cn>
Subject: [PATCH 2/2] cpufreq: cppc: Add comments for CPPC_EM_COST_GAP calculation
Date: Wed, 9 Apr 2025 17:51:50 +0800 [thread overview]
Message-ID: <tencent_2353FA17ABE475CC48686CA43867C9D6A605@qq.com> (raw)
In-Reply-To: <tencent_D6C4728C5C687C042BA7C156B0F3ECF7AE05@qq.com>
From: Yaxiong Tian <tianyaxiong@kylinos.cn>
The existing comments about CPPC_EM_COST_GAP were too brief. To help other
developers better understand its design rationale, this commit adds detailed
explanations about it.
Signed-off-by: Yaxiong Tian <tianyaxiong@kylinos.cn>
---
drivers/cpufreq/cppc_cpufreq.c | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
index 756034b21682..c8e281ca95c0 100644
--- a/drivers/cpufreq/cppc_cpufreq.c
+++ b/drivers/cpufreq/cppc_cpufreq.c
@@ -358,7 +358,34 @@ static void cppc_cpufreq_register_em(struct cpufreq_policy *policy);
#define CPPC_EM_CAP_STEP (20)
/* Increase the cost value by CPPC_EM_COST_STEP every performance state. */
#define CPPC_EM_COST_STEP (1)
-/* Add a cost gap correspnding to the energy of 4 CPUs. */
+
+/*
+ * In the current EM (Energy Model), energy consumption is calculated as:
+ * ps->cost * sum_util;
+ *
+ * For CPPC, the cost calculation uses a linear model: cost = a + b * step.
+ *
+ * For a task A with utilization 'util' in a performance domain (pd):
+ * Before placement:
+ * energy_pd_before = a * sum_util_pd + b * step * sum_util_pd;
+ * After placement:
+ * energy_pd_after = a * (sum_util_pd + util) + b * (sum_util_pd + util) *
+ * (step + util/CPPC_EM_CAP_STEP);
+ * Energy difference:
+ * energy_diff = a * util + b * util * step_pd +
+ * b * (sum_util_pd + util) * util/cap_step
+ *
+ * The placement decision depends on the bias 'a' and slope 'b'. Considering the
+ * extreme case where little cores are nearly full and big cores are nearly idle:
+ * energy_diff_pd = a_diff * util - b * util * step_pd_small -
+ * b * util * sum_util_pd_small/cap_step
+ *
+ * Ignoring smaller terms, the key condition becomes:
+ * a_diff > b * sum_util_pd_small / step_cap
+ *
+ * Therefore, for a pd domain with 4 CPUs, for ensures the scheduler will prefer
+ * placing it.we can configure accordingly.
+ */
#define CPPC_EM_COST_GAP (4 * SCHED_CAPACITY_SCALE * CPPC_EM_COST_STEP \
/ CPPC_EM_CAP_STEP)
--
2.25.1
prev parent reply other threads:[~2025-04-09 10:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-09 9:49 [PATCH 0/2] Fix and optimize some comments in the CPCC EM model Yaxiong Tian
2025-04-09 9:51 ` [PATCH 1/2] cpufreq: cppc: Update and opt comment for cost calculation method Yaxiong Tian
2025-04-09 9:51 ` Yaxiong Tian [this message]
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=tencent_2353FA17ABE475CC48686CA43867C9D6A605@qq.com \
--to=iambestgod@qq.com \
--cc=Pierre.Gondois@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=tianyaxiong@kylinos.cn \
--cc=viresh.kumar@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
all inboxes | Powered by JetHome®