--- //depot/vendor/freebsd/src/sys/fs/smbfs/smbfs_io.c	2007/06/01 14:37:18
+++ //depot/user/attilio/attilio_schedlock/fs/smbfs/smbfs_io.c	2007/06/04 11:32:08
@@ -475,8 +475,8 @@
 
 	kva = (vm_offset_t) bp->b_data;
 	pmap_qenter(kva, pages, npages);
-	cnt.v_vnodein++;
-	cnt.v_vnodepgsin += npages;
+	PCPU_INC(cnt.v_vnodein);
+	PCPU_ADD(cnt.v_vnodepgsin, npages);
 
 	iov.iov_base = (caddr_t) kva;
 	iov.iov_len = count;
@@ -626,8 +626,8 @@
 
 	kva = (vm_offset_t) bp->b_data;
 	pmap_qenter(kva, pages, npages);
-	cnt.v_vnodeout++;
-	cnt.v_vnodepgsout += count;
+	PCPU_INC(cnt.v_vnodeout);
+	PCPU_ADD(cnt.v_vnodepgsout, count);
 
 	iov.iov_base = (caddr_t) kva;
 	iov.iov_len = count;
--- //depot/vendor/freebsd/src/sys/kern/kern_synch.c	2007/06/01 01:22:34
+++ //depot/user/attilio/attilio_schedlock/kern/kern_synch.c	2007/06/04 10:32:52
@@ -412,7 +412,7 @@
 	td->td_runtime += new_switchtime - PCPU_GET(switchtime);
 	PCPU_SET(switchtime, new_switchtime);
 	td->td_generation++;	/* bump preempt-detect counter */
-	cnt.v_swtch++;
+	PCPU_INC(cnt.v_swtch);
 	PCPU_SET(switchticks, ticks);
 	CTR4(KTR_PROC, "mi_switch: old thread %ld (kse %p, pid %ld, %s)",
 	    td->td_tid, td->td_sched, p->p_pid, p->p_comm);
--- //depot/vendor/freebsd/src/sys/kern/kern_thread.c	2007/06/01 01:18:14
+++ //depot/user/attilio/attilio_schedlock/kern/kern_thread.c	2007/06/04 10:32:52
@@ -405,7 +405,7 @@
 	p->p_rux.rux_runtime += (new_switchtime - PCPU_GET(switchtime));
 	PCPU_SET(switchtime, new_switchtime);
 	PCPU_SET(switchticks, ticks);
-	cnt.v_swtch++;
+	PCPU_INC(cnt.v_swtch);
 	/*
 	 * Aggregate this thread's tick stats in the parent so they are not
 	 * lost.  Also add the child usage to our own when the final thread
--- //depot/vendor/freebsd/src/sys/kern/subr_trap.c	2007/06/01 01:22:34
+++ //depot/user/attilio/attilio_schedlock/kern/subr_trap.c	2007/06/04 10:32:52
@@ -190,8 +190,8 @@
 #endif
 	td->td_flags &= ~(TDF_ASTPENDING | TDF_NEEDSIGCHK |
 	    TDF_NEEDRESCHED | TDF_INTERRUPT);
-	cnt.v_trap++;
 	mtx_unlock_spin(&sched_lock);
+	PCPU_INC(cnt.v_trap);
 
 	/*
 	 * XXXKSE While the fact that we owe a user profiling
--- //depot/vendor/freebsd/src/sys/nfsclient/nfs_bio.c	2007/05/31 22:54:01
+++ //depot/user/attilio/attilio_schedlock/nfsclient/nfs_bio.c	2007/06/04 11:32:08
@@ -159,8 +159,8 @@
 
 	kva = (vm_offset_t) bp->b_data;
 	pmap_qenter(kva, pages, npages);
-	cnt.v_vnodein++;
-	cnt.v_vnodepgsin += npages;
+	PCPU_INC(cnt.v_vnodein);
+	PCPU_ADD(cnt.v_vnodepgsin, npages);
 
 	iov.iov_base = (caddr_t) kva;
 	iov.iov_len = count;
@@ -323,8 +323,8 @@
 
 	kva = (vm_offset_t) bp->b_data;
 	pmap_qenter(kva, pages, npages);
-	cnt.v_vnodeout++;
-	cnt.v_vnodepgsout += count;
+	PCPU_INC(cnt.v_vnodeout);
+	PCPU_ADD(cnt.v_vnodepgsout, count);
 
 	iov.iov_base = (caddr_t) kva;
 	iov.iov_len = count;
--- //depot/vendor/freebsd/src/sys/vm/swap_pager.c	2007/05/31 22:54:01
+++ //depot/user/attilio/attilio_schedlock/vm/swap_pager.c	2007/06/04 11:32:08
@@ -1037,8 +1037,8 @@
 	}
 	bp->b_npages = j - i;
 
-	cnt.v_swapin++;
-	cnt.v_swappgsin += bp->b_npages;
+	PCPU_INC(cnt.v_swapin);
+	PCPU_ADD(cnt.v_swappgsin, bp->b_npages);
 
 	/*
 	 * We still hold the lock on mreq, and our automatic completion routine
@@ -1072,7 +1072,7 @@
 		vm_page_lock_queues();
 		vm_page_flag_set(mreq, PG_REFERENCED);
 		vm_page_unlock_queues();
-		cnt.v_intrans++;
+		PCPU_INC(cnt.v_intrans);
 		if (msleep(mreq, VM_OBJECT_MTX(object), PSWP, "swread", hz*20)) {
 			printf(
 "swap_pager: indefinite wait buffer: bufobj: %p, blkno: %jd, size: %ld\n",
@@ -1263,8 +1263,8 @@
 		bp->b_dirtyoff = 0;
 		bp->b_dirtyend = bp->b_bcount;
 
-		cnt.v_swapout++;
-		cnt.v_swappgsout += bp->b_npages;
+		PCPU_INC(cnt.v_swapout);
+		PCPU_ADD(cnt.v_swappgsout, bp->b_npages);
 
 		/*
 		 * asynchronous
--- //depot/vendor/freebsd/src/sys/vm/vm_object.c	2007/05/31 22:54:01
+++ //depot/user/attilio/attilio_schedlock/vm/vm_object.c	2007/06/04 10:32:52
@@ -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);
-			cnt.v_pfree++;
+			PCPU_INC(cnt.v_pfree);
 		} else {
 			vm_page_remove(p);
 		}
--- //depot/vendor/freebsd/src/sys/vm/vm_page.c	2007/05/31 22:54:01
+++ //depot/user/attilio/attilio_schedlock/vm/vm_page.c	2007/06/04 10:32:52
@@ -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))
-			cnt.v_reactivated++;
+			PCPU_INC(cnt.v_reactivated);
 		vm_pageq_remove(m);
 		if (m->wire_count == 0 && (m->flags & PG_UNMANAGED) == 0) {
 			if (m->act_count < ACT_INIT)
@@ -1112,7 +1112,7 @@
 		mtx_assert(&vm_page_queue_mtx, MA_OWNED);
 	KASSERT(!pmap_page_is_mapped(m),
 	    ("vm_page_free_toq: freeing mapped page %p", m));
-	cnt.v_tfree++;
+	PCPU_INC(cnt.v_tfree);
 
 	if (m->busy || VM_PAGE_INQUEUE1(m, PQ_FREE)) {
 		printf(
@@ -1286,7 +1286,7 @@
 		return;
 	if (m->wire_count == 0 && (m->flags & PG_UNMANAGED) == 0) {
 		if (VM_PAGE_INQUEUE1(m, PQ_CACHE))
-			cnt.v_reactivated++;
+			PCPU_INC(cnt.v_reactivated);
 		vm_page_flag_clear(m, PG_WINATCFLS);
 		vm_pageq_remove(m);
 		if (athead)
@@ -1295,6 +1295,11 @@
 			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/05/31 22:54:01
+++ //depot/user/attilio/attilio_schedlock/vm/vm_pageout.c	2007/06/04 10:32:52
@@ -538,7 +538,7 @@
 				goto unlock_return;
 			}
 			next = TAILQ_NEXT(p, listq);
-			cnt.v_pdpages++;
+			PCPU_INC(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) {
 
-		cnt.v_pdpages++;
+		PCPU_INC(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);
-			cnt.v_dfree++;
+			PCPU_INC(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...
 		 */
-		cnt.v_pdpages++;
+		PCPU_INC(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);
-				cnt.v_dfree++;
+				PCPU_INC(cnt.v_dfree);
 				cache_last_free = cache_cur;
 				cache_first_failure = -1;
 				break;
@@ -1427,6 +1427,11 @@
 	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;
 
@@ -1524,7 +1529,7 @@
 			}
 		}
 		if (vm_pages_needed)
-			cnt.v_pdwakeups++;
+			PCPU_INC(cnt.v_pdwakeups);
 		mtx_unlock(&vm_page_queue_free_mtx);
 		vm_pageout_scan(pass);
 	}
--- //depot/vendor/freebsd/src/sys/vm/vnode_pager.c	2007/05/31 22:54:01
+++ //depot/user/attilio/attilio_schedlock/vm/vnode_pager.c	2007/06/04 11:32:08
@@ -728,8 +728,8 @@
 			if (i != reqpage)
 				vm_page_free(m[i]);
 		vm_page_unlock_queues();
-		cnt.v_vnodein++;
-		cnt.v_vnodepgsin++;
+		PCPU_INC(cnt.v_vnodein);
+		PCPU_INC(cnt.v_vnodepgsin);
 		error = vnode_pager_input_old(object, m[reqpage]);
 		VM_OBJECT_UNLOCK(object);
 		return (error);
@@ -757,8 +757,8 @@
 				vm_page_free(m[i]);
 		vm_page_unlock_queues();
 		VM_OBJECT_UNLOCK(object);
-		cnt.v_vnodein++;
-		cnt.v_vnodepgsin++;
+		PCPU_INC(cnt.v_vnodein);
+		PCPU_INC(cnt.v_vnodepgsin);
 		return vnode_pager_input_smlfs(object, m[reqpage]);
 	}
 
@@ -909,8 +909,8 @@
 	bp->b_runningbufspace = bp->b_bufsize;
 	atomic_add_int(&runningbufspace, bp->b_runningbufspace);
 
-	cnt.v_vnodein++;
-	cnt.v_vnodepgsin += count;
+	PCPU_INC(cnt.v_vnodein);
+	PCPU_ADD(cnt.v_vnodepgsin, count);
 
 	/* do the input */
 	bp->b_iooffset = dbtob(bp->b_blkno);
@@ -1157,8 +1157,8 @@
 	auio.uio_resid = maxsize;
 	auio.uio_td = (struct thread *) 0;
 	error = VOP_WRITE(vp, &auio, ioflags, curthread->td_ucred);
-	cnt.v_vnodeout++;
-	cnt.v_vnodepgsout += ncount;
+	PCPU_INC(cnt.v_vnodeout);
+	PCPU_ADD(cnt.v_vnodepgsout, ncount);
 
 	if (error) {
 		if ((ppscheck = ppsratecheck(&lastfail, &curfail, 1)))
