Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Normalize some machine dependent CPU frequenct sysctl variab...



details:   https://anonhg.NetBSD.org/src/rev/a0b029899799
branches:  trunk
changeset: 945298:a0b029899799
user:      nia <nia%NetBSD.org@localhost>
date:      Sun Oct 25 16:39:00 2020 +0000

description:
Normalize some machine dependent CPU frequenct sysctl variables.

This moves machdep.*.frequency.* to machdep.cpu.frequency.*.

This was proposed on tech-kern some time ago. The intention is to allow
third-party tools such as estd and conky to more easily and reliably
fetch or modify the current CPU frequency without iterating through
various machine-dependent variables to check their presence.

diffstat:

 share/man/man4/acpicpu.4                   |   6 +-----
 share/man/man4/man4.x86/est.4              |  12 ++++++------
 share/man/man4/man4.x86/powernow.4         |  12 ++++++------
 sys/arch/evbmips/loongson/loongson_clock.c |   8 ++++----
 sys/arch/macppc/dev/obio.c                 |   8 ++++----
 sys/arch/x86/acpi/acpi_cpu_md.c            |  23 +++--------------------
 sys/arch/x86/x86/est.c                     |  14 +++++++-------
 sys/arch/x86/x86/powernow.c                |  12 ++++++------
 8 files changed, 37 insertions(+), 58 deletions(-)

diffs (300 lines):

diff -r 823265519881 -r a0b029899799 share/man/man4/acpicpu.4
--- a/share/man/man4/acpicpu.4  Sun Oct 25 16:18:02 2020 +0000
+++ b/share/man/man4/acpicpu.4  Sun Oct 25 16:39:00 2020 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: acpicpu.4,v 1.35 2018/08/31 19:34:44 sevan Exp $
+.\" $NetBSD: acpicpu.4,v 1.36 2020/10/25 16:39:00 nia Exp $
 .\"
 .\" Copyright (c) 2010 Jukka Ruohonen <jruohonen%iki.fi@localhost>
 .\" All rights reserved.
@@ -257,10 +257,6 @@
 .Xr est 4
 and
 .Xr powernow 4 .
-Depending on the processor, the second-level node is either
-.Ic machdep.est
-or
-.Ic machdep.powernow .
 Please note that future versions of
 .Nm
 may however remove these system control variables without further notice.
diff -r 823265519881 -r a0b029899799 share/man/man4/man4.x86/est.4
--- a/share/man/man4/man4.x86/est.4     Sun Oct 25 16:18:02 2020 +0000
+++ b/share/man/man4/man4.x86/est.4     Sun Oct 25 16:39:00 2020 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: est.4,v 1.5 2017/02/17 22:10:47 christos Exp $
+.\" $NetBSD: est.4,v 1.6 2020/10/25 16:39:00 nia Exp $
 .\"
 .\" Copyright (c) 2011 Jukka Ruohonen <jruohonen%iki.fi@localhost>
 .\" All rights reserved.
@@ -24,7 +24,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd February 17, 2017
+.Dd September 7, 2020
 .Dt EST 4
 .Os
 .Sh NAME
@@ -41,13 +41,13 @@
 .Xr sysctl 8
 variables are available with
 .Nm :
-.Bl -tag -width "machdep.est.frequency.available" -offset indent
-.It Ic machdep.est.frequency.target
+.Bl -tag -width "machdep.cpu.frequency.available" -offset indent
+.It Ic machdep.cpu.frequency.target
 The target frequency of the
 .Tn CPUs .
-.It Ic machdep.est.frequency.current
+.It Ic machdep.cpu.frequency.current
 The current frequency.
-.It Ic machdep.est.frequency.available
+.It Ic machdep.cpu.frequency.available
 The frequencies recognized by
 .Nm .
 .El
diff -r 823265519881 -r a0b029899799 share/man/man4/man4.x86/powernow.4
--- a/share/man/man4/man4.x86/powernow.4        Sun Oct 25 16:18:02 2020 +0000
+++ b/share/man/man4/man4.x86/powernow.4        Sun Oct 25 16:39:00 2020 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: powernow.4,v 1.3 2017/02/17 22:10:47 christos Exp $
+.\" $NetBSD: powernow.4,v 1.4 2020/10/25 16:39:00 nia Exp $
 .\"
 .\" Copyright (c) 2011 Jukka Ruohonen <jruohonen%iki.fi@localhost>
 .\" All rights reserved.
@@ -24,7 +24,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd February 17, 2017
+.Dd September 7, 2020
 .Dt POWERNOW 4
 .Os
 .Sh NAME
@@ -46,13 +46,13 @@
 .Xr sysctl 8
 variables are available with
 .Nm :
-.Bl -tag -width "machdep.powernow.frequency.available" -offset 2n
-.It Ic machdep.powernow.frequency.target
+.Bl -tag -width "machdep.cpu.frequency.available" -offset 2n
+.It Ic machdep.cpu.frequency.target
 The target frequency of the
 .Tn CPUs .
-.It Ic machdep.powernow.frequency.current
+.It Ic machdep.cpu.frequency.current
 The current frequency.
-.It Ic machdep.powernow.frequency.available
+.It Ic machdep.cpu.frequency.available
 The available frequencies.
 .El
 .Pp
diff -r 823265519881 -r a0b029899799 sys/arch/evbmips/loongson/loongson_clock.c
--- a/sys/arch/evbmips/loongson/loongson_clock.c        Sun Oct 25 16:18:02 2020 +0000
+++ b/sys/arch/evbmips/loongson/loongson_clock.c        Sun Oct 25 16:39:00 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: loongson_clock.c,v 1.2 2020/05/29 12:30:40 rin Exp $   */
+/*     $NetBSD: loongson_clock.c,v 1.3 2020/10/25 16:39:00 nia Exp $   */
 
 /*
  * Copyright (c) 2011, 2016 Michael Lorenz
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: loongson_clock.c,v 1.2 2020/05/29 12:30:40 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: loongson_clock.c,v 1.3 2020/10/25 16:39:00 nia Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -110,9 +110,9 @@
        /* now setup sysctl */
        if (sysctl_createv(NULL, 0, NULL, 
            &me, 
-           CTLFLAG_READWRITE, CTLTYPE_NODE, "loongson", NULL, NULL,
+           CTLFLAG_READWRITE, CTLTYPE_NODE, "cpu", NULL, NULL,
            0, NULL, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL) != 0)
-               aprint_error("couldn't create 'loongson' node\n");
+               aprint_error("couldn't create 'cpu' node\n");
 
        if (sysctl_createv(NULL, 0, NULL, 
            &freq, 
diff -r 823265519881 -r a0b029899799 sys/arch/macppc/dev/obio.c
--- a/sys/arch/macppc/dev/obio.c        Sun Oct 25 16:18:02 2020 +0000
+++ b/sys/arch/macppc/dev/obio.c        Sun Oct 25 16:39:00 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: obio.c,v 1.46 2018/06/08 23:39:31 macallan Exp $       */
+/*     $NetBSD: obio.c,v 1.47 2020/10/25 16:39:00 nia Exp $    */
 
 /*-
  * Copyright (C) 1998  Internet Research Institute, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: obio.c,v 1.46 2018/06/08 23:39:31 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: obio.c,v 1.47 2020/10/25 16:39:00 nia Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -431,9 +431,9 @@
 
        if (sysctl_createv(NULL, 0, NULL, 
            &me, 
-           CTLFLAG_READWRITE, CTLTYPE_NODE, "intrepid", NULL, NULL,
+           CTLFLAG_READWRITE, CTLTYPE_NODE, "cpu", NULL, NULL,
            0, NULL, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL) != 0)
-               printf("couldn't create 'intrepid' node\n");
+               printf("couldn't create 'cpu' node\n");
        
        if (sysctl_createv(NULL, 0, NULL, 
            &freq, 
diff -r 823265519881 -r a0b029899799 sys/arch/x86/acpi/acpi_cpu_md.c
--- a/sys/arch/x86/acpi/acpi_cpu_md.c   Sun Oct 25 16:18:02 2020 +0000
+++ b/sys/arch/x86/acpi/acpi_cpu_md.c   Sun Oct 25 16:39:00 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu_md.c,v 1.83 2020/03/19 19:55:34 ad Exp $ */
+/* $NetBSD: acpi_cpu_md.c,v 1.84 2020/10/25 16:39:00 nia Exp $ */
 
 /*-
  * Copyright (c) 2010, 2011 Jukka Ruohonen <jruohonen%iki.fi@localhost>
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.83 2020/03/19 19:55:34 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.84 2020/10/25 16:39:00 nia Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -1003,25 +1003,8 @@
 acpicpu_md_pstate_sysctl_init(void)
 {
        const struct sysctlnode *fnode, *mnode, *rnode;
-       const char *str;
        int rv;
 
-       switch (cpu_vendor) {
-
-       case CPUVENDOR_IDT:
-       case CPUVENDOR_INTEL:
-               str = "est";
-               break;
-
-       case CPUVENDOR_AMD:
-               str = "powernow";
-               break;
-
-       default:
-               return ENODEV;
-       }
-
-
        rv = sysctl_createv(&acpicpu_log, 0, NULL, &rnode,
            CTLFLAG_PERMANENT, CTLTYPE_NODE, "machdep", NULL,
            NULL, 0, NULL, 0, CTL_MACHDEP, CTL_EOL);
@@ -1030,7 +1013,7 @@
                goto fail;
 
        rv = sysctl_createv(&acpicpu_log, 0, &rnode, &mnode,
-           0, CTLTYPE_NODE, str, NULL,
+           0, CTLTYPE_NODE, "cpu", NULL,
            NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL);
 
        if (rv != 0)
diff -r 823265519881 -r a0b029899799 sys/arch/x86/x86/est.c
--- a/sys/arch/x86/x86/est.c    Sun Oct 25 16:18:02 2020 +0000
+++ b/sys/arch/x86/x86/est.c    Sun Oct 25 16:39:00 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: est.c,v 1.31 2017/06/01 02:45:08 chs Exp $     */
+/*     $NetBSD: est.c,v 1.32 2020/10/25 16:39:00 nia Exp $     */
 /*
  * Copyright (c) 2003 Michael Eriksson.
  * All rights reserved.
@@ -76,7 +76,7 @@
  *   http://www.codemonkey.org.uk/projects/cpufreq/cpufreq-2.4.22-pre6-1.gz
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: est.c,v 1.31 2017/06/01 02:45:08 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: est.c,v 1.32 2020/10/25 16:39:00 nia Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -1296,11 +1296,11 @@
 est_sysctl(device_t self)
 {
        struct est_softc *sc = device_private(self);
-       const struct sysctlnode *node, *estnode, *freqnode;
+       const struct sysctlnode *node, *cpunode, *freqnode;
        int rv;
 
        /*
-        * Setup the sysctl sub-tree machdep.est.*
+        * Setup the sysctl sub-tree machdep.cpu.*
         */
        rv = sysctl_createv(&sc->sc_log, 0, NULL, &node,
            CTLFLAG_PERMANENT, CTLTYPE_NODE, "machdep", NULL,
@@ -1309,14 +1309,14 @@
        if (rv != 0)
                goto fail;
 
-       rv = sysctl_createv(&sc->sc_log, 0, &node, &estnode,
-           0, CTLTYPE_NODE, "est", NULL,
+       rv = sysctl_createv(&sc->sc_log, 0, &node, &cpunode,
+           0, CTLTYPE_NODE, "cpu", NULL,
            NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL);
 
        if (rv != 0)
                goto fail;
 
-       rv = sysctl_createv(&sc->sc_log, 0, &estnode, &freqnode,
+       rv = sysctl_createv(&sc->sc_log, 0, &cpunode, &freqnode,
            0, CTLTYPE_NODE, "frequency", NULL,
            NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL);
 
diff -r 823265519881 -r a0b029899799 sys/arch/x86/x86/powernow.c
--- a/sys/arch/x86/x86/powernow.c       Sun Oct 25 16:18:02 2020 +0000
+++ b/sys/arch/x86/x86/powernow.c       Sun Oct 25 16:39:00 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: powernow.c,v 1.10 2017/06/01 02:45:08 chs Exp $ */
+/*     $NetBSD: powernow.c,v 1.11 2020/10/25 16:39:00 nia Exp $ */
 /*     $OpenBSD: powernow-k8.c,v 1.8 2006/06/16 05:58:50 gwk Exp $ */
 
 /*-
@@ -57,7 +57,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: powernow.c,v 1.10 2017/06/01 02:45:08 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: powernow.c,v 1.11 2020/10/25 16:39:00 nia Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -249,7 +249,7 @@
 static int
 powernow_sysctl(device_t self)
 {
-       const struct sysctlnode *freqnode, *node, *pnownode;
+       const struct sysctlnode *freqnode, *node, *cpunode;
        struct powernow_softc *sc = device_private(self);
        int rv;
 
@@ -263,14 +263,14 @@
        if (rv != 0)
                goto fail;
 
-       rv = sysctl_createv(&sc->sc_log, 0, &node, &pnownode,
-           0, CTLTYPE_NODE, "powernow", NULL,
+       rv = sysctl_createv(&sc->sc_log, 0, &node, &cpunode,
+           0, CTLTYPE_NODE, "cpu", NULL,
            NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL);
 
        if (rv != 0)
                goto fail;
 
-       rv = sysctl_createv(&sc->sc_log, 0, &pnownode, &freqnode,
+       rv = sysctl_createv(&sc->sc_log, 0, &cpunode, &freqnode,
            0, CTLTYPE_NODE, "frequency", NULL,
            NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL);
 



Home | Main Index | Thread Index | Old Index