linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] RISC-V: Show CPU ID and Hart ID separately in /proc/cpuinfo
@ 2018-09-12 14:38 Anup Patel
  2018-09-12 16:47 ` Atish Patra
  2018-09-29  1:46 ` Palmer Dabbelt
  0 siblings, 2 replies; 8+ messages in thread
From: Anup Patel @ 2018-09-12 14:38 UTC (permalink / raw)
  To: Palmer Dabbelt, Albert Ou
  Cc: Atish Patra, Christoph Hellwig, linux-riscv, linux-kernel, Anup Patel

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

Signed-off-by: Anup Patel <anup@brainfault.org>
---
 arch/riscv/kernel/cpu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c
index f0f0ec2737b7..7c1342e242e6 100644
--- a/arch/riscv/kernel/cpu.c
+++ b/arch/riscv/kernel/cpu.c
@@ -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')
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] RISC-V: Show CPU ID and Hart ID separately in /proc/cpuinfo
  2018-09-12 14:38 [PATCH] RISC-V: Show CPU ID and Hart ID separately in /proc/cpuinfo Anup Patel
@ 2018-09-12 16:47 ` Atish Patra
  2018-09-13  3:39   ` Anup Patel
  2018-09-17 14:10   ` Christoph Hellwig
  2018-09-29  1:46 ` Palmer Dabbelt
  1 sibling, 2 replies; 8+ messages in thread
From: Atish Patra @ 2018-09-12 16:47 UTC (permalink / raw)
  To: Anup Patel, Palmer Dabbelt, Albert Ou
  Cc: Christoph Hellwig, linux-riscv, linux-kernel

On 9/12/18 7:38 AM, Anup Patel wrote:
> 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
> 
> Signed-off-by: Anup Patel <anup@brainfault.org>
> ---
>   arch/riscv/kernel/cpu.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c
> index f0f0ec2737b7..7c1342e242e6 100644
> --- a/arch/riscv/kernel/cpu.c
> +++ b/arch/riscv/kernel/cpu.c
> @@ -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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] RISC-V: Show CPU ID and Hart ID separately in /proc/cpuinfo
  2018-09-12 16:47 ` Atish Patra
@ 2018-09-13  3:39   ` Anup Patel
  2018-09-17 14:10   ` Christoph Hellwig
  1 sibling, 0 replies; 8+ messages in thread
From: Anup Patel @ 2018-09-13  3:39 UTC (permalink / raw)
  To: Atish Patra
  Cc: Palmer Dabbelt, Albert Ou, Christoph Hellwig, linux-riscv,
	linux-kernel@vger.kernel.org List

On Wed, Sep 12, 2018 at 10:17 PM Atish Patra <atish.patra@wdc.com> wrote:
>
> On 9/12/18 7:38 AM, Anup Patel wrote:
> > 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
> >
> > Signed-off-by: Anup Patel <anup@brainfault.org>
> > ---
> >   arch/riscv/kernel/cpu.c | 3 ++-
> >   1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c
> > index f0f0ec2737b7..7c1342e242e6 100644
> > --- a/arch/riscv/kernel/cpu.c
> > +++ b/arch/riscv/kernel/cpu.c
> > @@ -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 ?

Yes, we should certainly patch lscpu to parse CPU ID and
HART ID differently.

Regards,
Anup

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] RISC-V: Show CPU ID and Hart ID separately in /proc/cpuinfo
  2018-09-12 16:47 ` Atish Patra
  2018-09-13  3:39   ` Anup Patel
@ 2018-09-17 14:10   ` Christoph Hellwig
  2018-09-23 13:04     ` Anup Patel
  1 sibling, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2018-09-17 14:10 UTC (permalink / raw)
  To: Atish Patra
  Cc: Anup Patel, Palmer Dabbelt, Albert Ou, Christoph Hellwig,
	linux-riscv, linux-kernel

On Wed, Sep 12, 2018 at 09:47:55AM -0700, Atish Patra wrote:
> 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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] RISC-V: Show CPU ID and Hart ID separately in /proc/cpuinfo
  2018-09-17 14:10   ` Christoph Hellwig
@ 2018-09-23 13:04     ` Anup Patel
  0 siblings, 0 replies; 8+ messages in thread
From: Anup Patel @ 2018-09-23 13:04 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Atish Patra, Palmer Dabbelt, Albert Ou, linux-riscv,
	linux-kernel@vger.kernel.org List

On Mon, Sep 17, 2018 at 7:40 PM Christoph Hellwig <hch@infradead.org> wrote:
>
> On Wed, Sep 12, 2018 at 09:47:55AM -0700, Atish Patra wrote:
> > 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] RISC-V: Show CPU ID and Hart ID separately in /proc/cpuinfo
  2018-09-12 14:38 [PATCH] RISC-V: Show CPU ID and Hart ID separately in /proc/cpuinfo Anup Patel
  2018-09-12 16:47 ` Atish Patra
@ 2018-09-29  1:46 ` Palmer Dabbelt
  2018-09-29  6:12   ` Anup Patel
  1 sibling, 1 reply; 8+ messages in thread
From: Palmer Dabbelt @ 2018-09-29  1:46 UTC (permalink / raw)
  To: anup; +Cc: aou, atish.patra, Christoph Hellwig, linux-riscv, linux-kernel, anup

On Wed, 12 Sep 2018 07:38:22 PDT (-0700), anup@brainfault.org wrote:
> 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
>
> Signed-off-by: Anup Patel <anup@brainfault.org>
> ---
>  arch/riscv/kernel/cpu.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c
> index f0f0ec2737b7..7c1342e242e6 100644
> --- a/arch/riscv/kernel/cpu.c
> +++ b/arch/riscv/kernel/cpu.c
> @@ -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!

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] RISC-V: Show CPU ID and Hart ID separately in /proc/cpuinfo
  2018-09-29  1:46 ` Palmer Dabbelt
@ 2018-09-29  6:12   ` Anup Patel
  2018-10-01 16:42     ` Palmer Dabbelt
  0 siblings, 1 reply; 8+ messages in thread
From: Anup Patel @ 2018-09-29  6:12 UTC (permalink / raw)
  To: Palmer Dabbelt
  Cc: Albert Ou, Atish Patra, Christoph Hellwig, linux-riscv,
	linux-kernel@vger.kernel.org List

On Sat, Sep 29, 2018 at 7:16 AM Palmer Dabbelt <palmer@sifive.com> wrote:
>
> On Wed, 12 Sep 2018 07:38:22 PDT (-0700), anup@brainfault.org wrote:
> > 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
> >
> > Signed-off-by: Anup Patel <anup@brainfault.org>
> > ---
> >  arch/riscv/kernel/cpu.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c
> > index f0f0ec2737b7..7c1342e242e6 100644
> > --- a/arch/riscv/kernel/cpu.c
> > +++ b/arch/riscv/kernel/cpu.c
> > @@ -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.
>

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] RISC-V: Show CPU ID and Hart ID separately in /proc/cpuinfo
  2018-09-29  6:12   ` Anup Patel
@ 2018-10-01 16:42     ` Palmer Dabbelt
  0 siblings, 0 replies; 8+ messages in thread
From: Palmer Dabbelt @ 2018-10-01 16:42 UTC (permalink / raw)
  To: anup; +Cc: aou, atish.patra, Christoph Hellwig, linux-riscv, linux-kernel

On Fri, 28 Sep 2018 23:12:47 PDT (-0700), anup@brainfault.org wrote:
> On Sat, Sep 29, 2018 at 7:16 AM Palmer Dabbelt <palmer@sifive.com> wrote:
>>
>> On Wed, 12 Sep 2018 07:38:22 PDT (-0700), anup@brainfault.org wrote:
>> > 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
>> >
>> > Signed-off-by: Anup Patel <anup@brainfault.org>
>> > ---
>> >  arch/riscv/kernel/cpu.c | 3 ++-
>> >  1 file changed, 2 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c
>> > index f0f0ec2737b7..7c1342e242e6 100644
>> > --- a/arch/riscv/kernel/cpu.c
>> > +++ b/arch/riscv/kernel/cpu.c
>> > @@ -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.
>>
>
> 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!

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-10-01 16:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-12 14:38 [PATCH] RISC-V: Show CPU ID and Hart ID separately in /proc/cpuinfo Anup Patel
2018-09-12 16:47 ` Atish Patra
2018-09-13  3:39   ` Anup Patel
2018-09-17 14:10   ` Christoph Hellwig
2018-09-23 13:04     ` Anup Patel
2018-09-29  1:46 ` Palmer Dabbelt
2018-09-29  6:12   ` Anup Patel
2018-10-01 16:42     ` Palmer Dabbelt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).