summaryrefslogtreecommitdiffstats
path: root/sys/kern/sched_ule.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2011-12-29 16:17:16 +0000
committerjhb <jhb@FreeBSD.org>2011-12-29 16:17:16 +0000
commit784e4ad4ff32a49ce72ede57b9e77715cabcc2dd (patch)
tree2599264b221005efdeb22f04abce449e65d10909 /sys/kern/sched_ule.c
parent6d9bb657995cb846b97c7558a0454afe42964b3a (diff)
downloadFreeBSD-src-784e4ad4ff32a49ce72ede57b9e77715cabcc2dd.zip
FreeBSD-src-784e4ad4ff32a49ce72ede57b9e77715cabcc2dd.tar.gz
Cap the priority calculated from the current thread's running tick count
at SCHED_PRI_RANGE to prevent overflows in the priority value. This can happen due to irregularities with clock interrupts under certain virtualization environments. Tested by: Larry Rosenman ler lerctr org MFC after: 2 weeks
Diffstat (limited to 'sys/kern/sched_ule.c')
-rw-r--r--sys/kern/sched_ule.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c
index 1d34342..87e3655 100644
--- a/sys/kern/sched_ule.c
+++ b/sys/kern/sched_ule.c
@@ -1434,7 +1434,8 @@ sched_priority(struct thread *td)
} else {
pri = SCHED_PRI_MIN;
if (td->td_sched->ts_ticks)
- pri += SCHED_PRI_TICKS(td->td_sched);
+ pri += min(SCHED_PRI_TICKS(td->td_sched),
+ SCHED_PRI_RANGE);
pri += SCHED_PRI_NICE(td->td_proc->p_nice);
KASSERT(pri >= PRI_MIN_BATCH && pri <= PRI_MAX_BATCH,
("sched_priority: invalid priority %d: nice %d, "
OpenPOWER on IntegriCloud