Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Jan 2008 19:39:54 GMT
From:      Oleksandr Tymoshenko <gonzo@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 132729 for review
Message-ID:  <200801071939.m07Jdsi3010238@repoman.freebsd.org>

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

Change 132729 by gonzo@gonzo_jeeves on 2008/01/07 19:39:39

	o Add cpu_throw(9) implementation. Make it wrapper around
	    mips_cpu_throw, just like cpu_switch(9) is wrapper around
	    mips_cpu_switch.  We'll fix it once kernel is ready for testing.
	o Handle third argument of cpu_switch(9) and spin while td_lock
	    of new thread is blocked_lock.
	Reviewed by:	cognet

Affected files ...

.. //depot/projects/mips2-jnpr/src/sys/mips/include/proc.h#4 edit
.. //depot/projects/mips2-jnpr/src/sys/mips/mips/genassym.c#4 edit
.. //depot/projects/mips2-jnpr/src/sys/mips/mips/pm_machdep.c#4 edit
.. //depot/projects/mips2-jnpr/src/sys/mips/mips/swtch.S#6 edit
.. //depot/projects/mips2-jnpr/src/sys/mips/mips/vm_machdep.c#6 edit

Differences ...

==== //depot/projects/mips2-jnpr/src/sys/mips/include/proc.h#4 (text+ko) ====

@@ -64,6 +64,7 @@
 
 struct thread;
 
-void	mips_cpu_switch(struct thread *, struct thread *);
+void	mips_cpu_switch(struct thread *, struct thread *, struct mtx *);
+void	mips_cpu_throw(struct thread *, struct thread *);
 
 #endif	/* !_MACHINE_PROC_H_ */

==== //depot/projects/mips2-jnpr/src/sys/mips/mips/genassym.c#4 (text+ko) ====

@@ -67,6 +67,7 @@
 ASSYM(TD_UPTE, offsetof(struct thread, td_md.md_upte));
 ASSYM(TD_KSTACK, offsetof(struct thread, td_kstack));
 ASSYM(TD_FLAGS, offsetof(struct thread, td_flags));
+ASSYM(TD_LOCK, offsetof(struct thread, td_lock));
 
 ASSYM(U_PCB_REGS, offsetof(struct pcb, pcb_regs.zero));
 ASSYM(U_PCB_CONTEXT, offsetof(struct pcb, pcb_context));

==== //depot/projects/mips2-jnpr/src/sys/mips/mips/pm_machdep.c#4 (text+ko) ====

@@ -535,6 +535,6 @@
 void
 cpu_switch(struct thread *old, struct thread *new, struct mtx * new_lock)
 {
-	/* XXX this is lame, maybe, but we ignore new_lock */
-	func_2args_asmmacro(&mips_cpu_switch, old, new);
+
+	func_3args_asmmacro(&mips_cpu_switch, old, new, new_lock);
 }

==== //depot/projects/mips2-jnpr/src/sys/mips/mips/swtch.S#6 (text+ko) ====

@@ -229,13 +229,26 @@
 END(savectx)
 
 
+KSEG0TEXT_START;
+
+NON_LEAF(mips_cpu_throw, STAND_FRAME_SIZE, ra)
+	mfc0	t0, COP_0_STATUS_REG		# t0 = saved status register
+	nop
+	nop
+	mtc0	zero, COP_0_STATUS_REG		# Disable all interrupts
+	ITLBNOPFIX
+	j	mips_sw1			# We're not interested in old 
+						# thread's context, so jump 
+						# right to action
+	nop					# BDSLOT
+END(mips_cpu_throw)
+
 /*
  *XXX Fixme:	should be written to new interface that requires lock
  *		storage.  We fake it for now.
  * mips_cpu_switch(struct thread *old, struct thread *new);
  * Find the highest priority process and resume it.
  */
-KSEG0TEXT_START;
 NON_LEAF(mips_cpu_switch, STAND_FRAME_SIZE, ra)
 	mfc0	t0, COP_0_STATUS_REG		# t0 = saved status register
 	nop
@@ -243,7 +256,7 @@
 	mtc0	zero, COP_0_STATUS_REG		# Disable all interrupts
 	ITLBNOPFIX
 	beqz	a0, mips_sw1
-	move	a2, a0
+	move	a3, a0
 	lw	a0, TD_PCB(a0)		# load PCB addr of curproc
 	SAVE_U_PCB_CONTEXT(sp, 8, a0)		# save old sp
 	subu	sp, sp, STAND_FRAME_SIZE
@@ -266,7 +279,16 @@
 	 * to be saved with the other registers do so here.
 	 */
 
+	sw	a3, TD_LOCK(a0)			# Switchout td_lock 
+
 mips_sw1:
+#if defined(SMP) && defined(SCHED_ULE)
+	la	t0, _C_LABEL(blocked_lock)
+blocked_loop:
+	lw	t1, TD_LOCK(a1)
+	beq	t0, t1, blocked_loop
+	nop
+#endif
 	move	s7, a1	# Store newthread
 /*
  * Switch to new context.

==== //depot/projects/mips2-jnpr/src/sys/mips/mips/vm_machdep.c#6 (text+ko) ====

@@ -517,12 +517,10 @@
 	return (0);
 }
 
-#ifdef GONE_IN_7
 void
 cpu_throw(struct thread *old, struct thread *new)
 {
 
-	cpu_switch(old, new);
-	panic("cpu_throw() didn't");
+	func_2args_asmmacro(&mips_cpu_throw, old, new);
+	panic("mips_cpu_throw() returned");
 }
-#endif



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