Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftest/bpf/benchs: Make quiet option common

The "local-storage-tasks-trace" benchmark has a `--quiet` option. Move it to
the list of common options, so that the main code and other benchmarks can use
(new) env.quiet variable. Patch the run_bench_local_storage_rcu_tasks_trace.sh
helper script accordingly.

Signed-off-by: Anton Protopopov <aspsk@isovalent.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20230213091519.1202813-6-aspsk@isovalent.com

authored by

Anton Protopopov and committed by
Andrii Nakryiko
90c22503 96445462

+8 -15
+5
tools/testing/selftests/bpf/bench.c
··· 16 16 .warmup_sec = 1, 17 17 .duration_sec = 5, 18 18 .affinity = false, 19 + .quiet = false, 19 20 .consumer_cnt = 1, 20 21 .producer_cnt = 1, 21 22 }; ··· 263 262 { "consumers", 'c', "NUM", 0, "Number of consumer threads"}, 264 263 { "verbose", 'v', NULL, 0, "Verbose debug output"}, 265 264 { "affinity", 'a', NULL, 0, "Set consumer/producer thread affinity"}, 265 + { "quiet", 'q', NULL, 0, "Be more quiet"}, 266 266 { "prod-affinity", ARG_PROD_AFFINITY_SET, "CPUSET", 0, 267 267 "Set of CPUs for producer threads; implies --affinity"}, 268 268 { "cons-affinity", ARG_CONS_AFFINITY_SET, "CPUSET", 0, ··· 331 329 break; 332 330 case 'a': 333 331 env.affinity = true; 332 + break; 333 + case 'q': 334 + env.quiet = true; 334 335 break; 335 336 case ARG_PROD_AFFINITY_SET: 336 337 env.affinity = true;
+1
tools/testing/selftests/bpf/bench.h
··· 24 24 bool verbose; 25 25 bool list; 26 26 bool affinity; 27 + bool quiet; 27 28 int consumer_cnt; 28 29 int producer_cnt; 29 30 struct cpu_set prod_cpus;
+1 -14
tools/testing/selftests/bpf/benchs/bench_local_storage_rcu_tasks_trace.c
··· 12 12 static struct { 13 13 __u32 nr_procs; 14 14 __u32 kthread_pid; 15 - bool quiet; 16 15 } args = { 17 16 .nr_procs = 1000, 18 17 .kthread_pid = 0, 19 - .quiet = false, 20 18 }; 21 19 22 20 enum { 23 21 ARG_NR_PROCS = 7000, 24 22 ARG_KTHREAD_PID = 7001, 25 - ARG_QUIET = 7002, 26 23 }; 27 24 28 25 static const struct argp_option opts[] = { ··· 27 30 "Set number of user processes to spin up"}, 28 31 { "kthread_pid", ARG_KTHREAD_PID, "PID", 0, 29 32 "Pid of rcu_tasks_trace kthread for ticks tracking"}, 30 - { "quiet", ARG_QUIET, "{0,1}", 0, 31 - "If true, don't report progress"}, 32 33 {}, 33 34 }; 34 35 ··· 50 55 argp_usage(state); 51 56 } 52 57 args.kthread_pid = ret; 53 - break; 54 - case ARG_QUIET: 55 - ret = strtol(arg, NULL, 10); 56 - if (ret < 0 || ret > 1) { 57 - fprintf(stderr, "invalid quiet %ld\n", ret); 58 - argp_usage(state); 59 - } 60 - args.quiet = ret; 61 58 break; 62 59 break; 63 60 default: ··· 217 230 exit(1); 218 231 } 219 232 220 - if (args.quiet) 233 + if (env.quiet) 221 234 return; 222 235 223 236 printf("Iter %d\t avg tasks_trace grace period latency\t%lf ns\n",
+1 -1
tools/testing/selftests/bpf/benchs/run_bench_local_storage_rcu_tasks_trace.sh
··· 8 8 exit 1 9 9 fi 10 10 11 - ./bench --nr_procs 15000 --kthread_pid $kthread_pid -d 600 --quiet 1 local-storage-tasks-trace 11 + ./bench --nr_procs 15000 --kthread_pid $kthread_pid -d 600 --quiet local-storage-tasks-trace