[v2,10/10] perf: tests: Adapt mmap-basic.c for riscv

Message ID 20230512085321.13259-11-alexghiti@rivosinc.com
State New
Headers
Series riscv: Allow userspace to directly access perf counters |

Commit Message

Alexandre Ghiti May 12, 2023, 8:53 a.m. UTC
  riscv now supports mmaping hardware counters to userspace so adapt the test
to run on this architecture.

Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
---
 tools/perf/tests/mmap-basic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Andrew Jones May 31, 2023, 3:15 p.m. UTC | #1
On Fri, May 12, 2023 at 10:53:21AM +0200, Alexandre Ghiti wrote:
> riscv now supports mmaping hardware counters to userspace so adapt the test
> to run on this architecture.
> 
> Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
> ---
>  tools/perf/tests/mmap-basic.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c
> index e68ca6229756..f5075ca774f8 100644
> --- a/tools/perf/tests/mmap-basic.c
> +++ b/tools/perf/tests/mmap-basic.c
> @@ -284,7 +284,7 @@ static struct test_case tests__basic_mmap[] = {
>  			 "permissions"),
>  	TEST_CASE_REASON("User space counter reading of instructions",
>  			 mmap_user_read_instr,
> -#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
> +#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || __riscv_xlen == 64
>  			 "permissions"
>  #else
>  			 "unsupported"
> @@ -292,7 +292,7 @@ static struct test_case tests__basic_mmap[] = {
>  		),
>  	TEST_CASE_REASON("User space counter reading of cycles",
>  			 mmap_user_read_cycles,
> -#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
> +#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || __riscv_xlen == 64
>  			 "permissions"
>  #else
>  			 "unsupported"
> -- 
> 2.37.2
>

Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
  
Arnaldo Carvalho de Melo June 5, 2023, 1:53 p.m. UTC | #2
Em Wed, May 31, 2023 at 05:15:15PM +0200, Andrew Jones escreveu:
> On Fri, May 12, 2023 at 10:53:21AM +0200, Alexandre Ghiti wrote:
> > riscv now supports mmaping hardware counters to userspace so adapt the test
> > to run on this architecture.
> > 
> > Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
> > ---
> >  tools/perf/tests/mmap-basic.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c
> > index e68ca6229756..f5075ca774f8 100644
> > --- a/tools/perf/tests/mmap-basic.c
> > +++ b/tools/perf/tests/mmap-basic.c
> > @@ -284,7 +284,7 @@ static struct test_case tests__basic_mmap[] = {
> >  			 "permissions"),
> >  	TEST_CASE_REASON("User space counter reading of instructions",
> >  			 mmap_user_read_instr,
> > -#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
> > +#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || __riscv_xlen == 64
> >  			 "permissions"
> >  #else
> >  			 "unsupported"
> > @@ -292,7 +292,7 @@ static struct test_case tests__basic_mmap[] = {
> >  		),
> >  	TEST_CASE_REASON("User space counter reading of cycles",
> >  			 mmap_user_read_cycles,
> > -#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
> > +#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || __riscv_xlen == 64
> >  			 "permissions"
> >  #else
> >  			 "unsupported"
> > -- 
> > 2.37.2
> >
> 
> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>

Was the kernel part merged upstream?

- Arnaldo
  
Alexandre Ghiti June 5, 2023, 2:02 p.m. UTC | #3
(sorry mail client switched to html on its own)

On Mon, Jun 5, 2023 at 3:53 PM Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
>
> Em Wed, May 31, 2023 at 05:15:15PM +0200, Andrew Jones escreveu:
> > On Fri, May 12, 2023 at 10:53:21AM +0200, Alexandre Ghiti wrote:
> > > riscv now supports mmaping hardware counters to userspace so adapt the test
> > > to run on this architecture.
> > >
> > > Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
> > > ---
> > >  tools/perf/tests/mmap-basic.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c
> > > index e68ca6229756..f5075ca774f8 100644
> > > --- a/tools/perf/tests/mmap-basic.c
> > > +++ b/tools/perf/tests/mmap-basic.c
> > > @@ -284,7 +284,7 @@ static struct test_case tests__basic_mmap[] = {
> > >                      "permissions"),
> > >     TEST_CASE_REASON("User space counter reading of instructions",
> > >                      mmap_user_read_instr,
> > > -#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
> > > +#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || __riscv_xlen == 64
> > >                      "permissions"
> > >  #else
> > >                      "unsupported"
> > > @@ -292,7 +292,7 @@ static struct test_case tests__basic_mmap[] = {
> > >             ),
> > >     TEST_CASE_REASON("User space counter reading of cycles",
> > >                      mmap_user_read_cycles,
> > > -#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
> > > +#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || __riscv_xlen == 64
> > >                      "permissions"
> > >  #else
> > >                      "unsupported"
> > > --
> > > 2.37.2
> > >
> >
> > Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
>
> Was the kernel part merged upstream?

No, I still haven't answered the reviews :)

>
> - Arnaldo
  
Arnaldo Carvalho de Melo June 5, 2023, 2:31 p.m. UTC | #4
Em Mon, Jun 05, 2023 at 04:00:12PM +0200, Alexandre Ghiti escreveu:
> On Mon, Jun 5, 2023 at 3:53 PM Arnaldo Carvalho de Melo <acme@kernel.org>
> wrote:
> 
> > Em Wed, May 31, 2023 at 05:15:15PM +0200, Andrew Jones escreveu:
> > > On Fri, May 12, 2023 at 10:53:21AM +0200, Alexandre Ghiti wrote:
> > > > riscv now supports mmaping hardware counters to userspace so adapt the
> > test
> > > > to run on this architecture.
> > > >
> > > > Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
> > > > ---
> > > >  tools/perf/tests/mmap-basic.c | 4 ++--
> > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/tools/perf/tests/mmap-basic.c
> > b/tools/perf/tests/mmap-basic.c
> > > > index e68ca6229756..f5075ca774f8 100644
> > > > --- a/tools/perf/tests/mmap-basic.c
> > > > +++ b/tools/perf/tests/mmap-basic.c
> > > > @@ -284,7 +284,7 @@ static struct test_case tests__basic_mmap[] = {
> > > >                      "permissions"),
> > > >     TEST_CASE_REASON("User space counter reading of instructions",
> > > >                      mmap_user_read_instr,
> > > > -#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
> > > > +#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
> > || __riscv_xlen == 64
> > > >                      "permissions"
> > > >  #else
> > > >                      "unsupported"
> > > > @@ -292,7 +292,7 @@ static struct test_case tests__basic_mmap[] = {
> > > >             ),
> > > >     TEST_CASE_REASON("User space counter reading of cycles",
> > > >                      mmap_user_read_cycles,
> > > > -#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
> > > > +#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
> > || __riscv_xlen == 64
> > > >                      "permissions"
> > > >  #else
> > > >                      "unsupported"
> > > > --
> > > > 2.37.2
> > > >
> > >
> > > Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
> >
> > Was the kernel part merged upstream?
> >
> 
> No, I still haven't answered the reviews :)

Ok, I'll then wait for it to happen to consider merging the userland
parts,

Thanks,

- Arnaldo
  
Alexandre Ghiti June 15, 2023, 10:02 a.m. UTC | #5
On 31/05/2023 17:15, Andrew Jones wrote:
> On Fri, May 12, 2023 at 10:53:21AM +0200, Alexandre Ghiti wrote:
>> riscv now supports mmaping hardware counters to userspace so adapt the test
>> to run on this architecture.
>>
>> Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
>> ---
>>   tools/perf/tests/mmap-basic.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c
>> index e68ca6229756..f5075ca774f8 100644
>> --- a/tools/perf/tests/mmap-basic.c
>> +++ b/tools/perf/tests/mmap-basic.c
>> @@ -284,7 +284,7 @@ static struct test_case tests__basic_mmap[] = {
>>   			 "permissions"),
>>   	TEST_CASE_REASON("User space counter reading of instructions",
>>   			 mmap_user_read_instr,
>> -#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
>> +#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || __riscv_xlen == 64
>>   			 "permissions"
>>   #else
>>   			 "unsupported"
>> @@ -292,7 +292,7 @@ static struct test_case tests__basic_mmap[] = {
>>   		),
>>   	TEST_CASE_REASON("User space counter reading of cycles",
>>   			 mmap_user_read_cycles,
>> -#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
>> +#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || __riscv_xlen == 64
>>   			 "permissions"
>>   #else
>>   			 "unsupported"
>> -- 
>> 2.37.2
>>
> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>


Thanks for your review Andrew, as usual, always helpful.

And sorry for the delay!

Alex


>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
  

Patch

diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c
index e68ca6229756..f5075ca774f8 100644
--- a/tools/perf/tests/mmap-basic.c
+++ b/tools/perf/tests/mmap-basic.c
@@ -284,7 +284,7 @@  static struct test_case tests__basic_mmap[] = {
 			 "permissions"),
 	TEST_CASE_REASON("User space counter reading of instructions",
 			 mmap_user_read_instr,
-#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
+#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || __riscv_xlen == 64
 			 "permissions"
 #else
 			 "unsupported"
@@ -292,7 +292,7 @@  static struct test_case tests__basic_mmap[] = {
 		),
 	TEST_CASE_REASON("User space counter reading of cycles",
 			 mmap_user_read_cycles,
-#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
+#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || __riscv_xlen == 64
 			 "permissions"
 #else
 			 "unsupported"