[PATCH 1/2] perf tools riscv: Allow get_cpuid return empty MARCH and MIMP

Nikita Shubin nikita.shubin at maquefel.me
Tue May 16 03:28:50 PDT 2023


Hello Inochi Amaoto!

On Tue, 2023-05-16 at 10:37 +0800, Inochi Amaoto wrote:
> The T-HEAD C9xx series CPU only has MVENDOR defined, and left MARCH
> and MIMP unimplemented.

According to the docs you can still read them, but it's hardwired to
64h0.

How it's supposed to distinguish c906 and c910 for example ?

> 
> To make perf support T-HEAD C9xx events. remove the restriction of
> the MARCH and MIMP.
> 
> Signed-off-by: Inochi Amaoto <inochiama at outlook.com>
> ---
>  tools/perf/arch/riscv/util/header.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/tools/perf/arch/riscv/util/header.c
> b/tools/perf/arch/riscv/util/header.c
> index 4a41856938a8..031899c627f6 100644
> --- a/tools/perf/arch/riscv/util/header.c
> +++ b/tools/perf/arch/riscv/util/header.c
> @@ -55,18 +55,13 @@ static char *_get_cpuid(void)
>                                 goto free;
>                 } else if (!strncmp(line, CPUINFO_MARCH,
> strlen(CPUINFO_MARCH))) {
>                         marchid = _get_field(line);
> -                       if (!marchid)
> -                               goto free;
>                 } else if (!strncmp(line, CPUINFO_MIMP,
> strlen(CPUINFO_MIMP))) {
>                         mimpid = _get_field(line);
> -                       if (!mimpid)
> -                               goto free;
> -
>                         break;
>                 }
>         }

What does /proc/cpuinfo shows on c9xx ? Why can't we use zeroes ?

>  
> -       if (!mvendorid || !marchid || !mimpid)
> +       if (!mvendorid)
>                 goto free;
>  
>         if (asprintf(&cpuid, "%s-%s-%s", mvendorid, marchid, mimpid)
> < 0)



More information about the linux-riscv mailing list