mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Youquan Song <youquan.song@intel.com>
To: davej@redhat.com, cpufreq@vger.kernle.org
Cc: venki@google.com, arjan@linux.intel.com, lenb@kernel.org,
	suresh.b.siddha@intel.com, kent.liu@intel.com,
	chaohong.guo@intel.com, linux-kernel@vger.kernel.org,
	linux-acpi@vger.kernel.org,
	Youquan Song <youquan.song@linux.intel.com>,
	Youquan Song <youquan.song@intel.com>
Subject: [PATCH 6/6] cpufreq: Evaluate P1 before enter turbo mode
Date: Thu, 23 Dec 2010 14:17:06 +0800	[thread overview]
Message-ID: <1293085026-18173-7-git-send-email-youquan.song@intel.com> (raw)
In-Reply-To: <1293085026-18173-6-git-send-email-youquan.song@intel.com>

The Turbo Mode (P0) will comsume much more power compare with second largest
frequency (P1) and P1 frequency is often double, even more, with Pn lowest
frequency; Current logic will increase sharply to highest frequency Turbo Mode
when workload reach to up_threshold of current frequency capacity, even current
frequency at lowest frequency. In this patchset, it will firstly evaluate P1 if
it is enough to support current workload before directly enter into Turbo Mode.
If P1 can meet workload requirement, it will save power compare of being Turbo
Mode.  

Signed-off-by: Youquan Song <youquan.song@intel.com>
---
 drivers/cpufreq/cpufreq_ondemand.c |    7 ++++++-
 drivers/cpufreq/freq_table.c       |    9 +++++++++
 include/linux/cpufreq.h            |    1 +
 3 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index 85ca136..682b2ea 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -797,7 +797,12 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
 		if (policy->cur < policy->max)
 			this_dbs_info->rate_mult =
 				dbs_tuners_ins.sampling_down_factor;
-		dbs_freq_increase(policy, policy->max);
+		/* Before go to turbo, try P1 first */
+		if ((policy->max > policy->sec_max) &&
+				(policy->cur == policy->sec_max))
+			dbs_freq_increase(policy, policy->max);
+		else
+			dbs_freq_increase(policy, policy->sec_max);
 		return;
 	}
 
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index 0543221..d7dc010 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -26,6 +26,7 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
 {
 	unsigned int min_freq = ~0;
 	unsigned int max_freq = 0;
+	unsigned int sec_max_freq = 0;
 	unsigned int i;
 
 	for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {
@@ -41,10 +42,18 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
 			min_freq = freq;
 		if (freq > max_freq)
 			max_freq = freq;
+		/* Find the second largest frequency */
+		if ((freq < max_freq) && (freq > sec_max_freq))
+			sec_max_freq = freq;
 	}
 
 	policy->min = policy->cpuinfo.min_freq = min_freq;
 	policy->max = policy->cpuinfo.max_freq = max_freq;
+	/* Check CPU turbo mode enabled */
+	if (max_freq - sec_max_freq == 1000)
+		policy->sec_max = sec_max_freq;
+	else
+		policy->sec_max = max_freq;
 
 	if (policy->min == ~0)
 		return -EINVAL;
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index c3e9de8..0087e56 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -92,6 +92,7 @@ struct cpufreq_policy {
 
 	unsigned int		min;    /* in kHz */
 	unsigned int		max;    /* in kHz */
+	unsigned int		sec_max; /* in kHz*/
 	unsigned int		cur;    /* in kHz, only needed if cpufreq
 					 * governors are used */
         unsigned int		policy; /* see above */
-- 
1.6.4.2


  reply	other threads:[~2010-12-23  6:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-23  6:17 [PATCH 0/6] cpufreq: Add sampling window to enhance ondemand governor power efficiency Youquan Song
2010-12-23  6:17 ` [PATCH 1/6] cpufreq: Add sampling window for ondemand governor Youquan Song
2010-12-23  6:17   ` [PATCH 2/6] cpufreq: Add sampling_window tunable Youquan Song
2010-12-23  6:17     ` [PATCH 3/6] cpufreq: Add roll back non-sampling_window Youquan Song
2010-12-23  6:17       ` [PATCH 4/6] cpufreq: Add dynamic sampling window tunable Youquan Song
2010-12-23  6:17         ` [PATCH 5/6] cpufreq: Add down_differential tunable Youquan Song
2010-12-23  6:17           ` Youquan Song [this message]
2010-12-23  6:23 [PATCH 0/6] cpufreq: Add sampling window to enhance ondemand governor power efficiency Youquan Song
2010-12-23  6:23 ` [PATCH 1/6] cpufreq: Add sampling window for ondemand governor Youquan Song
2010-12-23  6:23   ` [PATCH 2/6] cpufreq: Add sampling_window tunable Youquan Song
2010-12-23  6:23     ` [PATCH 3/6] cpufreq: Add roll back non-sampling_window Youquan Song
2010-12-23  6:23       ` [PATCH 4/6] cpufreq: Add dynamic sampling window tunable Youquan Song
2010-12-23  6:23         ` [PATCH 5/6] cpufreq: Add down_differential tunable Youquan Song
2010-12-23  6:23           ` [PATCH 6/6] cpufreq: Evaluate P1 before enter turbo mode Youquan Song
2010-12-23 10:57             ` Dominik Brodowski
2010-12-23 14:38               ` Matthew Garrett
2010-12-23 18:13                 ` Venkatesh Pallipadi
2010-12-23 20:48                   ` Dominik Brodowski

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=1293085026-18173-7-git-send-email-youquan.song@intel.com \
    --to=youquan.song@intel.com \
    --cc=arjan@linux.intel.com \
    --cc=chaohong.guo@intel.com \
    --cc=cpufreq@vger.kernle.org \
    --cc=davej@redhat.com \
    --cc=kent.liu@intel.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=suresh.b.siddha@intel.com \
    --cc=venki@google.com \
    --cc=youquan.song@linux.intel.com \
    /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®