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
This commit is contained in:
Mitchell Horne 2023-05-22 20:54:36 -03:00
parent 7245ffd10e
commit 940e6d36de

View file

@ -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
}