--- //depot/vendor/freebsd/src/sys/amd64/amd64/trap.c	2007/06/04 21:44:15
+++ //depot/user/attilio/attilio_schedlock/amd64/amd64/trap.c	2007/06/06 15:22:20
@@ -736,12 +736,7 @@
 	int reg, regcnt;
 	ksiginfo_t ksi;
 
-	/*
-	 * note: PCPU_INC() can only be used if we can afford
-	 * occassional inaccuracy in the count.
-	 */
 	PCPU_INC(cnt.v_syscall);
-
 #ifdef DIAGNOSTIC
 	if (ISPL(frame->tf_cs) != SEL_UPL) {
 		panic("syscall");
--- //depot/vendor/freebsd/src/sys/amd64/ia32/ia32_syscall.c	2007/06/04 21:44:15
+++ //depot/user/attilio/attilio_schedlock/amd64/ia32/ia32_syscall.c	2007/06/06 15:22:20
@@ -104,12 +104,7 @@
 	u_int code;
 	ksiginfo_t ksi;
 
-	/*
-	 * note: PCPU_INC() can only be used if we can afford
-	 * occassional inaccuracy in the count.
-	 */
 	PCPU_INC(cnt.v_syscall);
-
 	td->td_pticks = 0;
 	td->td_frame = frame;
 	if (td->td_ucred != p->p_ucred) 
--- //depot/vendor/freebsd/src/sys/arm/include/pcpu.h	2007/06/04 21:44:15
+++ //depot/user/attilio/attilio_schedlock/arm/include/pcpu.h	2007/06/06 15:13:19
@@ -58,7 +58,7 @@
  * with respect to preemption.
  */
 #define	PCPU_ADD(member, value)	(__pcpu.pc_ ## member += (value))
-#define	PCPU_INC(member)	PCPU_LAZY_ADD(member, 1)
+#define	PCPU_INC(member)	PCPU_ADD(member, 1)
 #define	PCPU_PTR(member)	(&__pcpu.pc_ ## member)
 #define	PCPU_SET(member,value)	(__pcpu.pc_ ## member = (value))
 
--- //depot/vendor/freebsd/src/sys/i386/i386/trap.c	2007/06/04 21:44:15
+++ //depot/user/attilio/attilio_schedlock/i386/i386/trap.c	2007/06/06 15:22:20
@@ -921,12 +921,7 @@
 	u_int code;
 	ksiginfo_t ksi;
 
-	/*
-	 * note: PCPU_INC() can only be used if we can afford
-	 * occassional inaccuracy in the count.
-	 */
 	PCPU_INC(cnt.v_syscall);
-
 #ifdef DIAGNOSTIC
 	if (ISPL(frame->tf_cs) != SEL_UPL) {
 		panic("syscall");
--- //depot/vendor/freebsd/src/sys/sys/vmmeter.h	2007/05/31 22:54:01
+++ //depot/user/attilio/attilio_schedlock/sys/vmmeter.h	2007/06/06 14:52:36
@@ -35,70 +35,75 @@
 
 /*
  * System wide statistics counters.
+ * Locking:
+ *      A - PCPU_* locked
+ *      B - locked by vm_page_queue_mtx
+ *      C - locked by atomic operations
+ *      D - initialized and never changing
  */
 struct vmmeter {
 	/*
 	 * General system activity.
 	 */
-	u_int v_swtch;		/* context switches */
-	u_int v_trap;		/* calls to trap */
-	u_int v_syscall;	/* calls to syscall() */
-	u_int v_intr;		/* device interrupts */
-	u_int v_soft;		/* software interrupts */
+	u_int v_swtch;		/* (A) context switches */
+	u_int v_trap;		/* (A) calls to trap */
+	u_int v_syscall;	/* (A) calls to syscall() */
+	u_int v_intr;		/* (A) device interrupts */
+	u_int v_soft;		/* (A) software interrupts */
 	/*
 	 * Virtual memory activity.
 	 */
-	u_int v_vm_faults;	/* number of address memory faults */
-	u_int v_cow_faults;	/* number of copy-on-writes */
-	u_int v_cow_optim;	/* number of optimized copy-on-writes */
-	u_int v_zfod;		/* pages zero filled on demand */
-	u_int v_ozfod;		/* optimized zero fill pages */
-	u_int v_swapin;		/* swap pager pageins */
-	u_int v_swapout;	/* swap pager pageouts */
-	u_int v_swappgsin;	/* swap pager pages paged in */
-	u_int v_swappgsout;	/* swap pager pages paged out */
-	u_int v_vnodein;	/* vnode pager pageins */
-	u_int v_vnodeout;	/* vnode pager pageouts */
-	u_int v_vnodepgsin;	/* vnode_pager pages paged in */
-	u_int v_vnodepgsout;	/* vnode pager pages paged out */
-	u_int v_intrans;	/* intransit blocking page faults */
-	u_int v_reactivated;	/* number of pages reactivated from free list */
-	u_int v_pdwakeups;	/* number of times daemon has awaken from sleep */
-	u_int v_pdpages;	/* number of pages analyzed by daemon */
+	u_int v_vm_faults;	/* (A) number of address memory faults */
+	u_int v_cow_faults;	/* (A) number of copy-on-writes */
+	u_int v_cow_optim;	/* (A) number of optimized copy-on-writes */
+	u_int v_zfod;		/* (A) pages zero filled on demand */
+	u_int v_ozfod;		/* (A) optimized zero fill pages */
+	u_int v_swapin;		/* (A) swap pager pageins */
+	u_int v_swapout;	/* (A) swap pager pageouts */
+	u_int v_swappgsin;	/* (A) swap pager pages paged in */
+	u_int v_swappgsout;	/* (A) swap pager pages paged out */
+	u_int v_vnodein;	/* (A) vnode pager pageins */
+	u_int v_vnodeout;	/* (A) vnode pager pageouts */
+	u_int v_vnodepgsin;	/* (A) vnode_pager pages paged in */
+	u_int v_vnodepgsout;	/* (A) vnode pager pages paged out */
+	u_int v_intrans;	/* (A) intransit blocking page faults */
+	u_int v_reactivated;	/* (B) number of pages reactivated from free list */
+	u_int v_pdwakeups;	/* (B) number of times daemon has awaken from sleep */
+	u_int v_pdpages;	/* (B) number of pages analyzed by daemon */
 
-	u_int v_dfree;		/* pages freed by daemon */
-	u_int v_pfree;		/* pages freed by exiting processes */
-	u_int v_tfree;		/* total pages freed */
+	u_int v_dfree;		/* (B) pages freed by daemon */
+	u_int v_pfree;		/* (B) pages freed by exiting processes */
+	u_int v_tfree;		/* (A) total pages freed */
 	/*
 	 * Distribution of page usages.
 	 */
-	u_int v_page_size;	/* page size in bytes */
-	u_int v_page_count;	/* total number of pages in system */
-	u_int v_free_reserved;	/* number of pages reserved for deadlock */
-	u_int v_free_target;	/* number of pages desired free */
-	u_int v_free_min;	/* minimum number of pages desired free */
-	u_int v_free_count;	/* number of pages free */
-	u_int v_wire_count;	/* number of pages wired down */
-	u_int v_active_count;	/* number of pages active */
-	u_int v_inactive_target; /* number of pages desired inactive */
-	u_int v_inactive_count;	/* number of pages inactive */
-	u_int v_cache_count;	/* number of pages on buffer cache queue */
-	u_int v_cache_min;	/* min number of pages desired on cache queue */
-	u_int v_cache_max;	/* max number of pages in cached obj */
-	u_int v_pageout_free_min;   /* min number pages reserved for kernel */
-	u_int v_interrupt_free_min; /* reserved number of pages for int code */
-	u_int v_free_severe;	/* severe depletion of pages below this pt */
+	u_int v_page_size;	/* (D) page size in bytes */
+	u_int v_page_count;	/* (C) total number of pages in system */
+	u_int v_free_reserved;	/* (D) number of pages reserved for deadlock */
+	u_int v_free_target;	/* (D) number of pages desired free */
+	u_int v_free_min;	/* (D) minimum number of pages desired free */
+	u_int v_free_count;	/* (D) number of pages free */
+	u_int v_wire_count;	/* (C) number of pages wired down */
+	u_int v_active_count;	/* (D) number of pages active */
+	u_int v_inactive_target; /* (D) number of pages desired inactive */
+	u_int v_inactive_count;	/* (B) number of pages inactive */
+	u_int v_cache_count;	/* (D) number of pages on buffer cache queue */
+	u_int v_cache_min;	/* (D) min number of pages desired on cache queue */
+	u_int v_cache_max;	/* (D) max number of pages in cached obj */
+	u_int v_pageout_free_min;   /* (D) min number pages reserved for kernel */
+	u_int v_interrupt_free_min; /* (D) reserved number of pages for int code */
+	u_int v_free_severe;	/* (D) severe depletion of pages below this pt */
 	/*
 	 * Fork/vfork/rfork activity.
 	 */
-	u_int v_forks;		/* number of fork() calls */
-	u_int v_vforks;		/* number of vfork() calls */
-	u_int v_rforks;		/* number of rfork() calls */
-	u_int v_kthreads;	/* number of fork() calls by kernel */
-	u_int v_forkpages;	/* number of VM pages affected by fork() */
-	u_int v_vforkpages;	/* number of VM pages affected by vfork() */
-	u_int v_rforkpages;	/* number of VM pages affected by rfork() */
-	u_int v_kthreadpages;	/* number of VM pages affected by fork() by kernel */
+	u_int v_forks;		/* (C) number of fork() calls */
+	u_int v_vforks;		/* (C) number of vfork() calls */
+	u_int v_rforks;		/* (C) number of rfork() calls */
+	u_int v_kthreads;	/* (C) number of fork() calls by kernel */
+	u_int v_forkpages;	/* (C) number of VM pages affected by fork() */
+	u_int v_vforkpages;	/* (C) number of VM pages affected by vfork() */
+	u_int v_rforkpages;	/* (C) number of VM pages affected by rfork() */
+	u_int v_kthreadpages;	/* (C) number of VM pages affected by fork() by kernel */
 };
 #ifdef _KERNEL
 
--- //depot/vendor/freebsd/src/sys/vm/vm_object.c	2007/06/04 21:48:11
+++ //depot/user/attilio/attilio_schedlock/vm/vm_object.c	2007/06/06 15:11:19
@@ -655,7 +655,7 @@
 			"p->busy = %d, p->flags %x\n", p, p->busy, p->flags));
 		if (p->wire_count == 0) {
 			vm_page_free(p);
-			PCPU_INC(cnt.v_pfree);
+			cnt.v_pfree++;
 		} else {
 			vm_page_remove(p);
 		}
--- //depot/vendor/freebsd/src/sys/vm/vm_page.c	2007/06/04 21:48:11
+++ //depot/user/attilio/attilio_schedlock/vm/vm_page.c	2007/06/06 15:22:20
@@ -1045,7 +1045,7 @@
 	mtx_assert(&vm_page_queue_mtx, MA_OWNED);
 	if (VM_PAGE_GETKNOWNQUEUE2(m) != PQ_ACTIVE) {
 		if (VM_PAGE_INQUEUE1(m, PQ_CACHE))
-			PCPU_INC(cnt.v_reactivated);
+			cnt.v_reactivated++;
 		vm_pageq_remove(m);
 		if (m->wire_count == 0 && (m->flags & PG_UNMANAGED) == 0) {
 			if (m->act_count < ACT_INIT)
@@ -1286,7 +1286,7 @@
 		return;
 	if (m->wire_count == 0 && (m->flags & PG_UNMANAGED) == 0) {
 		if (VM_PAGE_INQUEUE1(m, PQ_CACHE))
-			PCPU_INC(cnt.v_reactivated);
+			cnt.v_reactivated++;
 		vm_page_flag_clear(m, PG_WINATCFLS);
 		vm_pageq_remove(m);
 		if (athead)
@@ -1295,11 +1295,6 @@
 			TAILQ_INSERT_TAIL(&vm_page_queues[PQ_INACTIVE].pl, m, pageq);
 		VM_PAGE_SETQUEUE2(m, PQ_INACTIVE);
 		vm_page_queues[PQ_INACTIVE].lcnt++;
-
-		/*
-		 * Just not use an atomic here since vm_page_queues_lock
-		 * alredy protects this field.
-		 */
 		cnt.v_inactive_count++;
 	}
 }
--- //depot/vendor/freebsd/src/sys/vm/vm_pageout.c	2007/06/05 00:03:37
+++ //depot/user/attilio/attilio_schedlock/vm/vm_pageout.c	2007/06/06 15:22:20
@@ -538,7 +538,7 @@
 				goto unlock_return;
 			}
 			next = TAILQ_NEXT(p, listq);
-			PCPU_INC(cnt.v_pdpages);
+			cnt.v_pdpages++;
 			if (p->wire_count != 0 ||
 			    p->hold_count != 0 ||
 			    p->busy != 0 ||
@@ -745,7 +745,7 @@
 	     m != NULL && maxscan-- > 0 && page_shortage > 0;
 	     m = next) {
 
-		PCPU_INC(cnt.v_pdpages);
+		cnt.v_pdpages++;
 
 		if (VM_PAGE_GETQUEUE(m) != PQ_INACTIVE) {
 			goto rescan0;
@@ -856,7 +856,7 @@
 			 * Invalid pages can be easily freed
 			 */
 			vm_page_free(m);
-			PCPU_INC(cnt.v_dfree);
+			cnt.v_dfree++;
 			--page_shortage;
 		} else if (m->dirty == 0) {
 			/*
@@ -1089,7 +1089,7 @@
 		 * The count for pagedaemon pages is done after checking the
 		 * page for eligibility...
 		 */
-		PCPU_INC(cnt.v_pdpages);
+		cnt.v_pdpages++;
 
 		/*
 		 * Check to see "how much" the page has been used.
@@ -1168,7 +1168,7 @@
 				    m));
 				vm_page_free(m);
 				VM_OBJECT_UNLOCK(object);
-				PCPU_INC(cnt.v_dfree);
+				cnt.v_dfree++;
 				cache_last_free = cache_cur;
 				cache_first_failure = -1;
 				break;
@@ -1429,11 +1429,6 @@
 	cnt.v_free_reserved = vm_pageout_page_count +
 	    cnt.v_pageout_free_min + (cnt.v_page_count / 768) + PQ_NUMCOLORS;
 	cnt.v_free_severe = cnt.v_free_min / 2;
-
-	/*
-	 * Here adds don't need to be atomic since we are only initializing
-	 * v_free_min and v_free_severe.
-	 */
 	cnt.v_free_min += cnt.v_free_reserved;
 	cnt.v_free_severe += cnt.v_free_reserved;
 
@@ -1531,7 +1526,7 @@
 			}
 		}
 		if (vm_pages_needed)
-			PCPU_INC(cnt.v_pdwakeups);
+			cnt.v_pdwakeups++;
 		mtx_unlock(&vm_page_queue_free_mtx);
 		vm_pageout_scan(pass);
 	}
