Skip to content

Commit 5956f30

Browse files
anakryikoAlexei Starovoitov
authored andcommitted
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: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 7866fc6 commit 5956f30

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tools/testing/selftests/bpf/veristat.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ static struct env {
141141
bool verbose;
142142
bool debug;
143143
bool quiet;
144+
bool force_checkpoints;
144145
enum resfmt out_fmt;
145146
bool show_version;
146147
bool comparison_mode;
@@ -209,6 +210,8 @@ static const struct argp_option opts[] = {
209210
{ "log-level", 'l', "LEVEL", 0, "Verifier log level (default 0 for normal mode, 1 for verbose mode)" },
210211
{ "log-fixed", OPT_LOG_FIXED, NULL, 0, "Disable verifier log rotation" },
211212
{ "log-size", OPT_LOG_SIZE, "BYTES", 0, "Customize verifier log size (default to 16MB)" },
213+
{ "test-states", 't', NULL, 0,
214+
"Force frequent BPF verifier state checkpointing (set BPF_F_TEST_STATE_FREQ program flag)" },
212215
{ "quiet", 'q', NULL, 0, "Quiet mode" },
213216
{ "emit", 'e', "SPEC", 0, "Specify stats to be emitted" },
214217
{ "sort", 's', "SPEC", 0, "Specify sort order" },
@@ -284,6 +287,9 @@ static error_t parse_arg(int key, char *arg, struct argp_state *state)
284287
argp_usage(state);
285288
}
286289
break;
290+
case 't':
291+
env.force_checkpoints = true;
292+
break;
287293
case 'C':
288294
env.comparison_mode = true;
289295
break;
@@ -989,6 +995,9 @@ static int process_prog(const char *filename, struct bpf_object *obj, struct bpf
989995
/* increase chances of successful BPF object loading */
990996
fixup_obj(obj, prog, base_filename);
991997

998+
if (env.force_checkpoints)
999+
bpf_program__set_flags(prog, bpf_program__flags(prog) | BPF_F_TEST_STATE_FREQ);
1000+
9921001
err = bpf_object__load(obj);
9931002
env.progs_processed++;
9941003

0 commit comments

Comments
 (0)