aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJulian Elischer <julian@FreeBSD.org>2004-09-13 23:06:39 +0000
committerJulian Elischer <julian@FreeBSD.org>2004-09-13 23:06:39 +0000
commit1f9f5df61da5a93f75136c4c3b192c61cd834474 (patch)
treeff11e3873217709b5a501be52c92c9275917eb02 /sys
parentb2578c6c063a154bf37a81d6017a84df75ed5cf3 (diff)
downloadsrc-1f9f5df61da5a93f75136c4c3b192c61cd834474.tar.gz
src-1f9f5df61da5a93f75136c4c3b192c61cd834474.zip
Commit a fix for some panics we've been seeing with preemption.
MFC after: 2 days
Notes
Notes: svn path=/head/; revision=135182
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_switch.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/kern/kern_switch.c b/sys/kern/kern_switch.c
index b937f8a91955..786c22bff0a1 100644
--- a/sys/kern/kern_switch.c
+++ b/sys/kern/kern_switch.c
@@ -224,7 +224,6 @@ slot_fill(struct ksegrp *kg)
}
}
-#ifdef SCHED_4BSD
/*
* Remove a thread from its KSEGRP's run queue.
* This in turn may remove it from a KSE if it was already assigned
@@ -274,7 +273,6 @@ remrunqueue(struct thread *td)
/* slot_fill(kg); */ /* will replace it with another */
}
}
-#endif
/*
* Change the priority of a thread that is on the run queue.
@@ -528,8 +526,18 @@ maybe_preempt(struct thread *td)
/*
* Our thread state says that we are already on a run queue, so
* update our state as if we had been dequeued by choosethread().
+ * However we must not actually be on the system run queue yet.
*/
MPASS(TD_ON_RUNQ(td));
+ MPASS(td->td_sched->ke_state != KES_ONRUNQ);
+ if (td->td_proc->p_flag & P_HADTHREADS) {
+ /*
+ * If this is a threaded process we actually ARE on the
+ * ksegrp run queue so take it off that first.
+ */
+ remrunqueue(td); /* maybe use a simpler version */
+ }
+
TD_SET_RUNNING(td);
CTR3(KTR_PROC, "preempting to thread %p (pid %d, %s)\n", td,
td->td_proc->p_pid, td->td_proc->p_comm);