Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Jun 2010 08:36:13 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r209328 - head/sys/dev/acpica
Message-ID:  <201006190836.o5J8aDbR025203@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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;
     }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201006190836.o5J8aDbR025203>