aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/sched_ule.c
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2012-03-03 11:50:48 +0000
committerAlexander Motin <mav@FreeBSD.org>2012-03-03 11:50:48 +0000
commit6022f0bcb35973fea81c5d188f3c279833d00067 (patch)
tree674a74911d915a0c4a47cfb658e2c5d626ae9263 /sys/kern/sched_ule.c
parent87775fcd35974c4bfbc9dfa554badace2a31a4de (diff)
downloadsrc-6022f0bcb35973fea81c5d188f3c279833d00067.tar.gz
src-6022f0bcb35973fea81c5d188f3c279833d00067.zip
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).
Notes
Notes: svn path=/head/; revision=232454
Diffstat (limited to 'sys/kern/sched_ule.c')
-rw-r--r--sys/kern/sched_ule.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c
index 126c135c49f2..c6b2d036bc72 100644
--- a/sys/kern/sched_ule.c
+++ b/sys/kern/sched_ule.c
@@ -662,16 +662,18 @@ cpu_search(const struct cpu_group *cg, struct cpu_search *low,
/* 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 flags)
/* 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 flags)
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