Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 May 2023 13:23:24 GMT
From:      Mitchell Horne <mhorne@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 940e6d36de1e - main - riscv: Print less CPU info
Message-ID:  <202305231323.34NDNO5n016587@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=940e6d36de1ef010f731e290c9b2b08535fff424

commit 940e6d36de1ef010f731e290c9b2b08535fff424
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2023-05-22 23:54:36 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2023-05-23 13:19:46 +0000

    riscv: Print less CPU info
    
    Change the reporting strategy to more closely follow what arm64
    implements:
     - Always print the one-line CPU summary when a core comes online
     - Only print the additional fields (e.g. ISA) when they differ from the
       CPU before it
    
    In the common case of identical CPUs this results in informative but
    non-repetitive output. For example, in QEMU:
    
      CPU 0  : Vendor=Unspecified Core=Unknown (Hart 0)
        marchid=0x80032, mimpid=0x80032
        MMU: 0x7<Sv39,Sv48,Sv57>
        ISA: 0x112d<Atomic,Compressed,Double,Float,Mult/Div>
      real memory  = 8589934592 (8192 MB)
      avail memory = 8332300288 (7946 MB)
      FreeBSD/SMP: Multiprocessor System Detected: 6 CPUs
      CPU 1  : Vendor=Unspecified Core=Unknown (Hart 1)
      CPU 2  : Vendor=Unspecified Core=Unknown (Hart 2)
      CPU 3  : Vendor=Unspecified Core=Unknown (Hart 3)
    
    Reviewed by:    markj
    MFC after:      2 weeks
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D40024
---
 sys/riscv/riscv/identcpu.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/sys/riscv/riscv/identcpu.c b/sys/riscv/riscv/identcpu.c
index 01e9fe9b4669..b68cc5c78352 100644
--- a/sys/riscv/riscv/identcpu.c
+++ b/sys/riscv/riscv/identcpu.c
@@ -447,18 +447,30 @@ printcpuinfo(u_int cpu)
 	KASSERT(desc->isa_extensions != 0,
 	    ("Empty extension set for CPU %u, did parsing fail?", cpu));
 
-	/* Print details for boot CPU or if we want verbose output */
-	if (cpu == 0 || bootverbose) {
-		/* Summary line. */
-		printf("CPU %-3u: Vendor=%s Core=%s (Hart %u)\n", cpu,
-		    desc->cpu_mvendor_name, desc->cpu_march_name, hart);
+	/*
+	 * Suppress the output of some fields in the common case of identical
+	 * CPU features.
+	 */
+#define	SHOULD_PRINT(_field)	\
+    (cpu == 0 || desc[0]._field != desc[-1]._field)
 
+	/* Always print summary line. */
+	printf("CPU %-3u: Vendor=%s Core=%s (Hart %u)\n", cpu,
+	    desc->cpu_mvendor_name, desc->cpu_march_name, hart);
+
+	/* These values are global. */
+	if (cpu == 0)
 		printf("  marchid=%#lx, mimpid=%#lx\n", marchid, mimpid);
+
+	if (SHOULD_PRINT(mmu_caps)) {
 		printf("  MMU: %#b\n", desc->mmu_caps,
 		    "\020"
 		    "\01Sv39"
 		    "\02Sv48"
 		    "\03Sv57");
+	}
+
+	if (SHOULD_PRINT(isa_extensions)) {
 		printf("  ISA: %#b\n", desc->isa_extensions,
 		    "\020"
 		    "\01Atomic"
@@ -467,4 +479,6 @@ printcpuinfo(u_int cpu)
 		    "\06Float"
 		    "\15Mult/Div");
 	}
+
+#undef SHOULD_PRINT
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202305231323.34NDNO5n016587>