Date: Tue, 26 May 1998 19:00:11 +0200 (SAT) From: John Hay <jhay@mikom.csir.co.za> To: smp@FreeBSD.ORG Subject: fix for systat -vmstat intr counts Message-ID: <199805261700.TAA17043@zibbi.mikom.csir.co.za>
next in thread | raw e-mail | index | archive | help
Hi, Here is a possible fix for the problem that systat -vmstat show half the real interrupt rate on a dual processor SMP machine. One thing I'm not sure about is if it is necessary to do more checking on the values that sysctl return and if the return value of any of the sysctl calls should be checked. Any comments? John -- John Hay -- John.Hay@mikom.csir.co.za --- usr.bin/systat/vmstat.c.org Thu Sep 25 03:14:25 1997 +++ usr.bin/systat/vmstat.c Tue May 26 13:52:22 1998 @@ -104,6 +104,7 @@ static void putfloat __P((double, int, int, int, int, int)); static int ucount __P((void)); +static int ncpu; static int ut; static char buf[26]; static time_t t; @@ -402,6 +403,7 @@ } failcnt = 0; etime /= hertz; + etime /= ncpu; inttotal = 0; for (i = 0; i < nintr; i++) { if (s.intrcnt[i] == 0) @@ -619,7 +621,7 @@ struct Info *s; enum state st; { - int mib[2], size; + int mib[2], size, smpmode; extern int errno; NREAD(X_CPTIME, s->time, sizeof s->time); @@ -642,6 +644,14 @@ error("Can't get kernel info: %s\n", strerror(errno)); bzero(&s->Total, sizeof(s->Total)); } + ncpu = 1; + smpmode = 0; + size = sizeof(ncpu); + sysctlbyname("hw.ncpu", &ncpu, &size, NULL, 0); + if (ncpu > 1) + sysctlbyname("machdep.smp_active", &smpmode, &size, NULL, 0); + if ((smpmode == 0) || (ncpu < 1)) + ncpu = 1; } static void To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-smp" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199805261700.TAA17043>