Skip to contentSkip to conversation

sched/fair: fix contribution calculation

PATCH In review Ganesh Mahendran 2 participants 3 messages Jul 5, 2017 – Jul 6, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched/fair: fix contribution calculation

Function __compute_runnable_contrib() is to calculate:
\Sum 1024*y^n {for (1..n_period)}
But LOAD_AVG_MAX returns sum of 1024*y^n (0..n_period). So we need to subtract 1024*y^0.

---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +1 -1
index 90e26b1..777ad49 100644
@@ -2508,7 +2508,7 @@ static u32 __compute_runnable_contrib(u64 n)
 	if (likely(n <= LOAD_AVG_PERIOD))
 		return runnable_avg_yN_sum[n];
 	else if (unlikely(n >= LOAD_AVG_MAX_N))
-		return LOAD_AVG_MAX;
+		return LOAD_AVG_MAX - 1024;
 
 	/* Compute \Sum k^n combining precomputed values for k^i, \Sum k^j */
 	do {
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 16 lines · Ganesh Mahendran

Function __compute_runnable_contrib() is to calculate:

   \Sum 1024*y^n {for (1..n_period)}

But LOAD_AVG_MAX returns sum of 1024*y^n (0..n_period). So we need to subtract 1024*y^0.

---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +0 -0
index 90e26b1..777ad49 100644

kernel/sched/fair.c static u32 __compute_runnable_contrib(u64 n) · line 2514

Quoted 8 lines
kernel/sched/fair.c +1 -1
@@ -2508,7 +2508,7 @@ static u32 __compute_runnable_contrib(u64 n)
 	if (likely(n <= LOAD_AVG_PERIOD))
 		return runnable_avg_yN_sum[n];
 	else if (unlikely(n >= LOAD_AVG_MAX_N))
-		return LOAD_AVG_MAX;
+		return LOAD_AVG_MAX - 1024;
 
 	/* Compute \Sum k^n combining precomputed values for k^i, \Sum k^j */
 	do {

This code no longer exists...

#2 lore raw

Hello, Peter:

2017-07-05 19:59 GMT+08:00 Peter Zijlstra <[email protected]>:

Quoted 23 lines · Ganesh Mahendran
Quoted 22 lines

Function __compute_runnable_contrib() is to calculate:

   \Sum 1024*y^n {for (1..n_period)}

But LOAD_AVG_MAX returns sum of 1024*y^n (0..n_period). So we need to subtract 1024*y^0.

---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +1 -1
index 90e26b1..777ad49 100644
@@ -2508,7 +2508,7 @@ static u32 __compute_runnable_contrib(u64 n)
      if (likely(n <= LOAD_AVG_PERIOD))
              return runnable_avg_yN_sum[n];
      else if (unlikely(n >= LOAD_AVG_MAX_N))
-             return LOAD_AVG_MAX;
+             return LOAD_AVG_MAX - 1024;
 
Quoted 5 lines

kernel/sched/fair.c static u32 __compute_runnable_contrib(u64 n) · line 2514

Quoted 2 lines
kernel/sched/fair.c +0 -0
      /* Compute \Sum k^n combining precomputed values for k^i, \Sum k^j */
      do {

This code no longer exists...

Yes, you are right. The latest kernel has fix this. Do we need to fix this in LTS 4.1, 4.4?

Thanks.