Commit 5956f301 authored by Andrii Nakryiko's avatar Andrii Nakryiko Committed by Alexei Starovoitov

veristat: add -t flag for adding BPF_F_TEST_STATE_FREQ program flag

Sometimes during debugging it's important that BPF program is loaded
with BPF_F_TEST_STATE_FREQ flag set to force verifier to do frequent
state checkpointing. Teach veristat to do this when -t ("test state")
flag is specified.
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20230505043317.3629845-2-andrii@kernel.orgSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 7866fc6a
...@@ -141,6 +141,7 @@ static struct env { ...@@ -141,6 +141,7 @@ static struct env {
bool verbose; bool verbose;
bool debug; bool debug;
bool quiet; bool quiet;
bool force_checkpoints;
enum resfmt out_fmt; enum resfmt out_fmt;
bool show_version; bool show_version;
bool comparison_mode; bool comparison_mode;
...@@ -209,6 +210,8 @@ static const struct argp_option opts[] = { ...@@ -209,6 +210,8 @@ static const struct argp_option opts[] = {
{ "log-level", 'l', "LEVEL", 0, "Verifier log level (default 0 for normal mode, 1 for verbose mode)" }, { "log-level", 'l', "LEVEL", 0, "Verifier log level (default 0 for normal mode, 1 for verbose mode)" },
{ "log-fixed", OPT_LOG_FIXED, NULL, 0, "Disable verifier log rotation" }, { "log-fixed", OPT_LOG_FIXED, NULL, 0, "Disable verifier log rotation" },
{ "log-size", OPT_LOG_SIZE, "BYTES", 0, "Customize verifier log size (default to 16MB)" }, { "log-size", OPT_LOG_SIZE, "BYTES", 0, "Customize verifier log size (default to 16MB)" },
{ "test-states", 't', NULL, 0,
"Force frequent BPF verifier state checkpointing (set BPF_F_TEST_STATE_FREQ program flag)" },
{ "quiet", 'q', NULL, 0, "Quiet mode" }, { "quiet", 'q', NULL, 0, "Quiet mode" },
{ "emit", 'e', "SPEC", 0, "Specify stats to be emitted" }, { "emit", 'e', "SPEC", 0, "Specify stats to be emitted" },
{ "sort", 's', "SPEC", 0, "Specify sort order" }, { "sort", 's', "SPEC", 0, "Specify sort order" },
...@@ -284,6 +287,9 @@ static error_t parse_arg(int key, char *arg, struct argp_state *state) ...@@ -284,6 +287,9 @@ static error_t parse_arg(int key, char *arg, struct argp_state *state)
argp_usage(state); argp_usage(state);
} }
break; break;
case 't':
env.force_checkpoints = true;
break;
case 'C': case 'C':
env.comparison_mode = true; env.comparison_mode = true;
break; break;
...@@ -989,6 +995,9 @@ static int process_prog(const char *filename, struct bpf_object *obj, struct bpf ...@@ -989,6 +995,9 @@ static int process_prog(const char *filename, struct bpf_object *obj, struct bpf
/* increase chances of successful BPF object loading */ /* increase chances of successful BPF object loading */
fixup_obj(obj, prog, base_filename); fixup_obj(obj, prog, base_filename);
if (env.force_checkpoints)
bpf_program__set_flags(prog, bpf_program__flags(prog) | BPF_F_TEST_STATE_FREQ);
err = bpf_object__load(obj); err = bpf_object__load(obj);
env.progs_processed++; env.progs_processed++;
......
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