PERFORCE change 61527 for review

Julian Elischer julian at FreeBSD.org
Tue Sep 14 22:15:46 PDT 2004


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

Change 61527 by julian at julian_ref on 2004/09/15 05:15:06

	more careful counting of slots

Affected files ...

.. //depot/projects/nsched/sys/kern/kern_switch.c#30 edit
.. //depot/projects/nsched/sys/kern/sched_4bsd.c#55 edit
.. //depot/projects/nsched/sys/kern/sched_ule.c#34 edit

Differences ...

==== //depot/projects/nsched/sys/kern/kern_switch.c#30 (text+ko) ====

@@ -266,7 +266,6 @@
 		 */
 		if (td) {
 			kg->kg_last_assigned = td;
-			kg->kg_avail_opennings--;
 			sched_add(td, SRQ_BORING);
 			CTR2(KTR_RUNQ, "slot_fill: td%p -> kg%p", td, kg);
 		} else {
@@ -301,7 +300,6 @@
 	if ((td->td_proc->p_flag & P_HADTHREADS) == 0) {
 		/* remve from sys run queue and free up a slot */
 		sched_rem(td);
-		kg->kg_avail_opennings++;
 		ke->ke_state = KES_THREAD; 
 		return;
 	}
@@ -316,7 +314,6 @@
 		 * see if we need to move the KSE in the run queues.
 		 */
 		sched_rem(td);
-		kg->kg_avail_opennings++;
 		ke->ke_state = KES_THREAD; 
 		td2 = kg->kg_last_assigned;
 		KASSERT((td2 != NULL), ("last assigned has wrong value"));
@@ -361,7 +358,6 @@
 			    TAILQ_PREV(td, threadqueue, td_runq);
 		}
 		sched_rem(td);
-		kg->kg_avail_opennings++;
 	}
 	TAILQ_REMOVE(&kg->kg_runq, td, td_runq);
 	kg->kg_runnable--;

==== //depot/projects/nsched/sys/kern/sched_4bsd.c#55 (text+ko) ====

@@ -792,6 +792,12 @@
 	/* 
 	 * The thread we are about to run needs to be counted as if it had been 
 	 * added to the run queue and selected.
+	 * it came from:
+	 * A preemption
+	 * An upcall 
+	 * A followon
+	 * Do this before saving curthread so that the slot count 
+	 * doesn't give an overly optimistic view when that happens.
 	 */
 	if (newtd) {
 		KASSERT((newtd->td_inhibitors == 0),
@@ -1045,12 +1051,17 @@
 
 	if ((td->td_proc->p_flag & P_NOLOAD) == 0)
 		sched_tdcnt--;
+	td->td_ksegrp->kg_avail_opennings++;
 	runq_remove(ke->ke_runq, ke);
 
 	ke->ke_state = KES_THREAD;
-	ke->ke_ksegrp->kg_runq_kses--;
+	td->td_ksegrp->kg_runq_kses--;
 }
 
+/*
+ * Select threads to run.
+ * Notice that the running threads still consume a slot.
+ */
 struct kse *
 sched_choose(void)
 {

==== //depot/projects/nsched/sys/kern/sched_ule.c#34 (text+ko) ====

@@ -1801,6 +1801,7 @@
 	    ("sched_rem: KSE not on run queue"));
 
 	ke->ke_state = KES_THREAD;
+	td->td_ksegrp->kg_avail_opennings++;
 	ke->ke_ksegrp->kg_runq_threads--;
 	kseq = KSEQ_CPU(ke->ke_cpu);
 	kseq_runq_rem(kseq, ke);


More information about the p4-projects mailing list