Skip to contentSkip to conversation

perf tools riscv: Add support for riscv lookup_binutils_path

PATCH Superseded paranlee 3 participants 5 messages Mar 11, 2023 – Mar 13, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

paranlee

author
#0 lore raw

PATCH 1/1 perf tools riscv: Add support for riscv lookup_binutils_path

Add to know RISC-V binutils path.
Secondarily, edit the code block with alphabetical order.

---
 tools/perf/arch/common.c | 51 +++++++++++++++++++++++++++-------------
 1 file changed, 35 insertions(+), 16 deletions(-)
tools/perf/arch/common.c +35 -16
index 59dd875fd5e4..058527ededdd 100644
@@ -29,11 +29,23 @@ const char *const arm_triplets[] = {
 };
 
 const char *const arm64_triplets[] = {
+	"aarch64-unknown-linux-",
 	"aarch64-linux-android-",
 	"aarch64-linux-gnu-",
 	NULL
 };
 
+const char *const mips_triplets[] = {
+	"mips-unknown-linux-gnu-",
+	"mipsel-linux-android-",
+	"mips-linux-gnu-",
+	"mips64-linux-gnu-",
+	"mips64el-linux-gnuabi64-",
+	"mips64-linux-gnuabi64-",
+	"mipsel-linux-gnu-",
+	NULL
+};
+
 const char *const powerpc_triplets[] = {
 	"powerpc-unknown-linux-gnu-",
 	"powerpc-linux-gnu-",
@@ -43,6 +55,20 @@ const char *const powerpc_triplets[] = {
 	NULL
 };
 
+const char *const riscv32_triplets[] = {
+	"riscv32-unknown-linux-gnu-",
+	"riscv32-linux-android-",
+	"riscv32-linux-gnu-",
+	NULL
+};
+
+const char *const riscv64_triplets[] = {
+	"riscv64-unknown-linux-gnu-",
+	"riscv64-linux-android-",
+	"riscv64-linux-gnu-",
+	NULL
+};
+
 const char *const s390_triplets[] = {
 	"s390-ibm-linux-",
 	"s390x-linux-gnu-",
@@ -78,17 +104,6 @@ const char *const x86_triplets[] = {
 	NULL
 };
 
-const char *const mips_triplets[] = {
-	"mips-unknown-linux-gnu-",
-	"mipsel-linux-android-",
-	"mips-linux-gnu-",
-	"mips64-linux-gnu-",
-	"mips64el-linux-gnuabi64-",
-	"mips64-linux-gnuabi64-",
-	"mipsel-linux-gnu-",
-	NULL
-};
-
 static bool lookup_path(char *name)
 {
 	bool found = false;
@@ -164,18 +179,22 @@ static int perf_env__lookup_binutils_path(struct perf_env *env,
 		path_list = arm_triplets;
 	else if (!strcmp(arch, "arm64"))
 		path_list = arm64_triplets;
+	else if (!strcmp(arch, "mips"))
+		path_list = mips_triplets;
 	else if (!strcmp(arch, "powerpc"))
 		path_list = powerpc_triplets;
-	else if (!strcmp(arch, "sh"))
-		path_list = sh_triplets;
+	else if (!strcmp(arch, "riscv32"))
+		path_list = riscv32_triplets;
+	else if (!strcmp(arch, "riscv64"))
+		path_list = riscv64_triplets;
 	else if (!strcmp(arch, "s390"))
-		path_list = s390_triplets;
+		path_list = s390_triplets;		
+	else if (!strcmp(arch, "sh"))
+		path_list = sh_triplets;		
 	else if (!strcmp(arch, "sparc"))
 		path_list = sparc_triplets;
 	else if (!strcmp(arch, "x86"))
 		path_list = x86_triplets;
-	else if (!strcmp(arch, "mips"))
-		path_list = mips_triplets;
 	else {
 		ui__error("binutils for %s not supported.\n", arch);
 		goto out_error;
Signature · 1 line
2.34.1
reviewer
#1 lore raw
Quoted 14 lines · paranlee

Add to know RISC-V binutils path.
Secondarily, edit the code block with alphabetical order.

---
 tools/perf/arch/common.c | 51 +++++++++++++++++++++++++++-------------
 1 file changed, 35 insertions(+), 16 deletions(-)
tools/perf/arch/common.c +0 -0
index 59dd875fd5e4..058527ededdd 100644

tools/perf/arch/common.c const char *const arm_triplets[] = { · line 32

Quoted 4 lines
tools/perf/arch/common.c +1 -0
@@ -29,11 +29,23 @@ const char *const arm_triplets[] = {
 };
 
 const char *const arm64_triplets[] = {
+       "aarch64-unknown-linux-",

Modifying ARM64 behavior should be a separate change.

Quoted 6 lines
tools/perf/arch/common.c +1 -0
        "aarch64-linux-android-",
        "aarch64-linux-gnu-",
        NULL
 };
 
+const char *const mips_triplets[] = {

tools/perf/arch/common.c const char *const arm_triplets[] = { · line 48

Quoted 10 lines
tools/perf/arch/common.c +10 -0
+       "mips-unknown-linux-gnu-",
+       "mipsel-linux-android-",
+       "mips-linux-gnu-",
+       "mips64-linux-gnu-",
+       "mips64el-linux-gnuabi64-",
+       "mips64-linux-gnuabi64-",
+       "mipsel-linux-gnu-",
+       NULL
+};
+

This will affect the blame history. It should probably be its own change too.

Quoted 49 lines
tools/perf/arch/common.c +16 -11
 const char *const powerpc_triplets[] = {
        "powerpc-unknown-linux-gnu-",
        "powerpc-linux-gnu-",
@@ -43,6 +55,20 @@ const char *const powerpc_triplets[] = {
        NULL
 };
 
+const char *const riscv32_triplets[] = {
+       "riscv32-unknown-linux-gnu-",
+       "riscv32-linux-android-",
+       "riscv32-linux-gnu-",
+       NULL
+};
+
+const char *const riscv64_triplets[] = {
+       "riscv64-unknown-linux-gnu-",
+       "riscv64-linux-android-",
+       "riscv64-linux-gnu-",
+       NULL
+};
+
 const char *const s390_triplets[] = {
        "s390-ibm-linux-",
        "s390x-linux-gnu-",
@@ -78,17 +104,6 @@ const char *const x86_triplets[] = {
        NULL
 };
 
-const char *const mips_triplets[] = {
-       "mips-unknown-linux-gnu-",
-       "mipsel-linux-android-",
-       "mips-linux-gnu-",
-       "mips64-linux-gnu-",
-       "mips64el-linux-gnuabi64-",
-       "mips64-linux-gnuabi64-",
-       "mipsel-linux-gnu-",
-       NULL
-};
-
 static bool lookup_path(char *name)
 {
        bool found = false;
@@ -164,18 +179,22 @@ static int perf_env__lookup_binutils_path(struct perf_env *env,
                path_list = arm_triplets;
        else if (!strcmp(arch, "arm64"))
                path_list = arm64_triplets;
+       else if (!strcmp(arch, "mips"))
+               path_list = mips_triplets;
        else if (!strcmp(arch, "powerpc"))

tools/perf/arch/common.c static int perf_env__lookup_binutils_path(struct perf_env *env, · line 191

Quoted 10 lines
tools/perf/arch/common.c +5 -3
                path_list = powerpc_triplets;
-       else if (!strcmp(arch, "sh"))
-               path_list = sh_triplets;
+       else if (!strcmp(arch, "riscv32"))
+               path_list = riscv32_triplets;
+       else if (!strcmp(arch, "riscv64"))
+               path_list = riscv64_triplets;
        else if (!strcmp(arch, "s390"))
-               path_list = s390_triplets;
+               path_list = s390_triplets;

whitespace issue?

tools/perf/arch/common.c static int perf_env__lookup_binutils_path(struct perf_env *env, · line 200

Quoted 11 lines
tools/perf/arch/common.c +2 -2
+       else if (!strcmp(arch, "sh"))
+               path_list = sh_triplets;
        else if (!strcmp(arch, "sparc"))
                path_list = sparc_triplets;
        else if (!strcmp(arch, "x86"))
                path_list = x86_triplets;
-       else if (!strcmp(arch, "mips"))
-               path_list = mips_triplets;
        else {
                ui__error("binutils for %s not supported.\n", arch);
                goto out_error;

I think in general we need to revamp this code. Two things that I see that are missing are (1) support for perf config and (2) addr2line should be configurable, you may want llvm-addr2line. Adding RISC-V is of course important too :-)

Thanks,
Ian

Quoted 3 lines

--
2.34.1

author
#2 lore raw

23. 3. 12. 15:27에 Ian Rogers 이(가) 쓴 글:

Quoted 27 lines · paranlee
Quoted 14 lines

Add to know RISC-V binutils path.
Secondarily, edit the code block with alphabetical order.

---
 tools/perf/arch/common.c | 51 +++++++++++++++++++++++++++-------------
 1 file changed, 35 insertions(+), 16 deletions(-)
tools/perf/arch/common.c +0 -0
index 59dd875fd5e4..058527ededdd 100644

tools/perf/arch/common.c const char *const arm_triplets[] = { · line 32

Quoted 4 lines
tools/perf/arch/common.c +1 -0
@@ -29,11 +29,23 @@ const char *const arm_triplets[] = {
 };
 
 const char *const arm64_triplets[] = {
+       "aarch64-unknown-linux-",

Modifying ARM64 behavior should be a separate change.

Quoted 5 lines
tools/perf/arch/common.c +0 -0
        "aarch64-linux-android-",
        "aarch64-linux-gnu-",
        NULL
 };
 
Quoted 13 lines

tools/perf/arch/common.c const char *const arm_triplets[] = { · line 48

Quoted 11 lines
tools/perf/arch/common.c +11 -0
+const char *const mips_triplets[] = {
+       "mips-unknown-linux-gnu-",
+       "mipsel-linux-android-",
+       "mips-linux-gnu-",
+       "mips64-linux-gnu-",
+       "mips64el-linux-gnuabi64-",
+       "mips64-linux-gnuabi64-",
+       "mipsel-linux-gnu-",
+       NULL
+};
+

This will affect the blame history. It should probably be its own change too.

Thank you for review! I agree. So I would split the patch.

Quoted 15 lines
Quoted 15 lines
tools/perf/arch/common.c +3 -3
-
 static bool lookup_path(char *name)
 {
        bool found = false;
@@ -164,18 +179,22 @@ static int perf_env__lookup_binutils_path(struct perf_env *env,
                path_list = arm_triplets;
        else if (!strcmp(arch, "arm64"))
                path_list = arm64_triplets;
+       else if (!strcmp(arch, "mips"))
+               path_list = mips_triplets;
        else if (!strcmp(arch, "powerpc"))
                path_list = powerpc_triplets;
-       else if (!strcmp(arch, "sh"))
-               path_list = sh_triplets;
+       else if (!strcmp(arch, "riscv32"))
Quoted 8 lines

tools/perf/arch/common.c static int perf_env__lookup_binutils_path(struct perf_env *env, · line 191

Quoted 6 lines
tools/perf/arch/common.c +4 -1
+               path_list = riscv32_triplets;
+       else if (!strcmp(arch, "riscv64"))
+               path_list = riscv64_triplets;
        else if (!strcmp(arch, "s390"))
-               path_list = s390_triplets;
+               path_list = s390_triplets;

whitespace issue?

I tried to correct the alphabetical order because it was vaguely sorted. And I'll try to work on blame history on each arch code block as well.

Quoted 12 lines

tools/perf/arch/common.c static int perf_env__lookup_binutils_path(struct perf_env *env, · line 200

Quoted 11 lines
tools/perf/arch/common.c +2 -2
+       else if (!strcmp(arch, "sh"))
+               path_list = sh_triplets;
        else if (!strcmp(arch, "sparc"))
                path_list = sparc_triplets;
        else if (!strcmp(arch, "x86"))
                path_list = x86_triplets;
-       else if (!strcmp(arch, "mips"))
-               path_list = mips_triplets;
        else {
                ui__error("binutils for %s not supported.\n", arch);
                goto out_error;
Quoted 7 lines

I think in general we need to revamp this code. Two things that I see that are missing are (1) support for perf config and (2) addr2line should be configurable, you may want llvm-addr2line. Adding RISC-V is of course important too :-)

Thanks,
Ian

May I ask documentation or hint that I can help work with?

P.S.

I'm interested in the Google Summer Of code perf category this year, especially the part about risc-v architecture, I recently purchased a development board and would like to be able to test perf on a Sifive U74 CPU based environment.
But I've only used perf with command tool and don't know much about the internals, so if there is a roadmap for perf development or contribution, I have interest in perf internals both kernel and user side. May I ask information to apply?
I am developing Linux Security Driver drivers for a security company.

BR
Paran Lee

reviewer
#3 lore raw
Quoted 108 lines · Paran Lee

23. 3. 12. 15:27에 Ian Rogers 이(가) 쓴 글:

Quoted 27 lines · paranlee
Quoted 14 lines

Add to know RISC-V binutils path.
Secondarily, edit the code block with alphabetical order.

---
 tools/perf/arch/common.c | 51 +++++++++++++++++++++++++++-------------
 1 file changed, 35 insertions(+), 16 deletions(-)
tools/perf/arch/common.c +0 -0
index 59dd875fd5e4..058527ededdd 100644

tools/perf/arch/common.c const char *const arm_triplets[] = { · line 32

Quoted 4 lines
tools/perf/arch/common.c +1 -0
@@ -29,11 +29,23 @@ const char *const arm_triplets[] = {
 };
 
 const char *const arm64_triplets[] = {
+       "aarch64-unknown-linux-",

Modifying ARM64 behavior should be a separate change.

Quoted 5 lines
tools/perf/arch/common.c +0 -0
        "aarch64-linux-android-",
        "aarch64-linux-gnu-",
        NULL
 };
 
Quoted 13 lines

tools/perf/arch/common.c const char *const arm_triplets[] = { · line 48

Quoted 11 lines
tools/perf/arch/common.c +11 -0
+const char *const mips_triplets[] = {
+       "mips-unknown-linux-gnu-",
+       "mipsel-linux-android-",
+       "mips-linux-gnu-",
+       "mips64-linux-gnu-",
+       "mips64el-linux-gnuabi64-",
+       "mips64-linux-gnuabi64-",
+       "mipsel-linux-gnu-",
+       NULL
+};
+

This will affect the blame history. It should probably be its own change too.

Thank you for review! I agree. So I would split the patch.

Quoted 15 lines
Quoted 15 lines
tools/perf/arch/common.c +3 -3
-
 static bool lookup_path(char *name)
 {
        bool found = false;
@@ -164,18 +179,22 @@ static int perf_env__lookup_binutils_path(struct perf_env *env,
                path_list = arm_triplets;
        else if (!strcmp(arch, "arm64"))
                path_list = arm64_triplets;
+       else if (!strcmp(arch, "mips"))
+               path_list = mips_triplets;
        else if (!strcmp(arch, "powerpc"))
                path_list = powerpc_triplets;
-       else if (!strcmp(arch, "sh"))
-               path_list = sh_triplets;
+       else if (!strcmp(arch, "riscv32"))
Quoted 8 lines

tools/perf/arch/common.c static int perf_env__lookup_binutils_path(struct perf_env *env, · line 191

Quoted 6 lines
tools/perf/arch/common.c +4 -1
+               path_list = riscv32_triplets;
+       else if (!strcmp(arch, "riscv64"))
+               path_list = riscv64_triplets;
        else if (!strcmp(arch, "s390"))
-               path_list = s390_triplets;
+               path_list = s390_triplets;

whitespace issue?

I tried to correct the alphabetical order because it was vaguely sorted. And I'll try to work on blame history on each arch code block as well.

Quoted 12 lines

tools/perf/arch/common.c static int perf_env__lookup_binutils_path(struct perf_env *env, · line 200

Quoted 11 lines
tools/perf/arch/common.c +2 -2
+       else if (!strcmp(arch, "sh"))
+               path_list = sh_triplets;
        else if (!strcmp(arch, "sparc"))
                path_list = sparc_triplets;
        else if (!strcmp(arch, "x86"))
                path_list = x86_triplets;
-       else if (!strcmp(arch, "mips"))
-               path_list = mips_triplets;
        else {
                ui__error("binutils for %s not supported.\n", arch);
                goto out_error;
Quoted 7 lines

I think in general we need to revamp this code. Two things that I see that are missing are (1) support for perf config and (2) addr2line should be configurable, you may want llvm-addr2line. Adding RISC-V is of course important too :-)

Thanks,
Ian

May I ask documentation or hint that I can help work with?

P.S.

I'm interested in the Google Summer Of code perf category this year, especially the part about risc-v architecture, I recently purchased a development board and would like to be able to test perf on a Sifive U74 CPU based environment.
But I've only used perf with command tool and don't know much about the internals, so if there is a roadmap for perf development or contribution, I have interest in perf internals both kernel and user side. May I ask information to apply?
I am developing Linux Security Driver drivers for a security company.

Quoted 2 lines

BR
Paran Lee

Hi Paran,

Thanks for being interested in GSoC with Linux perf. Here is what I posted on the mailing list:
https://lore.kernel.org/linux-perf-users/CAP-5=fWxF6in4vQyGuh=0kpAYEXAYZN_KobXCY=TX2oxssZ+HQ@mail.gmail.com/
Applications are ultimately sent to:
https://summerofcode.withgoogle.com/
and the entry requirements are there. I believe they are less strict than previously.

Wrt the patch, could you reply to Conor's response.

Thanks,
Ian