tools/testing/selftests/bpf/bench.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/bench.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/bench.c- Extension
.c- Size
- 24096 bytes
- Lines
- 809
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
argp.hlinux/compiler.hsys/time.hsched.hfcntl.hpthread.hsys/sysinfo.hsignal.hbench.hbpf_util.htesting_helpers.h
Detected Declarations
function libbpf_print_fnfunction setup_libbpffunction false_hits_report_progressfunction false_hits_report_finalfunction hits_drops_report_progressfunction grace_period_latency_basic_statsfunction grace_period_ticks_basic_statsfunction hits_drops_report_finalfunction ops_report_progressfunction ops_report_finalfunction local_storage_report_progressfunction local_storage_report_finalfunction parse_argfunction parse_cmdline_args_initfunction parse_cmdline_args_finalfunction sigalarm_handlerfunction setup_timerfunction set_thread_affinityfunction next_cpufunction find_benchmarkfunction setup_benchmarkfunction bench_force_donefunction collect_measurementsfunction main
Annotated Snippet
if (env.duration_sec <= 0) {
fprintf(stderr, "Invalid duration: %s\n", arg);
argp_usage(state);
}
break;
case 'w':
env.warmup_sec = strtol(arg, NULL, 10);
if (env.warmup_sec <= 0) {
fprintf(stderr, "Invalid warm-up duration: %s\n", arg);
argp_usage(state);
}
break;
case 'p':
env.producer_cnt = strtol(arg, NULL, 10);
if (env.producer_cnt < 0) {
fprintf(stderr, "Invalid producer count: %s\n", arg);
argp_usage(state);
}
break;
case 'c':
env.consumer_cnt = strtol(arg, NULL, 10);
if (env.consumer_cnt < 0) {
fprintf(stderr, "Invalid consumer count: %s\n", arg);
argp_usage(state);
}
break;
case 'a':
env.affinity = true;
break;
case 'q':
env.quiet = true;
break;
case 's':
env.stacktrace = true;
break;
case ARG_PROD_AFFINITY_SET:
env.affinity = true;
if (parse_num_list(arg, &env.prod_cpus.cpus,
&env.prod_cpus.cpus_len)) {
fprintf(stderr, "Invalid format of CPU set for producers.");
argp_usage(state);
}
break;
case ARG_CONS_AFFINITY_SET:
env.affinity = true;
if (parse_num_list(arg, &env.cons_cpus.cpus,
&env.cons_cpus.cpus_len)) {
fprintf(stderr, "Invalid format of CPU set for consumers.");
argp_usage(state);
}
break;
case ARGP_KEY_ARG:
if (pos_args++) {
fprintf(stderr,
"Unrecognized positional argument: %s\n", arg);
argp_usage(state);
}
env.bench_name = strdup(arg);
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
static void parse_cmdline_args_init(int argc, char **argv)
{
static const struct argp argp = {
.options = opts,
.parser = parse_arg,
.doc = argp_program_doc,
.children = bench_parsers,
};
if (argp_parse(&argp, argc, argv, 0, NULL, NULL))
exit(1);
}
static void parse_cmdline_args_final(int argc, char **argv)
{
struct argp_child bench_parsers[2] = {};
const struct argp argp = {
.options = opts,
.parser = parse_arg,
.doc = argp_program_doc,
.children = bench_parsers,
};
/* Parse arguments the second time with the correct set of parsers */
if (bench->argp) {
bench_parsers[0].argp = bench->argp;
Annotation
- Immediate include surface: `argp.h`, `linux/compiler.h`, `sys/time.h`, `sched.h`, `fcntl.h`, `pthread.h`, `sys/sysinfo.h`, `signal.h`.
- Detected declarations: `function libbpf_print_fn`, `function setup_libbpf`, `function false_hits_report_progress`, `function false_hits_report_final`, `function hits_drops_report_progress`, `function grace_period_latency_basic_stats`, `function grace_period_ticks_basic_stats`, `function hits_drops_report_final`, `function ops_report_progress`, `function ops_report_final`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.