diff options
author | phk <phk@FreeBSD.org> | 1999-11-29 11:29:04 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1999-11-29 11:29:04 +0000 |
commit | 8da3ba86dcb25f842958179693b5d802d91ae681 (patch) | |
tree | 4868f81c1c195acf2e065944af8bede54779fd0c /sys/kern/kern_resource.c | |
parent | d1d5bef80771c347e974ca1f996e28808a4077a7 (diff) | |
download | FreeBSD-src-8da3ba86dcb25f842958179693b5d802d91ae681.zip FreeBSD-src-8da3ba86dcb25f842958179693b5d802d91ae681.tar.gz |
Add a bit of sanity checking and problem avoidance in case the
timecounter hardware is bogus.
This will produce a new warning "microuptime() went backwards"
and try to not screw up the process resource accounting.
Diffstat (limited to 'sys/kern/kern_resource.c')
-rw-r--r-- | sys/kern/kern_resource.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c index fde934e..495175e 100644 --- a/sys/kern/kern_resource.c +++ b/sys/kern/kern_resource.c @@ -49,6 +49,7 @@ #include <sys/resourcevar.h> #include <sys/malloc.h> #include <sys/proc.h> +#include <sys/time.h> #include <vm/vm.h> #include <vm/vm_param.h> @@ -519,8 +520,13 @@ calcru(p, up, sp, ip) * quantum, which is much greater than the sampling error. */ microuptime(&tv); - tu += (tv.tv_usec - switchtime.tv_usec) + - (tv.tv_sec - switchtime.tv_sec) * (int64_t)1000000; + if (timevalcmp(&tv, &switchtime, <)) + printf("microuptime() went backwards (%ld.%06ld -> %ld,%06ld)\n", + switchtime.tv_sec, switchtime.tv_usec, + tv.tv_sec, tv.tv_usec); + else + tu += (tv.tv_usec - switchtime.tv_usec) + + (tv.tv_sec - switchtime.tv_sec) * (int64_t)1000000; } ptu = p->p_stats->p_uu + p->p_stats->p_su + p->p_stats->p_iu; if (tu < ptu || (int64_t)tu < 0) { |