summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2010-06-19 08:36:12 +0000
committermav <mav@FreeBSD.org>2010-06-19 08:36:12 +0000
commitc101fb6239b4d8595307325fc33552601fd93e88 (patch)
treef164e0e824d047c9d559be65fd08f2ebac6bea78 /sys/dev
parent3ab8676f7b4604c253c925ae463fd26f495a84b8 (diff)
downloadFreeBSD-src-c101fb6239b4d8595307325fc33552601fd93e88.zip
FreeBSD-src-c101fb6239b4d8595307325fc33552601fd93e88.tar.gz
While we indeed can't precisely measure time spent in C1, we can consider
measured interval as upper bound. It should be more precise then just assuming hz/2. For idle CPU it should be quite precise, for busy - not worse then before.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/acpica/acpi_cpu.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c
index 043f0c0..9398fc2 100644
--- a/sys/dev/acpica/acpi_cpu.c
+++ b/sys/dev/acpica/acpi_cpu.c
@@ -928,12 +928,16 @@ acpi_cpu_idle()
/*
* Execute HLT (or equivalent) and wait for an interrupt. We can't
- * calculate the time spent in C1 since the place we wake up is an
- * ISR. Assume we slept half of quantum and return.
+ * precisely calculate the time spent in C1 since the place we wake up
+ * is an ISR. Assume we slept no more then half of quantum.
*/
if (cx_next->type == ACPI_STATE_C1) {
- sc->cpu_prev_sleep = (sc->cpu_prev_sleep * 3 + 500000 / hz) / 4;
+ AcpiHwRead(&start_time, &AcpiGbl_FADT.XPmTimerBlock);
acpi_cpu_c1();
+ AcpiHwRead(&end_time, &AcpiGbl_FADT.XPmTimerBlock);
+ end_time = acpi_TimerDelta(end_time, start_time);
+ sc->cpu_prev_sleep = (sc->cpu_prev_sleep * 3 +
+ min(PM_USEC(end_time), 500000)) / 4;
return;
}
OpenPOWER on IntegriCloud