diff options
author | phk <phk@FreeBSD.org> | 2006-02-07 21:22:02 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2006-02-07 21:22:02 +0000 |
commit | bb2f62f5367d29657fc52a4cfcd3573c39679b70 (patch) | |
tree | 95918de865b5c6e707ecd4ce458d058d287406e9 /sys/kern/kern_exit.c | |
parent | c7f3a565d2e7b4fed16d19bfe4b300ca8ef7ad27 (diff) | |
download | FreeBSD-src-bb2f62f5367d29657fc52a4cfcd3573c39679b70.zip FreeBSD-src-bb2f62f5367d29657fc52a4cfcd3573c39679b70.tar.gz |
Modify the way we account for CPU time spent (step 1)
Keep track of time spent by the cpu in various contexts in units of
"cputicks" and scale to real-world microsec^H^H^H^H^H^H^H^Hclock_t
only when somebody wants to inspect the numbers.
For now "cputicks" are still derived from the current timecounter
and therefore things should by definition remain sensible also on
SMP machines. (The main reason for this first milestone commit is
to verify that hypothesis.)
On slower machines, the avoided multiplications to normalize timestams
at every context switch, comes out as a 5-7% better score on the
unixbench/context1 microbenchmark. On more modern hardware no change
in performance is seen.
Diffstat (limited to 'sys/kern/kern_exit.c')
-rw-r--r-- | sys/kern/kern_exit.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index b907981..8803ac9 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -110,7 +110,7 @@ sys_exit(struct thread *td, struct sys_exit_args *uap) void exit1(struct thread *td, int rv) { - struct bintime new_switchtime; + uint64_t new_switchtime; struct proc *p, *nq, *q; struct tty *tp; struct vnode *ttyvp; @@ -543,9 +543,8 @@ retry: ruadd(p->p_ru, &p->p_rux, &p->p_stats->p_cru, &p->p_crux); /* Do the same timestamp bookkeeping that mi_switch() would do. */ - binuptime(&new_switchtime); - bintime_add(&p->p_rux.rux_runtime, &new_switchtime); - bintime_sub(&p->p_rux.rux_runtime, PCPU_PTR(switchtime)); + new_switchtime = cpu_ticks(); + p->p_rux.rux_runtime += (new_switchtime - PCPU_GET(switchtime)); PCPU_SET(switchtime, new_switchtime); PCPU_SET(switchticks, ticks); cnt.v_swtch++; |