* [PATCH 0/3 v3] Expose the 'perf test -w' workloads functionality
@ 2024-10-20 2:18 Arnaldo Carvalho de Melo
2024-10-20 2:18 ` [PATCH 1/3] perf test: Introduce workloads__for_each() Arnaldo Carvalho de Melo
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-10-20 2:18 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, Jiri Olsa, Ian Rogers,
Adrian Hunter, Kan Liang, Clark Williams, linux-kernel,
linux-perf-users, Arnaldo Carvalho de Melo, James Clark
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Hi,
I noticed that the 'perf test -w' code wasn't well exposed, so
add a '--list-workloads' option to list the existing workloads and document it
in the 'perf test' man page.
- Arnaldo
v3:
- Fixup references to --list-workloads in a patch subject (Namhyumg)
- Fixup references to --list-workloads in the 'perf test' man page (James)
- Add an entry for --list-workloads in the 'perf test' man page.
v2:
- Use --list-workloads, as suggested by James Clark.
- Add info in the man page about the parameters the built-in workloads
accept.
Arnaldo Carvalho de Melo (3):
perf test: Introduce workloads__for_each()
perf test: Introduce --list-workloads to list the available workloads
perf test: Document the -w/--workload option
tools/perf/Documentation/perf-test.txt | 17 ++++++++++++++++
tools/perf/tests/builtin-test.c | 27 ++++++++++++++++++++++----
2 files changed, 40 insertions(+), 4 deletions(-)
--
2.46.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/3] perf test: Introduce workloads__for_each()
2024-10-20 2:18 [PATCH 0/3 v3] Expose the 'perf test -w' workloads functionality Arnaldo Carvalho de Melo
@ 2024-10-20 2:18 ` Arnaldo Carvalho de Melo
2024-10-20 2:18 ` [PATCH 2/3] perf test: Introduce --list-workloads to list the available workloads Arnaldo Carvalho de Melo
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-10-20 2:18 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, Jiri Olsa, Ian Rogers,
Adrian Hunter, Kan Liang, Clark Williams, linux-kernel,
linux-perf-users, Arnaldo Carvalho de Melo, James Clark
From: Arnaldo Carvalho de Melo <acme@redhat.com>
And use it in run_workload().
Testing it:
root@x1:~# perf trace -e *landlock* perf test -w landlock
0.000 ( 0.015 ms): :1274331/1274331 landlock_add_rule(ruleset_fd: 11, rule_type: LANDLOCK_RULE_PATH_BENEATH, rule_attr: 0x7ffd3fea55e0, flags: 45) = -1 EINVAL (Invalid argument)
0.018 ( 0.003 ms): :1274331/1274331 landlock_add_rule(ruleset_fd: 11, rule_type: LANDLOCK_RULE_NET_PORT, rule_attr: 0x7ffd3fea55f0, flags: 45) = -1 EINVAL (Invalid argument)
root@x1:~# perf test -w bla
No workload found: bla
root@x1:~#
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/lkml/20241011171449.1362979-2-acme@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/builtin-test.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 470a9709427ddaad..2201f7ed432ce9f2 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -155,6 +155,9 @@ static struct test_workload *workloads[] = {
&workload__landlock,
};
+#define workloads__for_each(workload) \
+ for (unsigned i = 0; i < ARRAY_SIZE(workloads) && ({ workload = workloads[i]; 1; }); i++)
+
static int num_subtests(const struct test_suite *t)
{
int num;
@@ -504,11 +507,9 @@ static int perf_test__list(int argc, const char **argv)
static int run_workload(const char *work, int argc, const char **argv)
{
- unsigned int i = 0;
struct test_workload *twl;
- for (i = 0; i < ARRAY_SIZE(workloads); i++) {
- twl = workloads[i];
+ workloads__for_each(twl) {
if (!strcmp(twl->name, work))
return twl->func(argc, argv);
}
--
2.46.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] perf test: Introduce --list-workloads to list the available workloads
2024-10-20 2:18 [PATCH 0/3 v3] Expose the 'perf test -w' workloads functionality Arnaldo Carvalho de Melo
2024-10-20 2:18 ` [PATCH 1/3] perf test: Introduce workloads__for_each() Arnaldo Carvalho de Melo
@ 2024-10-20 2:18 ` Arnaldo Carvalho de Melo
2024-10-20 2:18 ` [PATCH 3/3] perf test: Document the -w/--workload option Arnaldo Carvalho de Melo
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-10-20 2:18 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, Jiri Olsa, Ian Rogers,
Adrian Hunter, Kan Liang, Clark Williams, linux-kernel,
linux-perf-users, Arnaldo Carvalho de Melo, James Clark
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 '--list-workloads' to list the available ones.
$
$ perf test --list-workloads
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: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/lkml/20241011171449.1362979-3-acme@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/builtin-test.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 2201f7ed432ce9f2..cc43b9f366d09436 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -505,6 +505,17 @@ 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;
@@ -535,6 +546,7 @@ int cmd_test(int argc, const char **argv)
};
const char *skip = NULL;
const char *workload = NULL;
+ bool list_workloads = false;
const struct option test_options[] = {
OPT_STRING('s', "skip", &skip, "tests", "tests to skip"),
OPT_INCR('v', "verbose", &verbose,
@@ -544,7 +556,8 @@ 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 '--list-workloads' to list the available ones."),
+ OPT_BOOLEAN(0, "list-workloads", &list_workloads, "List the available builtin workloads to use with -w/--workload"),
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"),
@@ -570,6 +583,11 @@ int cmd_test(int argc, const char **argv)
if (workload)
return run_workload(workload, argc, argv);
+ if (list_workloads) {
+ workloads__fprintf_list(stdout);
+ return 0;
+ }
+
if (dont_fork)
sequential = true;
else if (parallel)
--
2.46.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] perf test: Document the -w/--workload option
2024-10-20 2:18 [PATCH 0/3 v3] Expose the 'perf test -w' workloads functionality Arnaldo Carvalho de Melo
2024-10-20 2:18 ` [PATCH 1/3] perf test: Introduce workloads__for_each() Arnaldo Carvalho de Melo
2024-10-20 2:18 ` [PATCH 2/3] perf test: Introduce --list-workloads to list the available workloads Arnaldo Carvalho de Melo
@ 2024-10-20 2:18 ` Arnaldo Carvalho de Melo
2024-10-21 8:11 ` [PATCH 0/3 v3] Expose the 'perf test -w' workloads functionality James Clark
2024-10-23 18:00 ` Namhyung Kim
4 siblings, 0 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-10-20 2:18 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, Jiri Olsa, Ian Rogers,
Adrian Hunter, Kan Liang, Clark Williams, linux-kernel,
linux-perf-users, Arnaldo Carvalho de Melo, James Clark
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Wasn't documented so far, mention that it is mostly used in the shell
regression tests.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/lkml/20241011171449.1362979-4-acme@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/Documentation/perf-test.txt | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/tools/perf/Documentation/perf-test.txt b/tools/perf/Documentation/perf-test.txt
index 9acb8d1f658890e9..efcdec528a8f7243 100644
--- a/tools/perf/Documentation/perf-test.txt
+++ b/tools/perf/Documentation/perf-test.txt
@@ -48,3 +48,20 @@ OPTIONS
--dso::
Specify a DSO for the "Symbols" test.
+
+-w::
+--workload=::
+ Run a built-in workload, to list them use '--list-workloads', current ones include:
+ noploop, thloop, leafloop, sqrtloop, brstack, datasym and landlock.
+
+ Used with the shell script regression tests.
+
+ Some accept an extra parameter:
+
+ seconds: leafloop, noploop, sqrtloop, thloop
+ nrloops: brstack
+
+ The datasym and landlock workloads don't accept any.
+
+--list-workloads::
+ List the available workloads to use with -w/--workload.
--
2.46.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/3 v3] Expose the 'perf test -w' workloads functionality
2024-10-20 2:18 [PATCH 0/3 v3] Expose the 'perf test -w' workloads functionality Arnaldo Carvalho de Melo
` (2 preceding siblings ...)
2024-10-20 2:18 ` [PATCH 3/3] perf test: Document the -w/--workload option Arnaldo Carvalho de Melo
@ 2024-10-21 8:11 ` James Clark
2024-10-23 18:00 ` Namhyung Kim
4 siblings, 0 replies; 6+ messages in thread
From: James Clark @ 2024-10-21 8:11 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, Jiri Olsa, Ian Rogers,
Adrian Hunter, Kan Liang, Clark Williams, linux-kernel,
linux-perf-users, Arnaldo Carvalho de Melo
On 20/10/2024 3:18 am, Arnaldo Carvalho de Melo wrote:
> From: Arnaldo Carvalho de Melo <acme@redhat.com>
>
> Hi,
>
> I noticed that the 'perf test -w' code wasn't well exposed, so
> add a '--list-workloads' option to list the existing workloads and document it
> in the 'perf test' man page.
>
> - Arnaldo
>
> v3:
>
> - Fixup references to --list-workloads in a patch subject (Namhyumg)
>
> - Fixup references to --list-workloads in the 'perf test' man page (James)
>
> - Add an entry for --list-workloads in the 'perf test' man page.
>
> v2:
>
> - Use --list-workloads, as suggested by James Clark.
>
> - Add info in the man page about the parameters the built-in workloads
> accept.
>
> Arnaldo Carvalho de Melo (3):
> perf test: Introduce workloads__for_each()
> perf test: Introduce --list-workloads to list the available workloads
> perf test: Document the -w/--workload option
>
> tools/perf/Documentation/perf-test.txt | 17 ++++++++++++++++
> tools/perf/tests/builtin-test.c | 27 ++++++++++++++++++++++----
> 2 files changed, 40 insertions(+), 4 deletions(-)
>
Reviewed-by: James Clark <james.clark@linaro.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/3 v3] Expose the 'perf test -w' workloads functionality
2024-10-20 2:18 [PATCH 0/3 v3] Expose the 'perf test -w' workloads functionality Arnaldo Carvalho de Melo
` (3 preceding siblings ...)
2024-10-21 8:11 ` [PATCH 0/3 v3] Expose the 'perf test -w' workloads functionality James Clark
@ 2024-10-23 18:00 ` Namhyung Kim
4 siblings, 0 replies; 6+ messages in thread
From: Namhyung Kim @ 2024-10-23 18:00 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Ingo Molnar, Thomas Gleixner, Jiri Olsa, Ian Rogers,
Adrian Hunter, Kan Liang, Clark Williams, linux-kernel,
linux-perf-users, Arnaldo Carvalho de Melo, James Clark
On Sat, 19 Oct 2024 23:18:39 -0300, Arnaldo Carvalho de Melo wrote:
> From: Arnaldo Carvalho de Melo <acme@redhat.com>
>
> Hi,
>
> I noticed that the 'perf test -w' code wasn't well exposed, so
> add a '--list-workloads' option to list the existing workloads and document it
> in the 'perf test' man page.
>
> [...]
Applied to perf-tools-next, thanks!
Best regards,
Namhyung
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-10-23 18:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-20 2:18 [PATCH 0/3 v3] Expose the 'perf test -w' workloads functionality Arnaldo Carvalho de Melo
2024-10-20 2:18 ` [PATCH 1/3] perf test: Introduce workloads__for_each() Arnaldo Carvalho de Melo
2024-10-20 2:18 ` [PATCH 2/3] perf test: Introduce --list-workloads to list the available workloads Arnaldo Carvalho de Melo
2024-10-20 2:18 ` [PATCH 3/3] perf test: Document the -w/--workload option Arnaldo Carvalho de Melo
2024-10-21 8:11 ` [PATCH 0/3 v3] Expose the 'perf test -w' workloads functionality James Clark
2024-10-23 18:00 ` Namhyung Kim
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).