From owner-svn-src-stable@FreeBSD.ORG Sat Nov 7 10:44:46 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 99AFD106566B; Sat, 7 Nov 2009 10:44:46 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 55E038FC0C; Sat, 7 Nov 2009 10:44:46 +0000 (UTC) Received: from fledge.watson.org (fledge.watson.org [65.122.17.41]) by cyrus.watson.org (Postfix) with ESMTPS id CC18646B23; Sat, 7 Nov 2009 05:44:45 -0500 (EST) Date: Sat, 7 Nov 2009 10:44:45 +0000 (GMT) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: John Baldwin In-Reply-To: <200911062033.nA6KXr20028001@svn.freebsd.org> Message-ID: References: <200911062033.nA6KXr20028001@svn.freebsd.org> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-7@freebsd.org Subject: Re: svn commit: r199004 - stable/7/usr.bin/vmstat X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Nov 2009 10:44:46 -0000 On Fri, 6 Nov 2009, John Baldwin wrote: > MFC 198620: > When fetching sum stats (vmstat -s) from a crash dump, fetch per-CPU counts > and sum them to form the total counts. At some point, we need to complete the migration to per-CPU stats for most of our statistics counters, as well as a migration to DPCPU to store them. Among other things, this will reduce the endemic problem we have with per-CPU stats from different CPUs being packed into the same cache line. Once we do that, we'll probably want a libkvm utility routine for managing DPCPU retrievals. Robert N M Watson Computer Laboratory University of Cambridge > > Modified: > stable/7/usr.bin/vmstat/vmstat.c > Directory Properties: > stable/7/usr.bin/vmstat/ (props changed) > > Modified: stable/7/usr.bin/vmstat/vmstat.c > ============================================================================== > --- stable/7/usr.bin/vmstat/vmstat.c Fri Nov 6 20:33:40 2009 (r199003) > +++ stable/7/usr.bin/vmstat/vmstat.c Fri Nov 6 20:33:53 2009 (r199004) > @@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > +#include > > #include > > @@ -420,10 +421,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) \ >