Skip to contentSkip to conversation

perf test: Add option to change objdump binary

PATCH Superseded James Clark 3 participants 5 messages Nov 3, 2023 – Nov 8, 2023 perf events

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf test: Add option to change objdump binary

All of the other Perf subcommands that use objdump have an option to specify the binary, so add the same option to perf test.

This is useful if you have built the kernel with a different toolchain to the system one, where the system objdump may fail to disassemble vmlinux.

Now this can be fixed with something like this:

  $ perf test --objdump llvm-objdump "object code reading"
---
 tools/perf/tests/builtin-test.c | 3 +++
 tools/perf/tests/code-reading.c | 2 +-
 tools/perf/tests/tests.h        | 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)
tools/perf/tests/builtin-test.c +3 -0
index cb6f1dd00dc4..a8d17dd50588 100644
@@ -32,6 +32,7 @@
 
 static bool dont_fork;
 const char *dso_to_test;
+const char *test_objdump_path = "objdump";
 
 /*
  * List of architecture specific tests. Not a weak symbol as the array length is
@@ -529,6 +530,8 @@ int cmd_test(int argc, const char **argv)
 		    "Do not fork for testcase"),
 	OPT_STRING('w', "workload", &workload, "work", "workload to run for testing"),
 	OPT_STRING(0, "dso", &dso_to_test, "dso", "dso to test"),
+	OPT_STRING(0, "objdump", &test_objdump_path, "path",
+		   "objdump binary to use for disassembly and annotations"),
 	OPT_END()
 	};
 	const char * const test_subcommands[] = { "list", NULL };
tools/perf/tests/code-reading.c +1 -1
index 3af81012014e..b353358acc3a 100644
@@ -185,7 +185,7 @@ static int read_via_objdump(const char *filename, u64 addr, void *buf,
 	int ret;
 
 	fmt = "%s -z -d --start-address=0x%"PRIx64" --stop-address=0x%"PRIx64" %s";
-	ret = snprintf(cmd, sizeof(cmd), fmt, "objdump", addr, addr + len,
+	ret = snprintf(cmd, sizeof(cmd), fmt, test_objdump_path, addr, addr + len,
 		       filename);
 	if (ret <= 0 || (size_t)ret >= sizeof(cmd))
 		return -1;
tools/perf/tests/tests.h +1 -0
index b394f3ac2d66..dad3d7414142 100644
@@ -207,5 +207,6 @@ DECLARE_WORKLOAD(brstack);
 DECLARE_WORKLOAD(datasym);
 
 extern const char *dso_to_test;
+extern const char *test_objdump_path;
 
 #endif /* TESTS_H */
Signature · 1 line
2.34.1
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · James Clark

All of the other Perf subcommands that use objdump have an option to specify the binary, so add the same option to perf test.

This is useful if you have built the kernel with a different toolchain to the system one, where the system objdump may fail to disassemble vmlinux.

Quoted 5 lines

Now this can be fixed with something like this:

  $ perf test --objdump llvm-objdump "object code reading"

There is also "perf config" for things like this.

Thanks,
Ian

#2 lore raw
Quoted 13 lines · Ian Rogers
Quoted 12 lines · James Clark

All of the other Perf subcommands that use objdump have an option to specify the binary, so add the same option to perf test.

This is useful if you have built the kernel with a different toolchain to the system one, where the system objdump may fail to disassemble vmlinux.

Now this can be fixed with something like this:

   $ perf test --objdump llvm-objdump "object code reading"
Quoted 8 lines
Quoted 1 line

There is also "perf config" for things like this.

Thanks,
Ian

That seems a bit better for this use case so I added it in V2.

Thanks for the review.

James

#3 lore raw

Em Tue, Nov 07, 2023 at 09:37:32AM +0000, James Clark escreveu:

Quoted 18 lines · Ian Rogers
Quoted 15 lines · James Clark
Quoted 13 lines

All of the other Perf subcommands that use objdump have an option to specify the binary, so add the same option to perf test.

This is useful if you have built the kernel with a different toolchain to the system one, where the system objdump may fail to disassemble vmlinux.

Now this can be fixed with something like this:

   $ perf test --objdump llvm-objdump "object code reading"
Quoted 8 lines
Quoted 6 lines

There is also "perf config" for things like this.

Thanks,
Ian

That seems a bit better for this use case so I added it in V2.

Have you posted it?

Quoted 3 lines

Thanks for the review.

James

Signature · 1 line
- Arnaldo
#4 lore raw

Em Wed, Nov 08, 2023 at 05:48:52PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 9 lines

Em Tue, Nov 07, 2023 at 09:37:32AM +0000, James Clark escreveu:

Quoted 6 lines · Ian Rogers
Quoted 3 lines

There is also "perf config" for things like this.

That seems a bit better for this use case so I added it in V2.

Have you posted it?

Yeah, b4 found it, nevermind.

- Arnaldo