summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_time.c
diff options
context:
space:
mode:
authorart <art@openbsd.org>2010-06-28 21:23:20 +0000
committerart <art@openbsd.org>2010-06-28 21:23:20 +0000
commit916db1f0ac1812208de7a6df9117678e3ad438dd (patch)
tree989dea01a75f74a13efb1f8021523a16c93ce3e2 /sys/kern/kern_time.c
parentA long time ago when wsconsctl was written it expected that ksym was uniq. (diff)
downloadwireguard-openbsd-916db1f0ac1812208de7a6df9117678e3ad438dd.tar.xz
wireguard-openbsd-916db1f0ac1812208de7a6df9117678e3ad438dd.zip
clock_gettime(CLOCK_PROF) didn't account for the time between the last
context switch and the call to clock_gettime. oga@ ok
Diffstat (limited to 'sys/kern/kern_time.c')
-rw-r--r--sys/kern/kern_time.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index bdc7daaf462..6fff2cd75d7 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_time.c,v 1.69 2010/04/04 03:47:02 guenther Exp $ */
+/* $OpenBSD: kern_time.c,v 1.70 2010/06/28 21:23:20 art Exp $ */
/* $NetBSD: kern_time.c,v 1.20 1996/02/18 11:57:06 fvdl Exp $ */
/*
@@ -183,6 +183,8 @@ settime(struct timespec *ts)
int
clock_gettime(struct proc *p, clockid_t clock_id, struct timespec *tp)
{
+ struct timeval tv;
+
switch (clock_id) {
case CLOCK_REALTIME:
nanotime(tp);
@@ -191,8 +193,11 @@ clock_gettime(struct proc *p, clockid_t clock_id, struct timespec *tp)
nanouptime(tp);
break;
case CLOCK_PROF:
- tp->tv_sec = p->p_rtime.tv_sec;
- tp->tv_nsec = p->p_rtime.tv_usec * 1000;
+ microuptime(&tv);
+ timersub(&tv, &curcpu()->ci_schedstate.spc_runtime, &tv);
+ timeradd(&tv, &p->p_rtime, &tv);
+ tp->tv_sec = tv.tv_sec;
+ tp->tv_nsec = tv.tv_usec * 1000;
break;
default:
return (EINVAL);