Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 May 2006 05:56:21 GMT
From:      Kip Macy <kmacy@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 96644 for review
Message-ID:  <200605040556.k445uLoV069253@repoman.freebsd.org>

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

Change 96644 by kmacy@kmacy_storage:sun4v_rwbuf on 2006/05/04 05:56:06

	factor out hash bucket locking into macros

Affected files ...

.. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/exception.S#46 edit

Differences ...

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

@@ -1331,6 +1331,33 @@
 END(tl0_intr)
 
 
+/* 
+ * workaround for CPP brokenness
+ */
+#define LOADLOAD #LoadLoad
+#define LOADSTORE #LoadStore 
+#define STORESTORE #StoreStore
+	
+#define THE_LOCK_ENTER(addr, lock_bit, oldval, newval, label1) \
+	mov	1, lock_bit	; \
+	add	addr, 8, addr	; \
+	sllx	lock_bit, 56, lock_bit ; \
+label1:				; \
+	ldxa	[addr]%asi, oldval;	\
+	andcc	%l7, lock_bit, %g0	; \
+	bnz,pn	%xcc, label1 ## b	; \
+	  or	oldval, lock_bit, newval; \
+	casxa	[addr]%asi, oldval, newval; \
+	cmp	oldval, newval	; \
+	bne,pn	%icc, label1 ## b	; \
+ 	  membar LOADLOAD	; \
+	sub	addr, 8, addr	; 
+
+#define THE_LOCK_EXIT(addr, lock_bit, tmp)\
+	membar	LOADSTORE | STORESTORE ; \
+	ldxa	[addr + 8]%asi, tmp ; \
+	andn	tmp, lock_bit, tmp ; \
+	stxa	tmp, [addr + 8]%asi ; 
 
 #define HASH_LOOKUP(addr, tag, searchtag, endlabel, matchlabel) \
 	ldda	[addr]%asi, tag	; \
@@ -1341,12 +1368,9 @@
 	be,pn	%xcc, endlabel	; \
 	  nop
 
-
 #define RESTORE_TRAPWIN(pcpu, cansave, label1, label2) \
 	brz	cansave, label1 ## f; \
 	  nop			; \
-	mov	-1, %l0		; \
-	mov	-1, %l7		; \
 	restore			; \
 	ba,a,pt	%xcc, label2 ## f ; \
 label1:				; \
@@ -1468,21 +1492,9 @@
 	! %g2==entry base
 	add	%g2, %l5, %g2			! base + offset == entry base
 	
-	mov	1, %l0
-	add	%g2, 8, %g2			! point g2 at data
-	sllx	%l0, 56, %l0			! %l0 == VTD_LOCK
-6:
-	ldxa	[%g2]%asi, %l7			! don't lock bus if bucket is locked
-	andcc	%l7, %l0, %g0	 
-	bnz,pn	%xcc, 6b
-	  or	%l7, %l0, %l6
-	casxa	[%g2]%asi, %l7, %l6
-	cmp	%l6, %l7
-	bne,pn	%icc, 6b
-	  nop
 
-	sub	%g2, 8, %g2			! point g2 back at tag
-
+	THE_LOCK_ENTER(%g2, %l0, %l7, %l6, 6)
+	
 	! %g1 == cansave
 	! %g2 == THE
 	! %g3 == TWDW ASI
@@ -1521,11 +1533,8 @@
 	! we need to jump to tl0_trap to drop us back down to tl0
 	! and take us to trap(...) to service the fault
 	wr	%g0, %l3, %asi
+	THE_LOCK_EXIT(%l5, %l0, %g2)
 
-	ldxa	[%l5 + 8]%asi, %g2
-	andn	%g2, %l0, %g2 
-	stxa	%g2, [%l5 + 8]%asi		! unlock head  of bucket
-
 	andn	%g5, %l1, %g5			! fault page PA
 
 	RESTORE_TRAPWIN(PCPU_REG, %g1, 14, 15)
@@ -1555,7 +1564,6 @@
 	or	%l7, VTD_W, %l7			! add modifed bit 
 9:	
 
-
 	andn	%l7, %l0, %l7			! remove lock bit
 	
         and	%g4, %l1, %g3			! size of TSB in pages
@@ -1588,18 +1596,14 @@
 12:
 #endif
 	stxa	%g0, [%g3 + %l4]ASI_REAL		! invalidate data	
+	membar	#StoreStore
 	stxa	%l6, [%g3]ASI_REAL			! store tag
+	membar	#StoreStore
 	stxa	%l7, [%g3 + %l4]ASI_REAL		! store data
-	stxa	%l7, [%g2 + 8]%asi			! update TTE
-
-	cmp	%g2, %l5
-	beq,a,pt %xcc, 17f
-	  nop
-	ldxa	[%l5 + 8]%asi, %l7
-	andn	%l7, %l0, %l7				! remove lock bit
-	stxa	%l7, [%l5 + 8]%asi			! unlock bucket
-17:	
-	membar	#Sync
+	stxa	%l7, [%g2 + 8]%asi			! update TTE with ref bit  
+	membar	#StoreLoad
+	
+	THE_LOCK_EXIT(%l5, %l0, %l7)
 	RESTORE_TRAPWIN(PCPU_REG, %g1, 13, 16)	
 upgrade_demap:
 	rdpr	%tt, %g3
@@ -1635,9 +1639,7 @@
 ! %l5 == head of bucket
 	
 ENTRY(prot_fault_trap)
-	ldxa	[%l5 + 8]%asi, %g2
-	andn	%g2, %l0, %g2			! remove lock bit
-	stxa	%g2, [%l5 + 8]%asi		! unlock head of bucket
+	THE_LOCK_EXIT(%l5, %l0, %g2)
 	RESTORE_TRAPWIN(PCPU_REG, %g1, 14, 15)
         sethi	%hi(trap), %g1
 	mov	T_DATA_PROTECTION, %g2			



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