Expose the 'perf test -w' workloads functionality
Arnaldo Carvalho de Melo
maintainerv3 cover Expose the 'perf test -w' workloads functionality
From: Arnaldo Carvalho de Melo <[email protected]>
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(-)
Signature · 1 line
2.46.2
Arnaldo Carvalho de Melo
maintainerPATCH v3 1/3 perf test: Introduce workloads__for_each()
From: Arnaldo Carvalho de Melo <[email protected]>
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:~#--- tools/perf/tests/builtin-test.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
tools/perf/tests/builtin-test.c +4 -3
@@ -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); }
Signature · 1 line
2.46.2
Arnaldo Carvalho de Melo
maintainerPATCH v3 2/3 perf test: Introduce --list-workloads to list the available workloads
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
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'.
--- tools/perf/tests/builtin-test.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
tools/perf/tests/builtin-test.c +19 -1
@@ -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)
Signature · 1 line
2.46.2
Arnaldo Carvalho de Melo
maintainerPATCH v3 3/3 perf test: Document the -w/--workload option
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Wasn't documented so far, mention that it is mostly used in the shell regression tests.
--- tools/perf/Documentation/perf-test.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
tools/perf/Documentation/perf-test.txt +17 -0
@@ -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.
Signature · 1 line
2.46.2
Quoted 25 lines · Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <[email protected]>
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.
Quoted 9 lines
Arnaldo Carvalho de Melo (3):
perf test: Introduceworkloads__for_each()
perf test: Introduce --list-workloads to list the available workloads perf test: Document the -w/--workload optiontools/perf/Documentation/perf-test.txt | 17 ++++++++++++++++ tools/perf/tests/builtin-test.c | 27 ++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 4 deletions(-)
Quoted 9 lines · Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <[email protected]>
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