svn commit: r209328 - head/sys/dev/acpica
Alexander Motin
mav at FreeBSD.org
Sat Jun 19 08:36:13 UTC 2010
Author: mav
Date: Sat Jun 19 08:36:12 2010
New Revision: 209328
URL: http://svn.freebsd.org/changeset/base/209328
Log:
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.
Modified:
head/sys/dev/acpica/acpi_cpu.c
Modified: head/sys/dev/acpica/acpi_cpu.c
==============================================================================
--- head/sys/dev/acpica/acpi_cpu.c Sat Jun 19 05:35:47 2010 (r209327)
+++ head/sys/dev/acpica/acpi_cpu.c Sat Jun 19 08:36:12 2010 (r209328)
@@ -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;
}
More information about the svn-src-head
mailing list