microtime_func = cc_microtime;

to a point after the CPU-specific setup routine is called because some of them
"turn off" the TSC because it's broken on those platforms, or not suitable
for use as an interval timer.

One such platform is the Cyrix/NSC Geode processor; when powersave mode is
enabled, the "hlt" instruction stops the TSC too. It continues to be perfectly
reasonable for program profiling as a cycle counter in this mode, but it is
unsuitable for interval time keeping (time doesn't stop just because you're
asleep or napping), and, for now, we don't have a separate flag to make this
distinction - we just test for the presence of TSC to enable cc_microtime().
This commit is contained in:
fair 2005-07-06 18:35:39 +00:00
parent 4f4cb6f0b3
commit c0ca9de9a9
2 changed files with 17 additions and 7 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu.c,v 1.22 2005/06/15 01:52:39 christos Exp $ */
/* $NetBSD: cpu.c,v 1.23 2005/07/06 18:35:39 fair Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.22 2005/06/15 01:52:39 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.23 2005/07/06 18:35:39 fair Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@ -409,6 +409,19 @@ cpu_init(ci)
if (ci->ci_cpu_class >= CPUCLASS_486)
lcr0(rcr0() | CR0_WP);
#endif
#if defined(I586_CPU) || defined(I686_CPU)
#ifndef NO_TSC_TIME
/*
* On systems with a cycle counter, use that for
* interval timing inbetween hz ticks in microtime(9)
* N.B. this is not a good idea on processors whose
* frequency varies a lot over time (e.g. modern laptops)
*/
if (cpu_feature & TSC) {
microtime_func = cc_microtime;
}
#endif
#endif
#if defined(I686_CPU)
/*
* On a P6 or above, enable global TLB caching if the

View File

@ -1,4 +1,4 @@
/* $NetBSD: identcpu.c,v 1.19 2005/06/16 00:04:25 seb Exp $ */
/* $NetBSD: identcpu.c,v 1.20 2005/07/06 18:35:39 fair Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.19 2005/06/16 00:04:25 seb Exp $");
__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.20 2005/07/06 18:35:39 fair Exp $");
#include "opt_cputype.h"
#include "opt_enhanced_speedstep.h"
@ -1198,9 +1198,6 @@ identifycpu(struct cpu_info *ci)
last_tsc = rdtsc();
delay(100000);
ci->ci_tsc_freq = (rdtsc() - last_tsc) * 10;
#ifndef NO_TSC_TIME
microtime_func = cc_microtime;
#endif
}
/* XXX end XXX */
#endif