From owner-freebsd-smp Tue May 26 10:00:30 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id KAA04069 for freebsd-smp-outgoing; Tue, 26 May 1998 10:00:30 -0700 (PDT) (envelope-from owner-freebsd-smp@FreeBSD.ORG) Received: from zibbi.mikom.csir.co.za (zibbi.mikom.csir.co.za [146.64.24.58]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id KAA04049 for ; Tue, 26 May 1998 10:00:15 -0700 (PDT) (envelope-from jhay@zibbi.mikom.csir.co.za) Received: (from jhay@localhost) by zibbi.mikom.csir.co.za (8.9.0.Beta5/8.9.0.Beta5) id TAA17043 for smp@freebsd.org; Tue, 26 May 1998 19:00:11 +0200 (SAT) From: John Hay Message-Id: <199805261700.TAA17043@zibbi.mikom.csir.co.za> Subject: fix for systat -vmstat intr counts To: smp@FreeBSD.ORG Date: Tue, 26 May 1998 19:00:11 +0200 (SAT) X-Mailer: ELM [version 2.4ME+ PL32 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-smp@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org 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