tools/testing/selftests/bpf/benchs/bench_lpm_trie_map.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/benchs/bench_lpm_trie_map.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/benchs/bench_lpm_trie_map.c- Extension
.c- Size
- 13050 bytes
- Lines
- 556
- 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/time64.hlinux/if_ether.hlpm_trie_bench.skel.hlpm_trie_map.skel.hbench.htesting_helpers.hprogs/lpm_trie.h
Detected Declarations
function lpm_parse_argfunction validate_commonfunction lpm_insert_validatefunction lpm_delete_validatefunction lpm_free_validatefunction fill_mapfunction empty_mapfunction attach_progfunction attach_prog_and_fill_mapfunction lpm_noop_setupfunction lpm_baseline_setupfunction lpm_lookup_setupfunction lpm_insert_setupfunction lpm_update_setupfunction lpm_delete_setupfunction lpm_free_setupfunction lpm_measurefunction bench_reinit_mapfunction takenfunction frac_second_report_finalfunction insert_ops_report_progressfunction delete_ops_report_progressfunction free_ops_report_progressfunction insert_ops_report_finalfunction delete_ops_report_finalfunction free_ops_report_final
Annotated Snippet
if (ret < 1 || ret > UINT_MAX) {
fprintf(stderr, "Invalid nr_entries count.");
argp_usage(state);
}
args.nr_entries = ret;
break;
case ARG_PREFIX_LEN:
ret = strtol(arg, NULL, 10);
if (ret < 1 || ret > UINT_MAX) {
fprintf(stderr, "Invalid prefix_len value.");
argp_usage(state);
}
args.prefixlen = ret;
break;
case ARG_RANDOM:
args.random = true;
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
const struct argp bench_lpm_trie_map_argp = {
.options = opts,
.parser = lpm_parse_arg,
};
static void validate_common(void)
{
if (env.consumer_cnt != 0) {
fprintf(stderr, "benchmark doesn't support consumer\n");
exit(1);
}
if (args.nr_entries == 0) {
fprintf(stderr, "Missing --nr_entries parameter\n");
exit(1);
}
if ((1UL << args.prefixlen) < args.nr_entries) {
fprintf(stderr, "prefix_len value too small for nr_entries\n");
exit(1);
}
}
static void lpm_insert_validate(void)
{
validate_common();
if (env.producer_cnt != 1) {
fprintf(stderr, "lpm-trie-insert requires a single producer\n");
exit(1);
}
if (args.random) {
fprintf(stderr, "lpm-trie-insert does not support --random\n");
exit(1);
}
}
static void lpm_delete_validate(void)
{
validate_common();
if (env.producer_cnt != 1) {
fprintf(stderr, "lpm-trie-delete requires a single producer\n");
exit(1);
}
if (args.random) {
fprintf(stderr, "lpm-trie-delete does not support --random\n");
exit(1);
}
}
static void lpm_free_validate(void)
{
validate_common();
if (env.producer_cnt != 1) {
fprintf(stderr, "lpm-trie-free requires a single producer\n");
exit(1);
}
if (args.random) {
fprintf(stderr, "lpm-trie-free does not support --random\n");
exit(1);
}
}
Annotation
- Immediate include surface: `argp.h`, `linux/time64.h`, `linux/if_ether.h`, `lpm_trie_bench.skel.h`, `lpm_trie_map.skel.h`, `bench.h`, `testing_helpers.h`, `progs/lpm_trie.h`.
- Detected declarations: `function lpm_parse_arg`, `function validate_common`, `function lpm_insert_validate`, `function lpm_delete_validate`, `function lpm_free_validate`, `function fill_map`, `function empty_map`, `function attach_prog`, `function attach_prog_and_fill_map`, `function lpm_noop_setup`.
- 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.