From: James Clark <james.clark@linaro.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Kan Liang <kan.liang@linux.intel.com>,
Clark Williams <williams@redhat.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: Re: [PATCH 2/3] perf test: Introduce '-w --list' to list the available workloads
Date: Fri, 11 Oct 2024 15:54:52 +0100 [thread overview]
Message-ID: <9513f8d7-7f42-4c1e-bdc9-d2078d46ba1f@linaro.org> (raw)
In-Reply-To: <20241011143906.1285675-3-acme@kernel.org>
On 11/10/2024 3:39 pm, Arnaldo Carvalho de Melo wrote:
> From: Arnaldo Carvalho de Melo <acme@redhat.com>
>
> Using it:
>
> $ perf test -w noplop
> No workload found: noplop
> $
> $ perf test -w
> Error: switch `w' requires a value
> Usage: perf test [<options>] [{list <test-name-fragment>|[<test-name-fragments>|<test-numbers>]}]
>
> -w, --workload <work>
> workload to run for testing, use '-w --list' to list the available ones.
> $
> $ perf test -w --list
> noploop
> thloop
> leafloop
> sqrtloop
> brstack
> datasym
> landlock
> $
>
> Would be good at some point to have a description in 'struct test_workload'.
>
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Cc: Ian Rogers <irogers@google.com>
> Cc: Jiri Olsa <jolsa@kernel.org>
> Cc: Kan Liang <kan.liang@linux.intel.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> ---
> tools/perf/tests/builtin-test.c | 18 +++++++++++++++++-
> 1 file changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
> index 2201f7ed432ce9f2..f0d10d2dd0d40019 100644
> --- a/tools/perf/tests/builtin-test.c
> +++ b/tools/perf/tests/builtin-test.c
> @@ -505,10 +505,26 @@ static int perf_test__list(int argc, const char **argv)
> return 0;
> }
>
> +static int workloads__fprintf_list(FILE *fp)
> +{
> + struct test_workload *twl;
> + int printed = 0;
> +
> + workloads__for_each(twl)
> + printed += fprintf(fp, "%s\n", twl->name);
> +
> + return printed;
> +}
> +
> static int run_workload(const char *work, int argc, const char **argv)
> {
> struct test_workload *twl;
>
> + if (!strcmp(work, "--list")) {
> + workloads__fprintf_list(stdout);
> + return 0;
> + }
> +
Very minor nit, but I think searching the workload name for an argument
instead of having a 'proper' toplevel argument seems a bit weird, but I
can see why you did it that way.
But maybe something like this might be a bit more readable especially
when searching in the usual places for an argument. And in the future
might survive auto doc attempts of known arguments:
$ perf test --list-workloads
And add it with OPT_BOOLEAN() etc.
> workloads__for_each(twl) {
> if (!strcmp(twl->name, work))
> return twl->func(argc, argv);
> @@ -544,7 +560,7 @@ int cmd_test(int argc, const char **argv)
> OPT_BOOLEAN('p', "parallel", ¶llel, "Run the tests in parallel"),
> OPT_BOOLEAN('S', "sequential", &sequential,
> "Run the tests one after another rather than in parallel"),
> - OPT_STRING('w', "workload", &workload, "work", "workload to run for testing"),
> + OPT_STRING('w', "workload", &workload, "work", "workload to run for testing, use '-w --list' to list the available ones."),
> 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"),
next prev parent reply other threads:[~2024-10-11 14:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-11 14:39 [PATCH 0/3] Document the 'perf test -w' workloads functionality Arnaldo Carvalho de Melo
2024-10-11 14:39 ` [PATCH 1/3] perf test: Introduce workloads__for_each() Arnaldo Carvalho de Melo
2024-10-11 14:39 ` [PATCH 2/3] perf test: Introduce '-w --list' to list the available workloads Arnaldo Carvalho de Melo
2024-10-11 14:54 ` James Clark [this message]
2024-10-11 14:39 ` [PATCH 3/3] perf test: Document the -w/--workload option Arnaldo Carvalho de Melo
-- strict thread matches above, loose matches on Subject: below --
2024-10-11 17:14 [PATCH v2 0/3] Document the 'perf test -w' workloads functionality Arnaldo Carvalho de Melo
2024-10-11 17:14 ` [PATCH 2/3] perf test: Introduce '-w --list' to list the available workloads Arnaldo Carvalho de Melo
2024-10-17 20:15 ` Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9513f8d7-7f42-4c1e-bdc9-d2078d46ba1f@linaro.org \
--to=james.clark@linaro.org \
--cc=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=tglx@linutronix.de \
--cc=williams@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).