aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/testing/selftests/bpf/bench.h
diff options
context:
space:
mode:
authorAnton Protopopov <aspsk@isovalent.com>2023-02-13 09:15:15 +0000
committerAndrii Nakryiko <andrii@kernel.org>2023-02-15 16:29:31 -0800
commit22ff7aeaa9e3d0533df613da3500db1ecf452253 (patch)
tree97b5eb2f97e7278a98697a51a512e6ff8cb814e7 /tools/testing/selftests/bpf/bench.h
parentselftest/bpf/benchs: Make a function static in bpf_hashmap_full_update (diff)
downloadwireguard-linux-22ff7aeaa9e3d0533df613da3500db1ecf452253.tar.xz
wireguard-linux-22ff7aeaa9e3d0533df613da3500db1ecf452253.zip
selftest/bpf/benchs: Enhance argp parsing
To parse command line the bench utility uses the argp_parse() function. This function takes as an argument a parent 'struct argp' structure which defines common command line options and an array of children 'struct argp' structures which defines additional command line options for particular benchmarks. This implementation doesn't allow benchmarks to share option names, e.g., if two benchmarks want to use, say, the --option option, then only one of them will succeed (the first one encountered in the array). This will be convenient if same option names could be used in different benchmarks (with the same semantics, e.g., --nr_loops=N). Fix this by calling the argp_parse() function twice. The first call is the same as it was before, with all children argps, and helps to find the benchmark name and to print a combined help message if anything is wrong. Given the name, we can call the argp_parse the second time, but now the children array points only to a correct benchmark thus always calling the correct parsers. (If there's no a specific list of arguments, then only one call to argp_parse will be done.) Signed-off-by: Anton Protopopov <aspsk@isovalent.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20230213091519.1202813-4-aspsk@isovalent.com
Diffstat (limited to 'tools/testing/selftests/bpf/bench.h')
-rw-r--r--tools/testing/selftests/bpf/bench.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/bench.h b/tools/testing/selftests/bpf/bench.h
index d748255877e2..3c8afa0131a3 100644
--- a/tools/testing/selftests/bpf/bench.h
+++ b/tools/testing/selftests/bpf/bench.h
@@ -47,6 +47,7 @@ struct bench_res {
struct bench {
const char *name;
+ const struct argp *argp;
void (*validate)(void);
void (*setup)(void);
void *(*producer_thread)(void *ctx);