Index: kern_resource.c =================================================================== RCS file: /cvsroot/src/sys/kern/kern_resource.c,v retrieving revision 1.181 diff -p -u -r1.181 kern_resource.c --- kern_resource.c 13 May 2018 14:45:23 -0000 1.181 +++ kern_resource.c 14 Mar 2019 00:24:26 -0000 @@ -488,7 +488,7 @@ void calcru(struct proc *p, struct timeval *up, struct timeval *sp, struct timeval *ip, struct timeval *rp) { - uint64_t u, st, ut, it, tot; + uint64_t u, st, ut, it, tot, dt; struct lwp *l; struct bintime tm; struct timeval tv; @@ -549,10 +549,12 @@ calcru(struct proc *p, struct timeval *u * which must have increased. */ if (p->p_xutime > ut) { - st -= p->p_xutime - ut; + dt = p->p_xutime - ut; + st -= uimin(dt, st); ut = p->p_xutime; } else if (p->p_xstime > st) { - ut -= p->p_xstime - st; + dt = p->p_xstime - st; + ut -= uimin(dt, ut); st = p->p_xstime; }