PERFORCE change 94531 for review

Kip Macy kmacy at FreeBSD.org
Mon Apr 3 09:10:14 UTC 2006


http://perforce.freebsd.org/chv.cgi?CH=94531

Change 94531 by kmacy at kmacy_storage:sun4v_work on 2006/04/03 09:10:02

	keep track of what cpus this pmap is running on and which cpus
	may have entries in the TLB, we really only need to send shootdowns
	to one of the threads on a core so this can definitely be optimized
	further

Affected files ...

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

Differences ...

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

@@ -54,9 +54,13 @@
  */
 ENTRY(cpu_switch)
 	save	%sp, -CCFSZ, %sp
-	GET_PCB(PCB_REG)
+	ldx	[PCPU(CURPCB)], PCB_REG
+
+	MAGIC_TRAP_ON
+	MAGIC_TRAP_OFF
+	
 	mov	%i1, %i0
-	
+
 	/*
 	 * If the current thread was using floating point in the kernel, save
 	 * its context.  The userland floating point context has already been
@@ -113,19 +117,15 @@
 	stx	%g3, [%g1 + KTR_PARM3]
 9:
 #endif
+	wrpr	%g0, PSTATE_NORMAL, %pstate	
 	ldx	[%i0 + TD_PCB], %i1
-	
+
 	stx	%i0, [PCPU(CURTHREAD)]
 	stx	%i1, [PCPU(CURPCB)]
 
-	wrpr	%g0, PSTATE_NORMAL, %pstate
 	mov	%i1, PCB_REG				! load in new PCB
 	wrpr	%g0, PSTATE_KERNEL, %pstate
 
-	/*
-	 *	End of saving old context
-	 *	Start of loading new context
-	 */
 	ldx	[PCB_REG + PCB_SP], %fp
 	ldx	[PCB_REG + PCB_PC], %i7
 	sub	%fp, CCFSZ, %sp
@@ -155,11 +155,38 @@
 	be,a,pn %xcc, 5f
 	  nop
 
-	ldx	[%i2 + PM_CONTEXT], %l5		! new context == kernel?
+	ldx	[%i2 + PM_CONTEXT], %l5		! new context
+	ldx	[%l2 + PM_CONTEXT], %l3		! old context
 	cmp	%g0, %l5
-	be,a,pn	%xcc, 5f
-	  nop	
+	be,a,pn	%xcc, 5f			! new context == kernel?
+	  lduw	[PCPU(CPUMASK)], %l4
+
+	brz	%l3, 10f			! old context == kernel?
+	  nop
+	/*
+	 * Mark the old pmap as no longer active on this CPU
+	 */
+	lduw	[%l2 + PM_ACTIVE], %l3
+	andn	%l3, %l4, %l3
+	stw	%l3, [%l2 + PM_ACTIVE]
+
+	/*
+	 * 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]
+
+	/*
+	 * 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]
 
+	
 	mov	SCRATCH_REG_HASH_USER, %l6
 	mov	SCRATCH_REG_TSB_USER, %l7
 	ldx	[%i2 + PM_HASHSCRATCH], %l3	
@@ -189,6 +216,8 @@
 	 */
 	
 	SET_MMU_CONTEXT(%l6, %l5)
+	
+
 	/*
 	 * Done.  Return and load the new process's window from the stack.
 	 */


More information about the p4-projects mailing list