--- old/usr/src/uts/i86pc/os/memnode.c	2015-08-18 18:36:34.681591185 -0400
+++ new/usr/src/uts/i86pc/os/memnode.c	2015-08-18 18:36:34.687066556 -0400
@@ -71,7 +71,6 @@
 mem_node_add_slice(pfn_t start, pfn_t end)
 {
 	int mnode;
-	mnodeset_t newmask, oldmask;
 
 	/*
 	 * DR will pass us the first pfn that is allocatable.
@@ -98,11 +97,7 @@
 		mem_node_config[mnode].physbase = start;
 		mem_node_config[mnode].physmax = end;
 		atomic_inc_16(&num_memnodes);
-		do {
-			oldmask = memnodes_mask;
-			newmask = memnodes_mask | (1ull << mnode);
-		} while (atomic_cas_64(&memnodes_mask, oldmask, newmask) !=
-		    oldmask);
+		atomic_or_64(&memnodes_mask, 1ull << mnode);
 	}
 
 	/*
@@ -123,7 +118,6 @@
 {
 	int mnode;
 	pgcnt_t delta_pgcnt, node_size;
-	mnodeset_t omask, nmask;
 
 	if (mem_node_physalign) {
 		start &= ~(btop(mem_node_physalign) - 1);
@@ -159,10 +153,7 @@
 		 * Delete the whole node.
 		 */
 		ASSERT(MNODE_PGCNT(mnode) == 0);
-		do {
-			omask = memnodes_mask;
-			nmask = omask & ~(1ull << mnode);
-		} while (atomic_cas_64(&memnodes_mask, omask, nmask) != omask);
+		atomic_and_64(&memnodes_mask, ~(1ull << mnode));
 		atomic_dec_16(&num_memnodes);
 		mem_node_config[mnode].exists = 0;
 	}
@@ -223,7 +214,6 @@
 mem_node_alloc()
 {
 	int mnode;
-	mnodeset_t newmask, oldmask;
 
 	/*
 	 * Find an unused memnode.  Update it atomically to prevent
@@ -240,10 +230,7 @@
 	mem_node_config[mnode].physbase = (pfn_t)-1l;
 	mem_node_config[mnode].physmax = 0;
 	atomic_inc_16(&num_memnodes);
-	do {
-		oldmask = memnodes_mask;
-		newmask = memnodes_mask | (1ull << mnode);
-	} while (atomic_cas_64(&memnodes_mask, oldmask, newmask) != oldmask);
+	atomic_or_64(&memnodes_mask, 1ull << mnode);
 
 	return (mnode);
 }
--- old/usr/src/uts/i86pc/os/x_call.c	2015-08-18 18:36:34.834998223 -0400
+++ new/usr/src/uts/i86pc/os/x_call.c	2015-08-18 18:36:34.840137087 -0400
@@ -64,7 +64,7 @@
  * with every message that finishes all processing.
  *
  * The code needs no mfence or other membar_*() calls. The uses of
- * atomic_cas_ptr(), atomic_cas_32() and atomic_dec_32() for the message
+ * atomic_cas_ptr(), atomic_inc_32_nv() and atomic_dec_32() for the message
  * passing are implemented with LOCK prefix instructions which are
  * equivalent to mfence.
  *
@@ -142,11 +142,7 @@
 static int
 xc_increment(struct machcpu *mcpu)
 {
-	int old;
-	do {
-		old = mcpu->xc_work_cnt;
-	} while (atomic_cas_32(&mcpu->xc_work_cnt, old, old + 1) != old);
-	return (old);
+	return (atomic_inc_32_nv(&mcpu->xc_work_cnt) - 1);
 }
 
 /*
--- old/usr/src/uts/sun4/os/memnode.c	2015-08-18 18:36:34.996572167 -0400
+++ new/usr/src/uts/sun4/os/memnode.c	2015-08-18 18:36:35.001781890 -0400
@@ -68,7 +68,6 @@
 mem_node_add_slice(pfn_t start, pfn_t end)
 {
 	int mnode;
-	mnodeset_t newmask, oldmask;
 
 	/*
 	 * DR will pass us the first pfn that is allocatable.
@@ -95,11 +94,7 @@
 		mem_node_config[mnode].physbase = start;
 		mem_node_config[mnode].physmax = end;
 		atomic_inc_16(&num_memnodes);
-		do {
-			oldmask = memnodes_mask;
-			newmask = memnodes_mask | (1ull << mnode);
-		} while (atomic_cas_64(&memnodes_mask, oldmask, newmask) !=
-			 oldmask);
+		atomic_or_64(&memnodes_mask, 1ull << mnode);
 	}
 	/*
 	 * Let the common lgrp framework know about the new memory
@@ -119,7 +114,6 @@
 {
 	int mnode;
 	pgcnt_t delta_pgcnt, node_size;
-	mnodeset_t omask, nmask;
 
 	if (mem_node_physalign) {
 		start &= ~(btop(mem_node_physalign) - 1);
@@ -156,10 +150,7 @@
 		 * Delete the whole node.
 		 */
 		ASSERT(MNODE_PGCNT(mnode) == 0);
-		do {
-			omask = memnodes_mask;
-			nmask = omask & ~(1ull << mnode);
-		} while (atomic_cas_64(&memnodes_mask, omask, nmask) != omask);
+		atomic_and_64(&memnodes_mask, ~(1ull << mnode));
 		atomic_dec_16(&num_memnodes);
 		mem_node_config[mnode].exists = 0;
 	}
@@ -214,7 +205,6 @@
 mem_node_alloc()
 {
 	int mnode;
-	mnodeset_t newmask, oldmask;
 
 	/*
 	 * Find an unused memnode.  Update it atomically to prevent
@@ -231,10 +221,7 @@
 	mem_node_config[mnode].physbase = (uint64_t)-1;
 	mem_node_config[mnode].physmax = 0;
 	atomic_inc_16(&num_memnodes);
-	do {
-		oldmask = memnodes_mask;
-		newmask = memnodes_mask | (1ull << mnode);
-	} while (atomic_cas_64(&memnodes_mask, oldmask, newmask) != oldmask);
+	atomic_or_64(&memnodes_mask, 1ull << mnode);
 
 	return (mnode);
 }
--- old/usr/src/uts/sun4/vm/vm_dep.c	2015-08-18 18:36:35.152489978 -0400
+++ new/usr/src/uts/sun4/vm/vm_dep.c	2015-08-18 18:36:35.158118319 -0400
@@ -888,19 +888,13 @@
 uint_t
 get_color_start(struct as *as)
 {
-	uint32_t old, new;
-
 	if (consistent_coloring == 2 || color_start_random) {
 		return ((uint_t)(((gettick()) << (vac_shift - MMU_PAGESHIFT)) &
 		    (hw_page_array[0].hp_colors - 1)));
 	}
 
-	do {
-		old = color_start_current;
-		new = old + (color_start_stride << (vac_shift - MMU_PAGESHIFT));
-	} while (atomic_cas_32(&color_start_current, old, new) != old);
-
-	return ((uint_t)(new));
+	return ((uint_t)atomic_add_32_nv(&color_start_current,
+	    color_start_stride << (vac_shift - MMU_PAGESHIFT)));
 }
 
 /*
