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
This commit is contained in:
Konstantin Belousov 2012-05-23 18:10:54 +00:00
parent 2920997423
commit 4d34e019c4
4 changed files with 7 additions and 1 deletions

View File

@ -878,6 +878,9 @@ fill_kinfo_proc_only(struct proc *p, struct kinfo_proc *kp)
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, struct kinfo_proc *kp, int preferthread)
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. */

View File

@ -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. */

View File

@ -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 */

View File

@ -805,6 +805,7 @@ RetryFault:;
if (!is_first_object_locked)
VM_OBJECT_LOCK(fs.object);
PCPU_INC(cnt.v_cow_faults);
curthread->td_cow++;
} else {
prot &= ~VM_PROT_WRITE;
}