Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Mar 2012 11:50:48 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r232454 - head/sys/kern
Message-ID:  <201203031150.q23BomB7080407@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Sat Mar  3 11:50:48 2012
New Revision: 232454
URL: http://svn.freebsd.org/changeset/base/232454

Log:
  Fix bug of r232207, when cpu_search() could prefer CPU group with best
  load, but with no CPU matching given limitations. It caused kernel panics
  in some cases when thread was bound to specific CPUs with cpuset(1).

Modified:
  head/sys/kern/sched_ule.c

Modified: head/sys/kern/sched_ule.c
==============================================================================
--- head/sys/kern/sched_ule.c	Sat Mar  3 11:11:56 2012	(r232453)
+++ head/sys/kern/sched_ule.c	Sat Mar  3 11:50:48 2012	(r232454)
@@ -662,16 +662,18 @@ cpu_search(const struct cpu_group *cg, s
 
 		/* We have info about child item. Compare it. */
 		if (match & CPU_SEARCH_LOWEST) {
-			if ((load < lload) ||
-			    (load == lload && lgroup.cs_load < low->cs_load)) {
+			if (lgroup.cs_load != INT_MAX &&
+			    (load < lload ||
+			     (load == lload && lgroup.cs_load < low->cs_load))) {
 				lload = load;
 				low->cs_cpu = lgroup.cs_cpu;
 				low->cs_load = lgroup.cs_load;
 			}
 		}
 		if (match & CPU_SEARCH_HIGHEST)
-			if ((load > hload) ||
-			    (load == hload && hgroup.cs_load > high->cs_load)) {
+			if (hgroup.cs_load != -1 &&
+			    (load > hload ||
+			     (load == hload && hgroup.cs_load > high->cs_load))) {
 				hload = load;
 				high->cs_cpu = hgroup.cs_cpu;
 				high->cs_load = hgroup.cs_load;
@@ -1230,6 +1232,7 @@ sched_pickcpu(struct thread *td, int fla
 	/* Search globally for the less loaded CPU. */
 	if (cpu == -1)
 		cpu = sched_lowest(cpu_top, mask, -1, INT_MAX, ts->ts_cpu);
+	KASSERT(cpu != -1, ("sched_pickcpu: Failed to find a cpu."));
 	/*
 	 * Compare the lowest loaded cpu to current cpu.
 	 */
@@ -1242,7 +1245,6 @@ sched_pickcpu(struct thread *td, int fla
 		SCHED_STAT_INC(pickcpu_lowest);
 	if (cpu != ts->ts_cpu)
 		SCHED_STAT_INC(pickcpu_migration);
-	KASSERT(cpu != -1, ("sched_pickcpu: Failed to find a cpu."));
 	return (cpu);
 }
 #endif



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