Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/cpuctl/arch Modify output of CPUID Fn0000000a.



details:   https://anonhg.NetBSD.org/src/rev/5e78144652b7
branches:  trunk
changeset: 366792:5e78144652b7
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Wed Jun 15 16:28:01 2022 +0000

description:
Modify output of CPUID Fn0000000a.

old:
cpu0: Perfmon-eax 0x8300805<VERSION=0x5,GPCounter=0x8,GPBitwidth=0x30>
cpu0: Perfmon-eax 0x8300805<Vectorlen=0x8>
cpu0: Perfmon-edx 0x8604<FixedFunc=0x4,FFBitwidth=0x30,ANYTHREADDEPR>

new:
cpu0: Perfmon: Ver. 5
cpu0: Perfmon: General: bitwidth 48, 8 counters
cpu0: Perfmon: General: avail 0xff<CORECYCL,INST,REFCYCL,LLCREF,LLCMISS,BRINST>
cpu0: Perfmon: General: avail 0xff<BRMISPR,TOPDOWNSLOT>
cpu0: Perfmon: Fixed: bitwidth 48, 4 counters
cpu0: Perfmon: Fixed: avail 0xf<INST,CLK_CORETHREAD,CLK_REF_TSC,TOPDOWNSLOT>

diffstat:

 usr.sbin/cpuctl/arch/i386.c |  49 ++++++++++++++++++++++++++++++++++++++------
 1 files changed, 42 insertions(+), 7 deletions(-)

diffs (72 lines):

diff -r 26e7c99f7ba8 -r 5e78144652b7 usr.sbin/cpuctl/arch/i386.c
--- a/usr.sbin/cpuctl/arch/i386.c       Wed Jun 15 16:25:33 2022 +0000
+++ b/usr.sbin/cpuctl/arch/i386.c       Wed Jun 15 16:28:01 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i386.c,v 1.127 2022/01/29 08:20:45 msaitoh Exp $       */
+/*     $NetBSD: i386.c,v 1.128 2022/06/15 16:28:01 msaitoh Exp $       */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: i386.c,v 1.127 2022/01/29 08:20:45 msaitoh Exp $");
+__RCSID("$NetBSD: i386.c,v 1.128 2022/06/15 16:28:01 msaitoh Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -2249,13 +2249,48 @@
                }
        } else if (cpu_vendor == CPUVENDOR_INTEL) {
                if (ci->ci_max_cpuid >= 0x0a) {
+                       unsigned int pmcver, ncounter, veclen;
+
                        x86_cpuid(0x0a, descs);
-                       print_bits(cpuname, "Perfmon-eax",
-                           CPUID_PERF_FLAGS0, descs[0]);
-                       print_bits(cpuname, "Perfmon-ebx",
+                       pmcver = __SHIFTOUT(descs[0], CPUID_PERF_VERSION);
+                       ncounter = __SHIFTOUT(descs[0], CPUID_PERF_NGPPC);
+                       veclen = __SHIFTOUT(descs[0], CPUID_PERF_BVECLEN);
+                       aprint_verbose("%s: Perfmon: Ver. %u",
+                           cpuname, pmcver);
+                       if (((pmcver >= 3) && (pmcver <= 4)) ||
+                           ((pmcver >= 5) &&
+                               (descs[3] & CPUID_PERF_ANYTHREADDEPR) == 0))
+                               aprint_verbose(" <ANYTHREAD>\n");
+                       else
+                               aprint_verbose("\n");
+                   
+                       aprint_verbose("%s: Perfmon: General: "
+                           "bitwidth %u, %u counters\n", cpuname,
+                           (uint32_t)__SHIFTOUT(descs[0], CPUID_PERF_NBWGPPC),
+                           ncounter);
+                       /* Invert logic for the output */
+                       descs[1] ^= __BITS(veclen - 1, 0);
+                       /*
+                        * Mask unrelated bits. An hypervisor reduces the
+                        * vector and set bit(s) out of the vector.
+                        */
+                       descs[1] &= __BITS(veclen - 1, 0);
+                       print_bits(cpuname, "Perfmon: General: avail",
                            CPUID_PERF_FLAGS1, descs[1]);
-                       print_bits(cpuname, "Perfmon-edx",
-                           CPUID_PERF_FLAGS3, descs[3]);
+
+                       if (pmcver >= 2) {
+                               ncounter = __SHIFTOUT(descs[3],
+                                   CPUID_PERF_NFFPC);
+                               aprint_verbose("%s: Perfmon: Fixed: "
+                                   "bitwidth %u, %u counters\n", cpuname,
+                                   (uint32_t)__SHIFTOUT(descs[3],
+                                       CPUID_PERF_NBWFFPC),
+                                   ncounter);
+                               if (pmcver <= 4)
+                                       descs[2] = __BITS(ncounter - 1, 0);
+                               print_bits(cpuname, "Perfmon: Fixed: avail",
+                                   CPUID_PERF_FLAGS2, descs[2]);
+                       }
                }
                if (ci->ci_max_cpuid >= 0x1a) {
                        x86_cpuid(0x1a, descs);



Home | Main Index | Thread Index | Old Index