Date: Wed, 23 May 2012 18:10:55 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r235850 - in head/sys: kern sys vm Message-ID: <201205231810.q4NIAteP087924@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Wed May 23 18:10:54 2012 New Revision: 235850 URL: http://svn.freebsd.org/changeset/base/235850 Log: Calculate the count of per-process cow faults. Export the count to userspace using the obscure spare int field in struct kinfo_proc. Submitted by: Andrey Zonov <andrey zonov org> MFC after: 1 week Modified: head/sys/kern/kern_proc.c head/sys/sys/proc.h head/sys/sys/user.h head/sys/vm/vm_fault.c Modified: head/sys/kern/kern_proc.c ============================================================================== --- head/sys/kern/kern_proc.c Wed May 23 17:49:59 2012 (r235849) +++ head/sys/kern/kern_proc.c Wed May 23 18:10:54 2012 (r235850) @@ -878,6 +878,9 @@ fill_kinfo_proc_only(struct proc *p, str kp->ki_childtime = kp->ki_childstime; timevaladd(&kp->ki_childtime, &kp->ki_childutime); + FOREACH_THREAD_IN_PROC(p, td0) + kp->ki_cow += td0->td_cow; + tp = NULL; if (p->p_pgrp) { kp->ki_pgid = p->p_pgrp->pg_id; @@ -990,6 +993,7 @@ fill_kinfo_thread(struct thread *td, str kp->ki_runtime = cputick2usec(td->td_rux.rux_runtime); kp->ki_pctcpu = sched_pctcpu(td); kp->ki_estcpu = td->td_estcpu; + kp->ki_cow = td->td_cow; } /* We can't get this anymore but ps etc never used it anyway. */ Modified: head/sys/sys/proc.h ============================================================================== --- head/sys/sys/proc.h Wed May 23 17:49:59 2012 (r235849) +++ head/sys/sys/proc.h Wed May 23 18:10:54 2012 (r235850) @@ -247,6 +247,7 @@ struct thread { int td_slptick; /* (t) Time at sleep. */ int td_blktick; /* (t) Time spent blocked. */ int td_swvoltick; /* (t) Time at last SW_VOL switch. */ + u_int td_cow; /* (*) Number of copy-on-write faults */ struct rusage td_ru; /* (t) rusage information. */ struct rusage_ext td_rux; /* (t) Internal rusage information. */ uint64_t td_incruntime; /* (t) Cpu ticks to transfer to proc. */ Modified: head/sys/sys/user.h ============================================================================== --- head/sys/sys/user.h Wed May 23 17:49:59 2012 (r235849) +++ head/sys/sys/user.h Wed May 23 18:10:54 2012 (r235850) @@ -159,7 +159,7 @@ struct kinfo_proc { u_int ki_estcpu; /* Time averaged value of ki_cpticks */ u_int ki_slptime; /* Time since last blocked */ u_int ki_swtime; /* Time swapped in or out */ - int ki_spareint1; /* unused (just here for alignment) */ + u_int ki_cow; /* number of copy-on-write faults */ u_int64_t ki_runtime; /* Real time in microsec */ struct timeval ki_start; /* starting time */ struct timeval ki_childtime; /* time used by process children */ Modified: head/sys/vm/vm_fault.c ============================================================================== --- head/sys/vm/vm_fault.c Wed May 23 17:49:59 2012 (r235849) +++ head/sys/vm/vm_fault.c Wed May 23 18:10:54 2012 (r235850) @@ -805,6 +805,7 @@ vnode_locked: if (!is_first_object_locked) VM_OBJECT_LOCK(fs.object); PCPU_INC(cnt.v_cow_faults); + curthread->td_cow++; } else { prot &= ~VM_PROT_WRITE; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201205231810.q4NIAteP087924>