svn commit: r236305 - in stable/8/sys: compat/freebsd32 kern sys vm

Konstantin Belousov kib at FreeBSD.org
Wed May 30 12:45:53 UTC 2012


Author: kib
Date: Wed May 30 12:45:52 2012
New Revision: 236305
URL: http://svn.freebsd.org/changeset/base/236305

Log:
  MFC r235850:
  Calculate the count of per-process cow faults.  Export the count to
  userspace using the obscure spare int field in struct kinfo_proc.
  
  MFC r236136:
  Fix ki_cow for compat32 binaries.

Modified:
  stable/8/sys/compat/freebsd32/freebsd32.h
  stable/8/sys/kern/kern_proc.c
  stable/8/sys/sys/proc.h
  stable/8/sys/sys/user.h
  stable/8/sys/vm/vm_fault.c
Directory Properties:
  stable/8/sys/   (props changed)

Modified: stable/8/sys/compat/freebsd32/freebsd32.h
==============================================================================
--- stable/8/sys/compat/freebsd32/freebsd32.h	Wed May 30 12:01:28 2012	(r236304)
+++ stable/8/sys/compat/freebsd32/freebsd32.h	Wed May 30 12:45:52 2012	(r236305)
@@ -297,7 +297,7 @@ struct kinfo_proc32 {
 	u_int	ki_estcpu;
 	u_int	ki_slptime;
 	u_int	ki_swtime;
-	int	ki_spareint1;
+	u_int	ki_cow;
 	u_int64_t ki_runtime;
 	struct	timeval32 ki_start;
 	struct	timeval32 ki_childtime;

Modified: stable/8/sys/kern/kern_proc.c
==============================================================================
--- stable/8/sys/kern/kern_proc.c	Wed May 30 12:01:28 2012	(r236304)
+++ stable/8/sys/kern/kern_proc.c	Wed May 30 12:45:52 2012	(r236305)
@@ -869,6 +869,10 @@ 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;
@@ -978,6 +982,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. */
@@ -1118,6 +1123,7 @@ freebsd32_kinfo_proc_out(const struct ki
 	CP(*ki, *ki32, ki_estcpu);
 	CP(*ki, *ki32, ki_slptime);
 	CP(*ki, *ki32, ki_swtime);
+	CP(*ki, *ki32, ki_cow);
 	CP(*ki, *ki32, ki_runtime);
 	TV_CP(*ki, *ki32, ki_start);
 	TV_CP(*ki, *ki32, ki_childtime);

Modified: stable/8/sys/sys/proc.h
==============================================================================
--- stable/8/sys/sys/proc.h	Wed May 30 12:01:28 2012	(r236304)
+++ stable/8/sys/sys/proc.h	Wed May 30 12:45:52 2012	(r236305)
@@ -240,6 +240,7 @@ struct thread {
 	u_int		td_estcpu;	/* (t) estimated cpu utilization */
 	int		td_slptick;	/* (t) Time at sleep. */
 	int		td_blktick;	/* (t) Time spent blocked. */
+	u_int		td_cow;		/* (*) Number of copy-on-write faults */
 	struct rusage	td_ru;		/* (t) rusage information. */
 	uint64_t	td_incruntime;	/* (t) Cpu ticks to transfer to proc. */
 	uint64_t	td_runtime;	/* (t) How many cpu ticks we've run. */

Modified: stable/8/sys/sys/user.h
==============================================================================
--- stable/8/sys/sys/user.h	Wed May 30 12:01:28 2012	(r236304)
+++ stable/8/sys/sys/user.h	Wed May 30 12:45:52 2012	(r236305)
@@ -151,7 +151,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: stable/8/sys/vm/vm_fault.c
==============================================================================
--- stable/8/sys/vm/vm_fault.c	Wed May 30 12:01:28 2012	(r236304)
+++ stable/8/sys/vm/vm_fault.c	Wed May 30 12:45:52 2012	(r236305)
@@ -823,6 +823,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;
 		}


More information about the svn-src-all mailing list