linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vincent Donnefort <vincent.donnefort@arm.com>
To: peterz@infradead.org, rjw@rjwysocki.net, viresh.kumar@linaro.org,
	vincent.guittot@linaro.org, qperret@google.com
Cc: linux-kernel@vger.kernel.org, ionela.voinescu@arm.com,
	lukasz.luba@arm.com, dietmar.eggemann@arm.com,
	Vincent Donnefort <vincent.donnefort@arm.com>
Subject: [PATCH v2 1/3] PM / EM: Fix inefficient state detection
Date: Fri, 21 May 2021 17:54:22 +0100	[thread overview]
Message-ID: <1621616064-340235-2-git-send-email-vincent.donnefort@arm.com> (raw)
In-Reply-To: <1621616064-340235-1-git-send-email-vincent.donnefort@arm.com>

Currently, a debug message is printed if an inefficient state is detected
in the Energy Model. Unfortunately, it won't detect if the first state is
inefficient or if two successive states are. Fix this behavior.

Signed-off-by: Vincent Donnefort <vincent.donnefort@arm.com>

diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c
index 0c620eb..c4871a8 100644
--- a/kernel/power/energy_model.c
+++ b/kernel/power/energy_model.c
@@ -107,8 +107,7 @@ static void em_debug_remove_pd(struct device *dev) {}
 static int em_create_perf_table(struct device *dev, struct em_perf_domain *pd,
 				int nr_states, struct em_data_callback *cb)
 {
-	unsigned long opp_eff, prev_opp_eff = ULONG_MAX;
-	unsigned long power, freq, prev_freq = 0;
+	unsigned long power, freq, prev_freq = 0, prev_cost = ULONG_MAX;
 	struct em_perf_state *table;
 	int i, ret;
 	u64 fmax;
@@ -153,25 +152,19 @@ static int em_create_perf_table(struct device *dev, struct em_perf_domain *pd,
 
 		table[i].power = power;
 		table[i].frequency = prev_freq = freq;
-
-		/*
-		 * The hertz/watts efficiency ratio should decrease as the
-		 * frequency grows on sane platforms. But this isn't always
-		 * true in practice so warn the user if a higher OPP is more
-		 * power efficient than a lower one.
-		 */
-		opp_eff = freq / power;
-		if (opp_eff >= prev_opp_eff)
-			dev_dbg(dev, "EM: hertz/watts ratio non-monotonically decreasing: em_perf_state %d >= em_perf_state%d\n",
-					i, i - 1);
-		prev_opp_eff = opp_eff;
 	}
 
 	/* Compute the cost of each performance state. */
 	fmax = (u64) table[nr_states - 1].frequency;
-	for (i = 0; i < nr_states; i++) {
+	for (i = nr_states - 1; i >= 0; i--) {
 		table[i].cost = div64_u64(fmax * table[i].power,
 					  table[i].frequency);
+		if (table[i].cost >= prev_cost) {
+			dev_dbg(dev, "EM: OPP:%lu is inefficient\n",
+				table[i].frequency);
+		} else {
+			prev_cost = table[i].cost;
+		}
 	}
 
 	pd->table = table;
-- 
2.7.4


  reply	other threads:[~2021-05-21 16:54 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-21 16:54 [PATCH v2 0/3] EM / PM: Inefficient OPPs Vincent Donnefort
2021-05-21 16:54 ` Vincent Donnefort [this message]
2021-05-24 12:41   ` [PATCH v2 1/3] PM / EM: Fix inefficient state detection Lukasz Luba
2021-05-25  9:50   ` Quentin Perret
2021-05-21 16:54 ` [PATCH v2 2/3] PM / EM: Extend em_perf_domain with a flag field Vincent Donnefort
2021-05-24 12:44   ` Lukasz Luba
2021-05-25  9:54   ` Quentin Perret
2021-05-21 16:54 ` [PATCH v2 3/3] PM / EM: Skip inefficient OPPs Vincent Donnefort
2021-05-24 12:55   ` Lukasz Luba
2021-05-25  8:48   ` Peter Zijlstra
2021-05-25  9:21     ` Vincent Donnefort
2021-05-25 10:00       ` Vincent Donnefort
2021-05-28  5:09     ` Viresh Kumar
2021-06-01  8:47       ` Vincent Donnefort
2021-06-01  8:56         ` Viresh Kumar
2021-06-01  9:07           ` Quentin Perret
2021-06-01  9:13             ` Viresh Kumar
2021-05-25  9:33   ` Quentin Perret
2021-05-25  9:46     ` Vincent Donnefort
2021-05-25 11:03       ` Lukasz Luba
2021-05-25 13:06         ` Quentin Perret
2021-05-25 13:34           ` Lukasz Luba
2021-05-25  9:47     ` Vincent Donnefort
2021-05-28  5:04   ` Viresh Kumar
2021-05-28  9:00     ` Lukasz Luba
2021-05-26  3:47 ` [PATCH v2 0/3] EM / PM: Inefficient OPPs Viresh Kumar
2021-05-26  8:56   ` Lukasz Luba
2021-05-26  9:33     ` Viresh Kumar
2021-05-27  7:13       ` Lukasz Luba
2021-05-26  9:01   ` Vincent Donnefort
2021-05-26  9:38     ` Viresh Kumar
2021-05-26  9:39       ` Viresh Kumar
2021-05-26 10:24       ` Lukasz Luba
2021-05-26 10:39         ` Lukasz Luba
2021-05-26 11:50           ` Lukasz Luba
2021-05-26 13:49       ` Vincent Donnefort

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=1621616064-340235-2-git-send-email-vincent.donnefort@arm.com \
    --to=vincent.donnefort@arm.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=ionela.voinescu@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=peterz@infradead.org \
    --cc=qperret@google.com \
    --cc=rjw@rjwysocki.net \
    --cc=vincent.guittot@linaro.org \
    --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;
as well as URLs for NNTP newsgroup(s).