From owner-freebsd-bugs@FreeBSD.ORG Thu Oct 29 17:40:05 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 29CAD1065676 for ; Thu, 29 Oct 2009 17:40:05 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 000928FC12 for ; Thu, 29 Oct 2009 17:40:04 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n9THe4Bf030943 for ; Thu, 29 Oct 2009 17:40:04 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n9THe4Wx030941; Thu, 29 Oct 2009 17:40:04 GMT (envelope-from gnats) Date: Thu, 29 Oct 2009 17:40:04 GMT Message-Id: <200910291740.n9THe4Wx030941@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: dfilter@FreeBSD.ORG (dfilter service) Cc: Subject: Re: bin/135893: commit references a PR X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: dfilter service List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Oct 2009 17:40:05 -0000 The following reply was made to PR bin/135893; it has been noted by GNATS. From: dfilter@FreeBSD.ORG (dfilter service) To: bug-followup@FreeBSD.org Cc: Subject: Re: bin/135893: commit references a PR Date: Thu, 29 Oct 2009 17:34:13 +0000 (UTC) Author: jhb Date: Thu Oct 29 17:34:02 2009 New Revision: 198620 URL: http://svn.freebsd.org/changeset/base/198620 Log: When fetching sum stats (vmstat -s) from a crash dump, fetch per-CPU counts and sum them to form the total counts. PR: bin/135893 Submitted by: Mikolaj Golub to my trociny of gmail MFC after: 1 week Modified: head/usr.bin/vmstat/vmstat.c Modified: head/usr.bin/vmstat/vmstat.c ============================================================================== --- head/usr.bin/vmstat/vmstat.c Thu Oct 29 17:21:41 2009 (r198619) +++ head/usr.bin/vmstat/vmstat.c Thu Oct 29 17:34:02 2009 (r198620) @@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -418,10 +419,90 @@ getuptime(void) } static void +fill_pcpu(struct pcpu ***pcpup, int* maxcpup) +{ + struct pcpu **pcpu; + + int maxcpu, size, i; + + *pcpup = NULL; + + if (kd == NULL) + return; + + maxcpu = kvm_getmaxcpu(kd); + if (maxcpu < 0) + errx(1, "kvm_getmaxcpu: %s", kvm_geterr(kd)); + + pcpu = calloc(maxcpu, sizeof(struct pcpu *)); + if (pcpu == NULL) + err(1, "calloc"); + + for (i = 0; i < maxcpu; i++) { + pcpu[i] = kvm_getpcpu(kd, i); + if (pcpu[i] == (struct pcpu *)-1) + errx(1, "kvm_getpcpu: %s", kvm_geterr(kd)); + } + + *maxcpup = maxcpu; + *pcpup = pcpu; +} + +static void +free_pcpu(struct pcpu **pcpu, int maxcpu) +{ + int i; + + for (i = 0; i < maxcpu; i++) + free(pcpu[i]); + free(pcpu); +} + +static void fill_vmmeter(struct vmmeter *vmmp) { + struct pcpu **pcpu; + int maxcpu, i; + if (kd != NULL) { kread(X_SUM, vmmp, sizeof(*vmmp)); + fill_pcpu(&pcpu, &maxcpu); + for (i = 0; i < maxcpu; i++) { + if (pcpu[i] == NULL) + continue; +#define ADD_FROM_PCPU(i, name) \ + vmmp->name += pcpu[i]->pc_cnt.name + ADD_FROM_PCPU(i, v_swtch); + ADD_FROM_PCPU(i, v_trap); + ADD_FROM_PCPU(i, v_syscall); + ADD_FROM_PCPU(i, v_intr); + ADD_FROM_PCPU(i, v_soft); + ADD_FROM_PCPU(i, v_vm_faults); + ADD_FROM_PCPU(i, v_cow_faults); + ADD_FROM_PCPU(i, v_cow_optim); + ADD_FROM_PCPU(i, v_zfod); + ADD_FROM_PCPU(i, v_ozfod); + ADD_FROM_PCPU(i, v_swapin); + ADD_FROM_PCPU(i, v_swapout); + ADD_FROM_PCPU(i, v_swappgsin); + ADD_FROM_PCPU(i, v_swappgsout); + ADD_FROM_PCPU(i, v_vnodein); + ADD_FROM_PCPU(i, v_vnodeout); + ADD_FROM_PCPU(i, v_vnodepgsin); + ADD_FROM_PCPU(i, v_vnodepgsout); + ADD_FROM_PCPU(i, v_intrans); + ADD_FROM_PCPU(i, v_tfree); + ADD_FROM_PCPU(i, v_forks); + ADD_FROM_PCPU(i, v_vforks); + ADD_FROM_PCPU(i, v_rforks); + ADD_FROM_PCPU(i, v_kthreads); + ADD_FROM_PCPU(i, v_forkpages); + ADD_FROM_PCPU(i, v_vforkpages); + ADD_FROM_PCPU(i, v_rforkpages); + ADD_FROM_PCPU(i, v_kthreadpages); +#undef ADD_FROM_PCPU + } + free_pcpu(pcpu, maxcpu); } else { size_t size = sizeof(unsigned int); #define GET_VM_STATS(cat, name) \ _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"