From d10a1df8d745bbaa9b0d09bfecdcd74a9184ba0a Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Wed, 16 Apr 2014 18:37:46 +0000 Subject: [PATCH] Fix VIRTUAL and PROF interval timers for short intervals, broken at r247903. Due to the way those timers are implemented, we can't handle very short intervals. In addition to that mentioned patch caused math overflows for short intervals. To avoid that round those intervals to 1 tick. PR: kern/187668 MFC after: 1 week --- sys/kern/kern_time.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 3aaed602d87..f6974c6fe5e 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -774,6 +774,14 @@ kern_setitimer(struct thread *td, u_int which, struct itimerval *aitv, timevalsub(&oitv->it_value, &ctv); } } else { + if (aitv->it_interval.tv_sec == 0 && + aitv->it_interval.tv_usec != 0 && + aitv->it_interval.tv_usec < tick) + aitv->it_interval.tv_usec = tick; + if (aitv->it_value.tv_sec == 0 && + aitv->it_value.tv_usec != 0 && + aitv->it_value.tv_usec < tick) + aitv->it_value.tv_usec = tick; PROC_SLOCK(p); *oitv = p->p_stats->p_timer[which]; p->p_stats->p_timer[which] = *aitv;