Module Name:    src
Committed By:   ad
Date:           Sat May 23 21:14:56 UTC 2020

Modified Files:
        src/sys/kern: kern_runq.c

Log Message:
sched_bestcpu(): There is a fallback CPU, in case the user manages to set
the system up so no CPU is permitted to run a given LWP.  Fix a bug where
that fallback CPU would sometimes get picked even if there was another CPU
that could legitimately run the LWP.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/kern/kern_runq.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/kern_runq.c
diff -u src/sys/kern/kern_runq.c:1.67 src/sys/kern/kern_runq.c:1.68
--- src/sys/kern/kern_runq.c:1.67	Mon Apr 13 16:09:21 2020
+++ src/sys/kern/kern_runq.c	Sat May 23 21:14:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_runq.c,v 1.67 2020/04/13 16:09:21 maxv Exp $	*/
+/*	$NetBSD: kern_runq.c,v 1.68 2020/05/23 21:14:55 ad Exp $	*/
 
 /*-
  * Copyright (c) 2019, 2020 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_runq.c,v 1.67 2020/04/13 16:09:21 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_runq.c,v 1.68 2020/05/23 21:14:55 ad Exp $");
 
 #include "opt_dtrace.h"
 
@@ -479,7 +479,13 @@ sched_bestcpu(struct lwp *l, struct cpu_
 	 */
 	bestci = pivot;
 	bestspc = &bestci->ci_schedstate;
-	bestpri = MAX(bestspc->spc_curpriority, bestspc->spc_maxpriority);
+	if (sched_migratable(l, bestci)) {
+		bestpri = MAX(bestspc->spc_curpriority,
+		    bestspc->spc_maxpriority);
+	} else {
+		/* Invalidate the priority. */
+		bestpri = PRI_COUNT;
+	}
 
 	/* In the outer loop scroll through all CPU packages. */
 	pivot = pivot->ci_package1st;

Reply via email to