From owner-svn-src-head@FreeBSD.ORG Tue Apr 8 02:36:28 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1592986A; Tue, 8 Apr 2014 02:36:28 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DD73E1578; Tue, 8 Apr 2014 02:36:27 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s382aRHT057352; Tue, 8 Apr 2014 02:36:27 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s382aR4W057350; Tue, 8 Apr 2014 02:36:27 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201404080236.s382aR4W057350@svn.freebsd.org> From: Adrian Chadd Date: Tue, 8 Apr 2014 02:36:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r264250 - head/sys/dev/acpica X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Apr 2014 02:36:28 -0000 Author: adrian Date: Tue Apr 8 02:36:27 2014 New Revision: 264250 URL: http://svnweb.freebsd.org/changeset/base/264250 Log: Add a basic set of data points which count the number of sleep entries that are being done by the OS. For now this'll match up with the "wakeups"; although I'll dig deeper into this to see if we can determine which sleep state the CPU managed to get into. Most things I've seen these days only expose up to C2 or C3 via ACPI even though the CPU goes all the way down to C6 or C7. Modified: head/sys/dev/acpica/acpi_cpu.c Modified: head/sys/dev/acpica/acpi_cpu.c ============================================================================== --- head/sys/dev/acpica/acpi_cpu.c Tue Apr 8 02:32:39 2014 (r264249) +++ head/sys/dev/acpica/acpi_cpu.c Tue Apr 8 02:36:27 2014 (r264250) @@ -172,6 +172,7 @@ static void acpi_cpu_idle(sbintime_t sbt static void acpi_cpu_notify(ACPI_HANDLE h, UINT32 notify, void *context); static int acpi_cpu_quirks(void); static int acpi_cpu_usage_sysctl(SYSCTL_HANDLER_ARGS); +static int acpi_cpu_usage_counters_sysctl(SYSCTL_HANDLER_ARGS); static int acpi_cpu_set_cx_lowest(struct acpi_cpu_softc *sc); static int acpi_cpu_cx_lowest_sysctl(SYSCTL_HANDLER_ARGS); static int acpi_cpu_global_cx_lowest_sysctl(SYSCTL_HANDLER_ARGS); @@ -938,6 +939,11 @@ acpi_cpu_startup_cx(struct acpi_cpu_soft OID_AUTO, "cx_usage", CTLTYPE_STRING | CTLFLAG_RD, (void *)sc, 0, acpi_cpu_usage_sysctl, "A", "percent usage for each Cx state"); + SYSCTL_ADD_PROC(&sc->cpu_sysctl_ctx, + SYSCTL_CHILDREN(device_get_sysctl_tree(sc->cpu_dev)), + OID_AUTO, "cx_usage_counters", CTLTYPE_STRING | CTLFLAG_RD, + (void *)sc, 0, acpi_cpu_usage_counters_sysctl, "A", + "Cx sleep state counters"); /* Signal platform that we can handle _CST notification. */ if (!cpu_cx_generic && cpu_cst_cnt != 0) { @@ -1237,6 +1243,35 @@ acpi_cpu_usage_sysctl(SYSCTL_HANDLER_ARG return (0); } +/* + * XXX TODO: actually add support to count each entry/exit + * from the Cx states. + */ +static int +acpi_cpu_usage_counters_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct acpi_cpu_softc *sc; + struct sbuf sb; + char buf[128]; + int i; + + sc = (struct acpi_cpu_softc *) arg1; + + /* Print out the raw counters */ + sbuf_new(&sb, buf, sizeof(buf), SBUF_FIXEDLEN); + + for (i = 0; i < sc->cpu_cx_count; i++) { + sbuf_printf(&sb, "%u ", sc->cpu_cx_stats[i]); + } + + sbuf_trim(&sb); + sbuf_finish(&sb); + sysctl_handle_string(oidp, sbuf_data(&sb), sbuf_len(&sb), req); + sbuf_delete(&sb); + + return (0); +} + static int acpi_cpu_set_cx_lowest(struct acpi_cpu_softc *sc) {