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]
Message-Id: <1373385338-12983-9-git-send-email-morten.rasmussen@arm.com>
Date:	Tue,  9 Jul 2013 16:55:37 +0100
From:	Morten Rasmussen <morten.rasmussen@....com>
To:	mingo@...nel.org, peterz@...radead.org
Cc:	arjan@...ux.intel.com, vincent.guittot@...aro.org,
	preeti@...ux.vnet.ibm.com, alex.shi@...el.com, efault@....de,
	pjt@...gle.com, len.brown@...el.com, corbet@....net,
	akpm@...ux-foundation.org, torvalds@...ux-foundation.org,
	tglx@...utronix.de, catalin.marinas@....com,
	linux-kernel@...r.kernel.org, linaro-kernel@...ts.linaro.org,
	morten.rasmussen@....com
Subject: [RFC][PATCH 8/9] sched: power: Add initial frequency scaling support to power scheduler

Extends the power scheduler capacity management algorithm to handle
frequency scaling and provide basic frequency/P-state selection hints
to the power driver.

Signed-off-by: Morten Rasmussen <morten.rasmussen@....com>
CC: Ingo Molnar <mingo@...nel.org>
CC: Peter Zijlstra <peterz@...radead.org>
CC: Catalin Marinas <catalin.marinas@....com>
---
 kernel/sched/power.c |   33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/power.c b/kernel/sched/power.c
index 9e44c0e..5fc32b0 100644
--- a/kernel/sched/power.c
+++ b/kernel/sched/power.c
@@ -21,6 +21,8 @@
 
 #define INTERVAL 5 /* ms */
 #define CPU_FULL 90 /* Busy %-age - TODO: Make tunable */
+#define CPU_TARGET 80 /* Target busy %-age - TODO: Make tunable */
+#define CPU_EMPTY 5 /* Idle noise %-age - TODO: Make tunable */
 
 struct power_domain {
 	/* Domain hierarchy pointers */
@@ -87,7 +89,7 @@ static void update_cpu_load(void)
 		u32 sum = rq->avg.runnable_avg_sum;
 		u32 period = rq->avg.runnable_avg_period;
 
-		load = (sum * power_sched_cpu_power(i)) / (period+1);
+		load = (sum * cpu_pd(i)->curr_power) / (period+1);
 		cpu_pd(i)->load = load;
 		cpu_pd(i)->nr_tasks = rq->nr_running;
 
@@ -160,19 +162,40 @@ static void calculate_cpu_capacities(void)
 
 	for_each_online_cpu(i) {
 		int t_cap = 0;
-		int sched_power = cpu_pd(i)->sched_power;
+		int curr_power = cpu_pd(i)->curr_power;
 
 		stats = cpu_pd(i);
-		t_cap = sched_power - stats->load;
+		t_cap = curr_power - stats->load;
 
-		if (t_cap < (sched_power * (100-CPU_FULL)) / 100) {
+		if (t_cap < (curr_power * (100-CPU_FULL)) / 100) {
 			/* Potential for spreading load */
 			if (stats->nr_tasks > 1)
 				t_cap = -(stats->load / stats->nr_tasks);
+			/*
+			 * Single task and higher p-state available on
+			 * current cpu
+			 */
+			else if (power_driver &&
+					curr_power < cpu_pd(i)->arch_power)
+				power_driver->req_power(i,
+						cpu_pd(i)->arch_power);
+		} else {
+			/* cpu not full - request lower p-state */
+			/*
+			 * TODO global view of spare capacity is needed to do
+			 * proper p-state selection
+			 */
+			if (power_driver)
+				power_driver->req_power(i,
+						(stats->load*100)/CPU_TARGET);
+
+			/* Don't let noise keep the cpu awake */
+			if (t_cap > (curr_power * CPU_EMPTY) / 100)
+				t_cap = curr_power;
 		}
 
 		/* Do we have enough capacity already? */
-		if (spare_cap + t_cap > sched_power) {
+		if (spare_cap + t_cap > curr_power) {
 			cpu_pd(i)->sched_power = 1;
 		} else {
 			cpu_pd(i)->sched_power = cpu_pd(i)->arch_power;
-- 
1.7.9.5


--
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