From d7479b596c2d828b63aeeaf729476664e4139ceb Mon Sep 17 00:00:00 2001 From: jhb Date: Thu, 29 Dec 2011 16:17:16 +0000 Subject: [PATCH 083/175] 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 git-svn-id: http://svn.freebsd.org/base/head@228960 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f (cherry picked from commit 11368ebd97ac3d29314ef9c59f319263f71a5779) Signed-off-by: Xin Li --- sys/kern/sched_ule.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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, " -- 1.7.9.4