diff options
author | jeff <jeff@FreeBSD.org> | 2009-03-14 11:41:36 +0000 |
---|---|---|
committer | jeff <jeff@FreeBSD.org> | 2009-03-14 11:41:36 +0000 |
commit | 96eaa9ff52409f0ad3651fdcae4178f5e236ffe9 (patch) | |
tree | 2ab6df5a89d03d43c82b280916aab4f65194db58 /sys/kern | |
parent | 69680f169ccd4273c491e709b2406f6aec2ad77e (diff) | |
download | FreeBSD-src-96eaa9ff52409f0ad3651fdcae4178f5e236ffe9.zip FreeBSD-src-96eaa9ff52409f0ad3651fdcae4178f5e236ffe9.tar.gz |
- Fix an error that occurs when mp_ncpu is an odd number. steal_thresh
is calculated as 0 which causes errors elsewhere.
Submitted by: KOIE Hidetaka <koie@suri.co.jp>
- When sched_affinity() is called with a thread that is not curthread we
need to handle the ON_RUNQ() case by adding the thread to the correct
run queue.
Submitted by: Justin Teller <justin.teller@gmail.com>
MFC after: 1 Week
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/sched_ule.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index 96f7280..a748b70 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -1337,11 +1337,11 @@ sched_initticks(void *dummy) */ balance_interval = realstathz; /* - * Set steal thresh to log2(mp_ncpu) but no greater than 4. This - * prevents excess thrashing on large machines and excess idle on - * smaller machines. + * Set steal thresh to roughly log2(mp_ncpu) but no greater than 4. + * This prevents excess thrashing on large machines and excess idle + * on smaller machines. */ - steal_thresh = min(ffs(mp_ncpus) - 1, 3); + steal_thresh = min(fls(mp_ncpus) - 1, 3); affinity = SCHED_AFFINITY_DEFAULT; #endif } @@ -2417,6 +2417,11 @@ sched_affinity(struct thread *td) ts = td->td_sched; if (THREAD_CAN_SCHED(td, ts->ts_cpu)) return; + if (TD_ON_RUNQ(td)) { + sched_rem(td); + sched_add(td, SRQ_BORING); + return; + } if (!TD_IS_RUNNING(td)) return; td->td_flags |= TDF_NEEDRESCHED; |