diff options
| author | sommerfeld <sommerfeld@NetBSD.org> | 2001-05-27 13:53:24 +0000 |
|---|---|---|
| committer | sommerfeld <sommerfeld@NetBSD.org> | 2001-05-27 13:53:24 +0000 |
| commit | 4aaf078a4a9014f3abc372b589eb44ae609bd320 (patch) | |
| tree | d539d09280487ca04dd4530d4454f0af29645280 /sys | |
| parent | 1bca7091cc16a4b881d61af9f4867feb716c4e32 (diff) | |
Assorted microtime fixes (similar to fixes I made yesterday when
porting this code to i386mp branch):
- call microset() early on each cpu so that calls to microtime()
before the first clock interrupt don't return trash. this manifested
itself as garbage runtimes in "ps" for kernel threads.
- avoid races between hardclock updating "time" and microset on a
different cpu reading it by adding a "microset_time" global which is
initialized from "time" on the primary cpu.
- call microset every hz ticks, not every hz+1 (cosmetic)
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/arch/alpha/alpha/clock.c | 12 | ||||
| -rw-r--r-- | sys/arch/alpha/alpha/cpu.c | 7 | ||||
| -rw-r--r-- | sys/arch/alpha/alpha/interrupt.c | 7 | ||||
| -rw-r--r-- | sys/arch/alpha/alpha/microtime.c | 10 | ||||
| -rw-r--r-- | sys/arch/alpha/include/cpu.h | 4 |
5 files changed, 27 insertions, 13 deletions
diff --git a/sys/arch/alpha/alpha/clock.c b/sys/arch/alpha/alpha/clock.c index 6111da648a7..b643b1f0191 100644 --- a/sys/arch/alpha/alpha/clock.c +++ b/sys/arch/alpha/alpha/clock.c @@ -1,4 +1,4 @@ -/* $NetBSD: clock.c,v 1.30 2001/04/28 06:10:49 thorpej Exp $ */ +/* $NetBSD: clock.c,v 1.31 2001/05/27 13:53:24 sommerfeld Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -44,7 +44,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.30 2001/04/28 06:10:49 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.31 2001/05/27 13:53:24 sommerfeld Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -223,6 +223,8 @@ inittodr(base) #ifdef DEBUG printf("=>%ld (%d)\n", time.tv_sec, base); #endif + microset_time = time; + microset(curcpu(), NULL); if (!badbase) { /* @@ -258,6 +260,12 @@ resettodr() if (!clockinitted) return; + microset_time = time; +#if defined(MULTIPROCESSOR) + alpha_multicast_ipi(cpus_running, ALPHA_IPI_MICROSET); +#endif + microset(curcpu(), NULL); + clock_secs_to_ymdhms(time.tv_sec, &dt); /* rt clock wants 2 digits */ diff --git a/sys/arch/alpha/alpha/cpu.c b/sys/arch/alpha/alpha/cpu.c index 7b678e128ed..780b3657997 100644 --- a/sys/arch/alpha/alpha/cpu.c +++ b/sys/arch/alpha/alpha/cpu.c @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.62 2001/04/24 20:03:20 thorpej Exp $ */ +/* $NetBSD: cpu.c,v 1.63 2001/05/27 13:53:24 sommerfeld Exp $ */ /*- * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.62 2001/04/24 20:03:20 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.63 2001/05/27 13:53:24 sommerfeld Exp $"); #include "opt_ddb.h" #include "opt_multiprocessor.h" @@ -544,7 +544,8 @@ cpu_hatch(ci) printf("%s: CPU %lu running\n", ci->ci_softc->sc_dev.dv_xname, cpu_number()); atomic_setbits_ulong(&cpus_running, cpumask); - + + microset(ci, NULL); /* Initialize our base "runtime". */ microtime(&ci->ci_schedstate.spc_runtime); } diff --git a/sys/arch/alpha/alpha/interrupt.c b/sys/arch/alpha/alpha/interrupt.c index 33bc754694c..fdd317b6483 100644 --- a/sys/arch/alpha/alpha/interrupt.c +++ b/sys/arch/alpha/alpha/interrupt.c @@ -1,4 +1,4 @@ -/* $NetBSD: interrupt.c,v 1.60 2001/05/14 19:56:22 ross Exp $ */ +/* $NetBSD: interrupt.c,v 1.61 2001/05/27 13:53:24 sommerfeld Exp $ */ /*- * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. @@ -72,7 +72,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.60 2001/05/14 19:56:22 ross Exp $"); +__KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.61 2001/05/27 13:53:24 sommerfeld Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -153,7 +153,8 @@ interrupt(unsigned long a0, unsigned long a1, unsigned long a2, #endif microset_iter-- == 0) { - microset_iter = hz; + microset_iter = hz-1; + microset_time = time; #if defined(MULTIPROCESSOR) alpha_multicast_ipi(cpus_running, ALPHA_IPI_MICROSET); diff --git a/sys/arch/alpha/alpha/microtime.c b/sys/arch/alpha/alpha/microtime.c index e331752f4de..e47a820a2e2 100644 --- a/sys/arch/alpha/alpha/microtime.c +++ b/sys/arch/alpha/alpha/microtime.c @@ -1,4 +1,4 @@ -/* $NetBSD: microtime.c,v 1.2 2001/04/29 17:04:41 sommerfeld Exp $ */ +/* $NetBSD: microtime.c,v 1.3 2001/05/27 13:53:24 sommerfeld Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -54,7 +54,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: microtime.c,v 1.2 2001/04/29 17:04:41 sommerfeld Exp $"); +__KERNEL_RCSID(0, "$NetBSD: microtime.c,v 1.3 2001/05/27 13:53:24 sommerfeld Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -63,6 +63,8 @@ __KERNEL_RCSID(0, "$NetBSD: microtime.c,v 1.2 2001/04/29 17:04:41 sommerfeld Exp #include <machine/cpu.h> #include <machine/rpb.h> +struct timeval microset_time; + /* * Return the best possible estimate of the time in the timeval to which * tvp points. The kernel logical time variable is interpolated between @@ -165,7 +167,7 @@ microset(struct cpu_info *ci, struct trapframe *framep) /* XXX BLOCK MACHINE CHECKS? */ denom = ci->ci_pcc_pcc; - t = time; /* XXXSMP: not atomic */ + t = microset_time; ci->ci_pcc_pcc = alpha_rpcc() & 0xffffffffUL; /* XXX UNBLOCK MACHINE CHECKS? */ @@ -194,7 +196,7 @@ microset(struct cpu_info *ci, struct trapframe *framep) * the time is probably be frobbed with by the timekeeper * or the human. */ - if (delta > 500000 && delta < 15000000) { + if (delta > 500000 && delta < 1500000) { ci->ci_pcc_ms_delta = delta; ci->ci_pcc_denom = denom; } else { diff --git a/sys/arch/alpha/include/cpu.h b/sys/arch/alpha/include/cpu.h index 63facd98a9c..cfe928fdece 100644 --- a/sys/arch/alpha/include/cpu.h +++ b/sys/arch/alpha/include/cpu.h @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.56 2001/04/28 06:10:50 thorpej Exp $ */ +/* $NetBSD: cpu.h,v 1.57 2001/05/27 13:53:25 sommerfeld Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -280,6 +280,8 @@ struct reg; struct rpb; struct trapframe; +extern struct timeval microset_time; + int badaddr(void *, size_t); void microset(struct cpu_info *, struct trapframe *); |
