Hi,
When a cpu is idle, and wants to steal, it should steal from worst loaded cpu,
i.e. with the highest cost, not the least cost.
Also, remove a dead store while here.
Thanks
Index: kern/kern_sched.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_sched.c,v
retrieving revision 1.64
diff -u -p -u -p -r1.64 kern_sched.c
--- kern/kern_sched.c 30 Jan 2020 08:51:27 -0000 1.64
+++ kern/kern_sched.c 4 Feb 2020 14:25:59 -0000
@@ -487,7 +487,7 @@ sched_steal_proc(struct cpu_info *self)
struct proc *best = NULL;
#ifdef MULTIPROCESSOR
struct schedstate_percpu *spc;
- int bestcost = INT_MAX;
+ int bestcost = 0;
struct cpu_info *ci;
struct cpuset set;
@@ -515,7 +515,7 @@ sched_steal_proc(struct cpu_info *self)
cost = sched_proc_to_cpu_cost(self, p);
- if (best == NULL || cost < bestcost) {
+ if (cost > bestcost) {
best = p;
bestcost = cost;
}
@@ -524,7 +524,6 @@ sched_steal_proc(struct cpu_info *self)
if (best == NULL)
return (NULL);
- spc = &best->p_cpu->ci_schedstate;
remrunqueue(best);
best->p_cpu = self;