Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 Nov 2005 17:29:47 GMT
From:      Robert Watson <rwatson@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 86239 for review
Message-ID:  <200511021729.jA2HTleT095807@repoman.freebsd.org>

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

Change 86239 by rwatson@rwatson_zoo on 2005/11/02 17:29:20

	When hinted not to preempt, also don't IPI.

Affected files ...

.. //depot/projects/netsmp/src/sys/kern/sched_4bsd.c#3 edit

Differences ...

==== //depot/projects/netsmp/src/sys/kern/sched_4bsd.c#3 (text+ko) ====

@@ -1159,29 +1159,40 @@
 		cpu = NOCPU;
 		ke->ke_runq = &runq;
 	}
-	
-	if (single_cpu && (cpu != PCPU_GET(cpuid))) {
-	        kick_other_cpu(td->td_priority,cpu);
-	} else {
-		
-		if (!single_cpu) {
-			cpumask_t me = PCPU_GET(cpumask);
-			int idle = idle_cpus_mask & me;	
+
+	/*
+	 * Once we've established where to schedule the thread, we have to
+	 * decide if we want to preempt the current thread, or IPI another
+	 * CPU to start immediate execution there.
+	 *
+	 * Currently, suppressing preemption on the scheduling also
+	 * suppresses IPIs to shedule on another CPU, as it is assumed that
+	 * starting the thread running at once will result in poor timing of
+	 * events, lock contention, etc.
+	 */
+	if (!(flags & SRQ_NOPREEMPT)) {
+		if (single_cpu && (cpu != PCPU_GET(cpuid))) {
+		        kick_other_cpu(td->td_priority,cpu);
+		} else {
+			if (!single_cpu) {
+				cpumask_t me = PCPU_GET(cpumask);
+				int idle = idle_cpus_mask & me;	
 
-			if (!idle && ((flags & SRQ_INTR) == 0) &&
-			    (idle_cpus_mask & ~(hlt_cpus_mask | me)))
-				forwarded = forward_wakeup(cpu);
-		}
+				if (!idle && ((flags & SRQ_INTR) == 0) &&
+				    (idle_cpus_mask & ~(hlt_cpus_mask | me)))
+					forwarded = forward_wakeup(cpu);
+			}
 
-		if (!forwarded) {
-			if ((flags & SRQ_YIELDING) == 0 &&
-			    (flags & SRQ_NOPREEMPT) == 0 &&
-			    maybe_preempt(td))
-				return;
-			else
-				maybe_resched(td);
+			if (!forwarded) {
+				if ((flags & SRQ_YIELDING) == 0 &&
+				    maybe_preempt(td))
+					return;
+				else
+					maybe_resched(td);
+			}
 		}
-	}
+	} else
+		maybe_resched(td);
 	
 	if ((td->td_proc->p_flag & P_NOLOAD) == 0)
 		sched_load_add();



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