summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/amd64/amd64/cpu.c4
-rw-r--r--sys/arch/aviion/aviion/machdep.c4
-rw-r--r--sys/arch/i386/i386/cpu.c4
-rw-r--r--sys/arch/luna88k/luna88k/machdep.c4
-rw-r--r--sys/arch/macppc/macppc/cpu.c4
-rw-r--r--sys/arch/mips64/mips64/clock.c4
-rw-r--r--sys/arch/mvme88k/mvme88k/machdep.c4
-rw-r--r--sys/arch/sparc64/sparc64/cpu.c4
-rw-r--r--sys/kern/init_main.c10
-rw-r--r--sys/kern/kern_acct.c24
-rw-r--r--sys/kern/kern_fork.c4
-rw-r--r--sys/kern/kern_resource.c48
-rw-r--r--sys/kern/kern_sched.c10
-rw-r--r--sys/kern/kern_sysctl.c18
-rw-r--r--sys/kern/kern_tc.c4
-rw-r--r--sys/kern/kern_time.c12
-rw-r--r--sys/kern/sched_bsd.c20
-rw-r--r--sys/kern/tty.c22
-rw-r--r--sys/miscfs/procfs/procfs_status.c4
-rw-r--r--sys/nfs/nfs_serv.c6
-rw-r--r--sys/sys/kernel.h4
-rw-r--r--sys/sys/proc.h8
-rw-r--r--sys/sys/resourcevar.h16
-rw-r--r--sys/sys/sched.h4
-rw-r--r--sys/sys/sysctl.h8
25 files changed, 134 insertions, 120 deletions
diff --git a/sys/arch/amd64/amd64/cpu.c b/sys/arch/amd64/amd64/cpu.c
index bfc625bba09..0814bc7c710 100644
--- a/sys/arch/amd64/amd64/cpu.c
+++ b/sys/arch/amd64/amd64/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.55 2013/05/30 15:58:06 mlarkin Exp $ */
+/* $OpenBSD: cpu.c,v 1.56 2013/06/03 16:55:21 guenther Exp $ */
/* $NetBSD: cpu.c,v 1.1 2003/04/26 18:39:26 fvdl Exp $ */
/*-
@@ -621,7 +621,7 @@ cpu_hatch(void *v)
lcr8(0);
enable_intr();
- microuptime(&ci->ci_schedstate.spc_runtime);
+ nanouptime(&ci->ci_schedstate.spc_runtime);
splx(s);
SCHED_LOCK(s);
diff --git a/sys/arch/aviion/aviion/machdep.c b/sys/arch/aviion/aviion/machdep.c
index 281a70b766b..6e128332d87 100644
--- a/sys/arch/aviion/aviion/machdep.c
+++ b/sys/arch/aviion/aviion/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.49 2012/12/26 22:32:13 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.50 2013/06/03 16:55:21 guenther Exp $ */
/*
* Copyright (c) 2007 Miodrag Vallat.
*
@@ -570,7 +570,7 @@ secondary_main()
ncpus++;
sched_init_cpu(ci);
- microuptime(&ci->ci_schedstate.spc_runtime);
+ nanouptime(&ci->ci_schedstate.spc_runtime);
ci->ci_curproc = NULL;
ci->ci_randseed = random();
diff --git a/sys/arch/i386/i386/cpu.c b/sys/arch/i386/i386/cpu.c
index e9363360680..12a113b4d69 100644
--- a/sys/arch/i386/i386/cpu.c
+++ b/sys/arch/i386/i386/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.49 2013/05/30 15:58:06 mlarkin Exp $ */
+/* $OpenBSD: cpu.c,v 1.50 2013/06/03 16:55:21 guenther Exp $ */
/* $NetBSD: cpu.c,v 1.1.2.7 2000/06/26 02:04:05 sommerfeld Exp $ */
/*-
@@ -597,7 +597,7 @@ cpu_hatch(void *v)
if (mp_verbose)
printf("%s: CPU at apid %ld running\n",
ci->ci_dev.dv_xname, ci->ci_cpuid);
- microuptime(&ci->ci_schedstate.spc_runtime);
+ nanouptime(&ci->ci_schedstate.spc_runtime);
splx(s);
SCHED_LOCK(s);
diff --git a/sys/arch/luna88k/luna88k/machdep.c b/sys/arch/luna88k/luna88k/machdep.c
index 1d40160b777..10e48678703 100644
--- a/sys/arch/luna88k/luna88k/machdep.c
+++ b/sys/arch/luna88k/luna88k/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.86 2013/02/17 18:07:36 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.87 2013/06/03 16:55:21 guenther Exp $ */
/*
* Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
@@ -777,7 +777,7 @@ secondary_main()
ncpus++;
sched_init_cpu(ci);
- microuptime(&ci->ci_schedstate.spc_runtime);
+ nanouptime(&ci->ci_schedstate.spc_runtime);
ci->ci_curproc = NULL;
ci->ci_randseed = random();
diff --git a/sys/arch/macppc/macppc/cpu.c b/sys/arch/macppc/macppc/cpu.c
index d13840e6857..22595524103 100644
--- a/sys/arch/macppc/macppc/cpu.c
+++ b/sys/arch/macppc/macppc/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.70 2013/03/07 03:19:38 brad Exp $ */
+/* $OpenBSD: cpu.c,v 1.71 2013/06/03 16:55:22 guenther Exp $ */
/*
* Copyright (c) 1997 Per Fogelstrom
@@ -804,7 +804,7 @@ cpu_hatch(void)
curcpu()->ci_cpl = 0;
s = splhigh();
- microuptime(&curcpu()->ci_schedstate.spc_runtime);
+ nanouptime(&curcpu()->ci_schedstate.spc_runtime);
splx(s);
intrstate = ppc_intr_disable();
diff --git a/sys/arch/mips64/mips64/clock.c b/sys/arch/mips64/mips64/clock.c
index a6ab97a041a..ceb7fce0ea2 100644
--- a/sys/arch/mips64/mips64/clock.c
+++ b/sys/arch/mips64/mips64/clock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clock.c,v 1.38 2012/10/03 11:18:23 miod Exp $ */
+/* $OpenBSD: clock.c,v 1.39 2013/06/03 16:55:22 guenther Exp $ */
/*
* Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
@@ -177,7 +177,7 @@ cp0_startclock(struct cpu_info *ci)
#ifdef MULTIPROCESSOR
if (!CPU_IS_PRIMARY(ci)) {
s = splhigh();
- microuptime(&ci->ci_schedstate.spc_runtime);
+ nanouptime(&ci->ci_schedstate.spc_runtime);
splx(s);
/* try to avoid getting clock interrupts early */
diff --git a/sys/arch/mvme88k/mvme88k/machdep.c b/sys/arch/mvme88k/mvme88k/machdep.c
index a1f1f092b60..832e3b2c87c 100644
--- a/sys/arch/mvme88k/mvme88k/machdep.c
+++ b/sys/arch/mvme88k/mvme88k/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.253 2013/05/17 22:51:59 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.254 2013/06/03 16:55:22 guenther Exp $ */
/*
* Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
@@ -620,7 +620,7 @@ secondary_main()
ncpus++;
sched_init_cpu(ci);
- microuptime(&ci->ci_schedstate.spc_runtime);
+ nanouptime(&ci->ci_schedstate.spc_runtime);
ci->ci_curproc = NULL;
ci->ci_randseed = random();
diff --git a/sys/arch/sparc64/sparc64/cpu.c b/sys/arch/sparc64/sparc64/cpu.c
index b1d9d3700a4..59501915ffa 100644
--- a/sys/arch/sparc64/sparc64/cpu.c
+++ b/sys/arch/sparc64/sparc64/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.59 2012/12/04 21:00:21 kettenis Exp $ */
+/* $OpenBSD: cpu.c,v 1.60 2013/06/03 16:55:22 guenther Exp $ */
/* $NetBSD: cpu.c,v 1.13 2001/05/26 21:27:15 chs Exp $ */
/*
@@ -736,7 +736,7 @@ cpu_hatch(void)
sparc_membar(Sync);
s = splhigh();
- microuptime(&ci->ci_schedstate.spc_runtime);
+ nanouptime(&ci->ci_schedstate.spc_runtime);
splx(s);
cpu_start_clock();
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index 51067dfae20..a7b4c43c512 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init_main.c,v 1.188 2013/03/28 16:55:25 deraadt Exp $ */
+/* $OpenBSD: init_main.c,v 1.189 2013/06/03 16:55:22 guenther Exp $ */
/* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */
/*
@@ -125,7 +125,7 @@ extern struct user *proc0paddr;
struct vnode *rootvp, *swapdev_vp;
int boothowto;
-struct timeval boottime;
+struct timespec boottime;
int ncpus = 1;
int ncpusfound = 1; /* number of cpus we find */
__volatile int start_init_exec; /* semaphore for start_init() */
@@ -496,11 +496,11 @@ main(void *framep)
* from the file system. Reset p->p_rtime as it may have been
* munched in mi_switch() after the time got set.
*/
- microtime(&boottime);
+ nanotime(&boottime);
LIST_FOREACH(p, &allproc, p_list) {
p->p_p->ps_start = boottime;
- microuptime(&p->p_cpu->ci_schedstate.spc_runtime);
- p->p_rtime.tv_sec = p->p_rtime.tv_usec = 0;
+ nanouptime(&p->p_cpu->ci_schedstate.spc_runtime);
+ timespecclear(&p->p_rtime);
}
uvm_swap_init();
diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c
index acab061862d..4edf52736ca 100644
--- a/sys/kern/kern_acct.c
+++ b/sys/kern/kern_acct.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_acct.c,v 1.26 2012/07/08 17:14:39 guenther Exp $ */
+/* $OpenBSD: kern_acct.c,v 1.27 2013/06/03 16:55:22 guenther Exp $ */
/* $NetBSD: kern_acct.c,v 1.42 1996/02/04 02:15:12 christos Exp $ */
/*-
@@ -161,7 +161,7 @@ acct_process(struct proc *p)
struct acct acct;
struct process *pr = p->p_p;
struct rusage *r;
- struct timeval ut, st, tmp;
+ struct timespec ut, st, tmp;
int t;
struct vnode *vp;
int error;
@@ -179,20 +179,20 @@ acct_process(struct proc *p)
bcopy(p->p_comm, acct.ac_comm, sizeof acct.ac_comm);
/* (2) The amount of user and system time that was used */
- calcru(&pr->ps_tu, &ut, &st, NULL);
- acct.ac_utime = encode_comp_t(ut.tv_sec, ut.tv_usec);
- acct.ac_stime = encode_comp_t(st.tv_sec, st.tv_usec);
+ calctsru(&pr->ps_tu, &ut, &st, NULL);
+ acct.ac_utime = encode_comp_t(ut.tv_sec, ut.tv_nsec);
+ acct.ac_stime = encode_comp_t(st.tv_sec, st.tv_nsec);
/* (3) The elapsed time the command ran (and its starting time) */
acct.ac_btime = pr->ps_start.tv_sec;
- getmicrotime(&tmp);
- timersub(&tmp, &pr->ps_start, &tmp);
- acct.ac_etime = encode_comp_t(tmp.tv_sec, tmp.tv_usec);
+ getnanotime(&tmp);
+ timespecsub(&tmp, &pr->ps_start, &tmp);
+ acct.ac_etime = encode_comp_t(tmp.tv_sec, tmp.tv_nsec);
/* (4) The average amount of memory used */
r = &p->p_ru;
- timeradd(&ut, &st, &tmp);
- t = tmp.tv_sec * hz + tmp.tv_usec / tick;
+ timespecadd(&ut, &st, &tmp);
+ t = tmp.tv_sec * hz + tmp.tv_nsec / (1000 * tick);
if (t)
acct.ac_mem = (r->ru_ixrss + r->ru_idrss + r->ru_isrss) / t;
else
@@ -236,14 +236,14 @@ acct_process(struct proc *p)
#define MAXFRACT ((1 << MANTSIZE) - 1) /* Maximum fractional value. */
comp_t
-encode_comp_t(u_long s, u_long us)
+encode_comp_t(u_long s, u_long ns)
{
int exp, rnd;
exp = 0;
rnd = 0;
s *= AHZ;
- s += us / (1000000 / AHZ); /* Maximize precision. */
+ s += ns / (1000000000 / AHZ); /* Maximize precision. */
while (s > MAXFRACT) {
rnd = s & (1 << (EXPSIZE - 1)); /* Round up? */
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index dd4de7f0c9b..5d3ee5312c6 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_fork.c,v 1.147 2013/06/01 16:04:46 tedu Exp $ */
+/* $OpenBSD: kern_fork.c,v 1.148 2013/06/03 16:55:22 guenther Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
@@ -492,7 +492,7 @@ fork1(struct proc *curp, int exitsig, int flags, void *stack, pid_t *tidptr,
* For new processes, set accounting bits
*/
if ((flags & FORK_THREAD) == 0) {
- getmicrotime(&pr->ps_start);
+ getnanotime(&pr->ps_start);
pr->ps_acflag = AFORK;
}
diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c
index ea4f8bf512b..272f2b99533 100644
--- a/sys/kern/kern_resource.c
+++ b/sys/kern/kern_resource.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_resource.c,v 1.41 2013/04/01 01:07:34 guenther Exp $ */
+/* $OpenBSD: kern_resource.c,v 1.42 2013/06/03 16:55:22 guenther Exp $ */
/* $NetBSD: kern_resource.c,v 1.38 1996/10/23 07:19:38 matthias Exp $ */
/*-
@@ -339,7 +339,7 @@ sys_getrlimit(struct proc *p, void *v, register_t *retval)
void
tuagg_sub(struct tusage *tup, struct proc *p)
{
- timeradd(&tup->tu_runtime, &p->p_rtime, &tup->tu_runtime);
+ timespecadd(&tup->tu_runtime, &p->p_rtime, &tup->tu_runtime);
tup->tu_uticks += p->p_uticks;
tup->tu_sticks += p->p_sticks;
tup->tu_iticks += p->p_iticks;
@@ -354,7 +354,7 @@ tuagg_unlocked(struct process *pr, struct proc *p)
{
tuagg_sub(&pr->ps_tu, p);
tuagg_sub(&p->p_tu, p);
- timerclear(&p->p_rtime);
+ timespecclear(&p->p_rtime);
p->p_uticks = 0;
p->p_sticks = 0;
p->p_iticks = 0;
@@ -375,8 +375,8 @@ tuagg(struct process *pr, struct proc *p)
* into user, system, and interrupt time usage.
*/
void
-calcru(struct tusage *tup, struct timeval *up, struct timeval *sp,
- struct timeval *ip)
+calctsru(struct tusage *tup, struct timespec *up, struct timespec *sp,
+ struct timespec *ip)
{
u_quad_t st, ut, it;
int freq;
@@ -386,28 +386,42 @@ calcru(struct tusage *tup, struct timeval *up, struct timeval *sp,
it = tup->tu_iticks;
if (st + ut + it == 0) {
- timerclear(up);
- timerclear(sp);
+ timespecclear(up);
+ timespecclear(sp);
if (ip != NULL)
- timerclear(ip);
+ timespecclear(ip);
return;
}
freq = stathz ? stathz : hz;
- st = st * 1000000 / freq;
- sp->tv_sec = st / 1000000;
- sp->tv_usec = st % 1000000;
- ut = ut * 1000000 / freq;
- up->tv_sec = ut / 1000000;
- up->tv_usec = ut % 1000000;
+ st = st * 1000000000 / freq;
+ sp->tv_sec = st / 1000000000;
+ sp->tv_nsec = st % 1000000000;
+ ut = ut * 1000000000 / freq;
+ up->tv_sec = ut / 1000000000;
+ up->tv_nsec = ut % 1000000000;
if (ip != NULL) {
- it = it * 1000000 / freq;
- ip->tv_sec = it / 1000000;
- ip->tv_usec = it % 1000000;
+ it = it * 1000000000 / freq;
+ ip->tv_sec = it / 1000000000;
+ ip->tv_nsec = it % 1000000000;
}
}
+void
+calcru(struct tusage *tup, struct timeval *up, struct timeval *sp,
+ struct timeval *ip)
+{
+ struct timespec u, s, i;
+
+ calctsru(tup, &u, &s, ip != NULL ? &i : NULL);
+ TIMESPEC_TO_TIMEVAL(up, &u);
+ TIMESPEC_TO_TIMEVAL(sp, &s);
+ if (ip != NULL)
+ TIMESPEC_TO_TIMEVAL(ip, &i);
+}
+
+
/* ARGSUSED */
int
sys_getrusage(struct proc *p, void *v, register_t *retval)
diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c
index 40aa5c8c163..dad6291081e 100644
--- a/sys/kern/kern_sched.c
+++ b/sys/kern/kern_sched.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sched.c,v 1.28 2013/04/19 21:44:08 tedu Exp $ */
+/* $OpenBSD: kern_sched.c,v 1.29 2013/06/03 16:55:22 guenther Exp $ */
/*
* Copyright (c) 2007, 2008 Artur Grabowski <art@openbsd.org>
*
@@ -190,13 +190,13 @@ void
sched_exit(struct proc *p)
{
struct schedstate_percpu *spc = &curcpu()->ci_schedstate;
- struct timeval tv;
+ struct timespec ts;
struct proc *idle;
int s;
- microuptime(&tv);
- timersub(&tv, &spc->spc_runtime, &tv);
- timeradd(&p->p_rtime, &tv, &p->p_rtime);
+ nanouptime(&ts);
+ timespecsub(&ts, &spc->spc_runtime, &ts);
+ timespecadd(&p->p_rtime, &ts, &p->p_rtime);
LIST_INSERT_HEAD(&spc->spc_deadproc, p, p_hash);
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index 00967454af0..d7bbfd4a4ba 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sysctl.c,v 1.234 2013/04/06 03:44:34 tedu Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.235 2013/06/03 16:55:22 guenther Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
@@ -356,9 +356,11 @@ kern_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
return (error);
case KERN_CLOCKRATE:
return (sysctl_clockrate(oldp, oldlenp, newp));
- case KERN_BOOTTIME:
- return (sysctl_rdstruct(oldp, oldlenp, newp, &boottime,
- sizeof(struct timeval)));
+ case KERN_BOOTTIME: {
+ struct timeval bt;
+ TIMESPEC_TO_TIMEVAL(&bt, &boottime);
+ return (sysctl_rdstruct(oldp, oldlenp, newp, &bt, sizeof bt));
+ }
case KERN_VNODE:
return (sysctl_vnode(oldp, oldlenp, p));
#ifndef SMALL_KERNEL
@@ -1543,7 +1545,7 @@ fill_kproc(struct proc *p, struct kinfo_proc *ki, int isthread,
struct process *pr = p->p_p;
struct session *s = pr->ps_session;
struct tty *tp;
- struct timeval ut, st;
+ struct timespec ut, st;
FILL_KPROC(ki, strlcpy, p, pr, p->p_cred, p->p_ucred, pr->ps_pgrp,
p, pr, s, p->p_vmspace, pr->ps_limit, p->p_sigacts, isthread,
@@ -1571,11 +1573,11 @@ fill_kproc(struct proc *p, struct kinfo_proc *ki, int isthread,
if (p->p_stat != SIDL)
ki->p_vm_rssize = vm_resident_count(p->p_vmspace);
- calcru(&p->p_tu, &ut, &st, NULL);
+ calctsru(&p->p_tu, &ut, &st, NULL);
ki->p_uutime_sec = ut.tv_sec;
- ki->p_uutime_usec = ut.tv_usec;
+ ki->p_uutime_usec = ut.tv_nsec/1000;
ki->p_ustime_sec = st.tv_sec;
- ki->p_ustime_usec = st.tv_usec;
+ ki->p_ustime_usec = st.tv_nsec/1000;
#ifdef MULTIPROCESSOR
if (p->p_cpu != NULL)
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
index cf8a9484a81..7b988a33dfc 100644
--- a/sys/kern/kern_tc.c
+++ b/sys/kern/kern_tc.c
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $OpenBSD: kern_tc.c,v 1.19 2013/06/02 20:59:09 guenther Exp $
+ * $OpenBSD: kern_tc.c,v 1.20 2013/06/03 16:55:22 guenther Exp $
* $FreeBSD: src/sys/kern/kern_tc.c,v 1.148 2003/03/18 08:45:23 phk Exp $
*/
@@ -296,7 +296,7 @@ tc_setrealtimeclock(struct timespec *ts)
bintime_sub(&bt, &bt2);
bintime_add(&bt2, &boottimebin);
boottimebin = bt;
- bintime2timeval(&bt, &boottime);
+ bintime2timespec(&bt, &boottime);
add_timer_randomness(ts->tv_sec);
/* XXX fiddle all the little crinkly bits around the fiords... */
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index fec84fbf5b4..dcb878639fd 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_time.c,v 1.78 2013/06/02 20:59:09 guenther Exp $ */
+/* $OpenBSD: kern_time.c,v 1.79 2013/06/03 16:55:22 guenther Exp $ */
/* $NetBSD: kern_time.c,v 1.20 1996/02/18 11:57:06 fvdl Exp $ */
/*
@@ -112,8 +112,6 @@ 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);
@@ -122,11 +120,9 @@ clock_gettime(struct proc *p, clockid_t clock_id, struct timespec *tp)
nanouptime(tp);
break;
case CLOCK_PROF:
- 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;
+ nanouptime(tp);
+ timespecsub(tp, &curcpu()->ci_schedstate.spc_runtime, tp);
+ timespecadd(tp, &p->p_rtime, tp);
break;
default:
return (EINVAL);
diff --git a/sys/kern/sched_bsd.c b/sys/kern/sched_bsd.c
index ff7a1d2c966..ed512c2af29 100644
--- a/sys/kern/sched_bsd.c
+++ b/sys/kern/sched_bsd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sched_bsd.c,v 1.32 2013/06/02 20:59:09 guenther Exp $ */
+/* $OpenBSD: sched_bsd.c,v 1.33 2013/06/03 16:55:22 guenther Exp $ */
/* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */
/*-
@@ -346,7 +346,7 @@ mi_switch(void)
struct process *pr = p->p_p;
struct rlimit *rlim;
rlim_t secs;
- struct timeval tv;
+ struct timespec ts;
#ifdef MULTIPROCESSOR
int hold_count;
int sched_count;
@@ -372,18 +372,18 @@ mi_switch(void)
* Compute the amount of time during which the current
* process was running, and add that to its total so far.
*/
- microuptime(&tv);
- if (timercmp(&tv, &spc->spc_runtime, <)) {
+ nanouptime(&ts);
+ if (timespeccmp(&ts, &spc->spc_runtime, <)) {
#if 0
printf("uptime is not monotonic! "
- "tv=%lld.%06lu, runtime=%lld.%06lu\n",
- (long long)tv.tv_sec, tv.tv_usec,
+ "ts=%lld.%09lu, runtime=%lld.%09lu\n",
+ (long long)tv.tv_sec, tv.tv_nsec,
(long long)spc->spc_runtime.tv_sec,
- spc->spc_runtime.tv_usec);
+ spc->spc_runtime.tv_nsec);
#endif
} else {
- timersub(&tv, &spc->spc_runtime, &tv);
- timeradd(&p->p_rtime, &tv, &p->p_rtime);
+ timespecsub(&ts, &spc->spc_runtime, &ts);
+ timespecadd(&p->p_rtime, &ts, &p->p_rtime);
}
/* add the time counts for this thread to the process's total */
@@ -443,7 +443,7 @@ mi_switch(void)
*/
KASSERT(p->p_cpu == curcpu());
- microuptime(&p->p_cpu->ci_schedstate.spc_runtime);
+ nanouptime(&p->p_cpu->ci_schedstate.spc_runtime);
#ifdef MULTIPROCESSOR
/*
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index 48e3ed66f7d..b3f87146101 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.97 2013/04/24 09:52:54 nicm Exp $ */
+/* $OpenBSD: tty.c,v 1.98 2013/06/03 16:55:22 guenther Exp $ */
/* $NetBSD: tty.c,v 1.68.4.2 1996/06/06 16:04:52 thorpej Exp $ */
/*-
@@ -2122,7 +2122,7 @@ ttyinfo(struct tty *tp)
{
struct process *pr;
struct proc *pick;
- struct timeval utime, stime;
+ struct timespec utime, stime;
int tmp;
if (ttycheckoutq(tp,0) == 0)
@@ -2152,20 +2152,20 @@ ttyinfo(struct tty *tp)
rss = pick->p_stat == SIDL || P_ZOMBIE(pick) ? 0 :
vm_resident_count(pick->p_vmspace);
- calcru(&pick->p_p->ps_tu, &utime, &stime, NULL);
+ calctsru(&pick->p_p->ps_tu, &utime, &stime, NULL);
/* Round up and print user time. */
- utime.tv_usec += 5000;
- if (utime.tv_usec >= 1000000) {
+ utime.tv_nsec += 5000000;
+ if (utime.tv_nsec >= 1000000000) {
utime.tv_sec += 1;
- utime.tv_usec -= 1000000;
+ utime.tv_nsec -= 1000000000;
}
/* Round up and print system time. */
- stime.tv_usec += 5000;
- if (stime.tv_usec >= 1000000) {
+ stime.tv_nsec += 5000000;
+ if (stime.tv_nsec >= 1000000000) {
stime.tv_sec += 1;
- stime.tv_usec -= 1000000;
+ stime.tv_nsec -= 1000000000;
}
ttyprintf(tp,
@@ -2174,8 +2174,8 @@ ttyinfo(struct tty *tp)
pick->p_stat == SONPROC ? "running" :
pick->p_stat == SRUN ? "runnable" :
pick->p_wmesg ? pick->p_wmesg : "iowait",
- utime.tv_sec, utime.tv_usec / 10000,
- stime.tv_sec, stime.tv_usec / 10000, pctcpu / 100, rss);
+ utime.tv_sec, utime.tv_nsec / 10000000,
+ stime.tv_sec, stime.tv_nsec / 10000000, pctcpu / 100, rss);
}
tp->t_rocount = 0; /* so pending input will be retyped if BS */
}
diff --git a/sys/miscfs/procfs/procfs_status.c b/sys/miscfs/procfs/procfs_status.c
index c19175825ef..89cec594922 100644
--- a/sys/miscfs/procfs/procfs_status.c
+++ b/sys/miscfs/procfs/procfs_status.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: procfs_status.c,v 1.12 2012/03/23 15:51:26 guenther Exp $ */
+/* $OpenBSD: procfs_status.c,v 1.13 2013/06/03 16:55:22 guenther Exp $ */
/* $NetBSD: procfs_status.c,v 1.11 1996/03/16 23:52:50 christos Exp $ */
/*
@@ -118,7 +118,7 @@ procfs_stat_gen(struct proc *p, char *s, int l)
}
snprintf(ps, sizeof(ps), " %ld,%ld",
- pr->ps_start.tv_sec, pr->ps_start.tv_usec);
+ pr->ps_start.tv_sec, pr->ps_start.tv_nsec/1000);
COUNTORCAT(s, l, ps, n);
calcru(&pr->ps_tu, &ut, &st, (void *) 0);
diff --git a/sys/nfs/nfs_serv.c b/sys/nfs/nfs_serv.c
index 73de3b3590c..074aa3f0e6d 100644
--- a/sys/nfs/nfs_serv.c
+++ b/sys/nfs/nfs_serv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_serv.c,v 1.92 2012/03/21 16:33:21 kettenis Exp $ */
+/* $OpenBSD: nfs_serv.c,v 1.93 2013/06/03 16:55:22 guenther Exp $ */
/* $NetBSD: nfs_serv.c,v 1.34 1997/05/12 23:37:12 fvdl Exp $ */
/*
@@ -826,7 +826,7 @@ nfsrv_write(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
* for debugging purposes.
*/
*tl++ = txdr_unsigned(boottime.tv_sec);
- *tl = txdr_unsigned(boottime.tv_usec);
+ *tl = txdr_unsigned(boottime.tv_nsec/1000);
} else {
fp = nfsm_build(&info.nmi_mb, NFSX_V2FATTR);
nfsm_srvfattr(nfsd, &va, fp);
@@ -2547,7 +2547,7 @@ nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
if (!error) {
tl = nfsm_build(&info.nmi_mb, NFSX_V3WRITEVERF);
*tl++ = txdr_unsigned(boottime.tv_sec);
- *tl = txdr_unsigned(boottime.tv_usec);
+ *tl = txdr_unsigned(boottime.tv_nsec/1000);
} else
error = 0;
nfsmout:
diff --git a/sys/sys/kernel.h b/sys/sys/kernel.h
index 3e8141a3362..651f4a9916a 100644
--- a/sys/sys/kernel.h
+++ b/sys/sys/kernel.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: kernel.h,v 1.13 2012/11/05 19:39:35 miod Exp $ */
+/* $OpenBSD: kernel.h,v 1.14 2013/06/03 16:55:22 guenther Exp $ */
/* $NetBSD: kernel.h,v 1.11 1995/03/03 01:24:16 cgd Exp $ */
/*-
@@ -47,7 +47,7 @@ extern char domainname[MAXHOSTNAMELEN];
extern int domainnamelen;
/* 1.2 */
-extern struct timeval boottime;
+extern struct timespec boottime;
extern struct timezone tz; /* XXX */
extern int tick; /* usec per tick (1000000 / hz) */
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index a3773520ea2..4e9c677d918 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.h,v 1.165 2013/02/11 11:11:42 mpi Exp $ */
+/* $OpenBSD: proc.h,v 1.166 2013/06/03 16:55:22 guenther Exp $ */
/* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */
/*-
@@ -125,7 +125,7 @@ extern int nemuls; /* Number of emuls */
* accumulated into these.
*/
struct tusage {
- struct timeval tu_runtime; /* Realtime. */
+ struct timespec tu_runtime; /* Realtime. */
uint64_t tu_uticks; /* Statclock hits in user mode. */
uint64_t tu_sticks; /* Statclock hits in system mode. */
uint64_t tu_iticks; /* Statclock hits processing intr. */
@@ -207,7 +207,7 @@ struct process {
/* End area that is copied on creation. */
#define ps_endcopy ps_refcnt
- struct timeval ps_start; /* starting time. */
+ struct timespec ps_start; /* starting time. */
struct timeout ps_realit_to; /* real-time itimer trampoline. */
struct timeout ps_virt_to; /* virtual itimer trampoline. */
struct timeout ps_prof_to; /* prof itimer trampoline. */
@@ -293,7 +293,7 @@ struct proc {
struct rusage p_ru; /* Statistics */
struct tusage p_tu; /* accumulated times. */
- struct timeval p_rtime; /* Real time. */
+ struct timespec p_rtime; /* Real time. */
u_int p_uticks; /* Statclock hits in user mode. */
u_int p_sticks; /* Statclock hits in system mode. */
u_int p_iticks; /* Statclock hits processing intr. */
diff --git a/sys/sys/resourcevar.h b/sys/sys/resourcevar.h
index 3dc7a2af309..18d9fa02716 100644
--- a/sys/sys/resourcevar.h
+++ b/sys/sys/resourcevar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: resourcevar.h,v 1.15 2012/03/23 15:51:26 guenther Exp $ */
+/* $OpenBSD: resourcevar.h,v 1.16 2013/06/03 16:55:22 guenther Exp $ */
/* $NetBSD: resourcevar.h,v 1.12 1995/11/22 23:01:53 cgd Exp $ */
/*
@@ -56,16 +56,18 @@ do { \
} while (0)
#ifdef _KERNEL
-void addupc_intr(struct proc *p, u_long pc);
-void addupc_task(struct proc *p, u_long pc, u_int ticks);
+void addupc_intr(struct proc *, u_long);
+void addupc_task(struct proc *, u_long, u_int);
void tuagg_unlocked(struct process *, struct proc *);
struct tusage;
-void calcru(struct tusage *, struct timeval *up, struct timeval *sp,
- struct timeval *ip);
-struct plimit *limcopy(struct plimit *lim);
+void calctsru(struct tusage *, struct timespec *, struct timespec *,
+ struct timespec *);
+void calcru(struct tusage *, struct timeval *, struct timeval *,
+ struct timeval *);
+struct plimit *limcopy(struct plimit *);
void limfree(struct plimit *);
-void ruadd(struct rusage *ru, struct rusage *ru2);
+void ruadd(struct rusage *, struct rusage *);
void virttimer_trampoline(void *);
void proftimer_trampoline(void *);
diff --git a/sys/sys/sched.h b/sys/sys/sched.h
index 16512054428..8a953934b24 100644
--- a/sys/sys/sched.h
+++ b/sys/sys/sched.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sched.h,v 1.30 2011/11/16 20:50:19 deraadt Exp $ */
+/* $OpenBSD: sched.h,v 1.31 2013/06/03 16:55:22 guenther Exp $ */
/* $NetBSD: sched.h,v 1.2 1999/02/28 18:14:58 ross Exp $ */
/*-
@@ -94,7 +94,7 @@
* XXX - expose to userland for now.
*/
struct schedstate_percpu {
- struct timeval spc_runtime; /* time curproc started running */
+ struct timespec spc_runtime; /* time curproc started running */
__volatile int spc_schedflags; /* flags; see below */
u_int spc_schedticks; /* ticks for schedclock() */
u_int64_t spc_cp_time[CPUSTATES]; /* CPU state statistics */
diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h
index c50efc1d384..e62a660f604 100644
--- a/sys/sys/sysctl.h
+++ b/sys/sys/sysctl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysctl.h,v 1.134 2013/04/15 16:47:14 guenther Exp $ */
+/* $OpenBSD: sysctl.h,v 1.135 2013/06/03 16:55:22 guenther Exp $ */
/* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */
/*
@@ -498,14 +498,14 @@ do { \
(kp)->p_estcpu = (p)->p_estcpu; \
if (isthread) { \
(kp)->p_rtime_sec = (p)->p_tu.tu_runtime.tv_sec; \
- (kp)->p_rtime_usec = (p)->p_tu.tu_runtime.tv_usec; \
+ (kp)->p_rtime_usec = (p)->p_tu.tu_runtime.tv_nsec/1000; \
(kp)->p_tid = (p)->p_pid + THREAD_PID_OFFSET; \
(kp)->p_uticks = (p)->p_tu.tu_uticks; \
(kp)->p_sticks = (p)->p_tu.tu_sticks; \
(kp)->p_iticks = (p)->p_tu.tu_iticks; \
} else { \
(kp)->p_rtime_sec = (pr)->ps_tu.tu_runtime.tv_sec; \
- (kp)->p_rtime_usec = (pr)->ps_tu.tu_runtime.tv_usec; \
+ (kp)->p_rtime_usec = (pr)->ps_tu.tu_runtime.tv_nsec/1000; \
(kp)->p_tid = -1; \
(kp)->p_uticks = (pr)->ps_tu.tu_uticks; \
(kp)->p_sticks = (pr)->ps_tu.tu_sticks; \
@@ -575,7 +575,7 @@ do { \
(kp)->p_uvalid = 1; \
\
(kp)->p_ustart_sec = (pr)->ps_start.tv_sec; \
- (kp)->p_ustart_usec = (pr)->ps_start.tv_usec; \
+ (kp)->p_ustart_usec = (pr)->ps_start.tv_nsec/1000; \
\
(kp)->p_uru_maxrss = (p)->p_ru.ru_maxrss; \
(kp)->p_uru_ixrss = (p)->p_ru.ru_ixrss; \