From: Jan Engelhardt Date: Thu, 18 Jan 2024 00:50:01 +0000 (+0000) Subject: lscpu: cure empty output of lscpu -b/-p X-Git-Tag: v2.40-rc1~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd9c4cac3d7c7969c6ca7f063cef42e862ce98a7;p=thirdparty%2Futil-linux.git lscpu: cure empty output of lscpu -b/-p On riscv, /proc/cpuinfo looks like: processor : 3 hart : 4 isa : rv64imafdc_zicntr_zicsr_zifencei_zihpm_zba_zbb mmu : sv39 uarch : sifive,u74-mc mvendorid : 0x489 marchid : 0x8000000000000007 mimpid : 0x4210427 hart isa : rv64imafdc_zicntr_zicsr_zifencei_zihpm_zba_zbb As none of the cputype_patterns match any of the fields in that file, `cpu->type` is never set, which causes `get_cell_data` to always return nullptr. The output of `lscpu -b --extended=CPU` and `lscpu -p` is then empty. Resolve that. [kzak@redhat.com: - fix DEF_PAT_CPUTYPE()s order - refresh lscpu/lscpu-rv64-linux test] Signed-off-by: Jan Engelhardt Signed-off-by: Karel Zak --- diff --git a/sys-utils/lscpu-cputype.c b/sys-utils/lscpu-cputype.c index e18e49867d..bcdf06e8db 100644 --- a/sys-utils/lscpu-cputype.c +++ b/sys-utils/lscpu-cputype.c @@ -221,12 +221,16 @@ static const struct cpuinfo_pattern type_patterns[] = DEF_PAT_CPUTYPE( "family", PAT_FAMILY, family), DEF_PAT_CPUTYPE( "features", PAT_FEATURES, flags), /* s390 */ DEF_PAT_CPUTYPE( "flags", PAT_FLAGS, flags), /* x86 */ + DEF_PAT_CPUTYPE( "marchid", PAT_FAMILY, family), /* riscv */ DEF_PAT_CPUTYPE( "max thread id", PAT_MAX_THREAD_ID, mtid), /* s390 */ + DEF_PAT_CPUTYPE( "mimpid", PAT_MODEL, model), /* riscv */ DEF_PAT_CPUTYPE( "model", PAT_MODEL, model), DEF_PAT_CPUTYPE( "model name", PAT_MODEL_NAME, modelname), + DEF_PAT_CPUTYPE( "mvendorid", PAT_VENDOR, vendor), /* riscv */ DEF_PAT_CPUTYPE( "revision", PAT_REVISION, revision), DEF_PAT_CPUTYPE( "stepping", PAT_STEPPING, stepping), DEF_PAT_CPUTYPE( "type", PAT_TYPE, flags), /* sparc64 */ + DEF_PAT_CPUTYPE( "uarch", PAT_MODEL_NAME, modelname), /* riscv */ DEF_PAT_CPUTYPE( "vendor", PAT_VENDOR, vendor), DEF_PAT_CPUTYPE( "vendor_id", PAT_VENDOR, vendor), /* s390 */ }; diff --git a/tests/expected/lscpu/lscpu-rv64-linux b/tests/expected/lscpu/lscpu-rv64-linux index 22767db75a..d741cae22f 100644 --- a/tests/expected/lscpu/lscpu-rv64-linux +++ b/tests/expected/lscpu/lscpu-rv64-linux @@ -1,16 +1,23 @@ CPU(s): 2 On-line CPU(s) list: 0,1 +Model name: sifive,u74-mc +Thread(s) per core: 2 +Core(s) per socket: 1 +Socket(s): 1 +L1d cache: 64 KiB (2 instances) +L1i cache: 64 KiB (2 instances) +L2 cache: 2 MiB (1 instance) # The following is the parsable format, which can be fed to other # programs. Each different item in every column has an unique ID # starting usually from zero. -# CPU,Core,Socket,Node -,,, -,,, +# CPU,Core,Socket,Node,,L1d,L1i,L2 +0,0,0,,,0,0,0 +1,0,0,,,1,1,0 # The following is the parsable format, which can be fed to other # programs. Each different item in every column has an unique ID # starting usually from zero. -# CPU,Core,Socket,Node -,,, -,,, +# CPU,Core,Socket,Node,,L1d,L1i,L2 +0,-,-,,,0,0,0 +1,-,-,,,1,1,0