diff options
author | phk <phk@FreeBSD.org> | 1998-05-28 09:30:28 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1998-05-28 09:30:28 +0000 |
commit | d3d65c6b2e376ac074f3ca386b6f5b70ea37636f (patch) | |
tree | 6beef0d8c93f6063bf0b9870b87a8c1ef8267cd4 /sys/kern/kern_resource.c | |
parent | 3654f28d394a609d42e7000c62963c45e3bba3db (diff) | |
download | FreeBSD-src-d3d65c6b2e376ac074f3ca386b6f5b70ea37636f.zip FreeBSD-src-d3d65c6b2e376ac074f3ca386b6f5b70ea37636f.tar.gz |
Some cleanups related to timecounters and weird ifdefs in <sys/time.h>.
Clean up (or if antipodic: down) some of the msgbuf stuff.
Use an inline function rather than a macro for timecounter delta.
Maintain process "on-cpu" time as 64 bits of microseconds to avoid
needless second rollover overhead.
Avoid calling microuptime the second time in mi_switch() if we do
not pass through _idle in cpu_switch()
This should reduce our context-switch overhead a bit, in particular
on pre-P5 and SMP systems.
WARNING: Programs which muck about with struct proc in userland
will have to be fixed.
Reviewed, but found imperfect by: bde
Diffstat (limited to 'sys/kern/kern_resource.c')
-rw-r--r-- | sys/kern/kern_resource.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c index 82ff088..a19f489 100644 --- a/sys/kern/kern_resource.c +++ b/sys/kern/kern_resource.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)kern_resource.c 8.5 (Berkeley) 1/21/94 - * $Id: kern_resource.c,v 1.35 1998/04/05 02:59:10 peter Exp $ + * $Id: kern_resource.c,v 1.36 1998/05/17 11:52:43 phk Exp $ */ #include "opt_compat.h" @@ -399,6 +399,13 @@ dosetrlimit(p, which, limp) switch (which) { + case RLIMIT_CPU: + if (limp->rlim_cur > RLIM_INFINITY / (rlim_t)1000000) + p->p_limit->p_cpulimit = RLIM_INFINITY; + else + p->p_limit->p_cpulimit = + (rlim_t)1000000 * limp->rlim_cur; + break; case RLIMIT_DATA: if (limp->rlim_cur > MAXDSIZ) limp->rlim_cur = MAXDSIZ; @@ -485,9 +492,8 @@ calcru(p, up, sp, ip) struct timeval *sp; struct timeval *ip; { - quad_t totusec; - u_quad_t u, st, ut, it, tot; - long sec, usec; + int64_t totusec; + u_int64_t u, st, ut, it, tot; int s; struct timeval tv; @@ -504,8 +510,7 @@ calcru(p, up, sp, ip) tot = 1; } - sec = p->p_rtime.tv_sec; - usec = p->p_rtime.tv_usec; + totusec = p->p_runtime; #ifdef SMP if (p->p_oncpu != (char)0xff) { #else @@ -517,10 +522,9 @@ calcru(p, up, sp, ip) * quantum, which is much greater than the sampling error. */ microuptime(&tv); - sec += tv.tv_sec - p->p_runtime.tv_sec; - usec += tv.tv_usec - p->p_runtime.tv_usec; + totusec += (tv.tv_usec - p->p_switchtime.tv_usec) + + (tv.tv_sec - p->p_switchtime.tv_sec) * (int64_t)1000000; } - totusec = (quad_t)sec * 1000000 + usec; if (totusec < 0) { /* XXX no %qd in kernel. Truncate. */ printf("calcru: negative time of %ld usec for pid %d (%s)\n", @@ -602,8 +606,7 @@ limcopy(lim) MALLOC(copy, struct plimit *, sizeof(struct plimit), M_SUBPROC, M_WAITOK); - bcopy(lim->pl_rlimit, copy->pl_rlimit, - sizeof(struct rlimit) * RLIM_NLIMITS); + bcopy(lim->pl_rlimit, copy->pl_rlimit, sizeof(struct plimit)); copy->p_lflags = 0; copy->p_refcnt = 1; return (copy); |