Date: Tue, 8 Apr 2014 02:36:27 +0000 (UTC) From: Adrian Chadd <adrian@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r264250 - head/sys/dev/acpica Message-ID: <201404080236.s382aR4W057350@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201404080236.s382aR4W057350>