lscpu: RISC-V: Print ISA information in summary
Subsystems (3)
PATCH v2 1/1 lscpu: RISC-V: Print ISA information in summary
The ISA information for RISC-V is important for understanding the different extensions supported by the CPU. Print the ISA information in the summary, with the Base ISA and single-letter extensions at the beginning, followed by multi-letter extensions sorted in alphabetical order. The information is the same as the cpuinfo information, except that underscores are replaced by spaces and multi-letter extensions are simply sorted instead of following any ISA string ordering rule.
The sample output below shows the difference between cpuinfo and lscpu.
cpuinfo output:
isa : rv64imafdch_zicbom_zicboz_zicntr_zicsr_zifencei_zihintntl_zihintpause_zihpm_zawrs_zfa_zba_zbb_zbc_zbs_smaia_ssaia_sstc
lscpu output:
ISA: rv64imafdch smaia ssaia sstc zawrs zba zbb zbc zbs zfa zicbom zicboz zicntr zicsr zifencei zihintntl zihintpause zihpm
---
Changes in v2:
1) Format the ISA string instead of simply printing the same from cpuinfo. (Feedback from Andrew Jones).
--- sys-utils/Makemodule.am | 1 + sys-utils/lscpu-cputype.c | 1 + sys-utils/lscpu-riscv.c | 57 +++++++++++++++++++++++++++++++++++++++ sys-utils/lscpu.c | 5 ++++ sys-utils/lscpu.h | 2 ++ sys-utils/meson.build | 1 + 6 files changed, 67 insertions(+) create mode 100644 sys-utils/lscpu-riscv.c
sys-utils/Makemodule.am +1 -0
@@ -461,6 +461,7 @@ lscpu_SOURCES = sys-utils/lscpu.c \ sys-utils/lscpu-virt.c \ sys-utils/lscpu-arm.c \ sys-utils/lscpu-dmi.c \ + sys-utils/lscpu-riscv.c \ sys-utils/lscpu.h lscpu_LDADD = $(LDADD) libcommon.la libsmartcols.la $(RTAS_LIBS) lscpu_CFLAGS = $(AM_CFLAGS) -I$(ul_libsmartcols_incdir)
sys-utils/lscpu-cputype.c +1 -0
@@ -233,6 +233,7 @@ 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 ("isa" ,PAT_ISA , isa),/* riscv */ 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 */
sys-utils/lscpu-riscv.c new file +57 -0
57 lines not on this page · raw message
sys-utils/lscpu.c +5 -0
@@ -954,6 +954,11 @@ print_summary_cputype(struct lscpu_cxt *cxt,if (ct->flags)add_summary_s (tb, sec,_ ("Flags:" ), ct->flags); + +if (ct->isa &&is_riscv (ct)) { +lscpu_format_isa_riscv (ct); +add_summary_s (tb, sec,_ ("ISA:" ), ct->isa); + } }/*
sys-utils/lscpu.h +2 -0
@@ -278,6 +278,7 @@ struct lscpu_cxt { CPU_ISSET_S((_cpu)->logical_id, (_cxt)->setsize, (_cxt)->present))int is_arm (struct lscpu_cxt *cxt); +bool is_riscv (struct lscpu_cputype *ct);struct lscpu_cputype *lscpu_new_cputype (void );void lscpu_ref_cputype (struct lscpu_cputype *ct);
@@ -320,6 +321,7 @@ int lscpu_create_cpus(struct lscpu_cxt *cxt, cpu_set_t *cpuset, size_t setsize);struct lscpu_cpu *lscpu_cpus_loopup_by_type (struct lscpu_cxt *cxt,struct lscpu_cputype *ct);void lscpu_decode_arm (struct lscpu_cxt *cxt); +void lscpu_format_isa_riscv (struct lscpu_cputype *ct);int lookup (char *line,char *pattern,char **value);
sys-utils/meson.build +1 -0
@@ -184,6 +184,7 @@ lscpu_sources = files( 'lscpu-virt.c', 'lscpu-arm.c', 'lscpu-dmi.c', + 'lscpu-riscv.c', ) lscpu_manadocs = files('lscpu.1.adoc')
Signature · 1 line
2.43.0
Quoted 21 lines · Sunil V L
The ISA information for RISC-V is important for understanding the different extensions supported by the CPU. Print the ISA information in the summary, with the Base ISA and single-letter extensions at the beginning, followed by multi-letter extensions sorted in alphabetical order. The information is the same as the cpuinfo information, except that underscores are replaced by spaces and multi-letter extensions are simply sorted instead of following any ISA string ordering rule.
The sample output below shows the difference between cpuinfo and lscpu.
cpuinfo output:
isa :rv64imafdch_zicbom_zicboz_zicntr_zicsr_zifencei_zihintntl_zihintpause_zihpm_zawrs_zfa_zba_zbb_zbc_zbs_smaia_ssaia_sstclscpu output:
ISA: rv64imafdch smaia ssaia sstc zawrs zba zbb zbc zbs zfa zicbom zicboz zicntr zicsr zifencei zihintntl zihintpause zihpmSigned-off-by Sunil V L <[email protected]>---
Changes in v2:
1) Format the ISA string instead of simply printing the same from cpuinfo. (Feedback from Andrew Jones).
Quoted 10 lines
--- sys-utils/Makemodule.am | 1 + sys-utils/lscpu-cputype.c | 1 + sys-utils/lscpu-riscv.c | 57 +++++++++++++++++++++++++++++++++++++++ sys-utils/lscpu.c | 5 ++++ sys-utils/lscpu.h | 2 ++ sys-utils/meson.build | 1 + 6 files changed, 67 insertions(+) create mode 100644 sys-utils/lscpu-riscv.c
Karel Zak
maintainerQuoted 8 lines · Sunil V L
sys-utils/Makemodule.am | 1 + sys-utils/lscpu-cputype.c | 1 + sys-utils/lscpu-riscv.c | 57 +++++++++++++++++++++++++++++++++++++++ sys-utils/lscpu.c | 5 ++++ sys-utils/lscpu.h | 2 ++ sys-utils/meson.build | 1 + 6 files changed, 67 insertions(+) create mode 100644 sys-utils/lscpu-riscv.c
Thank you, it looks good. I have created a PR from this patch to test it with our tests: https://github.com/util-linux/util-linux/pull/3465
I have also updated the tests/expected/lscpu/lscpu-rv64-* files:
https://github.com/util-linux/util-linux/pull/3465/commits/659dcaa76fae256de9323b00d40cd6b0df61ff6d
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Quoted 8 lines · Sunil V L
sys-utils/Makemodule.am | 1 + sys-utils/lscpu-cputype.c | 1 + sys-utils/lscpu-riscv.c | 57 +++++++++++++++++++++++++++++++++++++++ sys-utils/lscpu.c | 5 ++++ sys-utils/lscpu.h | 2 ++ sys-utils/meson.build | 1 + 6 files changed, 67 insertions(+) create mode 100644 sys-utils/lscpu-riscv.c
Applied, thanks.
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com