PERFORCE change 99969 for review

Kip Macy kmacy at FreeBSD.org
Sun Jun 25 05:47:17 UTC 2006


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

Change 99969 by kmacy at kmacy_storage:sun4v_work_sleepq on 2006/06/25 05:46:34

	grab thread lock before sleepq_remove to save some awkwardnesss

Affected files ...

.. //depot/projects/kmacy_sun4v/src/sys/kern/kern_synch.c#9 edit
.. //depot/projects/kmacy_sun4v/src/sys/kern/sys_generic.c#5 edit
.. //depot/projects/kmacy_sun4v/src/sys/kern/vfs_subr.c#7 edit

Differences ...

==== //depot/projects/kmacy_sun4v/src/sys/kern/kern_synch.c#9 (text+ko) ====

@@ -116,11 +116,7 @@
  * flag the mutex is not re-locked before returning.
  */
 int
-msleep(ident, mtx, priority, wmesg, timo)
-	void *ident;
-	struct mtx *mtx;
-	int priority, timo;
-	const char *wmesg;
+msleep(void *ident, struct mtx *mtx, int priority, const char *wmesg, int timo)
 {
 	struct thread *td;
 	struct proc *p;
@@ -133,6 +129,7 @@
 	if (KTRPOINT(td, KTR_CSW))
 		ktrcsw(1, 0);
 #endif
+	TD_SLOCK_ASSERT(td, MA_NOTOWNED);
 	WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, mtx == NULL ? NULL :
 	    &mtx->mtx_object, "Sleeping on \"%s\"", wmesg);
 	KASSERT(timo != 0 || mtx_owned(&Giant) || mtx != NULL,
@@ -161,9 +158,11 @@
 	 * sleep queue first.  We have to do this to handle recursive
 	 * sleeps.
 	 */
-	if (TD_ON_SLEEPQ(td))
+	if (TD_ON_SLEEPQ(td)) {
+		TD_SLOCK(td);
 		sleepq_remove(td, td->td_wchan);
-
+		TD_SUNLOCK(td);
+	}
 	flags = SLEEPQ_MSLEEP;
 	if (catch)
 		flags |= SLEEPQ_INTERRUPTIBLE;
@@ -224,11 +223,7 @@
 }
 
 int
-msleep_spin(ident, mtx, wmesg, timo)
-	void *ident;
-	struct mtx *mtx;
-	const char *wmesg;
-	int timo;
+msleep_spin(void *ident, struct mtx *mtx, const char *wmesg, int timo)
 {
 	struct thread *td;
 	struct proc *p;

==== //depot/projects/kmacy_sun4v/src/sys/kern/sys_generic.c#5 (text+ko) ====

@@ -1136,9 +1136,13 @@
 	}
 	TAILQ_REMOVE(&td->td_selq, sip, si_thrlist);
 	sip->si_thread = NULL;
+	mtx_unlock(&sellock);
+
 	atomic_clear_int(&td->td_flags, TDF_SELECT);
+	TD_SLOCK(td);
 	sleepq_remove(td, &selwait);
-	mtx_unlock(&sellock);
+	TD_SUNLOCK(td);
+
 }
 
 static void selectinit(void *);

==== //depot/projects/kmacy_sun4v/src/sys/kern/vfs_subr.c#7 (text+ko) ====

@@ -1731,7 +1731,9 @@
 	int ret = 0;
 
 	td = FIRST_THREAD_IN_PROC(updateproc);
+	TD_SLOCK(td);
 	sleepq_remove(td, &lbolt);
+	TD_SUNLOCK(td);
 	mtx_lock(&sync_mtx);
 	if (rushjob < syncdelay / 2) {
 		rushjob += 1;
@@ -1754,7 +1756,9 @@
 	if (howto & RB_NOSYNC)
 		return;
 	td = FIRST_THREAD_IN_PROC(updateproc);
+	TD_SLOCK(td);
 	sleepq_remove(td, &lbolt);
+	TD_SUNLOCK(td);
 	mtx_lock(&sync_mtx);
 	syncer_state = SYNCER_SHUTTING_DOWN;
 	rushjob = 0;


More information about the p4-projects mailing list