summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoravg <avg@FreeBSD.org>2011-12-19 20:01:21 +0000
committeravg <avg@FreeBSD.org>2011-12-19 20:01:21 +0000
commit8d78bfbee05852f5ebc3b662b38339d054324ce7 (patch)
tree269b9f5473eec33ab31a455b4b12db8353b2dc5d
parent291f526f0d0040a4222df61b67512e26e082864a (diff)
downloadFreeBSD-src-8d78bfbee05852f5ebc3b662b38339d054324ce7.zip
FreeBSD-src-8d78bfbee05852f5ebc3b662b38339d054324ce7.tar.gz
ule: ensure that batch timeshare threads are scheduled fairly
With the previous code, if the range of priorities for timeshare batch threads was greater than RQ_NQS, then the threads with low priorities in the part of the range above RQ_NQS would be scheduled to the run-queues as if they had high priorities at the beginning of the range. In other words, threads with a nice level of +N could be scheduled as if they had a nice level of -M. Reported by: George Mitchell <george@m5p.com> Reviewed by: jhb Tested by: George Mitchell <george@m5p.com> (earlier version) MFC after: 1 week
-rw-r--r--sys/kern/sched_ule.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c
index 31d3d11..1d34342 100644
--- a/sys/kern/sched_ule.c
+++ b/sys/kern/sched_ule.c
@@ -125,6 +125,7 @@ static struct td_sched td_sched0;
*/
#define PRI_TIMESHARE_RANGE (PRI_MAX_TIMESHARE - PRI_MIN_TIMESHARE + 1)
#define PRI_INTERACT_RANGE ((PRI_TIMESHARE_RANGE - SCHED_PRI_NRESV) / 2)
+#define PRI_BATCH_RANGE (PRI_TIMESHARE_RANGE - PRI_INTERACT_RANGE)
#define PRI_MIN_INTERACT PRI_MIN_TIMESHARE
#define PRI_MAX_INTERACT (PRI_MIN_TIMESHARE + PRI_INTERACT_RANGE - 1)
@@ -416,7 +417,6 @@ sched_shouldpreempt(int pri, int cpri, int remote)
return (0);
}
-#define TS_RQ_PPQ (((PRI_MAX_BATCH - PRI_MIN_BATCH) + 1) / RQ_NQS)
/*
* Add a thread to the actual run-queue. Keeps transferable counts up to
* date with what is actually on the run-queue. Selects the correct
@@ -449,7 +449,7 @@ tdq_runq_add(struct tdq *tdq, struct thread *td, int flags)
* realtime. Use the whole queue to represent these values.
*/
if ((flags & (SRQ_BORROWING|SRQ_PREEMPTED)) == 0) {
- pri = (pri - PRI_MIN_BATCH) / TS_RQ_PPQ;
+ pri = RQ_NQS * (pri - PRI_MIN_BATCH) / PRI_BATCH_RANGE;
pri = (pri + tdq->tdq_idx) % RQ_NQS;
/*
* This effectively shortens the queue by one so we
OpenPOWER on IntegriCloud