Commit 90c22503 authored by Anton Protopopov's avatar Anton Protopopov Committed by Andrii Nakryiko

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: default avatarAnton Protopopov <aspsk@isovalent.com>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20230213091519.1202813-6-aspsk@isovalent.com
parent 96445462
...@@ -16,6 +16,7 @@ struct env env = { ...@@ -16,6 +16,7 @@ struct env env = {
.warmup_sec = 1, .warmup_sec = 1,
.duration_sec = 5, .duration_sec = 5,
.affinity = false, .affinity = false,
.quiet = false,
.consumer_cnt = 1, .consumer_cnt = 1,
.producer_cnt = 1, .producer_cnt = 1,
}; };
...@@ -262,6 +263,7 @@ static const struct argp_option opts[] = { ...@@ -262,6 +263,7 @@ static const struct argp_option opts[] = {
{ "consumers", 'c', "NUM", 0, "Number of consumer threads"}, { "consumers", 'c', "NUM", 0, "Number of consumer threads"},
{ "verbose", 'v', NULL, 0, "Verbose debug output"}, { "verbose", 'v', NULL, 0, "Verbose debug output"},
{ "affinity", 'a', NULL, 0, "Set consumer/producer thread affinity"}, { "affinity", 'a', NULL, 0, "Set consumer/producer thread affinity"},
{ "quiet", 'q', NULL, 0, "Be more quiet"},
{ "prod-affinity", ARG_PROD_AFFINITY_SET, "CPUSET", 0, { "prod-affinity", ARG_PROD_AFFINITY_SET, "CPUSET", 0,
"Set of CPUs for producer threads; implies --affinity"}, "Set of CPUs for producer threads; implies --affinity"},
{ "cons-affinity", ARG_CONS_AFFINITY_SET, "CPUSET", 0, { "cons-affinity", ARG_CONS_AFFINITY_SET, "CPUSET", 0,
...@@ -330,6 +332,9 @@ static error_t parse_arg(int key, char *arg, struct argp_state *state) ...@@ -330,6 +332,9 @@ static error_t parse_arg(int key, char *arg, struct argp_state *state)
case 'a': case 'a':
env.affinity = true; env.affinity = true;
break; break;
case 'q':
env.quiet = true;
break;
case ARG_PROD_AFFINITY_SET: case ARG_PROD_AFFINITY_SET:
env.affinity = true; env.affinity = true;
if (parse_num_list(arg, &env.prod_cpus.cpus, if (parse_num_list(arg, &env.prod_cpus.cpus,
......
...@@ -24,6 +24,7 @@ struct env { ...@@ -24,6 +24,7 @@ struct env {
bool verbose; bool verbose;
bool list; bool list;
bool affinity; bool affinity;
bool quiet;
int consumer_cnt; int consumer_cnt;
int producer_cnt; int producer_cnt;
struct cpu_set prod_cpus; struct cpu_set prod_cpus;
......
...@@ -12,17 +12,14 @@ ...@@ -12,17 +12,14 @@
static struct { static struct {
__u32 nr_procs; __u32 nr_procs;
__u32 kthread_pid; __u32 kthread_pid;
bool quiet;
} args = { } args = {
.nr_procs = 1000, .nr_procs = 1000,
.kthread_pid = 0, .kthread_pid = 0,
.quiet = false,
}; };
enum { enum {
ARG_NR_PROCS = 7000, ARG_NR_PROCS = 7000,
ARG_KTHREAD_PID = 7001, ARG_KTHREAD_PID = 7001,
ARG_QUIET = 7002,
}; };
static const struct argp_option opts[] = { static const struct argp_option opts[] = {
...@@ -30,8 +27,6 @@ static const struct argp_option opts[] = { ...@@ -30,8 +27,6 @@ static const struct argp_option opts[] = {
"Set number of user processes to spin up"}, "Set number of user processes to spin up"},
{ "kthread_pid", ARG_KTHREAD_PID, "PID", 0, { "kthread_pid", ARG_KTHREAD_PID, "PID", 0,
"Pid of rcu_tasks_trace kthread for ticks tracking"}, "Pid of rcu_tasks_trace kthread for ticks tracking"},
{ "quiet", ARG_QUIET, "{0,1}", 0,
"If true, don't report progress"},
{}, {},
}; };
...@@ -56,14 +51,6 @@ static error_t parse_arg(int key, char *arg, struct argp_state *state) ...@@ -56,14 +51,6 @@ static error_t parse_arg(int key, char *arg, struct argp_state *state)
} }
args.kthread_pid = ret; args.kthread_pid = ret;
break; break;
case ARG_QUIET:
ret = strtol(arg, NULL, 10);
if (ret < 0 || ret > 1) {
fprintf(stderr, "invalid quiet %ld\n", ret);
argp_usage(state);
}
args.quiet = ret;
break;
break; break;
default: default:
return ARGP_ERR_UNKNOWN; return ARGP_ERR_UNKNOWN;
...@@ -230,7 +217,7 @@ static void report_progress(int iter, struct bench_res *res, long delta_ns) ...@@ -230,7 +217,7 @@ static void report_progress(int iter, struct bench_res *res, long delta_ns)
exit(1); exit(1);
} }
if (args.quiet) if (env.quiet)
return; return;
printf("Iter %d\t avg tasks_trace grace period latency\t%lf ns\n", printf("Iter %d\t avg tasks_trace grace period latency\t%lf ns\n",
......
...@@ -8,4 +8,4 @@ if [ -z $kthread_pid ]; then ...@@ -8,4 +8,4 @@ if [ -z $kthread_pid ]; then
exit 1 exit 1
fi fi
./bench --nr_procs 15000 --kthread_pid $kthread_pid -d 600 --quiet 1 local-storage-tasks-trace ./bench --nr_procs 15000 --kthread_pid $kthread_pid -d 600 --quiet local-storage-tasks-trace
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment