summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_tc.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1998-05-28 09:30:28 +0000
committerphk <phk@FreeBSD.org>1998-05-28 09:30:28 +0000
commitd3d65c6b2e376ac074f3ca386b6f5b70ea37636f (patch)
tree6beef0d8c93f6063bf0b9870b87a8c1ef8267cd4 /sys/kern/kern_tc.c
parent3654f28d394a609d42e7000c62963c45e3bba3db (diff)
downloadFreeBSD-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_tc.c')
-rw-r--r--sys/kern/kern_tc.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
index 1cb2233..5334bf0 100644
--- a/sys/kern/kern_tc.c
+++ b/sys/kern/kern_tc.c
@@ -39,7 +39,7 @@ static volatile int print_tci = 1;
* SUCH DAMAGE.
*
* @(#)kern_clock.c 8.5 (Berkeley) 1/21/94
- * $Id: kern_clock.c,v 1.68 1998/05/17 11:52:39 phk Exp $
+ * $Id: kern_clock.c,v 1.69 1998/05/19 18:54:38 phk Exp $
*/
#include <sys/param.h>
@@ -73,6 +73,7 @@ SYSINIT(clocks, SI_SUB_CLOCKS, SI_ORDER_FIRST, initclocks, NULL)
static void tco_forward __P((void));
static void tco_setscales __P((struct timecounter *tc));
+static __inline unsigned tco_getdelta __P((struct timecounter *tc));
/* Some of these don't belong here, but it's easiest to concentrate them. */
#if defined(SMP) && defined(BETTER_CLOCK)
@@ -493,8 +494,12 @@ sysctl_kern_clockrate SYSCTL_HANDLER_ARGS
SYSCTL_PROC(_kern, KERN_CLOCKRATE, clockrate, CTLTYPE_STRUCT|CTLFLAG_RD,
0, 0, sysctl_kern_clockrate, "S,clockinfo","");
-#define TC_DELTA(tc) \
- (((tc)->get_timecount() - (tc)->offset_count) & (tc)->counter_mask)
+static __inline unsigned
+tco_getdelta(struct timecounter *tc)
+{
+
+ return ((tc->get_timecount() - tc->offset_count) & tc->counter_mask);
+}
/*
* We have four functions for looking at the clock, two for microseconds
@@ -530,7 +535,7 @@ microtime(struct timeval *tv)
tc = (struct timecounter *)timecounter;
tv->tv_sec = tc->offset_sec;
tv->tv_usec = tc->offset_micro;
- tv->tv_usec += ((u_int64_t)TC_DELTA(tc) * tc->scale_micro) >> 32;
+ tv->tv_usec += ((u_int64_t)tco_getdelta(tc) * tc->scale_micro) >> 32;
tv->tv_usec += boottime.tv_usec;
tv->tv_sec += boottime.tv_sec;
while (tv->tv_usec >= 1000000) {
@@ -548,7 +553,7 @@ nanotime(struct timespec *tv)
tc = (struct timecounter *)timecounter;
tv->tv_sec = tc->offset_sec;
- count = TC_DELTA(tc);
+ count = tco_getdelta(tc);
delta = tc->offset_nano;
delta += ((u_int64_t)count * tc->scale_nano_f);
delta >>= 32;
@@ -590,7 +595,7 @@ microuptime(struct timeval *tv)
tc = (struct timecounter *)timecounter;
tv->tv_sec = tc->offset_sec;
tv->tv_usec = tc->offset_micro;
- tv->tv_usec += ((u_int64_t)TC_DELTA(tc) * tc->scale_micro) >> 32;
+ tv->tv_usec += ((u_int64_t)tco_getdelta(tc) * tc->scale_micro) >> 32;
if (tv->tv_usec >= 1000000) {
tv->tv_usec -= 1000000;
tv->tv_sec++;
@@ -600,13 +605,13 @@ microuptime(struct timeval *tv)
void
nanouptime(struct timespec *tv)
{
- u_int count;
+ unsigned count;
u_int64_t delta;
struct timecounter *tc;
tc = (struct timecounter *)timecounter;
tv->tv_sec = tc->offset_sec;
- count = TC_DELTA(tc);
+ count = tco_getdelta(tc);
delta = tc->offset_nano;
delta += ((u_int64_t)count * tc->scale_nano_f);
delta >>= 32;
@@ -725,7 +730,7 @@ sync_other_counter(void)
tco = tc->other;
*tc = *timecounter;
tc->other = tco;
- delta = TC_DELTA(tc);
+ delta = tco_getdelta(tc);
tc->offset_count += delta;
tc->offset_count &= tc->counter_mask;
tc->offset_nano += (u_int64_t)delta * tc->scale_nano_f;
@@ -799,10 +804,10 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, adjustment, CTLTYPE_INT | CTLFLAG_RW,
* timeservices.
*/
-static u_int
+static unsigned
dummy_get_timecount(void)
{
- static u_int now;
+ static unsigned now;
return (++now);
}
OpenPOWER on IntegriCloud