samples/bpf/map_perf_test.bpf.c
Source file repositories/reference/linux-study-clean/samples/bpf/map_perf_test.bpf.c
File Facts
- System
- Linux kernel
- Corpus path
samples/bpf/map_perf_test.bpf.c- Extension
.c- Size
- 6526 bytes
- Lines
- 298
- Domain
- Support Tooling And Documentation
- Bucket
- samples
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
vmlinux.herrno.hlinux/version.hbpf/bpf_helpers.hbpf/bpf_tracing.hbpf/bpf_core_read.h
Detected Declarations
struct inner_lrufunction BPF_KSYSCALLfunction BPF_KSYSCALLfunction BPF_KSYSCALLfunction BPF_KSYSCALLfunction BPF_KSYSCALLfunction BPF_KSYSCALLfunction BPF_KSYSCALLfunction BPF_KSYSCALL
Annotated Snippet
struct inner_lru {
__uint(type, BPF_MAP_TYPE_LRU_HASH);
__type(key, u32);
__type(value, long);
__uint(max_entries, MAX_ENTRIES);
__uint(map_flags, BPF_F_NUMA_NODE);
__uint(numa_node, 0);
} inner_lru_hash_map SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_ARRAY_OF_MAPS);
__uint(max_entries, MAX_NR_CPUS);
__uint(key_size, sizeof(u32));
__array(values, struct inner_lru); /* use inner_lru as inner map */
} array_of_lru_hashs SEC(".maps") = {
/* statically initialize the first element */
.values = { &inner_lru_hash_map },
};
struct {
__uint(type, BPF_MAP_TYPE_PERCPU_HASH);
__uint(key_size, sizeof(u32));
__uint(value_size, sizeof(long));
__uint(max_entries, MAX_ENTRIES);
} percpu_hash_map SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__type(key, u32);
__type(value, long);
__uint(max_entries, MAX_ENTRIES);
__uint(map_flags, BPF_F_NO_PREALLOC);
} hash_map_alloc SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_PERCPU_HASH);
__uint(key_size, sizeof(u32));
__uint(value_size, sizeof(long));
__uint(max_entries, MAX_ENTRIES);
__uint(map_flags, BPF_F_NO_PREALLOC);
} percpu_hash_map_alloc SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_LPM_TRIE);
__uint(key_size, 8);
__uint(value_size, sizeof(long));
__uint(max_entries, 10000);
__uint(map_flags, BPF_F_NO_PREALLOC);
} lpm_trie_map_alloc SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
__type(key, u32);
__type(value, long);
__uint(max_entries, MAX_ENTRIES);
} array_map SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_LRU_HASH);
__type(key, u32);
__type(value, long);
__uint(max_entries, MAX_ENTRIES);
} lru_hash_lookup_map SEC(".maps");
SEC("ksyscall/getuid")
int BPF_KSYSCALL(stress_hmap)
{
u32 key = bpf_get_current_pid_tgid();
long init_val = 1;
long *value;
int i;
for (i = 0; i < 10; i++) {
bpf_map_update_elem(&hash_map, &key, &init_val, BPF_ANY);
value = bpf_map_lookup_elem(&hash_map, &key);
if (value)
bpf_map_delete_elem(&hash_map, &key);
}
return 0;
}
SEC("ksyscall/geteuid")
int BPF_KSYSCALL(stress_percpu_hmap)
{
u32 key = bpf_get_current_pid_tgid();
long init_val = 1;
long *value;
int i;
Annotation
- Immediate include surface: `vmlinux.h`, `errno.h`, `linux/version.h`, `bpf/bpf_helpers.h`, `bpf/bpf_tracing.h`, `bpf/bpf_core_read.h`.
- Detected declarations: `struct inner_lru`, `function BPF_KSYSCALL`, `function BPF_KSYSCALL`, `function BPF_KSYSCALL`, `function BPF_KSYSCALL`, `function BPF_KSYSCALL`, `function BPF_KSYSCALL`, `function BPF_KSYSCALL`, `function BPF_KSYSCALL`.
- Atlas domain: Support Tooling And Documentation / samples.
- Implementation status: source implementation candidate.
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.