lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 23 Dec 2010 14:23:44 +0800
From:	Youquan Song <youquan.song@...el.com>
To:	davej@...hat.com, cpufreq@...r.kernel.org
Cc:	venki@...gle.com, arjan@...ux.intel.com, lenb@...nel.org,
	suresh.b.siddha@...el.com, kent.liu@...el.com,
	chaohong.guo@...el.com, linux-kernel@...r.kernel.org,
	linux-acpi@...r.kernel.org,
	Youquan Song <youquan.song@...ux.intel.com>,
	Youquan Song <youquan.song@...el.com>
Subject: [PATCH 6/6] cpufreq: Evaluate P1 before enter turbo mode

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@...el.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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ