Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-7]: src/sys/kern Pull up following revision(s) (requ...
details: https://anonhg.NetBSD.org/src/rev/bdfdd7e45228
branches: netbsd-7
changeset: 318823:bdfdd7e45228
user: martin <martin%NetBSD.org@localhost>
date: Sun May 06 09:53:27 2018 +0000
description:
Pull up following revision(s) (requested by mlelstv in ticket #1603):
sys/kern/kern_runq.c: revision 1.46
When balancing threads over multiple CPUs, use fixpoint arithmetic
for averages. Otherwise the decisions can be heavily biased by rounding
errors.
Add sysctl kern.sched_average_weight to change the weight of
historical data, the default is 50%.
diffstat:
sys/kern/kern_runq.c | 30 +++++++++++++++++++++++++-----
1 files changed, 25 insertions(+), 5 deletions(-)
diffs (86 lines):
diff -r 6a138e08992a -r bdfdd7e45228 sys/kern/kern_runq.c
--- a/sys/kern/kern_runq.c Thu May 03 15:14:14 2018 +0000
+++ b/sys/kern/kern_runq.c Sun May 06 09:53:27 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_runq.c,v 1.43 2014/08/03 19:14:24 wiz Exp $ */
+/* $NetBSD: kern_runq.c,v 1.43.2.1 2018/05/06 09:53:27 martin Exp $ */
/*
* Copyright (c) 2007, 2008 Mindaugas Rasiukevicius <rmind at NetBSD org>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_runq.c,v 1.43 2014/08/03 19:14:24 wiz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_runq.c,v 1.43.2.1 2018/05/06 09:53:27 martin Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -78,7 +78,7 @@
uint32_t r_bitmap[PRI_COUNT >> BITMAP_SHIFT];
/* Counters */
u_int r_count; /* Count of the threads */
- u_int r_avgcount; /* Average count of threads */
+ u_int r_avgcount; /* Average count of threads (* 256) */
u_int r_mcount; /* Count of migratable threads */
/* Runqueues */
queue_t r_rt_queue[PRI_RT_COUNT];
@@ -116,6 +116,7 @@
static u_int cacheht_time; /* Cache hotness time */
static u_int min_catch; /* Minimal LWP count for catching */
static u_int balance_period; /* Balance period */
+static u_int average_weight; /* Weight old thread count average */
static struct cpu_info *worker_ci; /* Victim CPU */
#ifdef MULTIPROCESSOR
static struct callout balance_ch; /* Callout of balancer */
@@ -132,6 +133,8 @@
/* Minimal count of LWPs for catching */
min_catch = 1;
+ /* Weight of historical average */
+ average_weight = 50; /* 0.5 */
/* Initialize balancing callout and run it */
#ifdef MULTIPROCESSOR
@@ -519,6 +522,10 @@
runqueue_t *ci_rq;
CPU_INFO_ITERATOR cii;
u_int highest;
+ u_int weight;
+
+ /* sanitize sysctl value */
+ weight = MIN(average_weight, 100);
hci = curcpu();
highest = 0;
@@ -527,8 +534,15 @@
for (CPU_INFO_FOREACH(cii, ci)) {
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;
+ /*
+ * 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) {
@@ -831,6 +845,12 @@
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,
Home |
Main Index |
Thread Index |
Old Index