tools/testing/selftests/bpf/progs/iters_task_vma.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/iters_task_vma.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/iters_task_vma.c- Extension
.c- Size
- 828 bytes
- Lines
- 44
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
vmlinux.hbpf_experimental.hbpf/bpf_helpers.hbpf_misc.h
Detected Declarations
function iter_task_vma_for_eachfunction bpf_for_each
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2023 Meta Platforms, Inc. and affiliates. */
#include "vmlinux.h"
#include "bpf_experimental.h"
#include <bpf/bpf_helpers.h>
#include "bpf_misc.h"
pid_t target_pid = 0;
unsigned int vmas_seen = 0;
struct {
__u64 vm_start;
__u64 vm_end;
} vm_ranges[1000];
SEC("raw_tp/sys_enter")
int iter_task_vma_for_each(const void *ctx)
{
struct task_struct *task = bpf_get_current_task_btf();
struct vm_area_struct *vma;
unsigned int seen = 0;
if (task->pid != target_pid)
return 0;
if (vmas_seen)
return 0;
bpf_for_each(task_vma, vma, task, 0) {
if (bpf_cmp_unlikely(seen, >=, 1000))
break;
vm_ranges[seen].vm_start = vma->vm_start;
vm_ranges[seen].vm_end = vma->vm_end;
seen++;
}
vmas_seen = seen;
return 0;
}
char _license[] SEC("license") = "GPL";
Annotation
- Immediate include surface: `vmlinux.h`, `bpf_experimental.h`, `bpf/bpf_helpers.h`, `bpf_misc.h`.
- Detected declarations: `function iter_task_vma_for_each`, `function bpf_for_each`.
- Atlas domain: Support Tooling And Documentation / tools.
- 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.