Subject: Load average and netbsd-4
To: NetBSD current-users <current-users@NetBSD.org>
From: Paul Ripke <stix@stix.id.au>
List: current-users
Date: 02/16/2007 21:41:31
--ADZbWkCsHQ7r3kzd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Given the changes to load average determination in -current, I'm
wondering if something like the attached patch would make sense for
netbsd-4. I'm running it on my workstation, and the load average
seems more sane. It's a minor thing, but maybe I'm just a little
tired of seeing inflated load averages.
BTW: I put the check for p_flag at the end so it wouldn't have to
touch every process struct. Hopefully some LWPs get weeded out by
the other cheaper checks.
cheers,
--
Paul
--ADZbWkCsHQ7r3kzd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="uvm_meter.patch"
Index: uvm_meter.c
===================================================================
RCS file: /usr/netbsd/cvsroot/src/sys/uvm/uvm_meter.c,v
retrieving revision 1.43
diff -u -d -r1.43 uvm_meter.c
--- uvm_meter.c 1 Nov 2006 10:18:27 -0000 1.43
+++ uvm_meter.c 16 Feb 2007 05:10:02 -0000
@@ -83,15 +83,19 @@
void
uvm_meter(void)
{
- if ((time_second % 5) == 0)
+ static int count;
+
+ if (++count >= 5) {
+ count = 0;
uvm_loadav(&averunnable);
+ }
if (lwp0.l_slptime > (maxslp / 2))
wakeup(&proc0);
}
/*
* uvm_loadav: compute a tenex style load average of a quantity on
- * 1, 5, and 15 minute internvals.
+ * 1, 5, and 15 minute intervals.
*/
static void
uvm_loadav(struct loadavg *avg)
@@ -99,21 +103,26 @@
int i, nrun;
struct lwp *l;
- proclist_lock_read();
nrun = 0;
+
+ proclist_lock_read();
LIST_FOREACH(l, &alllwp, l_list) {
+ if ((l->l_flag & L_SINTR) != 0)
+ continue;
switch (l->l_stat) {
case LSSLEEP:
- if (l->l_priority > PZERO || l->l_slptime > 1)
+ if (l->l_slptime > 1)
continue;
/* fall through */
case LSRUN:
case LSONPROC:
case LSIDL:
- nrun++;
+ if ((l->l_proc->p_flag & P_SYSTEM) == 0)
+ nrun++;
}
}
proclist_unlock_read();
+
for (i = 0; i < 3; i++)
avg->ldavg[i] = (cexp[i] * avg->ldavg[i] +
nrun * FSCALE * (FSCALE - cexp[i])) >> FSHIFT;
--ADZbWkCsHQ7r3kzd--