Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 5 May 2006 03:38:42 GMT
From:      Kip Macy <kmacy@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 96678 for review
Message-ID:  <200605050338.k453cgPH043348@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=96678

Change 96678 by kmacy@kmacy_storage:sun4v_rwbuf on 2006/05/05 03:38:34

	atomically clear and set active bits

Affected files ...

.. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/swtch.S#20 edit

Differences ...

==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/swtch.S#20 (text+ko) ====

@@ -40,6 +40,22 @@
 
 #define	PCB_REG	%g6
 
+#define ATOMIC_CLEAR_INT_BIT(addr, old, bit, new, label) \
+	lduw	[addr], old	; \
+label:	andn	old, bit, new	; \
+	cas	[addr], old, new ; \
+	cmp	old, new	; \
+	bne,pn	%icc, label ## b ; \
+	  mov	new, old
+
+#define ATOMIC_SET_INT_BIT(addr, old, bit, new, label) \
+	lduw	[addr], old	; \
+label:	or	old, bit, new	; \
+	cas	[addr], old, new ; \
+	cmp	old, new	; \
+	bne,pn	%icc, label ## b ; \
+	  mov	new, old
+	
 /*
  * void cpu_throw(struct thread *old, struct thread *new)
  */
@@ -127,9 +143,7 @@
 	ldx	[PCB_REG + PCB_PC], %i7
 	sub	%fp, CCFSZ, %sp
 
-
-		
-	/*
+ 	/*
 	 * Point to the pmaps of the new process, and of the last non-kernel
 	 * process to run.
 	 */
@@ -164,30 +178,14 @@
 	 * Mark the old pmap as no longer active on this CPU
 	 */
 	add	%l2, PM_ACTIVE, %l2
-	lduw	[%l2], %l3
-8:	andn	%l3, %l4, %l6
-	cas	[%l2], %l3, %l6
-	cmp	%l3, %l6
-	bne,pn	%icc, 8b
-	  mov	%l3, %l6
+	ATOMIC_CLEAR_INT_BIT(%l2, %l3, %l4, %l6, 8)	
 	
-	/*
-	 * Mark the new pmap as active on this CPU
-	 * XXX need to CAS
-	 */
 10:
-	lduw	[%i2 + PM_ACTIVE], %l3
-	or	%l3, %l4, %l3
-	stw	%l3, [%i2 + PM_ACTIVE]
+	add	%i2,  PM_ACTIVE, %i3
+	ATOMIC_SET_INT_BIT(%i3, %l3, %l4, %l6, 11)
 
-	/*
-	 * Mark the new pmap as possibly having TLB entries on this CPU
-	 * XXX need to CAS
-	 */
-	lduw	[%i2 + PM_TLBACTIVE], %l3
-	or	%l3, %l4, %l3
-	stw	%l3, [%i2 + PM_TLBACTIVE]
-
+	add	%i2, PM_TLBACTIVE, %i3
+	ATOMIC_SET_INT_BIT(%i3, %l3, %l4, %l6, 12)
 	
 	mov	SCRATCH_REG_HASH_USER, %l6
 	mov	SCRATCH_REG_TSB_USER, %l7



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200605050338.k453cgPH043348>