aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2010-06-19 08:36:12 +0000
committerAlexander Motin <mav@FreeBSD.org>2010-06-19 08:36:12 +0000
commit7150e67191aa71c317edb51c435a40f8ef5f6ca3 (patch)
treef164e0e824d047c9d559be65fd08f2ebac6bea78 /sys
parentcb0bd51d988e016eda6f2d78db289c29dc29392c (diff)
downloadsrc-7150e67191aa71c317edb51c435a40f8ef5f6ca3.tar.gz
src-7150e67191aa71c317edb51c435a40f8ef5f6ca3.zip
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.
Notes
Notes: svn path=/head/; revision=209328
Diffstat (limited to 'sys')
-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 043f0c071a20..9398fc2c8950 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;
}