From owner-svn-src-all@FreeBSD.ORG Sat Jun 19 08:36:13 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 31BD2106566B; Sat, 19 Jun 2010 08:36:13 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 213C28FC0C; Sat, 19 Jun 2010 08:36:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o5J8aDPs025205; Sat, 19 Jun 2010 08:36:13 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o5J8aDbR025203; Sat, 19 Jun 2010 08:36:13 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201006190836.o5J8aDbR025203@svn.freebsd.org> From: Alexander Motin Date: Sat, 19 Jun 2010 08:36:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r209328 - head/sys/dev/acpica X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Jun 2010 08:36:13 -0000 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; }