From nobody Wed Dec 31 07:13:42 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E111C4332F for ; Mon, 6 Nov 2023 15:11:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231358AbjKFPL1 (ORCPT ); Mon, 6 Nov 2023 10:11:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229839AbjKFPLZ (ORCPT ); Mon, 6 Nov 2023 10:11:25 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 883ECD8; Mon, 6 Nov 2023 07:11:22 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 81D2DC15; Mon, 6 Nov 2023 07:12:06 -0800 (PST) Received: from e127643.broadband (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7F23C3F6C4; Mon, 6 Nov 2023 07:11:19 -0800 (PST) From: James Clark To: linux-perf-users@vger.kernel.org, irogers@google.com Cc: James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Nathan Chancellor , Nick Desaulniers , Tom Rix , Fangrui Song , Kan Liang , Ravi Bangoria , Yang Jihong , Kajol Jain , Athira Rajeev , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH v2 1/2] perf test: Add option to change objdump binary Date: Mon, 6 Nov 2023 15:10:48 +0000 Message-Id: <20231106151051.129440-2-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231106151051.129440-1-james.clark@arm.com> References: <20231106151051.129440-1-james.clark@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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" Reviewed-by: Ian Rogers Signed-off-by: James Clark --- 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(-) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-tes= t.c index cb6f1dd00dc4..a8d17dd50588 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -32,6 +32,7 @@ =20 static bool dont_fork; const char *dso_to_test; +const char *test_objdump_path =3D "objdump"; =20 /* * List of architecture specific tests. Not a weak symbol as the array len= gth 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 testi= ng"), 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[] =3D { "list", NULL }; diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-readin= g.c index 3af81012014e..b353358acc3a 100644 --- a/tools/perf/tests/code-reading.c +++ b/tools/perf/tests/code-reading.c @@ -185,7 +185,7 @@ static int read_via_objdump(const char *filename, u64 a= ddr, void *buf, int ret; =20 fmt =3D "%s -z -d --start-address=3D0x%"PRIx64" --stop-address=3D0x%"PRIx= 64" %s"; - ret =3D snprintf(cmd, sizeof(cmd), fmt, "objdump", addr, addr + len, + ret =3D snprintf(cmd, sizeof(cmd), fmt, test_objdump_path, addr, addr + l= en, filename); if (ret <=3D 0 || (size_t)ret >=3D sizeof(cmd)) return -1; diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index b394f3ac2d66..dad3d7414142 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -207,5 +207,6 @@ DECLARE_WORKLOAD(brstack); DECLARE_WORKLOAD(datasym); =20 extern const char *dso_to_test; +extern const char *test_objdump_path; =20 #endif /* TESTS_H */ --=20 2.34.1 From nobody Wed Dec 31 07:13:42 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E95DC4332F for ; Mon, 6 Nov 2023 15:11:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232084AbjKFPLe (ORCPT ); Mon, 6 Nov 2023 10:11:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232047AbjKFPLb (ORCPT ); Mon, 6 Nov 2023 10:11:31 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 385161B2; Mon, 6 Nov 2023 07:11:28 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3C6C0DA7; Mon, 6 Nov 2023 07:12:12 -0800 (PST) Received: from e127643.broadband (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 393BD3F6C4; Mon, 6 Nov 2023 07:11:25 -0800 (PST) From: James Clark To: linux-perf-users@vger.kernel.org, irogers@google.com Cc: James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Nathan Chancellor , Nick Desaulniers , Tom Rix , Yonghong Song , Fangrui Song , Kan Liang , Yang Jihong , Athira Rajeev , Ravi Bangoria , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH v2 2/2] perf test: Add support for setting objdump binary via perf config Date: Mon, 6 Nov 2023 15:10:49 +0000 Message-Id: <20231106151051.129440-3-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231106151051.129440-1-james.clark@arm.com> References: <20231106151051.129440-1-james.clark@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add a perf config variable that does the same thing as "perf test --objdump ". Also update the man page. Signed-off-by: James Clark Tested-by: Arnaldo Carvalho de Melo --- tools/perf/Documentation/perf-config.txt | 4 ++++ tools/perf/tests/builtin-test.c | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/tools/perf/Documentation/perf-config.txt b/tools/perf/Document= ation/perf-config.txt index 0b4e79dbd3f6..16398babd1ef 100644 --- a/tools/perf/Documentation/perf-config.txt +++ b/tools/perf/Documentation/perf-config.txt @@ -722,6 +722,10 @@ session-.*:: Defines new record session for daemon. The value is record's command line without the 'record' keyword. =20 +test.*:: + + test.objdump:: + objdump binary to use for disassembly and annotations. =20 SEE ALSO -------- diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-tes= t.c index a8d17dd50588..113e92119e1d 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -14,6 +14,7 @@ #include #include #include "builtin.h" +#include "config.h" #include "hist.h" #include "intlist.h" #include "tests.h" @@ -514,6 +515,15 @@ static int run_workload(const char *work, int argc, co= nst char **argv) return -1; } =20 +static int perf_test__config(const char *var, const char *value, + void *data __maybe_unused) +{ + if (!strcmp(var, "test.objdump")) + test_objdump_path =3D value; + + return 0; +} + int cmd_test(int argc, const char **argv) { const char *test_usage[] =3D { @@ -541,6 +551,8 @@ int cmd_test(int argc, const char **argv) if (ret < 0) return ret; =20 + perf_config(perf_test__config, NULL); + /* Unbuffered output */ setvbuf(stdout, NULL, _IONBF, 0); =20 --=20 2.34.1