In article <alpine.deb.2.00.1611102238460.6...@inya.fehu.org>, Hubert Feyrer <hub...@feyrer.de> wrote: >On Thu, 10 Nov 2016, Michael van Elst wrote: >>>> Can you try this? >> >>> Tried it, and it seems to help with both 2 and 4 CPUs. >>> Codebase: -current >> >> Great, so the problem was just the rounding error. > >Yes. I've also played with it a bit more, and the "stealing" of processes >between CPUs seems to get less with the factor of r_mcount, e.g. with 4* >below I see less movement of processes on a 4-CPU system as shown in the >patch below. > >Maybe this should be made a sysctl or depend on the number of CPUs? > > > - Hubert > > > >--- sys/kern/kern_runq.c.orig 2016-11-10 21:11:10.000000000 +0000 >+++ sys/kern/kern_runq.c >@@ -534,7 +534,9 @@ sched_balance(void *nocallout) > ci_rq = ci->ci_schedstate.spc_sched_info; > > /* Average count of the threads */ >- ci_rq->r_avgcount = (ci_rq->r_avgcount + ci_rq->r_mcount) >> 1; >+ ci_rq->r_avgcount = (ci_rq->r_avgcount + >+ 4*ci_rq->r_mcount >+ ) /2; > > /* Look for CPU with the highest average */ > if (ci_rq->r_avgcount > highest) {
I think that the code is wrong here; I think it should be using r_count... u_int totcount = ci_rq->r_count + ci_rq->r_mcount; ci_rq->r_avgcount = totcount >> 1; /* Look for CPU with the highest total */ if (totcount > highest) { hci = ci; highest = totcount; } Why avgcount is kept anyway? christos