- /* Average count of the threads */
- ci_rq->r_avgcount = (ci_rq->r_avgcount + ci_rq->r_mcount) >> 1;
+ /*
+ * Average count of the threads
+ *
+ * The average is computed as a fixpoint number with
+ * 8 fractional bits.
+ */
+ ci_rq->r_avgcount = (
+ weight * ci_rq->r_avgcount + (100 - weight) * 256 * ci_rq->r_mcount
+ ) / 100;
/* Look for CPU with the highest average */
if (ci_rq->r_avgcount > highest) {
@@ -840,6 +854,12 @@ SYSCTL_SETUP(sysctl_sched_setup, "sysctl
CTL_CREATE, CTL_EOL);
sysctl_createv(clog, 0, &node, NULL,
CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
+ CTLTYPE_INT, "average_weight",
+ SYSCTL_DESCR("Thread count averaging weight (in percent)"),
+ NULL, 0, &average_weight, 0,
+ CTL_CREATE, CTL_EOL);
+ sysctl_createv(clog, 0, &node, NULL,
+ CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
CTLTYPE_INT, "min_catch",
SYSCTL_DESCR("Minimal count of threads for catching"),
NULL, 0, &min_catch, 0,