RISC-V: Show CPU ID and Hart ID separately in /proc/cpuinfo
PATCH 1/1 RISC-V: Show CPU ID and Hart ID separately in /proc/cpuinfo
Currently, /proc/cpuinfo show logical CPU ID as Hart ID which is in-correct. This patch shows CPU ID and Hart ID separately in /proc/cpuinfo using cpuid_to_hardid_map().
With this patch, contents of /proc/cpuinfo looks as follows:
cpu : 0
hart : 1
isa : rv64imafdcsu
mmu : sv48
cpu : 1
hart : 0
isa : rv64imafdcsu
mmu : sv48
cpu : 2
hart : 3
isa : rv64imafdcsu
mmu : sv48
cpu : 3
hart : 2
isa : rv64imafdcsu
mmu : sv48
--- arch/riscv/kernel/cpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/riscv/kernel/cpu.c +2 -1
@@ -87,7 +87,8 @@ static int c_show(struct seq_file *m, void *v) NULL);const char *compat, *isa, *mmu; -seq_printf (m,"hart\t: %lu\n" , cpu_id); +seq_printf (m,"cpu\t: %lu\n" , cpu_id); +seq_printf (m,"hart\t: %lu\n" ,cpuid_to_hardid_map (cpu_id));if (!of_property_read_string (node,"riscv,isa" , &isa) && isa[0 ] =='r' && isa[1 ] =='v' )
Signature · 1 line
2.17.1
Quoted 36 lines · Anup Patel
Currently,
/proc/cpuinfoshow logical CPU ID as Hart ID which is in-correct. This patch shows CPU ID and Hart ID separately in/proc/cpuinfousingcpuid_to_hardid_map().With this patch, contents of
/proc/cpuinfolooks as follows:
cpu : 0
hart : 1
isa : rv64imafdcsu
mmu : sv48cpu : 1
hart : 0
isa : rv64imafdcsu
mmu : sv48cpu : 2
hart : 3
isa : rv64imafdcsu
mmu : sv48cpu : 3
hart : 2
isa : rv64imafdcsu
mmu : sv48Signed-off-by Anup Patel <[email protected]>--- arch/riscv/kernel/cpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/riscv/kernel/cpu.c +0
-0
arch/riscv/kernel/cpu.c static int c_show(struct seq_file *m, void *v) · line 94
Quoted 9 lines
arch/riscv/kernel/cpu.c +2
-1@@ -87,7 +87,8 @@ static int c_show(struct seq_file *m, void *v) NULL);const char *compat, *isa, *mmu; -seq_printf (m,"hart\t: %lu\n" , cpu_id); +seq_printf (m,"cpu\t: %lu\n" , cpu_id); +seq_printf (m,"hart\t: %lu\n" ,cpuid_to_hardid_map (cpu_id));if (!of_property_read_string (node,"riscv,isa" , &isa) && isa[0 ] =='r' && isa[1 ] =='v' )
The extra hart information will not be parsed by lscpu which will make the cpu information inconsistent between lscpu & /proc/cpuinfo.
Should we patch lscpu as well to show correct hart id as well ?
Regards,
Atish
Quoted 51 lines · Atish Patra
Quoted 36 lines · Anup Patel
Currently,
/proc/cpuinfoshow logical CPU ID as Hart ID which is in-correct. This patch shows CPU ID and Hart ID separately in/proc/cpuinfousingcpuid_to_hardid_map().With this patch, contents of
/proc/cpuinfolooks as follows:
cpu : 0
hart : 1
isa : rv64imafdcsu
mmu : sv48cpu : 1
hart : 0
isa : rv64imafdcsu
mmu : sv48cpu : 2
hart : 3
isa : rv64imafdcsu
mmu : sv48cpu : 3
hart : 2
isa : rv64imafdcsu
mmu : sv48Signed-off-by Anup Patel <[email protected]>--- arch/riscv/kernel/cpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/riscv/kernel/cpu.c +0
-0arch/riscv/kernel/cpu.c static int c_show(struct seq_file *m, void *v) · line 94
Quoted 9 lines
arch/riscv/kernel/cpu.c +2
-1@@ -87,7 +87,8 @@ static int c_show(struct seq_file *m, void *v) NULL);const char *compat, *isa, *mmu; -seq_printf (m,"hart\t: %lu\n" , cpu_id); +seq_printf (m,"cpu\t: %lu\n" , cpu_id); +seq_printf (m,"hart\t: %lu\n" ,cpuid_to_hardid_map (cpu_id));if (!of_property_read_string (node,"riscv,isa" , &isa) && isa[0 ] =='r' && isa[1 ] =='v' )The extra hart information will not be parsed by lscpu which will make the cpu information inconsistent between lscpu &
/proc/cpuinfo.
Quoted 1 line
Should we patch lscpu as well to show correct hart id as well ?
Yes, we should certainly patch lscpu to parse CPU ID and HART ID differently.
Regards,
Anup
Quoted 4 lines · Atish Patra
The extra hart information will not be parsed by lscpu which will make the cpu information inconsistent between lscpu &
/proc/cpuinfo.Should we patch lscpu as well to show correct hart id as well ?
It would be good to follow whatever prescedent other architectures with different logical vs physical cpuids have set.
Quoted 9 lines · Christoph Hellwig
Quoted 4 lines · Atish Patra
The extra hart information will not be parsed by lscpu which will make the cpu information inconsistent between lscpu &
/proc/cpuinfo.Should we patch lscpu as well to show correct hart id as well ?
It would be good to follow whatever prescedent other architectures with different logical vs physical cpuids have set.
Most architectures (x86, ARM, ARM64), display logical CPU id as "processor" attribute. I think we should use same name for logical CPU id.
Other attributes in /proc/cpuinfo are very different accros architectures. For e.g. x86 shows physical CPU id as "core id"
I will revise this patch to use "processor" attribute name for logical CPU id.
Regards,
Anup
Quoted 35 lines · anup at brainfault.org
Currently,
/proc/cpuinfoshow logical CPU ID as Hart ID which is in-correct. This patch shows CPU ID and Hart ID separately in/proc/cpuinfousingcpuid_to_hardid_map().With this patch, contents of
/proc/cpuinfolooks as follows:
cpu : 0
hart : 1
isa : rv64imafdcsu
mmu : sv48cpu : 1
hart : 0
isa : rv64imafdcsu
mmu : sv48cpu : 2
hart : 3
isa : rv64imafdcsu
mmu : sv48cpu : 3
hart : 2
isa : rv64imafdcsu
mmu : sv48Signed-off-by Anup Patel <[email protected]>--- arch/riscv/kernel/cpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/riscv/kernel/cpu.c +0
-0
arch/riscv/kernel/cpu.c static int c_show(struct seq_file *m, void *v) · line 94
Quoted 9 lines
arch/riscv/kernel/cpu.c +2
-1@@ -87,7 +87,8 @@ static int c_show(struct seq_file *m, void *v) NULL);const char *compat, *isa, *mmu; -seq_printf (m,"hart\t: %lu\n" , cpu_id); +seq_printf (m,"cpu\t: %lu\n" , cpu_id); +seq_printf (m,"hart\t: %lu\n" ,cpuid_to_hardid_map (cpu_id));if (!of_property_read_string (node,"riscv,isa" , &isa) && isa[0 ] =='r' && isa[1 ] =='v' )
I like this, but it doesn't appear to apply. Do you mind sending something against Linus' master? Then I should be able to sort it out.
Thanks!
Quoted 40 lines · Palmer Dabbelt
Quoted 38 lines · anup at brainfault.org
Currently,
/proc/cpuinfoshow logical CPU ID as Hart ID which is in-correct. This patch shows CPU ID and Hart ID separately in/proc/cpuinfousingcpuid_to_hardid_map().With this patch, contents of
/proc/cpuinfolooks as follows:
cpu : 0
hart : 1
isa : rv64imafdcsu
mmu : sv48cpu : 1
hart : 0
isa : rv64imafdcsu
mmu : sv48cpu : 2
hart : 3
isa : rv64imafdcsu
mmu : sv48cpu : 3
hart : 2
isa : rv64imafdcsu
mmu : sv48Signed-off-by Anup Patel <[email protected]>--- arch/riscv/kernel/cpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/riscv/kernel/cpu.c +0
-0@@ -87,7 +87,8 @@ static int c_show(struct seq_file *m, void *v) NULL);const char *compat, *isa, *mmu;
Quoted 10 lines
arch/riscv/kernel/cpu.c static int c_show(struct seq_file *m, void *v) · line 94
Quoted 6 lines
arch/riscv/kernel/cpu.c +2
-1-seq_printf (m,"hart\t: %lu\n" , cpu_id); +seq_printf (m,"cpu\t: %lu\n" , cpu_id); +seq_printf (m,"hart\t: %lu\n" ,cpuid_to_hardid_map (cpu_id));if (!of_property_read_string (node,"riscv,isa" , &isa) && isa[0 ] =='r' && isa[1 ] =='v' )I like this, but it doesn't appear to apply. Do you mind sending something against Linus' master? Then I should be able to sort it out.
This patch is requires cpuid_to_hardid_map() added by Atish's patchset so I have requested Atish to make this patch part of his v6 patchset.
Thanks,
Anup
Quoted 52 lines · anup at brainfault.org
Quoted 40 lines · Palmer Dabbelt
Quoted 38 lines · anup at brainfault.org
Currently,
/proc/cpuinfoshow logical CPU ID as Hart ID which is in-correct. This patch shows CPU ID and Hart ID separately in/proc/cpuinfousingcpuid_to_hardid_map().With this patch, contents of
/proc/cpuinfolooks as follows:
cpu : 0
hart : 1
isa : rv64imafdcsu
mmu : sv48cpu : 1
hart : 0
isa : rv64imafdcsu
mmu : sv48cpu : 2
hart : 3
isa : rv64imafdcsu
mmu : sv48cpu : 3
hart : 2
isa : rv64imafdcsu
mmu : sv48Signed-off-by Anup Patel <[email protected]>--- arch/riscv/kernel/cpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/riscv/kernel/cpu.c +0
-0@@ -87,7 +87,8 @@ static int c_show(struct seq_file *m, void *v) NULL);const char *compat, *isa, *mmu;Quoted 10 lines
arch/riscv/kernel/cpu.c static int c_show(struct seq_file *m, void *v) · line 94
Quoted 6 lines
arch/riscv/kernel/cpu.c +2
-1-seq_printf (m,"hart\t: %lu\n" , cpu_id); +seq_printf (m,"cpu\t: %lu\n" , cpu_id); +seq_printf (m,"hart\t: %lu\n" ,cpuid_to_hardid_map (cpu_id));if (!of_property_read_string (node,"riscv,isa" , &isa) && isa[0 ] =='r' && isa[1 ] =='v' )I like this, but it doesn't appear to apply. Do you mind sending something against Linus' master? Then I should be able to sort it out.
Quoted 3 lines
This patch is requires
cpuid_to_hardid_map()added by Atish's patchset so I have requested Atish to make this patch part of his v6 patchset.
Thanks!