summaryrefslogtreecommitdiffstats
path: root/sys/kern/sched_ule.c
diff options
context:
space:
mode:
authorjeff <jeff@FreeBSD.org>2003-04-11 18:37:34 +0000
committerjeff <jeff@FreeBSD.org>2003-04-11 18:37:34 +0000
commit678516a39b4410978e61048ccc5fed46e9d350f5 (patch)
treeba803e088c945350e42530b3f76b4d50846150e8 /sys/kern/sched_ule.c
parente97478a53532e94e30496284b29e8c7af0cfb82a (diff)
downloadFreeBSD-src-678516a39b4410978e61048ccc5fed46e9d350f5.zip
FreeBSD-src-678516a39b4410978e61048ccc5fed46e9d350f5.tar.gz
- When migrating a kse from one kseq to the next actually insert it onto
the second kseq's run queue so that it is referenced by the kse when it is switched out. - Spell ksq_rslices properly. Reported by: Ian Freislich <ianf@za.uu.net>
Diffstat (limited to 'sys/kern/sched_ule.c')
-rw-r--r--sys/kern/sched_ule.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c
index 04dcf29..00be570 100644
--- a/sys/kern/sched_ule.c
+++ b/sys/kern/sched_ule.c
@@ -924,7 +924,7 @@ sched_clock(struct kse *ke)
*/
ke->ke_slice--;
#ifdef SMP
- kseq->ksq_rslice--;
+ kseq->ksq_rslices--;
#endif
if (ke->ke_slice > 0)
@@ -991,16 +991,11 @@ sched_choose(void)
{
struct kseq *kseq;
struct kse *ke;
-#ifdef SMP
- int steal;
-
- steal = 0;
-#endif
- kseq = KSEQ_SELF();
#ifdef SMP
retry:
#endif
+ kseq = KSEQ_SELF();
ke = kseq_choose(kseq);
if (ke) {
runq_remove(ke->ke_runq, ke);
@@ -1011,28 +1006,30 @@ retry:
ke, ke->ke_runq, ke->ke_slice,
ke->ke_thread->td_priority);
}
-#ifdef SMP
- /*
- * If we've stolen this thread we need to kill the pointer
- * to the run queue and reset the cpu id.
- */
- if (steal) {
- kseq_rem(kseq, ke);
- ke->ke_cpu = PCPU_GET(cpuid);
- kseq_add(KSEQ_SELF(), ke);
- }
-#endif
return (ke);
}
#ifdef SMP
- if (ke == NULL && smp_started) {
+ if (smp_started) {
/*
* Find the cpu with the highest load and steal one proc.
*/
- steal = 1;
- if ((kseq = kseq_load_highest()) != NULL)
- goto retry;
+ if ((kseq = kseq_load_highest()) == NULL)
+ return (NULL);
+
+ /*
+ * Remove this kse from this kseq and runq and then requeue
+ * on the current processor. Then we will dequeue it
+ * normally above.
+ */
+ ke = kseq_choose(kseq);
+ runq_remove(ke->ke_runq, ke);
+ ke->ke_state = KES_THREAD;
+ kseq_rem(kseq, ke);
+
+ ke->ke_cpu = PCPU_GET(cpuid);
+ sched_add(ke);
+ goto retry;
}
#endif
OpenPOWER on IntegriCloud