kernel/bpf/preload/iterators/iterators.bpf.c
Source file repositories/reference/linux-study-clean/kernel/bpf/preload/iterators/iterators.bpf.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/bpf/preload/iterators/iterators.bpf.c- Extension
.c- Size
- 2470 bytes
- Lines
- 119
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bpf.hbpf/bpf_helpers.hbpf/bpf_core_read.h
Detected Declarations
struct seq_filestruct bpf_iter_metastruct bpf_mapstruct bpf_iter__bpf_mapstruct btf_typestruct btf_headerstruct btfstruct bpf_prog_auxstruct bpf_progstruct bpf_iter__bpf_progfunction dump_bpf_mapfunction dump_bpf_prog
Annotated Snippet
struct bpf_iter_meta {
struct seq_file *seq;
__u64 session_id;
__u64 seq_num;
};
struct bpf_map {
__u32 id;
char name[16];
__u32 max_entries;
};
struct bpf_iter__bpf_map {
struct bpf_iter_meta *meta;
struct bpf_map *map;
};
struct btf_type {
__u32 name_off;
};
struct btf_header {
__u32 str_len;
};
struct btf {
const char *strings;
struct btf_type **types;
struct btf_header hdr;
};
struct bpf_prog_aux {
__u32 id;
char name[16];
const char *attach_func_name;
struct bpf_prog *dst_prog;
struct bpf_func_info *func_info;
struct btf *btf;
};
struct bpf_prog {
struct bpf_prog_aux *aux;
};
struct bpf_iter__bpf_prog {
struct bpf_iter_meta *meta;
struct bpf_prog *prog;
};
#pragma clang attribute pop
static const char *get_name(struct btf *btf, long btf_id, const char *fallback)
{
struct btf_type **types, *t;
unsigned int name_off;
const char *str;
if (!btf)
return fallback;
str = btf->strings;
types = btf->types;
bpf_probe_read_kernel(&t, sizeof(t), types + btf_id);
name_off = BPF_CORE_READ(t, name_off);
if (name_off >= btf->hdr.str_len)
return fallback;
return str + name_off;
}
__s64 bpf_map_sum_elem_count(struct bpf_map *map) __ksym;
SEC("iter/bpf_map")
int dump_bpf_map(struct bpf_iter__bpf_map *ctx)
{
struct seq_file *seq = ctx->meta->seq;
__u64 seq_num = ctx->meta->seq_num;
struct bpf_map *map = ctx->map;
if (!map)
return 0;
if (seq_num == 0)
BPF_SEQ_PRINTF(seq, " id name max_entries cur_entries\n");
BPF_SEQ_PRINTF(seq, "%4u %-16s %10d %10lld\n",
map->id, map->name, map->max_entries,
bpf_map_sum_elem_count(map));
return 0;
}
SEC("iter/bpf_prog")
Annotation
- Immediate include surface: `linux/bpf.h`, `bpf/bpf_helpers.h`, `bpf/bpf_core_read.h`.
- Detected declarations: `struct seq_file`, `struct bpf_iter_meta`, `struct bpf_map`, `struct bpf_iter__bpf_map`, `struct btf_type`, `struct btf_header`, `struct btf`, `struct bpf_prog_aux`, `struct bpf_prog`, `struct bpf_iter__bpf_prog`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- 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.