]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lscpu: cure empty output of lscpu -b/-p
authorJan Engelhardt <jengelh@inai.de>
Thu, 18 Jan 2024 00:50:01 +0000 (00:50 +0000)
committerKarel Zak <kzak@redhat.com>
Tue, 23 Jan 2024 10:18:31 +0000 (11:18 +0100)
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 <jengelh@inai.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/lscpu-cputype.c
tests/expected/lscpu/lscpu-rv64-linux

index e18e49867d57cbf6e17cb6075ed6b9900a32201d..bcdf06e8db06dbcb14dfae5ef75d0a5015868fb3 100644 (file)
@@ -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 */
 };
index 22767db75aab05f139e1b075367b2e9df6a5aabb..d741cae22fd2776095ea95598d93b784672d9177 100644 (file)
@@ -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