summaryrefslogtreecommitdiffstats
path: root/meta-eas/recipes-kernel/linux/linux-renesas/0058-sched-fair-Add-energy_diff-dead-zone-margin.patch
blob: 163fb7c4b19013249e2f42a5765a23451e2cdbc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
From 91820aa3145f93421c29834315616f338b4fcca2 Mon Sep 17 00:00:00 2001
From: Morten Rasmussen <morten.rasmussen@arm.com>
Date: Wed, 30 Mar 2016 14:20:12 +0100
Subject: [PATCH 58/92] sched/fair: Add energy_diff dead-zone margin

It is not worth the overhead to migrate tasks for tiny insignificant
energy savings. To prevent this, an energy margin is introduced in
energy_diff() which effectively adds a dead-zone that rounds tiny energy
differences to zero. Since no scale is enforced for energy model data
the margin can't be absolute. Instead it is defined as +/-1.56% energy
saving compared to the current total estimated energy consumption.

(cherry picked from commit c36ecf27db72f60934ce2c9ca7e3d97a80926c1c)
Signed-off-by: Gaku Inami <gaku.inami.xw@bp.renesas.com>
---
 kernel/sched/fair.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 799e2b5..5e13787 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5556,6 +5556,7 @@ static int energy_diff(struct energy_env *eenv)
 	struct sched_domain *sd;
 	struct sched_group *sg;
 	int sd_cpu = -1, energy_before = 0, energy_after = 0;
+	int diff, margin;
 
 	struct energy_env eenv_before = {
 		.util_delta	= 0,
@@ -5588,7 +5589,18 @@ static int energy_diff(struct energy_env *eenv)
 		}
 	} while (sg = sg->next, sg != sd->groups);
 
-	return energy_after-energy_before;
+	/*
+	 * Dead-zone margin preventing too many migrations.
+	 */
+
+	margin = energy_before >> 6; /* ~1.56% */
+
+	diff = energy_after-energy_before;
+
+	if (abs(diff) < margin)
+		return 0;
+
+	return diff;
 }
 
 /*
-- 
1.9.1