Add slop to "backwards" cpu accounting messages, 3 usec or 1% whichever

triggers.

This should eliminate all the trivial messages which result from minor
increases in cpu_tick frequency.

Machines which don't du cpu clock fiddling shouldn't issue "backwards"
messages now.

Laptops and other machines where the initial estimate of cputicks may be
waaaay off will still issue warnings.
This commit is contained in:
Poul-Henning Kamp 2006-03-09 09:33:17 +00:00
parent 6cda760f09
commit 0f038c05ea

View File

@ -779,7 +779,11 @@ calcru1(struct proc *p, struct rusage_ext *ruxp, struct timeval *up,
uu = (tu * ut) / tt;
su = (tu * st) / tt;
iu = tu - uu - su;
if (tu < ptu) {
if (tu + 3 > ptu) {
/* Numeric slop for low counts */
} else if (101 * tu > 100 * ptu) {
/* 1% slop for large counts */
} else {
printf(
"calcru: runtime went backwards from %ju usec to %ju usec for pid %d (%s)\n",
(uintmax_t)ptu, (uintmax_t)tu, p->p_pid, p->p_comm);