Skip to contentSkip to conversation

sched/core: use correct cpu_capacity in wake_affine_weight()

PATCH In review Honglei Wang 3 participants 3 messages Nov 16, 2022 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched/core: use correct cpu_capacity in wake_affine_weight()

It seems make more sense to do the load weight calculation with respective cpu_capacity.

---
 kernel/sched/fair.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/fair.c +2 -2
index e4a0b8bd941c..a9f75040969b 100644
@@ -6262,13 +6262,13 @@ wake_affine_weight(struct sched_domain *sd, struct task_struct *p,
 	this_eff_load += task_load;
 	if (sched_feat(WA_BIAS))
 		this_eff_load *= 100;
-	this_eff_load *= capacity_of(prev_cpu);
+	this_eff_load *= capacity_of(this_cpu);
 
 	prev_eff_load = cpu_load(cpu_rq(prev_cpu));
 	prev_eff_load -= task_load;
 	if (sched_feat(WA_BIAS))
 		prev_eff_load *= 100 + (sd->imbalance_pct - 100) / 2;
-	prev_eff_load *= capacity_of(this_cpu);
+	prev_eff_load *= capacity_of(prev_cpu);
 
 	/*
 	 * If sync, adjust the weight of prev_eff_load such that if
Signature · 1 line
2.14.1
maintainer
#1 lore raw
Quoted 16 lines · Honglei Wang

It seems make more sense to do the load weight calculation with respective cpu_capacity.

---
 kernel/sched/fair.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/fair.c +0 -0
index e4a0b8bd941c..a9f75040969b 100644
@@ -6262,13 +6262,13 @@ wake_affine_weight(struct sched_domain *sd, struct task_struct *p,
        this_eff_load += task_load;
        if (sched_feat(WA_BIAS))

kernel/sched/fair.c wake_affine_weight(struct sched_domain *sd, struct task_struct *p, · line 6271

Quoted 10 lines
kernel/sched/fair.c +2 -2
                this_eff_load *= 100;
-       this_eff_load *= capacity_of(prev_cpu);
+       this_eff_load *= capacity_of(this_cpu);
 
        prev_eff_load = cpu_load(cpu_rq(prev_cpu));
        prev_eff_load -= task_load;
        if (sched_feat(WA_BIAS))
                prev_eff_load *= 100 + (sd->imbalance_pct - 100) / 2;
-       prev_eff_load *= capacity_of(this_cpu);
+       prev_eff_load *= capacity_of(prev_cpu);

we want to test :

    (cpu_load(this_rq) + task_h_load(p) ) / capacity_of(this_cpu)  <

cpu_load(prev_rq) / capacity_of(prev_cpu)

but instead of doing expensive division, we do the below which gives the same result

    (cpu_load(this_rq) + task_h_load(p) ) * capacity_of(prev_cpu)  <

cpu_load(prev_rq) * capacity_of(this_cpu)

Quoted 6 lines
kernel/sched/fair.c +0 -1
        /*
         * If sync, adjust the weight of prev_eff_load such that if
--

2.14.1

#2 lore raw
Quoted 29 lines · Vincent Guittot
Quoted 16 lines · Honglei Wang

It seems make more sense to do the load weight calculation with respective cpu_capacity.

---
  kernel/sched/fair.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/fair.c +0 -0
index e4a0b8bd941c..a9f75040969b 100644
@@ -6262,13 +6262,13 @@ wake_affine_weight(struct sched_domain *sd, struct task_struct *p,
         this_eff_load += task_load;
         if (sched_feat(WA_BIAS))

kernel/sched/fair.c wake_affine_weight(struct sched_domain *sd, struct task_struct *p, · line 6271

Quoted 10 lines
kernel/sched/fair.c +2 -2
                 this_eff_load *= 100;
-       this_eff_load *= capacity_of(prev_cpu);
+       this_eff_load *= capacity_of(this_cpu);
 
         prev_eff_load = cpu_load(cpu_rq(prev_cpu));
         prev_eff_load -= task_load;
         if (sched_feat(WA_BIAS))
                 prev_eff_load *= 100 + (sd->imbalance_pct - 100) / 2;
-       prev_eff_load *= capacity_of(this_cpu);
+       prev_eff_load *= capacity_of(prev_cpu);

we want to test :

Quoted 9 lines
     (cpu_load(this_rq) + task_h_load(p) ) / capacity_of(this_cpu)  <

cpu_load(prev_rq) / capacity_of(prev_cpu)

but instead of doing expensive division, we do the below which gives the same result

     (cpu_load(this_rq) + task_h_load(p) ) * capacity_of(prev_cpu)  <

cpu_load(prev_rq) * capacity_of(this_cpu)

ha, I misunderstand the strategy, thanks for coaching, Vincent.

Quoted 6 lines
Quoted 6 lines
kernel/sched/fair.c +0 -1
         /*
          * If sync, adjust the weight of prev_eff_load such that if
--

2.14.1