Skip to contentSkip to conversation

sched/fair: Fix load_above_capacity fixed point arithmetic width

PATCH In review Dietmar Eggemann 3 participants 3 messages Aug 10, 2016 – Sep 5, 2016 Scheduler

lore
Share & tools
lore

Dietmar Eggemann

author reviewer
#0 lore raw

PATCH 1/1 sched/fair: Fix load_above_capacity fixed point arithmetic width

Since commit 2159197d6677 ("sched/core: Enable increased load resolution on 64-bit kernels") we now have two different fixed point units for load.
load_above_capacity has to have 10 bit fixed point unit like PELT whereas NICE_0_LOAD has 20 bit fixed point unit on 64-bit kernels. Fix this by scaling down NICE_0_LOAD when multiplying load_above_capacity with it.

---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +1 -1
index 4088eedea763..fe4093807852 100644
@@ -7147,7 +7147,7 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s
 		load_above_capacity = busiest->sum_nr_running * SCHED_CAPACITY_SCALE;
 		if (load_above_capacity > busiest->group_capacity) {
 			load_above_capacity -= busiest->group_capacity;
-			load_above_capacity *= NICE_0_LOAD;
+			load_above_capacity *= scale_load_down(NICE_0_LOAD);
 			load_above_capacity /= busiest->group_capacity;
 		} else
 			load_above_capacity = ~0UL;
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 19 lines · Dietmar Eggemann

Since commit 2159197d6677 ("sched/core: Enable increased load resolution on 64-bit kernels") we now have two different fixed point units for load.
load_above_capacity has to have 10 bit fixed point unit like PELT whereas NICE_0_LOAD has 20 bit fixed point unit on 64-bit kernels. Fix this by scaling down NICE_0_LOAD when multiplying load_above_capacity with it.

---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +0 -0
index 4088eedea763..fe4093807852 100644

kernel/sched/fair.c static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s · line 7150

Quoted 5 lines
kernel/sched/fair.c +1 -1
@@ -7147,7 +7147,7 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s
                load_above_capacity = busiest->sum_nr_running * SCHED_CAPACITY_SCALE;
                if (load_above_capacity > busiest->group_capacity) {
                        load_above_capacity -= busiest->group_capacity;
-                       load_above_capacity *= NICE_0_LOAD;
+                       load_above_capacity *= scale_load_down(NICE_0_LOAD);

FWIW, Acked-by: Vincent Guittot <[email protected]>

Quoted 6 lines
kernel/sched/fair.c +0 -1
                        load_above_capacity /= busiest->group_capacity;
                } else
                        load_above_capacity = ~0UL;
--

1.9.1

#2 lore raw
In reply to Dietmar Eggemann
sched/fair: Fix load_above_capacity fixed point arithmetic width
Commit-ID:  2665621506e178a1f62e59200403c359c463ea5e
Gitweb:     http://git.kernel.org/tip/2665621506e178a1f62e59200403c359c463ea5e
Author:     Dietmar Eggemann <[email protected]>
AuthorDate: Wed, 10 Aug 2016 11:27:27 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 5 Sep 2016 13:29:44 +0200

sched/fair: Fix load_above_capacity fixed point arithmetic width

Since commit:

2159197d6677 ("sched/core: Enable increased load resolution on 64-bit kernels")

we now have two different fixed point units for load.

load_above_capacity has to have 10 bits fixed point unit like PELT, whereas NICE_0_LOAD has 20 bit fixed point unit on 64-bit kernels.

Fix this by scaling down NICE_0_LOAD when multiplying load_above_capacity with it.

---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +1 -1
index 9a18aae..6011bfe 100644
@@ -7193,7 +7193,7 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s
 		load_above_capacity = busiest->sum_nr_running * SCHED_CAPACITY_SCALE;
 		if (load_above_capacity > busiest->group_capacity) {
 			load_above_capacity -= busiest->group_capacity;
-			load_above_capacity *= NICE_0_LOAD;
+			load_above_capacity *= scale_load_down(NICE_0_LOAD);
 			load_above_capacity /= busiest->group_capacity;
 		} else
 			load_above_capacity = ~0UL;