Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Apr 2006 19:22:13 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 95075 for review
Message-ID:  <200604121922.k3CJMD2f028996@repoman.freebsd.org>

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

Change 95075 by jhb@jhb_slimer on 2006/04/12 19:21:13

	Change [tm]sleep() calls that don't want to change curthread's
	priority to pass 0 instead of 'curthread->td_priority' as there
	are races in the latter.

Affected files ...

.. //depot/projects/smpng/sys/dev/hwpmc/hwpmc_mod.c#15 edit
.. //depot/projects/smpng/sys/dev/random/randomdev_soft.c#11 edit
.. //depot/projects/smpng/sys/kern/kern_intr.c#74 edit
.. //depot/projects/smpng/sys/kern/kern_poll.c#20 edit
.. //depot/projects/smpng/sys/kern/kern_thr.c#32 edit
.. //depot/projects/smpng/sys/kern/kern_umtx.c#23 edit
.. //depot/projects/smpng/sys/kern/sched_4bsd.c#53 edit
.. //depot/projects/smpng/sys/kern/subr_taskqueue.c#29 edit
.. //depot/projects/smpng/sys/kern/uipc_mqueue.c#6 edit
.. //depot/projects/smpng/sys/modules/crash/crash.c#32 edit
.. //depot/projects/smpng/sys/modules/crash2/crash2.c#7 edit
.. //depot/projects/smpng/sys/vm/vm_zeroidle.c#28 edit

Differences ...

==== //depot/projects/smpng/sys/dev/hwpmc/hwpmc_mod.c#15 (text+ko) ====

@@ -646,15 +646,8 @@
 static void
 pmc_force_context_switch(void)
 {
-	u_char	curpri;
 
-	mtx_lock_spin(&sched_lock);
-	curpri = curthread->td_priority;
-	mtx_unlock_spin(&sched_lock);
-
-	(void) tsleep((void *) pmc_force_context_switch, curpri,
-	    "pmcctx", 1);
-
+	(void) tsleep((void *) pmc_force_context_switch, 0, "pmcctx", 1);
 }
 
 /*

==== //depot/projects/smpng/sys/dev/random/randomdev_soft.c#11 (text+ko) ====

@@ -211,8 +211,7 @@
 	 * Command the hash/reseed thread to end and wait for it to finish
 	 */
 	random_kthread_control = -1;
-	tsleep((void *)&random_kthread_control, curthread->td_priority, "term",
-	    0);
+	tsleep((void *)&random_kthread_control, 0, "term", 0);
 
 	/* Destroy the harvest fifos */
 	while (!STAILQ_EMPTY(&emptyfifo.head)) {
@@ -285,8 +284,7 @@
 
 		/* Found nothing, so don't belabour the issue */
 		if (!active)
-			tsleep(&harvestfifo, curthread->td_priority, "-",
-			    hz / 10);
+			tsleep(&harvestfifo, 0, "-", hz / 10);
 
 	}
 

==== //depot/projects/smpng/sys/kern/kern_intr.c#74 (text+ko) ====

@@ -371,8 +371,7 @@
 	/* Create a thread if we need one. */
 	while (ie->ie_thread == NULL && !(flags & INTR_FAST)) {
 		if (ie->ie_flags & IE_ADDING_THREAD)
-			msleep(ie, &ie->ie_lock, curthread->td_priority,
-			    "ithread", 0);
+			msleep(ie, &ie->ie_lock, 0, "ithread", 0);
 		else {
 			ie->ie_flags |= IE_ADDING_THREAD;
 			mtx_unlock(&ie->ie_lock);
@@ -458,8 +457,7 @@
 		TAILQ_REMOVE(&ie->ie_handlers, handler, ih_next);
 	mtx_unlock_spin(&sched_lock);
 	while (handler->ih_flags & IH_DEAD)
-		msleep(handler, &ie->ie_lock, curthread->td_priority, "iev_rmh",
-		    0);
+		msleep(handler, &ie->ie_lock, 0, "iev_rmh", 0);
 	intr_event_update(ie);
 #ifdef notyet
 	/*
@@ -683,7 +681,7 @@
 			    ie->ie_name);
 			ie->ie_warned = 1;
 		}
-		tsleep(&ie->ie_count, curthread->td_priority, "istorm", 1);
+		tsleep(&ie->ie_count, 0, "istorm", 1);
 	} else
 		ie->ie_count++;
 

==== //depot/projects/smpng/sys/kern/kern_poll.c#20 (text+ko) ====

@@ -577,13 +577,11 @@
 {
 	struct thread *td = curthread;
 	struct rtprio rtp;
-	int pri;
 
 	rtp.prio = RTP_PRIO_MAX;	/* lowest priority */
 	rtp.type = RTP_PRIO_IDLE;
 	mtx_lock_spin(&sched_lock);
 	rtp_to_pri(&rtp, td->td_ksegrp);
-	pri = td->td_priority;
 	mtx_unlock_spin(&sched_lock);
 
 	for (;;) {
@@ -595,7 +593,7 @@
 			mtx_unlock_spin(&sched_lock);
 		} else {
 			idlepoll_sleeping = 1;
-			tsleep(&idlepoll_sleeping, pri, "pollid", hz * 3);
+			tsleep(&idlepoll_sleeping, 0, "pollid", hz * 3);
 		}
 	}
 }

==== //depot/projects/smpng/sys/kern/kern_thr.c#32 (text+ko) ====

@@ -368,8 +368,8 @@
 	}
 	PROC_LOCK(td->td_proc);
 	if ((td->td_flags & TDF_THRWAKEUP) == 0)
-		error = msleep((void *)td, &td->td_proc->p_mtx,
-		    td->td_priority | PCATCH, "lthr", hz);
+		error = msleep((void *)td, &td->td_proc->p_mtx, PCATCH, "lthr",
+		    hz);
 	if (td->td_flags & TDF_THRWAKEUP) {
 		mtx_lock_spin(&sched_lock);
 		td->td_flags &= ~TDF_THRWAKEUP;

==== //depot/projects/smpng/sys/kern/kern_umtx.c#23 (text+ko) ====

@@ -168,7 +168,7 @@
 	while (umtxq_chains[chain].uc_flags & UCF_BUSY) {
 		umtxq_chains[chain].uc_flags |= UCF_WANT;
 		msleep(&umtxq_chains[chain], umtxq_mtx(chain),
-		       curthread->td_priority, "umtxq_busy", 0);
+		    0, "umtxq_busy", 0);
 	}
 	umtxq_chains[chain].uc_flags |= UCF_BUSY;
 }
@@ -424,8 +424,7 @@
 		 */
 		umtxq_lock(&uq->uq_key);
 		if (old == owner && (td->td_flags & TDF_UMTXQ)) {
-			error = umtxq_sleep(td, &uq->uq_key,
-				       td->td_priority | PCATCH,
+			error = umtxq_sleep(td, &uq->uq_key, PCATCH,
 				       "umtx", timo);
 		}
 		umtxq_busy(&uq->uq_key);
@@ -547,7 +546,7 @@
 		umtxq_lock(&uq->uq_key);
 		if (td->td_flags & TDF_UMTXQ)
 			error = umtxq_sleep(td, &uq->uq_key,
-			       td->td_priority | PCATCH, "ucond", 0);
+			    PCATCH, "ucond", 0);
 		if (!(td->td_flags & TDF_UMTXQ))
 			error = 0;
 		else
@@ -560,8 +559,7 @@
 		for (;;) {
 			umtxq_lock(&uq->uq_key);
 			if (td->td_flags & TDF_UMTXQ) {
-				error = umtxq_sleep(td, &uq->uq_key,
-					    td->td_priority | PCATCH,
+				error = umtxq_sleep(td, &uq->uq_key, PCATCH,
 					    "ucond", tvtohz(&tv));
 			}
 			if (!(td->td_flags & TDF_UMTXQ)) {

==== //depot/projects/smpng/sys/kern/sched_4bsd.c#53 (text+ko) ====

@@ -543,7 +543,7 @@
 
 	for (;;) {
 		schedcpu();
-		tsleep(&nowake, curthread->td_priority, "-", hz);
+		tsleep(&nowake, 0, "-", hz);
 	}
 }
 

==== //depot/projects/smpng/sys/kern/subr_taskqueue.c#29 (text+ko) ====

@@ -356,7 +356,7 @@
 	TQ_LOCK(tq);
 	do {
 		taskqueue_run(tq);
-		TQ_SLEEP(tq, tq, &tq->tq_mutex, curthread->td_priority, "-", 0);
+		TQ_SLEEP(tq, tq, &tq->tq_mutex, 0, "-", 0);
 	} while ((tq->tq_flags & TQ_FLAGS_ACTIVE) != 0);
 
 	/* rendezvous with thread that asked us to terminate */

==== //depot/projects/smpng/sys/kern/uipc_mqueue.c#6 (text+ko) ====

@@ -1657,7 +1657,7 @@
 		}
 		mq->mq_senders++;
 		error = msleep(&mq->mq_senders, &mq->mq_mutex,
-			    curthread->td_priority | PCATCH, "mqsend", timo);
+			    PCATCH, "mqsend", timo);
 		mq->mq_senders--;
 		if (error == EAGAIN)
 			error = ETIMEDOUT;
@@ -1809,7 +1809,7 @@
 		}
 		mq->mq_receivers++;
 		error = msleep(&mq->mq_receivers, &mq->mq_mutex,
-			    curthread->td_priority | PCATCH, "mqrecv", timo);
+			    PCATCH, "mqrecv", timo);
 		mq->mq_receivers--;
 		if (error == EAGAIN)
 			error = ETIMEDOUT;

==== //depot/projects/smpng/sys/modules/crash/crash.c#32 (text+ko) ====

@@ -160,7 +160,7 @@
 {
 	rw_init(&baz, "baz");
 	rw_rlock(&baz);
-	tsleep(&baz, curthread->td_priority, "-", 1);
+	tsleep(&baz, 0, "-", 1);
 	rw_runlock(&baz);
 	rw_destroy(&baz);
 }
@@ -674,7 +674,7 @@
 
 	printf("Should panic\n");
 	THREAD_NO_SLEEPING();
-	tsleep(&test1_mtx, curthread->td_priority, "sleep", 1);
+	tsleep(&test1_mtx, 0, "sleep", 1);
 	THREAD_SLEEPING_OK();
 }
 CRASH_EVENT("sleep while sleeping is prohibited", test_no_sleeping);

==== //depot/projects/smpng/sys/modules/crash2/crash2.c#7 (text+ko) ====

@@ -101,7 +101,7 @@
 {
 
 	mtx_lock(&bar);
-	tsleep(&bar, curthread->td_priority, "bar", hz/100);
+	tsleep(&bar, 0, "bar", hz/100);
 	mtx_unlock(&bar);
 }
 CRASH2_EVENT("sleep holding bar", bar_sleep, bar_sleep, bar_sleep, bar_sleep);

==== //depot/projects/smpng/sys/vm/vm_zeroidle.c#28 (text+ko) ====

@@ -140,9 +140,7 @@
 static void
 vm_pagezero(void __unused *arg)
 {
-	struct thread *td;
 
-	td = curthread;
 	idlezero_enable = idlezero_enable_default;
 
 	for (;;) {
@@ -159,7 +157,7 @@
 			vm_page_lock_queues();
 			wakeup_needed = TRUE;
 			msleep(&zero_state, &vm_page_queue_mtx,
-			    PDROP | td->td_priority, "pgzero", hz * 300);
+			    PDROP, "pgzero", hz * 300);
 		}
 	}
 }



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